-
Notifications
You must be signed in to change notification settings - Fork 74.8k
Closed
Labels
Description
The tf.image.resize_images() seems to use a strange padding option, which one is not clear to me at the moment. I tried to replicate the bilinear interpolation with various padding options in for example skimage, but cant replicate the behaviour.
It would be nice to be able to set the padding option used in tf.images.resize_images(), or document what is used at least.
Example code for comparing the results of tf.images.resize_images() and skimage transform:
Looks like tf.images.resize_images() does some weird unsymmetrical padding!?
Using tensorflow 0.12.1:
import tensorflow as tf
import tensorlayer as tl
import numpy as np
import skimage
from scipy.misc import imread, imresize, imsave
sess = tf.InteractiveSession()
#create simple test image
imsize = 3
xa, ya = np.ogrid[:imsize, :imsize]
img = np.repeat((xa + ya)[..., np.newaxis], 3, 2) / float(imsize + imsize)
x = tf.placeholder(tf.float32, [1, imsize, imsize, 3])
y = tf.image.resize_images(x,(imsize*3, imsize*3))
sess.run(tf.global_variables_initializer())
upsampled_tf_result = sess.run(y, feed_dict={x: [img]})
upsampled_skimage_result = skimage.transform.rescale(img,
3,
mode='symmetric',
cval=0,
order=1,
preserve_range=False)
print(np.allclose(upsampled_tf_result, upsampled_skimage_result))
imsave('upsampled_tf_result.png', np.squeeze(upsampled_tf_result))
imsave('upsampled_skimage_result.png', upsampled_skimage_result)
NavinF, thefiddler, Sanster, loretoparisi, Ouwen and 8 more