Warp

Apply projective or affine transformation to an image

Library

Geometric Transformations

visiongeotforms

  • Warp block

Description

The Warp block applies a projective or affine transformation to an image. You can transform the entire image or portions of the image using either a polygonal or rectangular region of interest (ROI).

Input Port Descriptions

Port Input/OutputDescriptionSupported Data Types
ImageInput

M-by-N grayscale image or M-by-N-by-3 truecolor image.

  • M— Number of rows in the image.

  • N— Number of columns in the image.

  • Double-precision floating point

  • Single-precision floating point

  • 8- or 16-bit unsigned integers

  • 16-bit signed integers

  • logical

TFormInput

When you set Transformation matrix source to Input port, the TForm port accepts these inputs:

  • 3-by-2 matrix (affine transform).

  • 3-by-3 matrix (projective transform).

When you set Transformation matrix source to Custom, specify the source in the Transformation matrix field.

  • Double-precision floating point

  • Single-precision floating point

ROIInput

When you enable the ROI input port, you can also enable an Err_roi output port to indicate if any part of an ROI is outside the input image. The ROI input port accepts an ROI rectangle, specified as a 4-element vector: [x y width height].

  • Double-precision floating point

  • Single-precision floating point

  • 8-, 16-, or 32-bit signed integers

  • 8-, 16-, or 32-bit unsigned integers

ImageOutput

Transformed image.

Same as input

Err_roiOutput

Indicates if any part of an ROI is outside the input image.

Boolean

Parameters

Transformation matrix source

Input matrix source, specified as either Input port or Custom. If you select Custom, you can enter the transformation matrix parameter in the field that appears with this selection.

Transformation matrix

Custom transformation matrix, specified as a 3-by-2 or 3-by-3 matrix. This parameters appears when you set Transformation matrix source to Custom.

Interpolation method

Interpolation method used to calculate output pixel values, specified as Nearest neighbor, Bilinear, or Bicubic. See Nearest Neighbor, Bilinear, and Bicubic Interpolation Methodsfor an overview of these methods.

Background fill value

Value of the pixels that are outside of the input image, specified as either a scalar value or a 3-element vector.

Output image position source

Source of the output image size, specified as either either Same as input image or Custom. If you select Custom, you can specify the bounding box in the field that appears with this selection.

Output image position vector [x y width height]

Position, width, and height of the output image, specified as a 4-element vector: [x y width height]. This parameter appears when you set Output image position source to Custom.

Enable ROI input port

Select this check box to enable the ROI input port. Use this port to specify the rectangular region you want to transform.

Enable output port indicating if any part of ROI is outside input image

Select this check box to enable the Err_roi output port.

References

[1] Wolberg, George . Digital Image Warping, 3rd edition. IEEE Computer Society Press, 1994.

[2] Hartley, Richard, and Andrew Zisserman. Multiple View Geometry in Computer Vision. 2nd edition. IEEE Computer Society Press, 2003.

Algorithms

expand all

The size of the transformation matrix dictates the transformation type.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

See Also

Introduced in R2015b