warp_perspective#

rlemasklib.RLEMask.warp_perspective(H, output_imshape)[source]#

Apply a perspective warping (homography) transformation to the mask.

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

Parameters:
  • H (ndarray) – the perspective transformation matrix as a 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

Scale by 0.5x and translate (shift output right by 3, down by 2):

.warp_perspective(H, output_imshape=(6, 8)) ==