Image Resampling and Warping

Imagine rotating a photograph by seventeen degrees. Or stitching two overlapping camera shots into a seamless panorama. Both tasks require evaluating an image at coordinates that were never sampled. This is the resampling and warping problem. Given a discrete grid of pixel values, reconstruct a continuous image. Then apply a geometric transform, and re-sample it onto a new grid. This must happen without introducing blur, ringing, or aliasing. Every step of a modern vision pipeline that touches geometry ultimately calls a resampling routine. This includes camera calibration, stereo rectification, image stitching, augmented reality overlays, and data augmentation for neural networks. Getting it right (and fast) is therefore a foundational skill. The subject sits at the intersection of two ideas. These come from Digital Images and Sampling and The Fourier View of Images. A digital image is a set of point samples of an underlying continuous signal. Any resampling operation is only as good as the reconstruction filter used to interpolate between samples. Naively picking the nearest pixel or averaging four neighbors works passably at small scales. But it breaks down catastrophically under large rotations, shears, or minifications. This produces jagged edges or moiré patterns. The Nyquist–Shannon sampling theorem governs exactly when this happens. It also tells us how to prevent it. This article develops the full machinery. It covers how to express geometric transforms as coordinate mappings, and how forward and inverse warping differ. It presents the standard family of interpolation kernels: nearest neighbor, bilinear, bicubic, and windowed sinc. It also explains how antialiasing via prefiltering or mipmapping keeps high-frequency content from folding back into visible artifacts. We derive complexity bounds and walk through a fully worked numerical example of an inverse-warped rotation. We also catalog the pitfalls that make resampling code notoriously easy to get subtly wrong. By the end you will be able to implement a correct, efficient image warp from scratch. You will be able to choose an interpolation kernel appropriate to a given accuracy/speed budget. And you will be able to diagnose aliasing versus blur in a broken resampling pipeline.

Key takeaways
  • Resampling reconstructs a continuous image from samples, applies a geometric transform, then re-samples onto a new grid.
  • Inverse warping (map destination pixels back to source coordinates) avoids holes and is the standard approach; forward warping can leave gaps and needs splatting.
  • Interpolation kernels trade cost for quality: nearest neighbor (blocky), bilinear (smooth but blurs), bicubic (sharper, needs care with overshoot), windowed sinc (near-ideal, expensive).
  • Minification (shrinking) requires prefiltering or mipmapping; otherwise high frequencies alias into low-frequency artifacts — a direct consequence of the sampling theorem.
  • Complexity is linear in the number of output pixels times a constant kernel footprint: O(N · k²) time, O(N) or O(N log N) space depending on whether mipmaps are stored.
  • Correctness rests on treating images as sampled continuous signals: warping is composition of reconstruction, coordinate transform, and resampling, each with its own error source.
The core insight

Warping is not "moving pixels" — it is reconstruct-transform-resample, and every visible artifact traces back to one of those three stages being done wrong.

The idea

A digital image is a discrete grid of samples I[i,j]I[i,j] of an underlying continuous function f(x,y)f(x,y). A geometric transform is a mapping T:R2→R2T: \mathbb{R}^2 \to \mathbb{R}^2 that sends a coordinate (x,y)(x,y) in one image to a coordinate (x′,y′)=T(x,y)(x', y') = T(x,y) in another. Common transforms include translation, rotation, similarity, affine, and projective (homography) maps; the latter three are commonly written as 2×32 \times 3 or 3×33 \times 3 matrices acting on homogeneous coordinates (x,y,1)T(x, y, 1)^T.

Resampling is the process of producing a new discrete grid of samples of ff evaluated at a new set of locations — either because we changed resolution (scaling) or because we composed ff with a transform TT (warping). Since ff is only known at integer grid points, we must reconstruct a continuous approximation f^(x,y)=∑i,jI[i,j] h(x−i,y−j)\hat f(x,y) = \sum_{i,j} I[i,j] \, h(x-i, y-j) using an interpolation kernel hh, evaluate f^\hat f at the required non-integer location, and — if the local scale factor is less than one (minification) — prefilter to remove frequencies that would otherwise alias. There are two algorithmic strategies for applying TT to an image. Forward warping iterates over source pixels, computes T(x,y)T(x,y), and scatters (splats) the value into the destination; this can leave holes where no source pixel lands, and can double-write when multiple source pixels map to the same destination cell, requiring splatting kernels or z-buffering for occlusion. Inverse warping iterates over destination pixels (x′,y′)(x', y'), computes the source location T−1(x′,y′)T^{-1}(x', y'), and gathers (interpolates) a value from the source; every destination pixel is filled exactly once, with no holes, which is why inverse warping is the standard choice whenever T−1T^{-1} is available in closed form (true for all affine and projective maps).

How it works

The inverse-warping algorithm has three cleanly separated stages: compute the inverse transform, loop over destination pixels, and for each one reconstruct a value from the (possibly prefiltered) source image.

Step 1 — Invert the transform. For an affine map T(x)=Ax+bT(\mathbf{x}) = A\mathbf{x} + \mathbf{b}, the inverse is T−1(x′)=A−1(x′−b)T^{-1}(\mathbf{x}') = A^{-1}(\mathbf{x}' - \mathbf{b}), requiring one 2×2 (or 3×3 homogeneous) matrix inversion done once, not per pixel.

Step 2 — Determine the local scale factor. Compute the Jacobian of T−1T^{-1} at each destination pixel (or, for affine/projective maps, from the singular values of A−1A^{-1}). If the minimum singular value is less than 1, the map is shrinking the image locally and a wider reconstruction/prefiltering kernel is needed to avoid aliasing.

Step 3 — Gather and interpolate. For each destination pixel, map back to a source coordinate, take the (possibly scaled) interpolation kernel footprint around that coordinate, and compute a weighted sum of the neighboring source pixels. ``` function INVERSE_WARP(src, H, out_width, out_height, kernel, antialias): H_inv = INVERT(H) # invert 3x3 homography once dst = new image(out_width, out_height) for y_dst in 0 .. out_height - 1: for x_dst in 0 .. out_width - 1:

# map destination pixel center to source coordinates (xs, ys, w) = H_inv * (x_dst + 0.5, y_dst + 0.5, 1) xs = xs / w ys = ys / w if not IN_BOUNDS(src, xs, ys): dst[x_dst, y_dst] = BACKGROUND continue if antialias: scale = LOCAL_MINIFICATION_SCALE(H_inv, x_dst, y_dst) sigma = max(1.0, 1.0 / scale) # widen kernel when shrinking else: sigma = 1.0 dst[x_dst, y_dst] = RECONSTRUCT(src, xs, ys, kernel, sigma) return dst function RECONSTRUCT(src, xs, ys, kernel, sigma):

# gather weighted sum over kernel support, scaled by sigma radius = kernel.support sigma x0 = floor(xs - radius) x1 = ceil(xs + radius) y0 = floor(ys - radius) y1 = ceil(ys + radius) accum = 0.0 weight_sum = 0.0 for j in y0 .. y1: for i in x0 .. x1: wx = kernel.weight((xs - i) / sigma) / sigma wy = kernel.weight((ys - j) / sigma) / sigma w = wx wy accum += w * CLAMP_FETCH(src, i, j) weight_sum += w return accum / weight_sum # normalize (handles boundary truncation) ``` The kernel abstraction covers the standard interpolation families:

  • Nearest neighbor: h(t)=1h(t) = 1 if ∣t∣<0.5|t| < 0.5, else 00. Support radius 0.50.5. Zero computation beyond a round, but produces blocky, jagged edges — it reconstructs a piecewise-constant signal, the worst approximation to a smooth image.
  • Bilinear: h(t)=max⁡(0,1−∣t∣)h(t) = \max(0, 1-|t|), a triangle (tent) filter, applied separably in xx and yy. Support radius 11. This is the convolution of two box filters, equivalent to linear interpolation along each axis, hence "bilinear."
  • Bicubic: piecewise cubic polynomial (e.g., the Catmull-Rom or Mitchell-Netravali family), support radius 22, matches value and first derivative continuity at sample points, producing sharper results with controlled ringing.
  • Windowed sinc (e.g., Lanczos): h(t)=sinc(t)⋅sinc(t/a)h(t) = \mathrm{sinc}(t)\cdot \mathrm{sinc}(t/a) for ∣t∣<a|t| < a, an apodized approximation to the ideal (infinite-support) sinc reconstruction filter dictated by the sampling theorem. Best frequency response, most expensive, can ring on hard edges.

Antialiasing during minification works by widening the reconstruction kernel (equivalently, prefiltering the continuous reconstructed signal with a low-pass filter matched to the new, coarser sampling rate) before resampling — this is exactly the `sigma` scaling in the pseudocode above. An engineering alternative, used pervasively in GPUs and texture mapping, is mipmapping: precompute a pyramid of progressively half-scale, prefiltered copies of the source image, then at each destination pixel select (or trilinearly blend between) the pyramid level whose sample spacing matches the local minification factor. This turns an expensive wide-kernel convolution into a cheap fixed-size lookup at precomputed resolutions.

Figure
Inverse warping pipeline: destination pixel maps back through T⁻¹ into source space, where a kernel gathers neighboring samples
Destination grid (output image) (x', y') T⁻¹ Source grid (input image samples) (xs, ys) Green dots: kernel support neighbors gathered and weighted 1. Pick destination pixel (x', y') 2. Apply T⁻¹ to get source coordinate (xs, ys) 3. Gather neighboring source samples, weight by kernel h 4. Write weighted sum into dst[x', y'] — every output pixel filled once

Complexity & correctness

Time complexity. For an output image of N=Wout×HoutN = W_{out} \times H_{out} pixels and an interpolation kernel with fixed support radius rr (so a k×kk \times k neighborhood with k=O(r)k = O(r)), the inverse-warp loop performs O(N⋅k2)O(N \cdot k^2) work: one O(k2)O(k^2) gather-and-weight computation per destination pixel, plus O(1)O(1) amortized cost for the one-time matrix inversion. Nearest neighbor is k=1k=1, bilinear k=2k=2, bicubic k=4k=4, a typical windowed sinc k∈{6,8}k \in \{6, 8\}. This is linear in image size for any fixed kernel, which is optimal — you cannot produce NN output pixels in sublinear time. When antialiasing widens the kernel adaptively under strong minification, kk can grow proportionally to the minification factor 1/s1/s, making brute-force prefiltering O(N/s2)O(N/s^2) in the worst case (shrinking by 10×10\times in both axes costs 100×100\times the naive per-pixel work). Mipmapping avoids this: building the pyramid costs O(Nsrc)O(N_{src}) total (a geometric series of half-resolution prefiltering passes summing to at most 43Nsrc\tfrac{4}{3}N_{src}), and each destination lookup afterward is O(1)O(1) (or O(k2)O(k^2) for a fixed small trilinear-blend kernel), independent of the minification factor — trading a bounded amount of extra memory, O(43Nsrc)O(\tfrac{4}{3} N_{src}), for a guarantee against worst-case aliasing cost.

Space complexity. A basic inverse warp needs only O(N)O(N) space for the output buffer (the source is read-only and can be streamed or memory-mapped). Mipmap-based antialiasing adds O(Nsrc)O(N_{src}) extra space for the pyramid.

Correctness argument. The central claim is: inverse warping with a properly scaled reconstruction kernel produces, for each destination pixel, the value that a band-limited continuous reconstruction of the source, transformed by TT, would have at that location — up to the kernel's approximation error. The argument has two parts. No holes, no double-writes (coverage). Because the destination loop enumerates every integer pixel (x′,y′)(x', y') exactly once and always computes a defined source coordinate via T−1T^{-1} (assuming TT is invertible, true for similarity/affine/projective maps with nonzero determinant), every output pixel receives exactly one write. This is an immediate structural invariant of the algorithm — contrast with forward warping, where the image of the integer destination grid under TT is not guaranteed to cover all integer source... rather destination... coordinates, since TT can be expansive (magnification creates gaps) or contractive (minification creates collisions), forcing hole-filling or splatting heuristics that inverse warping sidemsteps entirely. Approximation quality is governed by the sampling theorem. By the Nyquist–Shannon theorem (from The Fourier View of Images), a signal sampled at rate fsf_s is exactly recoverable via sinc interpolation only if it is band-limited to frequencies below fs/2f_s/2. Real images are not perfectly band-limited (edges have infinite-extent spectra), so any finite-support kernel is an approximation to ideal sinc reconstruction, and its Fourier transform (the kernel's frequency response) determines the error: a good kernel has a Fourier transform close to a box (unit gain in-band, zero out-of-band). Nearest neighbor and bilinear have frequency responses that fall off slowly (a sinc\mathrm{sinc} and sinc2\mathrm{sinc}^2 respectively in the reciprocal domain) and pass significant energy above Nyquist, which manifests as blur (attenuated in-band high frequencies) and some residual aliasing; windowed sinc kernels approximate the ideal box response far more closely at higher computational cost. When the local transform is a minification (scale factor s<1s<1), the effective output sampling rate is s⋅fss \cdot f_s, so the reconstructed continuous signal must be low-pass filtered to below sfs/2s f_s / 2 before resampling — skipping this step lets frequencies above the new Nyquist limit fold back (alias) into low frequencies, which is precisely why the `sigma` widening step in the pseudocode is not an optional nicety but a mathematical requirement for correctness under minification.

Tradeoffs, honestly stated. Higher-order kernels reduce blur and aliasing but cost more compute and can introduce ringing (Gibbs-phenomenon overshoot near sharp edges) because no finite-support, non-negative kernel can have an ideal brick-wall frequency response — the Fourier uncertainty principle forbids a filter that is simultaneously compact in space and perfectly band-limited in frequency. Mipmapping is fast and alias-free at coarse scales but blurs anisotropically-foreshortened regions (e.g., a ground plane receding to the horizon) unless combined with anisotropic filtering, which samples multiple mip levels along the direction of maximum compression.

Worked example

We rotate a small 4×44\times 4 grayscale image by θ=30°\theta = 30° about its center, using inverse warping with bilinear interpolation, and trace one destination pixel by hand. Source image (row jj, column ii, values 0–255):

i=0i=1i=2i=3
j=010203040
j=150607080
j=290100110120
j=3130140150160

Center of rotation: (cx,cy)=(1.5,1.5)(c_x, c_y) = (1.5, 1.5). The forward rotation matrix (image coords, yy down) is

R(θ)=(cos⁡θ−sin⁡θsin⁡θcos⁡θ),θ=30°R(\theta) = \begin{pmatrix}\cos\theta & -\sin\theta \\ \sin\theta & \cos\theta\end{pmatrix}, \quad \theta = 30°

Since rotations are orthogonal, R−1=R(−θ)=R(θ)TR^{-1} = R(-\theta) = R(\theta)^T. We compute the source location for destination pixel (x′,y′)=(2,1)(x', y') = (2, 1):

Step 1 — center the coordinate:

(xc′,yc′)=(2−1.5, 1−1.5)=(0.5, −0.5)(x'_c, y'_c) = (2 - 1.5,\ 1 - 1.5) = (0.5,\ -0.5)

Step 2 — apply R−1=R(−30°)R^{-1} = R(-30°), with cos⁡(−30°)=0.8660\cos(-30°) = 0.8660, sin⁡(−30°)=−0.5\sin(-30°) = -0.5:

xc=0.8660(0.5)−(−0.5)(−0.5)=0.4330−0.25=0.1830x_c = 0.8660(0.5) - (-0.5)(-0.5) = 0.4330 - 0.25 = 0.1830
yc=(−0.5)(0.5)+0.8660(−0.5)=−0.25−0.4330=−0.6830y_c = (-0.5)(0.5) + 0.8660(-0.5) = -0.25 - 0.4330 = -0.6830

Step 3 — uncenter:

(xs,ys)=(0.1830+1.5, −0.6830+1.5)=(1.6830, 0.8170)(x_s, y_s) = (0.1830 + 1.5,\ -0.6830 + 1.5) = (1.6830,\ 0.8170)

So destination pixel (2,1)(2,1) maps back to source coordinate (1.683,0.817)(1.683, 0.817), which lies inside the image bounds — good, no background fill needed.

Step 4 — bilinear gather. The four surrounding integer samples are at i∈{1,2}i \in \{1,2\}, j∈{0,1}j \in \{0,1\}:

I[1,0]=20,I[2,0]=30,I[1,1]=60,I[2,1]=70I[1,0]=20,\quad I[2,0]=30,\quad I[1,1]=60,\quad I[2,1]=70

Fractional offsets: a=xs−1=0.683a = x_s - 1 = 0.683, b=ys−0=0.817b = y_s - 0 = 0.817. Bilinear interpolation:

top=(1−a)⋅I[1,0]+a⋅I[2,0]=0.317(20)+0.683(30)=6.34+20.49=26.83\text{top} = (1-a)\cdot I[1,0] + a\cdot I[2,0] = 0.317(20) + 0.683(30) = 6.34 + 20.49 = 26.83
bottom=(1−a)⋅I[1,1]+a⋅I[2,1]=0.317(60)+0.683(70)=19.02+47.81=66.83\text{bottom} = (1-a)\cdot I[1,1] + a\cdot I[2,1] = 0.317(60) + 0.683(70) = 19.02 + 47.81 = 66.83
value=(1−b)⋅top+b⋅bottom=0.183(26.83)+0.817(66.83)=4.91+54.60=59.51\text{value} = (1-b)\cdot \text{top} + b\cdot \text{bottom} = 0.183(26.83) + 0.817(66.83) = 4.91 + 54.60 = 59.51

So the rotated output pixel (2,1)(2,1) gets value ≈ 59.5 (rounded to 60 for an 8-bit image). Repeating this for every destination pixel — including checking bounds for corner pixels like (0,0)(0,0), which will map outside the source and must be filled with a background value or clamped/extrapolated — completes the warp. Note that no source pixel was "moved"; every output value was independently reconstructed, which is exactly why inverse warping guarantees full, gap-free coverage of the destination grid.

A minification check. Suppose instead the same rotation is combined with a uniform scale of s=0.3s = 0.3 (shrinking to 30% size) mapping into a much smaller destination grid. The local Jacobian of T−1T^{-1} now has singular values ≈1/0.3=3.33\approx 1/0.3 = 3.33 in the source-to-destination stretch, meaning each destination pixel corresponds to a 3.33×3.333.33 \times 3.33 block of source pixels. Using plain bilinear interpolation (support radius 1) here would only look at 4 source pixels while ignoring roughly 11 pixels' worth of high-frequency content in between — a textbook aliasing setup. The corrected antialiased version widens σ≈3.33\sigma \approx 3.33, effectively box- or tent-filtering over the full 3.33×3.333.33\times3.33 neighborhood before subsampling, which is the discrete analogue of low-pass filtering to the new Nyquist limit.

Common pitfalls & traps

PitfallWhy it happensFix
Using forward warping and getting speckled holesDestination pixels not covered by any mapped source pixel are left undefinedUse inverse warping, or splat with a reconstruction kernel and normalize by accumulated weight
Aliasing (moiré, jagged shrunk text) under minificationReconstruction kernel too narrow relative to the shrink factor; violates the sampling theoremWiden the kernel (prefilter) proportional to 1/s1/s, or use mipmapping
Off-by-half-pixel misalignmentConfusing pixel-center convention (pixel ii centered at i+0.5i+0.5) with pixel-corner convention (centered at integer ii)Fix a single convention project-wide and add the same 0.5 offset consistently in both directions
Ringing/overshoot near edges with bicubic or sinc kernelsAny finite-support approximation to an ideal low-pass filter has negative side lobes (Gibbs phenomenon)Use a non-negative kernel (bilinear, Mitchell-Netravali with tuned parameters) or clamp output range
Dividing by zero or a degenerate homographyTransform matrix is singular or point maps to the line at infinity in projective coordinatesCheck determinant/denominator before inverting; guard w≈0w \approx 0 in homogeneous division
Wasting compute on huge kernels for every pixel regardless of local scaleUniform worst-case kernel size ignores that most of the image may not be minifiedCompute the local Jacobian per pixel (or per tile) and adapt kernel size, or precompute mipmaps
Boundary artifacts (dark fringe at image edges)Kernel support extends past the image, and out-of-bounds samples are treated as zero instead of being excluded and renormalizedClamp-to-edge, mirror, or renormalize by the sum of in-bounds weights only

Pioneers & history

The theory underlying resampling — that a discrete signal is a set of samples of a continuous one, recoverable exactly only if band-limited — traces to sampling theory developed for communications engineering and formalized rigorously by Claude Shannon, building on earlier work by Harry Nyquist. Its application to two-dimensional images and computer graphics matured through the 1970s–1980s as digital image processing and computer graphics became practical, with foundational texture-mapping and antialiasing techniques (mipmapping, elliptical weighted averaging) developed to make real-time and offline rendering tractable.

Origins · 1 minClaude Elwood Shannon and how this was discovered
CE
Claude Elwood Shannon
1916–2001 · Bell Labs, the mathematical theory of communication and sampling

Shannon's 1949 paper formalized the sampling theorem — that a band-limited signal is fully determined by samples taken above twice its highest frequency — giving image resampling its rigorous mathematical foundation: every interpolation kernel is, at heart, an attempt to approximate the ideal reconstruction filter his theorem implies.

History
1928
— Nyquist articulates the relationship between signal bandwidth and required sampling rate for telegraphy.
1949
— Shannon publishes the sampling theorem underlying exact reconstruction of band-limited signals.
1983
— Lance Williams introduces mipmapping, precomputed prefiltered image pyramids for fast antialiased texture minification.
1986
— Ned Greene and Paul Heckbert develop elliptical weighted averaging for anisotropic texture filtering.
1989
— Paul Heckbert's survey formalizes image warping and resampling as a unified geometric-plus-signal-processing pipeline.

Where this matters

Image resampling and warping underlie nearly every geometric operation in a vision or graphics system. Camera calibration and lens-distortion correction resample a distorted image onto an undistorted grid using a per-pixel inverse map. Stereo rectification warps left and right camera images onto a common epipolar geometry before matching. Panorama stitching software (and phone camera "pano" modes) warp overlapping photos onto a shared cylindrical or spherical canvas using exactly the inverse-warp-plus-bilinear (or better) pipeline described here. GPUs implement mipmapped, anisotropically filtered texture sampling in hardware for real-time rendering in games and simulators. Data augmentation pipelines for training convolutional neural networks apply random rotations, scales, and perspective jitter to training images, and sloppy resampling there can silently bake aliasing artifacts into a training set. Medical imaging registration, satellite image orthorectification, and augmented-reality overlay compositing all reduce, at their geometric core, to the same reconstruct-transform-resample loop.

Ask the tutor: How would you design an adaptive-kernel warping routine that automatically balances aliasing suppression against blur for an arbitrary homography?

Why does bilinear interpolation blur images compared to the source?

Bilinear interpolation convolves the image with a tent (triangle) kernel, whose Fourier transform is a squared-sinc function that attenuates high frequencies well before Nyquist rather than passing them cleanly. This means fine detail and sharp edges lose contrast even when no explicit blurring is intended. The effect worsens as the number of successive resampling operations increases, since each pass reapplies the same attenuation. Sharper kernels like bicubic or windowed sinc reduce this loss at the cost of more computation and potential ringing near edges. In practice, bilinear is chosen when speed matters more than fidelity, such as real-time preview rendering, while offline high-quality resizing favors sharper kernels.

What is the difference between resampling and warping?

Resampling is the general operation of evaluating an image at a new set of sample locations, which includes simple resizing (uniform scaling) as a special case. Warping specifically refers to resampling under an arbitrary, possibly nonuniform geometric transform such as rotation, perspective correction, or lens undistortion. Every warp requires resampling, but not every resampling operation is a warp — shrinking an image to half size along both axes uniformly is resampling without any change in geometric shape. The same reconstruct-transform-resample framework and antialiasing concerns apply to both, since both change the relationship between the continuous signal and the discrete sampling grid.

How do you handle pixels that map outside the source image boundary?

When the inverse-mapped source coordinate falls outside the valid image extent, several boundary policies are common: filling with a constant background color, clamping the coordinate to the nearest valid edge pixel, mirroring the coordinate back into the image, or wrapping around periodically (useful for tiling textures). The choice matters because a naive "treat out-of-bounds samples as zero" approach, without renormalizing the interpolation weights, creates a visible dark fringe near edges since the kernel effectively divides by a weight sum that includes phantom zero-valued neighbors. Renormalizing by only the in-bounds weight mass, or explicitly clamping the fetch coordinate before sampling, avoids this artifact.

Why is the local Jacobian relevant to choosing an interpolation kernel?

The Jacobian of the inverse transform at a destination pixel describes how much a small neighborhood of the destination maps to in the source: its singular values give the local magnification or minification factors along the two principal directions. When a singular value is much less than one, a large area of source pixels compresses into a small destination area, meaning naive point-sampling would skip most of the source's high-frequency content and alias. Using the Jacobian to size the reconstruction kernel per pixel (or per tile) lets an algorithm apply just enough prefiltering exactly where needed, rather than uniformly over-blurring the entire image or under-filtering and aliasing in compressed regions.

Is nearest-neighbor interpolation ever the right choice?

Yes, in specific contexts: when resampling label maps or segmentation masks, where averaging discrete class indices would produce meaningless fractional labels, nearest neighbor is the only interpolation that preserves valid categorical values. It is also used when speed is paramount and visual quality is secondary, such as quick previews, or when the transform is a pure integer-pixel shift with no fractional offset, in which case nearest neighbor is exact and lossless. Outside these cases, its piecewise-constant reconstruction produces visibly blocky results and should be avoided for continuous-valued images undergoing rotation or scaling.

How does this relate to convolutional neural network training pipelines?

Modern CNN training pipelines routinely apply random rotations, crops, and rescalings as data augmentation, each implemented as an inverse warp with some interpolation kernel, typically bilinear for speed. If minification antialiasing is skipped, aliasing artifacts get baked into training images, which can bias what high-frequency patterns the network learns to rely on, sometimes contributing to a documented gap between training-time and test-time image statistics. Some recent architecture and training-pipeline work explicitly revisits resizing and antialiasing choices as a source of accuracy discrepancies, underscoring that this decades-old signal-processing concern remains directly relevant to state-of-the-art deep learning systems.

What is the relationship between resampling and the sampling theorem from Fourier analysis?

The sampling theorem states that a signal band-limited to frequency fmaxf_{max} is exactly recoverable from samples taken at rate at least 2fmax2f_{max}, via convolution with an ideal sinc reconstruction filter. Every interpolation kernel used in image resampling — nearest neighbor, bilinear, bicubic, windowed sinc — is an approximation to that ideal sinc filter, trading frequency-domain accuracy for finite spatial support and computational cost. When resampling changes the effective sampling rate (as in minification), the theorem also dictates that the signal must be low-pass filtered to the new Nyquist limit before resampling, which is the formal justification for prefiltering and mipmapping rather than just an empirical trick.

Before this