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
我知道有一個這樣的功能,但正如你所說的嘗試鍛鍊 –