0
我想用双线性插值调整图像大小。我找到了新的强度值,但我不知道我该如何使用它..代码如下这是我写的..在python中用双线性插值调整图像大小
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
That is output accorting to written code
我知道有一个这样的功能,但正如你所说的尝试锻炼 –