# Lenna and the Math of Image Processing

By Murray Bourne, 13 Mar 2007

Every image that you see on the Internet has been **compressed**. The images have gone through a mathematical process that has reduced the file size without significantly affecting the image quality.

Lenna

This photo of Lenna, a 70s model, is probably the most gawked-at image in computer- and math-nerd history. The photo has been used as a test image for many years, because of its different textures, lighting, skin tones and colours.

The photo has a JPG extension, indicating it has been compressed using the JPEG (Joint Photographic Experts Group) method. This method is **lossy**, which means there is a trade-off between the file size and the data that has been lost from the picture. The human eye is good at filling in the gaps of an image, so we don't notice mild amounts of compression. But especially on computer screens, it doesn't matter much at all if the image has been compressed. When we print images that we got from the Internet, we can usually notice compression artifacts (globby bits that were not on the original photo but arise when the image is compressed.)

Here is Lenna using a compression ratio of 99. The image is barely recognisable:

The mathematics behind JPEG images is the **discrete cosine transform**, which is related to the Fourier Transform. [See Fast Fourier Transform, which describes how digital audio is sampled.] The discrete cosine transform also involves matrices.

According to this Wikipedia article,

The human eye is good at seeing small differences in brightness over a relatively large area, but not so good at distinguishing the exact strength of a high frequency brightness variation. This fact allows one to get away with greatly reducing the amount of information in the high frequency components. This is done by simply dividing each component in the frequency domain by a constant for that component, and then rounding to the nearest integer. This is the main lossy operation in the whole process. As a result of this, it is typically the case that many of the higher frequency components are rounded to zero, and many of the rest become small positive or negative numbers, which take many fewer bits to store.

There is a similar concept in use for digital movies (the MPG format is also lossy) and music compression (think MP3 and MP4).

**Footnote:** Lenna's story is quite interesting. You can see more of Lenna and find out what magazine she was modeling for at www.lenna.org. (If artistic nudity offends, don't go any further.)

See the 3 Comments below.