remap

Pixel-wise remapping of the image.

Move each pixel of an image to a given [x, y] location defined by the map. Function is similar to dcv.imgproc.imgmanip.warp, except displacement of pixels is absolute, rather than relative.

pure
remap
(
alias interp = linear
ImageTensor
MapTensor
)
(
ImageTensor image
,
MapTensor map
,
ImageTensor prealloc = ImageTensor.init
)

Parameters

interp

(template parameter) Interpolation function, default linear.

image
Type: ImageTensor

Input image, which is remapped. Single and multiple channel images are allowed.

map
Type: MapTensor

Target map, which holds [x, y] position for each pixel of an image.

prealloc
Type: ImageTensor

Pre-allocated memory where resulting remapped image is stored, if defined. Should be of same shape as input image, or an emptySlice, which implies newly allocated image is used.

Return Value

Type: auto

Remapped input image by given map.

Examples

Test if warp and remap always returns slice of corresponding format.

1 t
2 {
3     import std.random : uniform01;
4     import mir.ndslice.allocation;
5 
6     auto image = iota(3, 3).as!float.slice;
7     auto wmap = iota(3, 3, 2).map!(v => cast(float)uniform01).slice;
8 
9     auto warped = image.warp(wmap);
10     assert(warped.shape == image.shape);
11 
12     auto remapped = image.remap(wmap);
13     assert(remapped.shape == image.shape

Meta