warp_coords
-
skimage.transform.warp_coords(coord_map, shape, dtype=)
[source] -
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 : np.dtype or string
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 thecoord_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 thanwarp
performs after the call tondi.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)
Please login to continue.