cupyx.scipy.ndimage.affine_transform#
- cupyx.scipy.ndimage.affine_transform(input, matrix, offset=0.0, output_shape=None, output=None, order=3, mode='constant', cval=0.0, prefilter=True, *, texture_memory=False)[source]#
Apply an affine transformation.
Given an output image pixel index vector
o
, the pixel value is determined from the input image at positioncupy.dot(matrix, o) + offset
.- Parameters:
input (cupy.ndarray) – The input array.
matrix (cupy.ndarray) –
The inverse coordinate transformation matrix, mapping output coordinates to input coordinates. If
ndim
is the number of dimensions ofinput
, the given matrix must have one of the following shapes:(ndim, ndim)
: the linear transformation matrix for each output coordinate.(ndim,)
: assume that the 2D transformation matrix is diagonal, with the diagonal specified by the given value.(ndim + 1, ndim + 1)
: assume that the transformation is specified using homogeneous coordinates. In this case, any value passed tooffset
is ignored.(ndim, ndim + 1)
: as above, but the bottom row of a homogeneous transformation matrix is always[0, 0, ..., 1]
, and may be omitted.
offset (float or sequence) – The offset into the array where the transform is applied. If a float,
offset
is the same for each axis. If a sequence,offset
should contain one value for each axis.output_shape (tuple of ints) – Shape tuple.
output (cupy.ndarray or dtype) – The array in which to place the output, or the dtype of the returned array.
order (int) – The order of the spline interpolation, default is 3. Must be in the range 0-5.
mode (str) – Points outside the boundaries of the input are filled according to the given mode (
'constant'
,'nearest'
,'mirror'
,'reflect'
,'wrap'
,'grid-mirror'
,'grid-wrap'
,'grid-constant'
or'opencv'
).cval (scalar) – Value used for points outside the boundaries of the input if
mode='constant'
ormode='opencv'
. Default is 0.0prefilter (bool) – Determines if the input array is prefiltered with
spline_filter
before interpolation. The default is True, which will create a temporaryfloat64
array of filtered values iforder > 1
. If setting this to False, the output will be slightly blurred iforder > 1
, unless the input is prefiltered, i.e. it is the result of callingspline_filter
on the original input.texture_memory (bool) –
If True, uses GPU texture memory. Supports only:
2D and 3D float32 arrays as input
(ndim + 1, ndim + 1)
homogeneous float32 transformationmatrix
mode='constant'
andmode='nearest'
order=0
(nearest neighbor) andorder=1
(linearinterpolation)
NVIDIA CUDA GPUs
- Returns:
The transformed input. If
output
is given as a parameter,None
is returned.- Return type:
cupy.ndarray or None
See also