ImageProcessingBasics.com

Digital image processing tutorials and interactive applets

### Sampling and (anti)aliasing

#### Short tutorial

A typical approach of storing an image digitally on a computer, is by sampling the image at a rectangular grid. The color, or intensity, at each of these points is converted into a numeric value and stored in the computer. Apart from the color/intensity at those specific points, everything else is discarded when the image is stored in the computer.

When displaying this digital image, we again form a continuous image by interpolating between the stored samples. One way to do the interpolation is to say that for every ('continuous') point, we merely choose the value at the closest sample. This is known as nearest neighbor interpolation and causes each digital image sample to be drawn on screen as a sharply-defined square. Bilinear or higher-order interpolation gives continuous, smoother and more 'correct' image reconstruction.

Regardless of how we reconstruct the image, if we do not use enough digital samples, that is, not enough samples per image area, we are not able to
reconstruct the original, continuous image. In such a case, the digital image does not contain the same information as that of the original image. The
spatial frequency content of the original image gives rise to different spatial frequency content in the digital image. This is called *aliasing*.

To be able to reconstruct the original image, (that is, avoid aliasing), we have to sample with a spatial frequency that is higher than twice the highest
spatial frequency of the original image. This result is known as the Shannon-Nyquist sampling theorem (or simply *the sampling theorem*).

The above applet will (re)sample an image and reconstruct it by painting each sample as an (enlarged) square. In areas where the original image has a high spatial frequency (or a high resolution, or a high level of details), aliasing will become evident, and the sampled image will contain different content than what is in the original image.

To avoid aliasing, we remove, or dampen, the highest spatial frequency (or the smallest details) of the image, details that we are not able to handle in
the digital image, **before** we do the samling. This is known as *anti-aliasing* filtering.

Related links:

The sampling theorem at Wikipedia.org

#### Applet instructions

Click the images on the upper right to change the image being sampled. The red dots show the sample points. The number of sampling points (the sample resolution) can be adjusted using the slidebar. Checking the anti-aliasing button applies a lowpass filter prior to sampling. The lower image shows the sampled image, where each pixel is being painted as a (enlarged) square.#### Comments

comments powered by DisqusImageProcessingBasics.com © 2008-2016