def resize_to_shape(data, height, width, order=1):
h, w = np.shape(data)[0:2]
factor_h = height / float(h)
factor_w = width / float(w)
if len(np.shape(data)) == 3:
scale_factor = [factor_h, factor_w, 1.0]
else:
scale_factor = [factor_h, factor_w]
return sci.zoom(data, scale_factor, order=order)
评论列表
文章目录