tensorflow之读取jpg图像长和宽

有时需要读取jpg图像的长和宽,tensorflow提供了很好的支持

直接上示例

decode_jpeg_data = tf.placeholder(dtype=tf.string)
decode_jpeg = tf.image.decode_jpeg(decode_jpeg_data, channels=3)

image_data = tf.gfile.FastGFile("C:/Users/shenwei/Desktop/timg.jpg", 'rb').read()
print(len(image_data))
with tf.Session() as sess:
    image = sess.run(decode_jpeg,feed_dict={decode_jpeg_data: image_data})
    print(image.shape[0])
    print(image.shape[1])

注意看image,shape是(800,800,3) 表示长为800 宽为800 3个通道

猜你喜欢

转载自blog.csdn.net/g0415shenw/article/details/86488522