nvidia.dali.fn.warp_affine

nvidia.dali.fn.warp_affine(__data, __mtx=None, /, *, bytes_per_sample_hint=[0], dtype=None, fill_value=None, interp_type=DALIInterpType.INTERP_LINEAR, inverse_map=True, matrix=[], preserve=False, seed=-1, size=[], device=None, name=None)

Applies an affine transformation to the images.

This operator supports volumetric data.

Supported backends
  • ‘cpu’

  • ‘gpu’

Parameters:
  • __data (TensorList ('HWC', 'FHWC', 'DHWC', 'FDHWC')) – The image or volume to be warped

  • __mtx (TensorList of float, optional) – Like matrix argument, but can be placed in GPU memory

Keyword Arguments:
  • bytes_per_sample_hint (int or list of int, optional, default = [0]) –

    Output size hint, in bytes per sample.

    If specified, the operator’s outputs residing in GPU or page-locked host memory will be preallocated to accommodate a batch of samples of this size.

  • dtype (nvidia.dali.types.DALIDataType, optional) –

    Output data type.

    If not set, the input type is used.

  • fill_value (float, optional) –

    Value used to fill areas that are outside the source image.

    If a value is not specified, the source coordinates are clamped and the border pixel is repeated.

  • interp_type (nvidia.dali.types.DALIInterpType, optional, default = DALIInterpType.INTERP_LINEAR) – Type of interpolation used.

  • inverse_map (bool, optional, default = True) – Set to False if the given transform is a destination to source mapping, True otherwise.

  • matrix (float or list of float or TensorList of float, optional, default = []) –

    Transform matrix.

    When the inverse_map option is set to true (default), the matrix represents a destination to source mapping. With a list of values (M11, M12, M13, M21, M22, M23), this operation produces a new image by using the following formula:

    dst(x,y) = src(M11 * x + M12 * y + M13, M21 * x + M22 * y + M23)
    

    Where [0, 0] coordinate means the corner of the first pixel.

    If the inverse_map option is set to false, the matrix represents a source to destination transform and it is inverted before applying the formula above.

    It is equivalent to OpenCV’s warpAffine operation with the inverse_map argument being analog to the WARP_INVERSE_MAP flag.

    Note

    Instead of this argument, the operator can take a second positional input, in which case the matrix can be placed on the GPU.

    Supports per-frame inputs.

  • preserve (bool, optional, default = False) – Prevents the operator from being removed from the graph even if its outputs are not used.

  • seed (int, optional, default = -1) –

    Random seed.

    If not provided, it will be populated based on the global seed of the pipeline.

  • size (float or list of float or TensorList of float, optional, default = []) –

    Output size, in pixels/points.

    Non-integer sizes are rounded to nearest integer. The channel dimension should be excluded (for example, for RGB images, specify (480,640), not (480,640,3).

  • output_dtype (nvidia.dali.types.DALIDataType) –

    Warning

    The argument output_dtype is a deprecated alias for dtype. Use dtype instead.