0

Je veux redimensionner l'image avec l'interpolation bilinéaire. J'ai trouvé une nouvelle valeur d'intensité, mais je ne sais pas comment je peux l'utiliser .. Le code est ci-dessous que j'est écrit ..redimensionner l'image avec l'interpolation bilinéaire en 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) 

d'abord obtenir le rapport de la largeur d'image variable et rapport hauteur

lena.png 0.5 1 

Orginal image is here

That is output accorting to written code

Répondre

0

Je ne sais pas si vous voulez le faire manuellement comme un exercice ...

sinon, il ya scipy.mics.imresize qui peut faire ce que vous voulez

+0

Je sais qu'il y a une fonction pour cela mais comme vous dites essayer –