import tensorflow as tf
import matplotlib.pyplot as plt
image_raw_data = tf.gfile.FastGFile('cat.jpg', 'rb').read()
with tf.Session() as sess:
img_data = tf.image.decode_jpeg(image_raw_data)
print(img_data.eval())
plt.imshow(img_data.eval())
plt.show()
img_data = tf.image.convert_image_dtype(img_data, dtype=tf.uint8)
encoded_image = tf.image.encode_jpeg(img_data)
with tf.gfile.GFile('output', 'wb') as f:
f.write(encoded_image.eval())
图像编码处理
最新推荐文章于 2024-05-31 09:05:13 发布