Skip to content

Arbitrary remapping

Provide a source coordinate for every destination pixel.

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

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

YOUR IMAGE · REAL OPENCV

Experiment at pixel level

Open full lab ↗

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.

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

Undistort lenses, apply displacement fields, align plates or implement custom image warps.

How it works

  1. 01Build x and y maps in destination coordinates.
  2. 02Look up each requested source location.
  3. 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.