Interpolation
Mathematical methods for estimating new pixel values during image scaling, rotation, or warping. Balances quality against computational cost.
Interpolation is the mathematical process of estimating pixel values at non-integer coordinates during geometric transformations such as resizing, rotation, and distortion correction. Since digital images are discrete pixel grids, computing values between existing samples requires interpolation from surrounding pixels.
Common algorithms in order of quality:
- Nearest Neighbour: Uses the value of the closest pixel. Fastest but produces jagged edges (aliasing). Ideal for pixel art where sharp edges must be preserved
- Bilinear: Weighted average of 4 surrounding pixels (2×2 grid). Smoother than nearest neighbour but introduces slight blurring. Standard for real-time applications
- Bicubic: Uses 16 surrounding pixels (4×4 grid) with cubic polynomial weighting. Sharper than bilinear with better edge preservation. Photoshop's default method
- Lanczos: Based on the sinc function. Produces the sharpest results but is computationally expensive. May introduce ringing artefacts near high-contrast edges
Selection guidelines by use case:
- Downscaling: Lanczos or bicubic with anti-aliasing pre-filter to prevent moiré and aliasing
- Upscaling: Bicubic (sharper variant) or AI super-resolution. Traditional interpolation has inherent limits for large upscale factors
- Real-time rendering: Bilinear. The GPU texture sampling standard, offering acceptable quality at minimal cost
CSS image-rendering controls browser interpolation: pixelated forces nearest-neighbour for retro pixel art display, while crisp-edges attempts to preserve edges without smoothing.