【发布时间】:2018-03-19 19:14:03
【问题描述】:
我想用双线性插值调整图像大小。我找到了新的强度值,但我不知道如何使用它。下面是我编写的代码。
def resizeImageBI(im,width,height):
temp = np.zeros((height,width),dtype=np.uint8)
ratio_1 = float(im.size[0] - 1 )/ float(width - 1)
ratio_0 = float(im.size[1] - 1) / float(height - 1)
xx,yy = np.mgrid[:height, :width]
xmap = np.around(xx * ratio_0)
ymap = np.around(yy * ratio_1)
for i in xrange(0, height):
for j in xrange(0,width):
temp[i][j]=im.getpixel( ( ymap[i][j], xmap[i][j]) ) * getNewIntensity(i,j,ratio_1,ratio_0)
return Image.fromarray(temp)
首先得到可变的图像宽高比
lena.png 0.5 1
【问题讨论】:
标签: python python-2.7 image-processing python-imaging-library resize-image