Arbitrary remapping
Provide a source coordinate for every destination pixel.
A magnified patch makes the interpolation arithmetic visible.
An arbitrary coordinate map requests this fractional source location.
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.
Interpolate neighbours and apply the border rule when sampling outside the image.
Illustrative example. The stages explain the method; they are not a live OpenCV execution.
Try it on an image
Experiment at pixel level
Build a sinusoidal sampling map. Amplitude zero is the identity; positive values bend rows horizontally.
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
Undistort lenses, apply displacement fields, align plates or implement custom image warps.
How it works
- 01Build x and y maps in destination coordinates.
- 02Look up each requested source location.
- 03Interpolate neighbours and apply the border rule when sampling outside the image.
dst(x,y) = src(mapX(x,y), mapY(x,y))
What to tune
map1/map2 encode coordinates; interpolation controls sampling; borderMode governs unavailable pixels.
Where it breaks down
These are inverse sampling maps. A forward motion field cannot be passed directly without the appropriate inversion. Alpha and colour should share the same maps.
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
Image resizing
Sample the source on a new pixel grid at a different resolution.
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.