← All Articles

Image Scaling Algorithms Explained: Bilinear, Bicubic Interpolation

March 2026 · 7 min read

When you enlarge or shrink an image, the computer must "guess" the color values of new pixels. This process is called interpolation. Different interpolation algorithms produce dramatically different results — some preserve sharp edges while others aim for smooth gradients. Understanding these algorithms helps you make the best choice for each use case.

What Is Image Interpolation?

Digital images are composed of individual pixels. When we resize an image, the target pixel positions may fall "between" original pixels. The interpolation algorithm's job is to calculate the color values at these new positions based on surrounding known pixel values.

Key takeaway: The core question of interpolation is: given known surrounding pixel colors, how do we reasonably estimate the color of a new pixel? Different algorithms make different trade-offs between speed and quality.

Nearest-Neighbor Interpolation

Nearest-neighbor is the simplest method: it directly uses the value of the closest original pixel as the new pixel's value.

Characteristics

Bilinear Interpolation

Bilinear interpolation considers the 4 nearest pixels (2x2 grid) around the target point, computing a weighted average based on distance. It performs linear interpolation first in the X direction, then in the Y direction.

Process

  1. Locate the 4 surrounding pixels in the source image
  2. Calculate the distance ratios from the target position to each pixel
  3. Perform two horizontal linear interpolations
  4. Perform one vertical linear interpolation to get the final value

Characteristics

Bicubic Interpolation

Bicubic interpolation considers the 16 surrounding pixels (4x4 grid), using cubic polynomials for weighted computation. This produces smoother results while preserving more detail and sharpness.

Characteristics

Comparison of the Three Algorithms

FeatureNearest-NeighborBilinearBicubic
Sample pixels14 (2x2)16 (4x4)
SpeedFastestMediumSlower
Upscale qualityPixelatedSlightly blurrySmoothest
Edge preservationHard edgesMediumSharp
Upscale usePixel artGeneral purposePhotography
Downscale useNot recommendedAcceptableRecommended

Implementation in the Canvas API

When using HTML5 Canvas for image scaling in the browser, you can control interpolation quality through the imageSmoothingEnabled and imageSmoothingQuality properties:

Advanced: Lanczos Resampling

Lanczos resampling is a higher-quality algorithm that uses the sinc function as its basis, sampling a larger area (typically 6x6 or 8x8 pixels). It excels at downscaling, effectively avoiding aliasing and moire patterns.

Many professional image editors (such as Photoshop and GIMP) use Lanczos as the default or recommended scaling algorithm.

Try the Image Resize Tool →

Conclusion

Choosing the right interpolation algorithm depends on your use case. Use nearest-neighbor for pixel art, bilinear for general purposes, and bicubic or Lanczos for professional quality. Understanding these fundamentals helps you get the best results every time you resize an image.

References

  1. Gonzalez, R. C. & Woods, R. E. "Digital Image Processing." Pearson, 4th Edition, 2018. Chapter 2: Digital Image Fundamentals — Interpolation.
  2. Wikipedia contributors. "Bilinear interpolation." Wikipedia, The Free Encyclopedia, 2025. https://en.wikipedia.org/wiki/Bilinear_interpolation
  3. Wikipedia contributors. "Bicubic interpolation." Wikipedia, The Free Encyclopedia, 2025. https://en.wikipedia.org/wiki/Bicubic_interpolation
  4. MDN Web Docs. "CanvasRenderingContext2D: imageSmoothingQuality property." Mozilla Developer Network, 2025. https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/imageSmoothingQuality