tf.image.crop_and_resize()使用

1,344 阅读1分钟
f.image.crop_and_resize()
官方链接:tensorflow.google.cn/api ... age…

用法
tf.image.crop_and_resize(
image,
boxes,
box_ind,
crop_size,
method='bilinear',
extrapolation_value=0,
name=None
)
参数
image:张量。必须是下列类型之一:uint8,uint16,int8,int16,int32,int64,half,float32,float64;
boxes:float32类型张量,指需要划分的区域,输入格式为 [[ymin,xmin,ymax,xmax]] ;
box_ind:int32类型张量;
crop_size:裁剪尺寸;
method:方法,"bilinear", "nearest"。
例子
import tensorflow as tf
import matplotlib.pyplot as plt
img = plt.imread('F:aa.jpg')
shape = img.shape
img = img.reshape([1,shape[0], shape[1], shape[2]])
a = tf.image.crop_and_resize(img,[[0.5,0.5,0.6,0.2],[0.5,0.5,1.3,0.9]],
box_ind=[0,0],crop_size=(100,100))
sess = tf.Session()
b = a.eval(session = sess)
plt.imshow(b[0]/255)
plt.imshow(b[0].astype('uint8'))
img = plt.imread('F:aa.jpg')#代表路径
结果


---------------------
作者:蹦跶的小羊羔
来源:CSDN
原文:blog.csdn.net/yql_6175402…
版权声明:本文为博主原创文章,转载请附上博文链接!

更多学习资料可关注:annalin1203获取