megengine.functional.nn.warp_affine#

warp_affine(inp, mat, out_shape, border_mode='replicate', border_val=0.0, format='NHWC', interp_mode='linear')[source]#

Batched affine transformation on 2D images. Affine transformation is a linear transformation between two-dimensional coordinates.

Parameters:
  • inp (Tensor) – input image.

  • mat (Tensor) – (batch, 2, 3) transformation matrix.

  • out_shape (Union[Tuple[int, int], int, Tensor]) – output tensor shape.

  • border_mode (str) – pixel extrapolation method. Default: “replicate”. Currently “constant”, “reflect”, “reflect_101”, “isolated”, “wrap”, “replicate”, “transparent” are supported.

  • border_val (float) – value used in case of a constant border. Default: 0

  • format (str) – NHWC” as default based on historical concerns, “NCHW” is also supported. Default: “NHWC”.

  • interp_mode (str) – interpolation methods. Could be “linear”, “nearest”, “cubic”, “area”. Default: “linear”.

Return type:

Tensor

Returns:

output tensor.

Note

Here all available options for params are listed, however it does not mean that you can use all the combinations. On different platforms, different combinations are supported. warp_affine only support forward inference, Please refer to warp_perspective if backward is needed.