Week 01 · Pixels, colour, and sampling

See how downsampling creates false patterns and how a filter helps.

Subject contents · Week 2 →

See how downsampling creates false patterns and how a filter helps.

Work through the problem

A digital image samples intensities at discrete positions. A two-times reduction keeps one position out of each pair along each axis. High spatial frequencies can alias into lower frequencies when the new grid cannot distinguish them. A prefilter removes some high-frequency energy before the reduction.

Take a black-and-white checkerboard where every adjacent pixel flips. Sampling the top-left of each 2×2 cell yields only black. Averaging all four pixels before sampling yields gray, preserving mean brightness. This example uses linear intensities. For physical brightness, decode nonlinear colour values before averaging them.

Reducing a fine checkerboard. Panels from left to right: Original, Direct sample, Average first.

Reducing a fine checkerboard.

Run the Python lab

import numpy as np
image = np.indices((12,12)).sum(0)%2
direct = image[::2,::2]
filtered = image.reshape(6,2,6,2).mean((1,3))
print("Means:",image.mean(),direct.mean(),filtered.mean())
assert np.all(direct==0) and np.all(filtered==.5)

Output from the lab

Means: 0.5 0.0 0.5

Practice

  1. If you sample the other phase of the checkerboard, what changes?

Check your reasoning

  1. Offset one axis by one pixel and the direct sample becomes all white. Prefiltered cells still average to gray.

Subject contents · Week 2 →

Further reading · Szeliski · Computer Vision: Algorithms and Applications