import tensorflow as tf
import matplotlib.pyplot as plt
import glob
from skimage import io
image_raw_data=tf.gfile.FastGFile('flower/daisy/5547758_eea9edfd54_n.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();
image_data=tf.image.convert_image_dtype(img_data,dtype=tf.uint8);
print(image_data);
encoded_image=tf.image.encode_jpeg(image_data);
with tf.gfile.GFile('path/output.jpg','wb') as f:
f.write(encoded_image.eval());
i=tf.gfile.FastGFile('path/output.jpg','rb').read();
img=tf.image.decode_jpeg(i);
print(img.eval());
利用tensorflow对jpeg格式图像编码解码操作
最新推荐文章于 2024-06-26 09:44:57 发布