# Thread: Methods of interpolation for scaling images

1. ## Methods of interpolation for scaling images

Hi dear Community,

today i coded a small algorithm for skaling images.
It works like this:

In the following example image i want to scale a 5*s5 pixel image to 3*3.

I have marked one example pixel.

On the left you can see, which source pixels match the destination pixel.
For calculating the value of the destination pixel, i use all pixels from the source image that are covered by the rectangle corresponding to the destination pixel. I give each pixel a weight according to the area of it that is covered.
Sounds complicated, but i can scale down (factor 2) a 2Megapixel-RGB-image in 150ms on my pc (no supercluster ).

When i compare my result with these of Gimp and Photoshop, i don't see a difference in quality, but still a difference.
I am also surprised that Gimp-bilinear is not the same as Photoshop-bilinear. Its the same game with bicubic interpolation.

Here is an example image:

Original (128*128):

Zoom:

Scaled (48*48):

Gimp-bilinear:
http://24htpichost001.24.funpic.de/i...imp_linear.png
Zoom:

Photoshop-bilinear:
http://24htpichost001.24.funpic.de/i...p_bilinear.png
Zoom:

Gimp-bicubic:
http://24htpichost001.24.funpic.de/i..._bikubisch.png
Zoom:

Photoshop-bicubic:
http://24htpichost001.24.funpic.de/i..._bikubisch.png
Zoom:

My Algorithm:
http://24htpichost001.24.funpic.de/i...mgconv_neu.png
Zoom:

In small everything looks the same, but in the zoomed version (this time of course without interpolation) the differences are well visible.

Does anyone of you know, what they make different? I did not get it out of the gimp-sources (scale-region.c). And I am interested in getting to know why Gimp and Photoshop differ. I thought that "bilinear" and "bicubic" are mathematically well defined.

It would be great if someone could help me out.