image.resize_images()-tensorflow里面用于改变图像大小的函数

https://blog.csdn.net/UESTC_C2_403/article/details/72699260

tensorflow里面用于改变图像大小的函数是

tf.image.resize_images(image, (w, h), method)

image表示需要改变此存的图像,

(w,h)第二个参数改变之后图像的大小,

method用于表示改变图像过程用的差值方法。0:双线性差值。1:最近邻居法。2:双三次插值法。3:面积插值法。

例如:

import matplotlib.pyplot as plt;
import tensorflow as tf;
 
image_raw_data_jpg = tf.gfile.FastGFile('11.jpg', 'r').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.float32)
	resize_0 = tf.image.resize_images(img_data_jpg, (500, 500), method=0)
	resize_1 = tf.image.resize_images(img_data_jpg, (500, 500), method=1)
	resize_2 = tf.image.resize_images(img_data_jpg, (500, 500), method=2)
	resize_3 = tf.image.resize_images(img_data_jpg, (500, 500), method=3)
	
	print resize_0.get_shape
 
	plt.figure(0)
	plt.imshow(resize_0.eval())
	plt.figure(1)
	plt.imshow(resize_1.eval())
	plt.figure(2)
	plt.imshow(resize_2.eval())
	plt.figure(3)
	plt.imshow(resize_3.eval())
 
	plt.show()

结果:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值