Image resizing
Sample the source on a new pixel grid at a different resolution.
A magnified patch makes the interpolation arithmetic visible.
This destination pixel falls at fractional offsets dx = 0.25 and dy = 0.60 between source centres.
The four weights sum to one. Nearer samples contribute more along each axis.
Repeat the mapping and interpolation for every destination pixel. Other interpolation flags use different sampling rules.
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
Experiment at pixel level
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.
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
Select a pixel
Select a pixel
When to use it
Create thumbnails, image pyramids or model inputs.
How it works
- 01Map each destination pixel back to a source location.
- 02Choose neighbouring source samples using the interpolation rule.
- 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.
Related methods
Arbitrary remapping
Provide a source coordinate for every destination pixel.
Affine transformations
Map points with a linear transform plus translation, preserving straight lines and parallelism.
Homography and RANSAC
Estimate a projective mapping between two views of a plane, rejecting inconsistent point matches.
Polar and log-polar warps
Re-express an image using angle and radius around a chosen centre.