warp_affine#

rlemasklib.RLEMask.warp_affine(M, output_imshape)[source]#

Apply an affine warping transformation to the mask.

The transformation matrix M should be the forward transformation, i.e. the output location of an input pixel is calculated as x_out = M @ x_in_homogeneous.

Parameters:
  • M (ndarray) – the affine transformation matrix as a 2x3 or 3x3 numpy array

  • output_imshape (Sequence[int]) – the shape of the output image as (height, width)

Returns:

A new RLEMask object representing the warped mask.

Return type:

RLEMask

Examples

Translation by (2, 1) moves the mask right and down:

.warp_affine(M, output_imshape=(4, 6)) == # M = [[1,0,2],[0,1,1]]