🍋
Menu
Image

Image Interpolation

Image Interpolation (Pixel Resampling)

Image interpolation is the method used to calculate new pixel values when resizing an image. Different algorithms (nearest-neighbor, bilinear, bicubic, Lanczos) trade speed for quality when scaling images up or down.

Detalhe técnico

Nearest-neighbor copies the closest pixel (fastest, blocky). Bilinear averages 4 neighbors. Bicubic uses 16 neighbors with cubic weighting. Lanczos uses a sinc-based windowed filter for the sharpest results.

Exemplo

```javascript
// Image compression via Canvas
canvas.toBlob(
  blob => console.log(`Size: ${(blob.size/1024).toFixed(0)} KB`),
  'image/jpeg',
  0.8  // quality: 0.0 (smallest) to 1.0 (best)
);

// WebP output (25-34% smaller than JPEG)
canvas.toBlob(cb, 'image/webp', 0.8);
```

Ferramentas relacionadas

Termos relacionados