读图的时候是用 tensorflow 的函数,存图像用的 scipy.misc 的 imsave 函数。
因为在使用 tensorflow 的队列时对存图像大小的限制有疑问所以进行测试。
import tensorflow as tf
import numpy as np
import scipy.misc
#读取图像可任意大小
filenames = ['img1.png','img2.png']
filename_queue = tf.train.string_input_producer(filenames)
reader = tf.WholeFileReader()
key,value = reader.read(filename_queue)
images = tf.image.decode_png(value)
#设置图像大小
newsize = tf.convert_to_tensor([256,256])
resized = tf.image.resize_images(images, newsize)
print(resized)
#输出是Tensor("Squeeze:0", shape=(256, 256, ?), dtype=float32)
resized.set_shape([256,256,3])
print(resized)
#输出是Tensor("Squeeze:0", shape=(256, 256, 3), dtype=float32)
flipped_images = tf.image.flip_up_down(resized)
print(flipped_images)
#输出是Tensor("ReverseV2:0", shape=(256, 256, 3), dtype=float32)
with tf.Session() as sess:
coord = tf.