matplotlib.pyplot是一个python的画图工具,当读取jpg格式的文件时,可以对图像进行解码,解码之后的结果是一个张量,利用程序输出解码之后的三维矩阵和重构出的解码后的图像,代码以及结果如下:

import tensorflow as tf
import matplotlib.pyplot as plt
sess = tf.Session()
# 加载一张彩色图像
image_filename = '97.jpg'
image_file = tf.gfile.FastGFile(image_filename,'rb').read()
# 解码
image1 = tf.image.decode_jpeg(image_file)
#print(image1.eval())
print(sess.run(image1))
#print(image.eval())
plt.imshow(sess.run(image1))
plt.show()

python对jpeg图像的编码

相关文章:

  • 2021-12-02
  • 2022-12-23
  • 2021-11-01
  • 2022-12-23
  • 2022-01-21
  • 2021-12-09
猜你喜欢
  • 2022-01-15
  • 2021-09-05
  • 2022-12-23
  • 2021-08-18
  • 2022-12-23
  • 2021-06-10
  • 2021-04-27
相关资源
相似解决方案