{ } Raw JSON

bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / transform / _warps / warp_coords

function

skimage.transform._warps:warp_coords

source: /dev/scikit-image/src/skimage/transform/_warps.py :643

Signature

def   warp_coords ( coord_map shape dtype = <class 'numpy.float64'> )

Summary

Build the source coordinates for the output of a 2-D image warp.

Parameters

coord_map : callable like GeometricTransform.inverse

Return input coordinates for given output coordinates. Coordinates are in the shape (P, 2), where P is the number of coordinates and each element is a (row, col) pair.

shape : tuple

Shape of output image (rows, cols[, bands]).

dtype : dtype-like

dtype for return value (sane choices: float32 or float64).

Returns

coords : (ndim, rows, cols[, bands]) array of dtype `dtype`

Coordinates for scipy.ndimage.map_coordinates, that will yield an image of shape (orows, ocols, bands) by drawing from source points according to the coord_transform_fn.

Notes

This is a lower-level routine that produces the source coordinates for 2-D images used by warp().

It is provided separately from warp to give additional flexibility to users who would like, for example, to re-use a particular coordinate mapping, to use specific dtypes at various points along the the image-warping process, or to implement different post-processing logic than warp performs after the call to ndi.map_coordinates.

Examples

Produce a coordinate map that shifts an image up and to the right:
from skimage import data
from scipy.ndimage import map_coordinates
def shift_up10_left20(xy):
    return xy - np.array([-20, 10])[None, :]
image = data.astronaut().astype(np.float32)
coords = warp_coords(shift_up10_left20, image.shape)
warped_image = map_coordinates(image, coords)

Aliases

  • skimage.transform.warp_coords