cupyx.scipy.ndimage.affine_transform(input, matrix, offset=0.0, output_shape=None, output=None, order=None, mode='constant', cval=0.0, prefilter=True)

Apply an affine transformation.

Given an output image pixel index vector o, the pixel value is determined from the input image at position, o) + offset.

  • 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 of input, 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 to offset 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. If it is not given, order 1 is used. It is different from scipy.ndimage and can change in the future. Currently it supports only order 0 and 1.
  • mode (str) – Points outside the boundaries of the input are filled according to the given mode ('constant', 'nearest', 'mirror' or 'opencv'). Default is 'constant'.
  • cval (scalar) – Value used for points outside the boundaries of the input if mode='constant' or mode='opencv'. Default is 0.0
  • prefilter (bool) – It is not used yet. It just exists for compatibility with scipy.ndimage.

The transformed input. If output is given as a parameter, None is returned.

Return type:

cupy.ndarray or None