您的位置:首页 > 其它

tensorflow改变图片大小且不改变像素大小的方法

2019-06-24 16:10 134 查看

方法:tf.image.resize_images(img_data_jpg, (256,256), method=0)
参数:image表示需要改变此存的图像,第二个参数改变之后图像的大小,method用于表示改变图像过程用的差值方法。0:双线性差值。1:最近邻居法。2:双三次插值法。3:面积插值法。

import matplotlib.pyplot as plt
import tensorflow as tf
image_raw_data_jpg = tf.gfile.FastGFile('./5441.png', 'rb').read()
with tf.Session() as sess:
img_data_jpg = tf.image.decode_jpeg(image_raw_data_jpg)
#img_data_jpg = tf.image.convert_image_dtype(img_data_jpg, dtype=tf.uint8)
resize_0 = tf.image.resize_images(img_data_jpg, (256,256), method=0)
resize_1 = tf.image.resize_images(img_data_jpg, (256,256), method=1)
resize_2 = tf.image.resize_images(img_data_jpg, (256,256), method=2)
resize_3 = tf.image.resize_images(img_data_jpg, (256,256), method=3)#像素值变了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: