The Math Behind How Digital Photo Resizing Works

When you resize (and resample) a photo in Photoshop, you’re given the option of strategies such as Nearest Neighbor and Bilinear. If you have no idea what those mean, check out this 9-minute video by Computerphile.

In it, Dr. Mike Pound of the University of Nottingham explains Nearest Neighbor and Bilinear using pen and paper.

penpaper

Here’s how Wikipedia describes the two:

Nearest Neighbor: “Replacing every pixel with a number of pixels of the same color: The resulting image is larger than the original, and preserves all the original detail, but has (possibly undesirable) jaggedness. Diagonal lines, for example, will show the “stairway” shape characteristic of nearest-neighbor interpolation.”

Bilinear and Bicubic: “This works by interpolating pixel color values, introducing a continuous transition into the output even where the original material has discrete transitions. Although this is desirable for continuous-tone images, this algorithm reduces contrast (sharp edges) in a way that may be undesirable for line art. Bicubic interpolation yields substantially better results, with only a small increase in computational complexity.”

Check out the Wikipedia article on “Image Scaling” for a more comprehensive look at the other strategies commonly (and less commonly) used.

Discussion