tfg.image.transformer.perspective_transform

Applies a projective transformation to an image.

The projective transformation is represented by a 3 x 3 matrix [[a0, a1, a2], [b0, b1, b2], [c0, c1, c2]], mapping a point [x, y] to a transformed point [x', y'] = [(a0 x + a1 y + a2) / k, (b0 x + b1 y + b2) / k], where k = c0 x + c1 y + c2.

Note:

The transformation matrix maps target to source by transforming output points to input points.

image A tensor of shape [B, H_i, W_i, C], where B is the batch size, H_i the height of the image, W_i the width of the image, and C the number of channels of the image.
transform_matrix A tensor of shape [B, 3, 3] containing projective transform matrices. The transformation maps target to source by transforming output points to input points.
output_shape The heigh H_o and width W_o output dimensions after the transform. If None, output is the same size as input image.
resampling_type Resampling mode. Supported values are ResamplingType.NEAREST and ResamplingType.BILINEAR.
border_type Border mode. Supported values are BorderType.ZERO and BorderType.DUPLICATE.
pixel_type Pixel mode. Supported values are PixelType.INTEGER and PixelType.HALF_INTEGER.
name A name for this op. Defaults to "perspective_transform".

A tensor of shape [B, H_o, W_o, C] containing transformed images.

ValueError If image has rank != 4. If transform_matrix has rank < 3 or its last two dimensions are not 3. If image and transform_matrix batch dimension does not match.