def scale_to_h(img,target_height,order=1,dtype=dtype('f'),cval=0):
h,w = img.shape
scale = target_height*1.0/h
target_width = int(scale*w)
output = interpolation.affine_transform(1.0*img,eye(2)/scale,order=order,
output_shape=(target_height,target_width),
mode='constant',cval=cval)
output = array(output,dtype=dtype)
return output
评论列表
文章目录