I have a raster image (A) of size 20x20 and I want to scale it down to a size of 10x10 (B).

Naturally in the resulting picture B one pixel will represent 4 pixels shaped 2x2 from A.

Is it possible to give a canonical answer to how the pixel values of B have to be calculated if no neighbouring pixels (surrounding the 2x2 subset) in A should be taken into account? Mean, maximum or something else?


Bilinear is the most widely used method. The nearest neighbor down-sampling algorithm is the fastest but least accurate.

Note that when you are trying to down-scale an image by half, the bilinear sampling algorithm becomes the average (mean as you mentioned):

x1[i/2][j/2] = (x[i][j] + x[i+1][j] + x[i][j+1] + x[i+1][j+1]) / 4;

I believe the answer (bilateral is good) can be balanced by the luminance quantization (from 1-bit black and white or true color), and the fact that your image is very small, so standard statistics don't apply here.

Indeed, a mean over $4$ pixels is generally not an integer, and will be rounded at the end. If you stick to $2\times2$ blocks, I would suggest to take the median of the four values: get rid of the min and the max of the four, and take the "nearest" integer (ceil or floor depending on whether you want a darker or brighter icon), and the min or max of the mean of the two remaining pixels. I expect this to limit "intermediate luminance borders" that may not be useful at this size, and avoids grays on low-quantization images. I would treat the corners by "duplicating" the corner value (to limit the chances of an ugly color change at the borders): you will get $5$ pixel values, and then the standard median will be an integer.

More involved processing may resort to averaging $4\times 4$ patches, with a lower weight for the 10 surrounding pixels.

Of course, the effectiveness depends on the morphology of yoour image: is it flat, smoothly varying or stochastic?

Honestly, I suspect this proposal won't change dramatically the result on standard displays.


I also recommend bilinear.

Beware that the default setting of most image editing apps is bicubic interpolation.

Bicubic makes sense for a wide range of scaling: up/down, photo/vector (comparisons here). But when scaling down by a power of two, bilinear results in less distortion.

In this image, I have resized part of an "R" character using bilinear sampling from ImageMagick's -scale option. (In this case, the original image was larger by a power of 2, so we are taking the mean.)

Image shrunk by ImageMagick with -scale

This is bicubic scaling with The GIMP's "cubic" option. Notice how a few extra bright and dark "ringing" pixels were introduced, which make the edge appear sharper, but also look a bit dirty under close inspection.

Image shrunk by The GIMP with cubic scaling

The effect is even stronger when scaling with ImageMagick's -geometry or -resize option.

Image shrunk by ImageMagick with -resize


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.