Skip to content

Image resizing

Sample the source on a new pixel grid at a different resolution.

Try it on your image ↓

VISUAL WALKTHROUGHGeometry
REFERENCE INPUTFour neighbouring source samples

A magnified patch makes the interpolation arithmetic visible.

RESULTInterpolate one destination value

Repeat the mapping and interpolation for every destination pixel. Other interpolation flags use different sampling rules.

STEP 03 / 03

Combine the samples into one output pixel.

Illustrative example. The stages explain the method; they are not a live OpenCV execution.

Try it on an image

YOUR IMAGE · REAL OPENCV

Experiment at pixel level

Open full lab ↗

Resample the colour image. Input and output have different pixel coordinates when their sizes differ.

The engine loads on your first run. Your images stay in this browser.

Input448 × 320
OutputWaiting for a result

Scroll over either image to zoom at the pointer. Use the scrollbars to pan both views over the same relative area. Zoom is relative to the input; pixel coordinates belong to each image. Warps can change scene correspondence.

Pixel inspector RGBA · native values · matched scale · 9 × 9 output pixels
Hover to inspect. Click to pin a pixel.
Input
Select a pixel

Output
Select a pixel

Sample models and licenses

When to use it

Create thumbnails, image pyramids or model inputs.

How it works

  1. 01Map each destination pixel back to a source location.
  2. 02Choose neighbouring source samples using the interpolation rule.
  3. 03Combine the samples into one output pixel.

destination grid → source coordinates → interpolation

What to tune

INTER_AREA is useful for shrinking; nearest preserves discrete labels; linear and cubic trade sharpness against cost.

Where it breaks down

Downsampling can alias high-frequency texture. Premultiply RGB before resizing transparent images to avoid coloured fringes.

TypeScript API

Open an entry for its exact overloads, parameter descriptions, result ownership and pinned upstream source.

All of these calls execute on the CPU. Native objects need explicit disposal. See matrices and ownership and build compatibility.