BookNotesSlidesP-sets Syllabusdraft · v0.2.49.1
◀▲⌂▶
💬Comments welcome. To leave a note, select any text and click the note / highlight button that pops up — or open the panel with the tab at the top-right (‹). Notes are visible only inside our private review group.
💡 In a hurry? Jump to this chapter’s 6 big lessons ↓

6.4 Sampling, downsampling, and aliasing⧉

A camera integrates light over each pixel’s spatial footprint and exposure interval, then records those measurements on a grid. We can model this as filtering followed by point sampling. The filtering reduces fine detail, but generally does not remove every frequency the grid cannot resolve. Resizing introduces another sampling step and another opportunity for aliasing. Chapter 6.5, Resampling and upsampling treats reconstruction between samples; here we examine the information lost or confused by the sampling grid.

6.4.1 Aliasing: a high frequency in disguise⧉

Picture photographing a building's facade (rows of fine windows, or a striped shirt) and shrinking the result. Where the stripes are finer than the output pixels, they do not melt into a uniform gray; they reorganize into bold, wrong, low-frequency bands and swirls that are not in the scene at all: moiré. Intuitively, when a pixel must summarize detail it cannot represent, it ought to return the local average, a neutral gray. Instead, the leftover high frequency gets misread as a low one.

The clean case is a single sine wave (Figure 6.4.1). Sample a high-frequency sine too coarsely (fewer than two samples per cycle) and the samples you collect fall into a pattern indistinguishable from a lower-frequency sine. The original travels in disguise as a different frequency; that impostor frequency is its alias. The damage is not blur (lost detail you could shrug off); it is corruption: energy that lands at the wrong frequency and masquerades as real structure. The same masquerade plays out in 2-D on a real photograph (Figure 6.4.2): a facade's regular window grid is a high spatial frequency, and sampling it too coarsely without a pre-filter folds that grid down into bold, slow moiré bands that are not in the building.

fig-aliasing
Figure 6.4.1. Sampling a sine too coarsely → aliasing. A high-frequency sinusoid (light) is sampled at too few points per cycle; the samples (dots) are consistent with a completely different, lower-frequency sinusoid (dark), its alias. Below twice the signal's frequency (the Nyquist rate) the two are indistinguishable from the samples alone: the high frequency "folds" down and masquerades as a low one. This is the moiré / wagon-wheel effect.
fig-aliasing-photo
Figure 6.4.2. The same aliasing on a real photo. A building facade, a dense, near-periodic grid of windows, i.e. a high spatial frequency, sampled ×7 by simply dropping samples, with no pre-filter. The window frequency, above the coarse grid's Nyquist, folds back into bold, slow, curved moiré bands that are not in the building (center; zoom at the bottom). It is the one-dimensional sine of the previous figure acting in two dimensions on a real image: high frequency masquerading as low. The cure (pre-filter, then sample) is below.

6.4.2 Nyquist and the sampling theorem⧉

For an ideal band-limited signal with highest frequency $f_{\max}$, uniform samples at rate $f_s>2f_{\max}$ determine the signal exactly. The Nyquist frequency is $f_s/2$. The strict inequality avoids the boundary case: a sine exactly at Nyquist can vanish at every sample for one phase. The theorem assumes an unlimited sequence of exact samples; finite, noisy measurements require further choices.

Frequencies separated by an integer multiple of the sampling rate produce identical complex samples:

$$e^{2\pi i(f+mf_s)n/f_s}=e^{2\pi ifn/f_s},\qquad m,n\in\mathbb Z.$$

For example, at 100 samples per unit length, cosines at 70 and 30 cycles per unit length give the same samples. A lone sampled image cannot distinguish them without assumptions. Additional shifted measurements or a restrictive scene model can resolve some ambiguities; applying a blur afterward cannot generally separate components already mixed by aliasing.

💡 Big lesson (L6.13) — Nyquist–Shannon: sample above twice the highest frequency, or it aliases

Sample above twice the highest retained frequency. If the signal is too detailed for the grid, low-pass it before sampling. This applies to space and time. Real prefilters have finite transition bands, so allow a margin below Nyquist and check residual aliasing.

The theorem cuts both ways, which is why it is so central. It tells you when sampling is safe (the signal is already band-limited below Nyquist, so nothing folds) and exactly what to do when it is not: kill the offending frequencies before they fold. And because it is a statement about any sampled signal, it reappears far beyond image shrinking: in audio (the 44.1 kHz CD rate is a little over twice the ~20 kHz of human hearing), in video frame rates, and (on the time rather than the space axis) as the temporal aliasing we just named.

6.4.3 In two dimensions, aliasing has a direction⧉

On a rectangular 2-D grid, aliasing folds each frequency coordinate by the sampling rate along that axis. A frequency vector can therefore change both length and orientation. A purely vertical grille does not acquire an arbitrary diagonal orientation on an aligned rectangular grid; both frequency coordinates and the grid geometry determine the alias.

A sharp slanted edge contains arbitrarily high frequencies perpendicular to the edge. Point-sampling it produces a staircase whose pattern depends on its position relative to the grid. Pixel-area integration softens the staircase, though a box footprint is not an ideal band limit. Rendering and image reduction use the same prefiltering principle.

fig-aliasing-2d
Figure 6.4.3. Aliasing is directional in 2-D. A regular 2-D pattern (a near-periodic grid and a slanted edge), point-sampled on a coarse grid without a prefilter, aliases in ways 1-D cannot: the grid's high spatial frequency folds to a low frequency of a different orientation, so the moiré bands run in a direction unrelated to the windows that caused them, while the slanted edge breaks into the canonical stair-step / "jaggies." A 2-D frequency carries a direction as well as a rate, and aliasing folds both, which is why 2-D moiré appears in unexpected directions. The cure is the same as in 1-D: prefilter (area-average) before sampling.

For example, sample a sinusoid with frequency components 0.6 cycles per pixel horizontally and 0.2 vertically on an integer pixel grid. Subtracting one horizontal cycle per pixel changes its frequency vector to (−0.4, 0.2) without changing the samples: the phase difference at every integer horizontal coordinate is a whole number of cycles. The apparent orientation changes because the horizontal component has folded while the vertical component has not. A regular texture containing several frequency components can therefore produce moiré at orientations absent from the visible coarse structure of the original texture.

6.4.4 Sampling in the frequency domain: spectral replicas⧉

In the frequency domain the mechanism is vivid. Sampling on a grid is multiplying the signal by a comb of spikes, and multiplying by a comb in space replicates the spectrum: it pastes shifted copies of the signal's spectrum at every multiple of the sampling rate. If the original spectrum is narrow enough (band-limited below Nyquist), the copies sit side by side without touching and the original can be isolated. If it is too wide, the copies overlap, the tails fold back over the genuine low frequencies, and that overlap is aliasing. Seen this way the fix is obvious: band-limit the signal before you sample it. Run a low-pass filter (a blur) first, to delete the frequencies above Nyquist that would otherwise fold, then sample. This pre-filter (anti-aliasing) trades a little sharpness for the removal of false structure, and it is why a well-written image-shrinking routine blurs before it downsamples. The space-versus-frequency tradeoff returns: a perfectly sharp cutoff in frequency is a sinc spread out forever in space, so practical pre-filters compromise.

Figure 6.4.4 draws the multiplication in space first, then the replicated spectrum it produces.

fig-sampling-comb-1d
Figure 6.4.4, stage 1. Sampling as multiplication by a Dirac comb. Left: the input f(x), a sine, a box, a sawtooth, a box train, or one row of a photograph (linearly interpolated and tapered at its ends). Middle: the comb Σ δ(x − nT), unit Diracs drawn as arrows every T. Right: their product, Diracs of weight f(nT), with f drawn faintly behind. Change the input, its parameters and the sampling rate 1/T: the arrows on the right are all that remains of f.
fig-sampling-comb-1d
Figure 6.4.4, stage 2. The same three signals with, below each, its Fourier transform, u in cycles per unit length. Left: the input's spectrum, Diracs (arrows) for the periodic inputs and a continuous curve for the box and the scanline; real spectra (box, box train) are drawn signed, the others as magnitudes. Middle: the comb's transform, another comb, with teeth of weight 1/T every 1/T, each in its own color, k and −k different (blue for k = 0, red for +1, orange for −1, green for +2, purple for −2). Right: the samples' transform, (1/T) Σ F(u − k/T), one copy of the input's spectrum per tooth in that tooth's color, drawn over their sum in gray. Dirac copies that land on the same frequency add, and that sum is drawn black too. The black curve is computed from the samples themselves (their discrete-time Fourier transform) and matches the sum of copies, which is Poisson summation. The shaded band is ±1/(2T), the Nyquist band. Lower the rate until a copy with k ≠ 0 enters the band: that is aliasing. A sine at 3 cycles per unit sampled at 4.5 per unit shows its k = ±1 copies at ±1.5.
fig-sampling-comb-1d
Figure 6.4.4, stage 3. Prefilter first. The same pipeline with the input replaced by $g = f \ast h$, where $h$ is a box of width $T$, a Gaussian with $\sigma = T/2$, or a Lanczos-3 kernel stretched to the sampling period (Gaussian by default; "none" brings back the unfiltered case to compare). Top left, $g$ with $f$ faint behind it; below, $G = F\cdot H$ with $|F|$ faint and $H$ in gray. The samples now read $g$, and the samples' spectrum keeps the scale the unfiltered copies had, so what the prefilter removed shows: the copies' tails that reached into the Nyquist band, the aliasing of the previous stage, are mostly gone, at the price of the detail $H$ attenuates below Nyquist. A sine at 7 cycles per unit sampled at 10 per unit still aliases to 3 cycles per unit, but the Gaussian has kept only 0.09 of it.
💡 Big lesson (L6.14) — sampling replicates the spectrum; aliasing is the replicas overlapping

Sampling on a grid is multiplication by a comb (a train of deltas), and a comb's Fourier transform is another comb, so sampling replicates the signal's spectrum at every multiple of the sampling rate. If the spectrum is band-limited below Nyquist the copies sit side by side and the original is recoverable; if it is not, the copies overlap, and the folded-over tails land on top of the genuine low frequencies as aliasing: energy appearing at completely wrong frequencies (moiré, the backward wagon-wheel). The cure is to band-limit before sampling: low-pass away everything above Nyquist first, then sample.

6.4.5 Seeing it: sampling and pre-filtering, hands on⧉

The demos below show this directly. The first demo is the one-dimensional story (a single signal, your hand on the sampling rate), and the second is the two-dimensional one, the same physics on a real photograph where aliasing shows up as moiré.

fig-sampling-1d-demo
Figure 6.4.5. Interactive (1-D): sampling, aliasing, and the pre-filter. An input, by default the same image scanline as Figure 6.4.4 (the middle row of the old-town rooftops), or a periodic signal (a sine, square or sawtooth at a frequency you choose), is shown with its samples; drag the sampling rate and watch the reconstructed signal alias to a lower frequency the moment you drop below Nyquist (two samples per cycle), with both the signal and its spectrum (the replicated spectral copies) drawn side by side. Where replicas overlap, the spectrum shows the magnitude of their complex sum, which includes reinforcement and cancellation; the magnitudes of overlapping copies do not simply add. Toggle the anti-aliasing pre-filter (a low-pass blur applied before sampling) and watch the offending high frequencies attenuated before they can fold: the alias fades, at the cost of a little blur. A Gaussian or other finite filter attenuates rather than strictly band-limits, so some alias can remain. Tick marks mark the sample locations.
fig-sampling-2d-demo
Figure 6.4.6, stage 3. Interactive (2-D): downsampling, aliasing, and the pre-filter. Choose a source, a high-frequency zone-plate (the default; concentric rings that get finer toward the edge), a resolution chart, or a real photo, and downsample it by an adjustable factor, shown three ways side by side. Original: the true rings. No pre-filter: point-sampling the coarse grid folds the fine outer rings into bold, spurious moiré rosettes that are nowhere in the pattern: 2-D aliasing. With pre-filter: attenuating the fine rings before decimating removes most of the moiré; no finite filter removes all of it. Choose the filter, box (area average), bilinear, the bicubic (Mitchell–Netravali) family, or Lanczos (windowed sinc, the sharpest), and raise the factor to watch the middle's moiré grow while the right mostly softens. Compare residual moiré, blur and ringing across the filters: none is best on all three. The panels are cropped to the valid interior so every pixel shown had the pre-filter's full support: a kernel near the image edge reaches past it and the demo edge-clamps those reads, which would bias the border, so the artifact you might worry about there is boundary handling, not kernel truncation (the truncated kernel is renormalised), and cropping to full-support pixels removes it from the display.

The full sampling pipeline generalizes to two dimensions just as cleanly, and the spectral picture is the most revealing part: in 2-D, sampling replicates the spectrum on a whole lattice of copies, and aliasing is a copy drifting in to overlap the baseband.

fig-sampling-2d-pipeline
Figure 6.4.7. Interactive (2-D pipeline): the planar version of the 1-D figure, four columns (input → pre-filtered → sampled → reconstructed), each shown both as an image (top) and as its 2-D Fourier magnitude (bottom, DC centered, out to about 3.3× the sampling Nyquist); with no pre-filter, the second column is left empty. The input is a 2-D sine (set frequency and orientation) or a straight edge (set its angle). Sampling on a coarse grid tiles the spectrum on a lattice: drop the rate and the replicas march inward until one overlaps the baseband: 2-D aliasing, which the reconstruction then renders as a wrong, lower-frequency moiré. A dashed box on the pre-filtered spectrum marks the sampling Nyquist, and in the sampled spectrum the baseband is blue and the alias replicas red, so red over blue is the aliasing at a glance. A pre-filter attenuates the baseband's high frequencies so the copies overlap less, though a finite filter does not remove every alias; the reconstruction filter interpolates the samples back. The pre-filter and reconstruction run as real spatial convolutions, and the upper images are what to judge. The spectrum panels are illustrations: for the sine they come from windowed FFT magnitudes, for the edge from a broadened, flattened model of an ideal step's spectral line (drawn for legibility, not the exact $1/f$ transform), and the red and blue overlays add magnitudes to show where copies could overlap, without the phase that decides the actual sampled transform. Each panel is scaled on its own, so brightness does not compare energy across panels.
Video 6.4.1. Video: The more general uncertainty principle, regarding Fourier transforms, by 3Blue1Brown (YouTube).

6.4.6 The ideal reconstruction filter: sinc, and why it is unreachable⧉

For uniform spacing $T=1/f_s$, ideal reconstruction of a signal band-limited below Nyquist is

$$I(x)=\sum_{n=-\infty}^{\infty} I(nT)\operatorname{sinc}(x/T-n),\qquad \operatorname{sinc}(z)=\frac{\sin(\pi z)}{\pi z},\quad \operatorname{sinc}(0)=1.$$

Each sample contributes a shifted sinc. At the sample locations, every other sinc is zero. The infinite sum makes exact reconstruction impractical for a finite image. Practical kernels limit support and trade passband attenuation, stopband leakage, and ringing. Sharp low-pass filtering can overshoot an edge even before truncation; truncation is not the sole cause. Chapter 6.5, Resampling and upsampling develops the usable kernels.

💡 Big lesson (L6.15) — the ideal sampling filter is a sinc, which does not exist in practice

Ideal band limiting and ideal interpolation use sinc kernels, scaled for their respective grids. Their infinite support requires approximation in finite computations. A finite filter trades computation and frequency selectivity; inspect both aliasing and edge overshoot.

fig-sinc-vs-practical
Figure 6.4.8. Ideal sinc vs a practical filter, in both domains. Top row (space): the ideal sinc reconstruction kernel ripples on forever, while a practical filter has finite support. Bottom row (frequency): the sinc is a perfect box (flat passband, vertical cutoff at Nyquist, zero beyond), whereas the practical filter rolls off gradually, slightly softening mid-frequencies and leaking a little past Nyquist. The vertical wall in frequency is exactly what forces the infinite ripple in space.

Figure 6.4.9 puts the whole chain in one place, one column per step: the input, the prefilter, the samples, the reconstruction, and the reconstruction as a viewer perceives it.

fig-sampling-reconstruction-1d
Figure 6.4.9, stage 1. The sampling pipeline in one dimension, one column per step, each signal above and its Fourier transform below (u in cycles per unit length). The first column is the input: a box train (period 0.37, half on, the default), a sine, a box, a sawtooth, or one row of a photograph. Periodic inputs have Diracs for spectra, drawn as arrows; real spectra are drawn signed, the others as magnitudes.
fig-sampling-reconstruction-1d
Figure 6.4.9, stage 2. The prefilter, g = f ∗ h, with h tied to the sample spacing T: a box of width T, a Gaussian of standard deviation T/2, or a Lanczos-3 windowed sinc scaled by T. Below, G = F·H, with H in gray on a scale where the top rule is 1, and the Nyquist band ±1/(2T) shaded. The stage opens on the Gaussian, which at 10 samples per unit keeps 0.70 of the box train's fundamental (2.70 cycles per unit) and 0.04 of its third harmonic (8.11). Switch the filter and move the rate to see what each keeps inside the band and lets through beyond it.
fig-sampling-reconstruction-1d
Figure 6.4.9, stage 3. Sampling: Diracs of weight g(nT), with g faint behind. Below, the samples' spectrum (1/T) Σ G(u − k/T), one copy of G per multiple of 1/T, each in the color of its tooth in Figure 6.4.4 (blue for k = 0, red for +1, orange for −1, green for +2, purple for −2). Where copies land on the same frequency they add, and an arrow two or more copies share is black. Set the prefilter to none: the box train's third harmonic, at 8.11 cycles per unit, comes back at 1.89 as a red arrow inside the band, and higher harmonics scatter colored arrows across it. That is aliasing.
fig-sampling-reconstruction-1d
Figure 6.4.9, stage 4. Reconstruction: r(x) = Σ g(nT) k((x − nT)/T), with the kernel k nearest, linear, cubic (Keys) or a Lanczos-3 windowed sinc, and the input f faint behind. Below, the copies multiplied by the kernel's transform k̂(uT), its magnitude in gray. The k = 0 copy is the one we want; what survives of the others is imaging, and it is what makes the steps of a nearest reconstruction: at 10 samples per unit the fundamental's first image, at 7.30 cycles per unit, keeps 0.33 of its weight. Linear leaves 0.12 of that image, cubic 0.10 and the windowed sinc 0.004; linear also attenuates the fundamental most (0.76, against 0.87 for nearest, 0.90 for cubic and 0.995 for the windowed sinc).
fig-sampling-reconstruction-1d
Figure 6.4.9, stage 5. Perception: the reconstruction filtered by the contrast sensitivity function of Mannos and Sakrison (1974), drawn in gray below, with frequency converted to cycles per degree by the viewing distance (a unit seen from d units away spans 180/(π d) degrees). The faint curve is the input under the same filter. At 57 units, one cycle per unit is about one cycle per degree and the image copy at 7.30 cycles per unit sits at the CSF's peak (0.996); at 300 units it is at 38 cycles per degree and the CSF weighs it 0.075, while the fundamental keeps 0.80, so the steps disappear. The CSF also removes most of the mean (0.05 at zero frequency), since vision responds to contrast. The last column is the original as perceived, the input under the same filter, with how far the perceived reconstruction is from it (RMS over the window shown): the pipeline succeeds when the two last columns look alike, even if the reconstruction itself does not match the input.

6.4.7 Practical filters: from the box to bicubic and Lanczos⧉

Downsampling needs a prefilter, and the previous section named the ideal one: a sinc scaled to the output spacing, whose transform is a box that keeps every frequency the coarser grid can hold and removes all the others. The sinc cannot be used as it is. It is infinitely wide, so every output pixel would read the whole image, and its lobes decay so slowly that truncating it changes its response, while its negative lobes overshoot at edges (Figure 6.4.10). Every practical prefilter is therefore a finite kernel that approximates it. The crudest is the box: averaging each $q\times q$ block of pixels into one output pixel, the usual way to halve an image. Its transform is itself a sinc, which keeps only 0.64 of the signal at the new Nyquist frequency and lets through as much as a fifth beyond it. The tent and the Gaussian are smoother, and the cubics and the Lanczos windowed sinc come closest to the ideal. The same kernels, used at the input's spacing rather than the output's, reconstruct a continuous image from its samples, which is how upsampling uses them (Chapter 6.5, Resampling and upsampling), and the trade-offs below hold for both uses.

fig-sinc-wide
Figure 6.4.10. The sinc, $\operatorname{sinc}(x)=\sin(\pi x)/(\pi x)$, over 30 sample spacings on each side. It is 1 at its own sample and 0 at every other one (dots), and between them it oscillates with alternating sign, the lobes shrinking only as $1/(\pi|x|)$ (dashed envelope): the lobe near $x=30$ is still about 1% of the peak. The shaded band, $|x|\le3$, is the part of it that Lanczos-3 keeps.

So every practical prefilter or reconstruction kernel is an approximation of sinc with finite support, balancing two competing evils that are clearest in the frequency domain (Figure 6.4.8). A kernel that is too gentle loses medium frequencies (its response rolls off early and the image goes soft), while one too aggressive lets high frequencies alias: it leaks past the grid's limit and admits jaggies and moiré. Every kernel is a point on this blur-versus-alias tradeoff. The two famous families both live on it.

💡 Big lesson (L6.16) — a resampling / anti-aliasing filter trades the ideal sinc against compact support

Fourier analysis says the perfect reconstruction and anti-aliasing filter is the sinc, a perfect box in frequency. But the sinc is infinitely wide and rings when truncated, so no real filter can be it. Every practical kernel (bilinear, bicubic, Lanczos) is a deliberate compromise between approximating that idealized sinc (what Fourier wants) and staying compactly supported (what computation, and ringing, demand): reach wider and you approach sinc; truncate harder and it gets cheaper and less ringy but further from ideal.

💡 Big lesson (L6.17) — choosing a resampling filter trades passband droop against stopband leak

Read off the frequency response, the same compromise is a tug-of-war between two errors. Passband droop: a too-gentle filter attenuates frequencies below Nyquist that the grid could have represented, so the image goes soft. Stopband leak: a too-aggressive filter lets frequencies above Nyquist through, which alias into jaggies and moiré. A good kernel sits at the sweet spot (flat passband up to Nyquist, sharp rejection beyond) and box, tent, bicubic and Lanczos are just different points on this droop-versus-leak curve.

Lanczos is sinc literally windowed by a wider sinc:

$$ k(x) \;=\; \operatorname{sinc}(x)\,\cdot\,\operatorname{sinc}\!\big(x / a\big), \qquad |x| < a, $$

over a support of $a$ samples on each side (and zero beyond, with $k(0)=1$). It hugs the ideal closely and looks crisp, at the cost of some ringing near strong edges, the surviving side-lobes of the truncated sinc (Figure 6.4.11).

fig-lanczos-kernel
Figure 6.4.11. The Lanczos kernel $\operatorname{sinc}(\pi x)\,\operatorname{sinc}(\pi x/a)$ over its $a$-sample support (Lanczos-2 and Lanczos-3) against the plain infinite sinc: a tall central lobe flanked by alternating side-lobes, truncated at $\pm a$, closest to the ideal box spectrum, but the surviving side-lobes are what produce edge ringing.

Bicubic uses a piecewise cubic polynomial: smooth, compact (four samples wide in 1-D), the standard default in image editors. It typically carries small negative lobes to the sides, and those are not a bug: they give the reconstruction a built-in mild sharpening (much like the unsharp mask) that makes upscaled images crisper. The cubic kernel is not unique: there is a family. Once you impose the natural requirements (the kernel should be symmetric, should be smooth where the cubic pieces meet, and should sum to one so it preserves brightness), a cubic still has two free parameters left. Mitchell and Netravali (1988) named them $B$ and $C$ (an open-access summary with the kernel formula is the Wikipedia article on Mitchell–Netravali filters); the result is a single piecewise cubic, supported over four samples (two on each side):

$$ k_{BC}(x)=\frac{1}{6}\begin{cases}(12-9B-6C)\,|x|^3+(-18+12B+6C)\,|x|^2+(6-2B), & |x|<1\\[2pt] (-B-6C)\,|x|^3+(6B+30C)\,|x|^2+(-12B-48C)\,|x|+(8B+24C), & 1\le|x|<2\\[2pt] 0,& |x|\ge2\end{cases}$$

one cubic whose two knobs slide it between sharper and smoother. Three points of the $(B,C)$ plane are the canonical members worth knowing by name:

fig-bicubic-kernels
Figure 6.4.12. The cubic kernel $k_{BC}(x)$ as a one-parameter-pair family, plotted for the three standard members: cubic B-spline $(B,C)=(1,0)$, all-positive and smooth; Catmull–Rom $(0,\tfrac12)$, interpolating with strong negative side-lobes; and Mitchell–Netravali $(\tfrac13,\tfrac13)$, the balanced default between them. The deeper the negative lobes, the sharper (and ringier) the reconstruction.
fig-resample-kernels-2d
Figure 6.4.13. The kernels in 2-D, formed as the separable outer product $k(x)\,k(y)$ for Catmull–Rom and Lanczos-3, each shown as a diverging-color image and as a height field. The smooth central mound is ringed by a shallow negative moat, the sharpening side-lobes seen from above.

A separable 2-D kernel $k(x)k(y)$ generally treats axes and diagonals differently. The continuous Gaussian is both separable and radially symmetric; truncation on a square only approximates that symmetry. For a rectangular sampling lattice, ideal rectangular-band reconstruction uses a separable product of sincs. It is not radially symmetric. A circular passband has a radial jinc kernel and discards some frequencies allowed near the corners of the rectangular Nyquist region.

💡 Big lesson (L6.18) — bicubic (and friends) are convolution with a fixed kernel, not polynomial regression

The cubic-convolution filters used here evaluate a fixed piecewise-cubic kernel at fractional offsets and sum weighted samples. They do not solve a regression for every output pixel. Other methods also called bicubic interpolation use polynomial or spline constructions; the name alone does not identify the algorithm or its downsampling behavior.

Mitchell and Netravali (1988) found their balance by running a perceptual study mapping which $(B,C)$ choices look best, charting where each lands among three failure modes: residual blur (too little negative lobe), ringing (ghost edges from too-strong negative lobes), and anisotropy (a visible preference for the horizontal / vertical / diagonal directions). A broad region of the $(B,C)$ map looks satisfactory, but different points suit different images, which is exactly why Photoshop and friends offer you a choice of bicubic ("bicubic smoother" for enlargements, "bicubic sharper" for reductions) rather than one fixed filter. There is no universally best answer, only a tradeoff you tune to the image: a slightly blurry original can afford a sharper kernel, a crisp one cannot.

Real software exposes exactly these kernel choices. Photoshop's Image Size resample menu lets you pick Nearest Neighbor, Bilinear, Bicubic, Bicubic Smoother (for enlargements), Bicubic Sharper (for reductions), and Preserve Details: the very box / tent / cubic family, and the smooth-versus-sharp bicubic tradeoff, turned into a dropdown (Figure 6.4.14).

fig-photoshop-resample
Figure 6.4.14. Adobe Photoshop's Image Size resample-method dropdown (© Adobe Inc., reproduced for educational commentary), with each menu option mapped to its kernel: Nearest Neighbor → box, Bilinear → tent, Bicubic → cubic, Bicubic Smoother → cubic biased smooth (enlarge), Bicubic Sharper → cubic biased sharp (reduce), Preserve Details → an edge-aware / learned upsampler. The shipping product is this chapter's kernel zoo as a menu.
A surprising amount of "bicubic" on the internet is wrong

Specify the cubic kernel, coordinate convention, boundary rule, and whether its support widens during reduction. Two libraries can both say “bicubic” and produce different results. Resizing differences can substantially alter generative-model evaluation (Parmar et al.). Scaling is also part of an adversarial attack surface (Gao et al.); the simple nearest-neighbor example below illustrates one mechanism, not the full class of attacks.

fig-nn-downsample-adversarial
Figure 6.4.15. An adversarial-resampling demo (interactive). The visible picture on the left carries a second, hidden picture: one pixel of every $k\times k$ block, the one nearest-neighbor downsampling by $k$ reads, is replaced by the hidden picture's pixel, so only $1/k^2$ of the pixels change and the image still reads as the visible one (the zoom shows the planted lattice; click the picture to move it). Downsampled by exactly $1/k$ with nearest neighbor, the output is the hidden picture. Move the reduction slider a few thousandths off $k$ (it snaps onto whole numbers, and a button sets it back to the planted factor) and the visible picture snaps back: the sampling lattice drifts off the planted pixels, and only bands where it still lines up show the hidden picture. Box filtering averages each planted pixel with the $k^2-1$ around it, so its weight is $1/k^2$ and the visible picture wins. Bilinear and bicubic without antialiasing read only a few pixels around each sample, as many resize calls do: for odd $k$ the bilinear sample lands exactly on the planted pixel and reveals the hidden picture, for even $k$ it weighs a quarter; widening the kernel by the scale (antialias) defeats the attack. The readout correlates the output with each picture, so which one it shows is a number. This is the simplest image-scaling attack (arXiv:2104.11222, arXiv:2104.08690); variants target other resizers, and a prefilter matched to the scale is the defense. The default cover, the peacock feathers, is the one whose planted pixels show least, here hiding a child running; they show mostly on the smooth eye. Peacock photograph by Bernard Spragg (CC0).
fig-resample-kernels-real
Figure 6.4.16. The kernel ladder on a real photograph, in both regimes, resampled under a 35° rotation (the general case, not a clean axis-aligned zoom). The subject is a near-Nyquist window grid (the Prudential facade) chosen because fine repeating structure is exactly where the kernel choice bites. Top row, upsampling (reconstruction): magnify a small patch and the kernel reconstructs the in-between values: nearest holds each sample as a hard square (blocky), bilinear is smooth but soft, bicubic (Catmull–Rom) restores edge contrast with its negative side-lobes, Lanczos (a windowed sinc) is the sharpest; on smooth natural content bicubic and Lanczos are close, their negative-lobe ringing visible mainly at high-contrast edges. Bottom row, downsampling (prefilter / anti-aliasing): shrink the grid and the kernel must now act as a prefilter (its footprint widened to the new sample spacing). Nearest does not prefilter: it point-samples and the grid aliases into moiré; bilinear, bicubic and Lanczos average over the discarded detail and stay clean. The kernels were implemented explicitly and evaluated in floating point so their true character (including over/undershoot) is preserved, not clamped away.

A separable kernel is cheap because a horizontal one-dimensional operation followed by a vertical one replaces a full two-dimensional neighborhood sum. The price can be directional behavior. Rotate a slanted edge while keeping the sampling grid fixed and compare the result: a square product footprint can treat the axis-aligned and diagonal cases differently. The continuous Gaussian shows that separability and radial symmetry can coexist, because the product of its two one-dimensional exponentials depends only on squared radius. A product of sinc kernels instead corresponds to the rectangular frequency region of the sampling grid. Choosing a circular footprint changes that region; it is not merely a more accurate implementation of the same filter.

Recap: big lessons of this chapter

💡 Big lesson (L6.13) — Nyquist–Shannon: sample above twice the highest frequency, or it aliases

Sample above twice the highest retained frequency. If the signal is too detailed for the grid, low-pass it before sampling. This applies to space and time. Real prefilters have finite transition bands, so allow a margin below Nyquist and check residual aliasing.

💡 Big lesson (L6.14) — sampling replicates the spectrum; aliasing is the replicas overlapping

Sampling on a grid is multiplication by a comb (a train of deltas), and a comb's Fourier transform is another comb, so sampling replicates the signal's spectrum at every multiple of the sampling rate. If the spectrum is band-limited below Nyquist the copies sit side by side and the original is recoverable; if it is not, the copies overlap, and the folded-over tails land on top of the genuine low frequencies as aliasing: energy appearing at completely wrong frequencies (moiré, the backward wagon-wheel). The cure is to band-limit before sampling: low-pass away everything above Nyquist first, then sample.

💡 Big lesson (L6.15) — the ideal sampling filter is a sinc, which does not exist in practice

Ideal band limiting and ideal interpolation use sinc kernels, scaled for their respective grids. Their infinite support requires approximation in finite computations. A finite filter trades computation and frequency selectivity; inspect both aliasing and edge overshoot.

💡 Big lesson (L6.16) — a resampling / anti-aliasing filter trades the ideal sinc against compact support

Fourier analysis says the perfect reconstruction and anti-aliasing filter is the sinc, a perfect box in frequency. But the sinc is infinitely wide and rings when truncated, so no real filter can be it. Every practical kernel (bilinear, bicubic, Lanczos) is a deliberate compromise between approximating that idealized sinc (what Fourier wants) and staying compactly supported (what computation, and ringing, demand): reach wider and you approach sinc; truncate harder and it gets cheaper and less ringy but further from ideal.

💡 Big lesson (L6.17) — choosing a resampling filter trades passband droop against stopband leak

Read off the frequency response, the same compromise is a tug-of-war between two errors. Passband droop: a too-gentle filter attenuates frequencies below Nyquist that the grid could have represented, so the image goes soft. Stopband leak: a too-aggressive filter lets frequencies above Nyquist through, which alias into jaggies and moiré. A good kernel sits at the sweet spot (flat passband up to Nyquist, sharp rejection beyond) and box, tent, bicubic and Lanczos are just different points on this droop-versus-leak curve.

💡 Big lesson (L6.18) — bicubic (and friends) are convolution with a fixed kernel, not polynomial regression

The cubic-convolution filters used here evaluate a fixed piecewise-cubic kernel at fractional offsets and sum weighted samples. They do not solve a regression for every output pixel. Other methods also called bicubic interpolation use polynomial or spline constructions; the name alone does not identify the algorithm or its downsampling behavior.