Anti-Aliasing
Aliasing happens when a signal is sampled too sparsely. A high-frequency component then produces exactly the same samples as a lower-frequency one, so after reconstruction it appears as that lower frequency. The lecture describes aliases as signals “traveling in disguise” as other frequencies. Anti-aliasing is any method that prevents this.
Measure frequency in cycles per pixel, on a grid with one sample per pixel. A sinusoid at and one at , for any integer , give identical samples. A cosine at also matches one at , since cosine is even. So only frequencies in can be told apart. In general, a grid with sampling rate represents frequencies up to the Nyquist frequency , so each period must span at least samples. A component above the limit is reconstructed at the lowest frequency that fits its samples, for the integer nearest to .
Downsampling by halves the sampling rate, so it halves the highest representable frequency, from to cycle per original pixel. Detail between those limits aliases unless it is removed first. The lecture gives two fixes. We can sample more often (more megapixels), which cannot go on forever. Or we can make the signal less “wiggly” with a low-pass filter before sampling, which loses detail but is better than aliasing. For images the standard fix is to blur, then subsample:
Here is the image at level of a Gaussian pyramid, is a normalized Gaussian filter, and keeps every other row and column. The order matters, because a blur after subsampling cannot remove an alias that is already in the samples. The filter size should double for each halving of the image size, since each halving halves the cutoff frequency. Common aliases are the wagon-wheel effect in video, Moiré patterns on fabric and brick, and the “disintegrating” checkerboard of a rendered floor.
Which Pixels Measure the Frequency
Discussion 3 says the highest frequency halves after downsampling by . That statement measures frequency in original pixels, where the limit drops from to cycle per pixel. Measured in the new, larger pixels, the limit is still cycle per pixel. Mixing the two units is the usual source of wrong answers. Every frequency in a calculation should be converted to one pixel size first.
Intuition
Sampling writes down a signal’s values at points, and reconstruction draws the smoothest curve through them. If the signal wiggles faster than the samples, the dots trace out a slower wave. Information is lost, which is unsurprising. The surprising part is that the result is a different, believable signal. In the figure below, the true wave makes cycles every samples. Its dots fit a wave with cycle every samples, flipped upside down. An alias is a false name, and here a high frequency travels under the name of a low one. Anti-aliasing removes the frequencies that would take a false identity, before they are sampled.
\usepackage{tikz}
\usepackage{amsmath}
\begin{document}
\definecolor{fake}{HTML}{D9483B}
\definecolor{mid}{HTML}{8A8A8A}
\begin{tikzpicture}[x=1.15cm,y=1.1cm,>=latex,font=\small]
\draw[->] (0,0) -- (8.5,0) node[right] {$n$ (pixels)};
\draw[->] (0,-1.3) -- (0,1.5);
\foreach \n in {0,...,8} {\draw (\n,0.06) -- (\n,-0.06) node[below=1pt] {\scriptsize $\n$};}
\draw[mid,thin,domain=0:8,samples=400] plot (\x,{sin(315*\x)});
\draw[fake,very thick,domain=0:8,samples=120] plot (\x,{-sin(45*\x)});
\foreach \n in {0,...,8} {\fill (\n,{-sin(45*\n)}) circle (2.2pt);}
\node[mid,anchor=west] at (0.2,1.35) {true signal $\sin(2\pi \cdot \tfrac{7}{8} n)$};
\node[fake,anchor=west] at (4.6,1.35) {alias $-\sin(2\pi \cdot \tfrac{1}{8} n)$};
\end{tikzpicture}
\end{document}The trade-off is between detail and correctness. A blur removes real detail before sampling. Skipping it replaces that detail with false detail, such as the wavy bands that appear on a striped shirt when odd rows and columns are deleted. A blurred thumbnail still looks like the scene. An aliased one shows patterns the scene never had.
Properties
(Filter Width Doubles) Halving the cutoff frequency requires a Gaussian twice as wide.
The Fourier transform of a Gaussian with standard deviation pixels is a Gaussian with standard deviation cycles per pixel. Its frequency reach is inversely proportional to its width, so each halving of the Nyquist limit calls for a doubled . A pyramid that applies the same kernel at every level gets this automatically, since one pixel at level spans original pixels. Shrinking by in one step needs a twice as large as shrinking by . A stack, which never shrinks, must widen its blur explicitly from level to level.
(A Practical Kernel) The binomial weights form a common blur for a factor- shrink.
These are the bell-shaped weights from the lecture’s weighted moving average. They sum to , so flat regions keep their brightness. They are the probabilities of to heads in four fair coin flips, so their variance is , which gives pixel. On the alternating row (the finest pattern, at cycle per pixel) the output is , so that pattern is removed completely. At the new limit of cycle per pixel the kernel passes of the amplitude. A Gaussian never cuts off sharply, so a weak alias always remains. The lecture’s rule of thumb sets the kernel half-width to about .
(Order Matters) Subsampling first folds high frequencies onto low ones, after which no filter can separate them.
Before subsampling, the alias-prone content sits at frequencies above cycle per original pixel, apart from the safe content below. A low-pass filter can remove it there. After , that content has moved onto the same low frequencies as real scene structure. A blur would now weaken both together. Discussion 4 states that blurring after downsampling cannot undo aliasing that has already occurred. Discussion 3 notes that pyramids built without careful anti-aliasing produce distorted coarse levels, which can break coarse-to-fine alignment in Project 1.
(Lowest-Frequency Reconstruction) Reconstruction resolves the ambiguity by choosing the lowest frequency that fits the samples.
The samples cannot tell from or from . Reconstruction picks the member of that family in , so an alias always appears at a lower frequency than the truth. Content slightly above the limit folds to slightly below it. Content near a multiple of the sampling rate folds to near and shows up as slow, broad patterns such as Moiré bands. For a sine the folding also flips the sign, since at integer . A rotation sampled in time can therefore appear to run backward, which is the wagon-wheel effect.
\usepackage{tikz}
\usepackage{amsmath}
\begin{document}
\definecolor{fake}{HTML}{D9483B}
\definecolor{safe}{HTML}{2F80ED}
\begin{tikzpicture}[x=9cm,y=1cm,>=latex,font=\small]
\fill[safe!15] (0,-0.2) rectangle (0.5,0.2);
\draw[->] (0,0) -- (1.08,0) node[right] {$u$ (cycles per pixel)};
\draw (0,0.12) -- (0,-0.12) node[below] {$0$};
\draw (0.5,0.12) -- (0.5,-0.12) node[below] {$\tfrac12$ (Nyquist)};
\draw (1,0.12) -- (1,-0.12) node[below] {$1$};
\node[safe,below] at (0.22,-0.25) {representable};
\fill[fake] (0.9,0) circle (1.6pt);
\fill[fake] (0.6667,0) circle (1.6pt);
\fill[safe] (0.1,0) circle (1.6pt);
\fill[safe] (0.3333,0) circle (1.6pt);
\draw[->,fake,thick] (0.9,0.1) to[bend right=50] node[above] {$0.9 \mapsto 0.1$} (0.1,0.1);
\draw[->,fake,thick] (0.6667,0.1) to[bend right=40] node[above] {$\tfrac23 \mapsto \tfrac13$} (0.3333,0.1);
\end{tikzpicture}
\end{document}(Aliasing in Time) A short shutter samples motion at isolated instants, so fast periodic motion aliases.
Video samples time at a fixed rate, such as frames per second. When the shutter is open for only a fraction of the frame time, each frame is a nearly instant sample with no motion blur. A wheel with identical spokes looks the same after turning by one spoke spacing. Its rotation per frame is therefore known only up to that spacing. A long exposure blurs the motion over the frame time. That blur acts as a low-pass filter in time and weakens the effect.
Examples
(Easy) Dots That Lie
A row of pixels samples the signal at the integers
Which frequency does reconstruction show? What changes if the signal is instead? The frequency cycle per pixel is above the limit of . The nearest integer is , so the alias is at cycle per pixel, a period of pixels. At integer , because . The reconstruction is a slow wave, times slower than the truth and upside down. For the cosine the same steps give , the same slow wave without the flip.
(Medium) The Wagon Wheel
A wheel with identical spokes spins clockwise at revolutions per second. A video camera records it at frames per second with a short shutter.
How does the wheel appear to move? At what speed does it look frozen, and what is the fastest speed shown correctly? . With spokes the pattern repeats every , so a turn of looks the same as a turn of . The eye picks the smallest motion, so the wheel seems to turn per frame counterclockwise. That is per second, or revolution per second backward.
Per frame the wheel turns
At revolutions per second the wheel turns exactly per frame, and every frame looks identical, so the wheel looks frozen. The motion is shown correctly only while the turn per frame stays below half the spoke spacing, . That is the Nyquist condition here, and it allows at most revolutions per second.
(Hard) Brick Stripes in a Pyramid
A wall photo contains horizontal stripes with a period of pixels, modeled along one column as . We build the next pyramid level with and without the blur .
Is the stripe safe at full resolution? What does plain show? How strong is the alias after blur-then-subsample? At full resolution , so the stripe is represented correctly.
Plain keeps . In the new pixels the frequency is , so it aliases to cycle per new pixel. The kept values repeat , the same numbers as the original. Each new pixel spans original pixels, so the stripes now have a period of original pixels. The coarse level shows full-contrast stripes at half their true frequency.
The kernel is symmetric, so filtering a cosine returns the same cosine scaled by the kernel’s frequency response
At both cosines equal , so . The blurred stripe is , and after the false stripes remain at of their contrast. They are still aliases, but times weaker and hard to see. A wider blur would weaken them further and also soften real detail near the new limit.
See Also
- 2.3. Resampling, for and .
- 2.5. Image Pyramids, which apply blur-then-subsample at every level.
- 2.2. Fourier Transform in Images, for the Gaussian-to-Gaussian transform pair and the box-to-sinc pair.
- 2.10 Sampling Theory, the signals treatment of the sampling theorem.