我是tensorflow的新手。我正在从文件中读取图像,并使用tf.image.decode_jpeg对其进行解码,然后使用matplotlib绘制解码图像。但不知何故原始和解码图像是不同的。Tensorflow没有正确解码图像
filenames = ['/Users/darshak/TensorFlow/100.jpg', '/Users/darshak/TensorFlow/10.jpg']
filename_queue = tf.train.string_input_producer(filenames)
reader = tf.WholeFileReader()
filename, content = reader.read(filename_queue)
image = tf.image.decode_jpeg(content, channels=3)
image = tf.cast(image, tf.float32)
resized_image = tf.image.resize_images(image, [256, 256])
image_batch = tf.train.batch([resized_image], batch_size=9)
sess = tf.InteractiveSession()
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(sess=sess, coord=coord)
plt.imshow(image.eval())
plt.show()
sess.close()
你能告诉我们你使用绘制代码图片? – Suever
没有代码,我最好的猜测是你使用OpenCV来加载图像,它们将它们加载为BGR并将它们加载matplotlib,将它们绘制为RGB,从而产生问题。 –