This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

vision.GeometricTransformer System object

Package: vision

Apply projective or affine transformation to image


    Note:   The vision.GeometricTransformer System object will be removed in a future release. Use the imwarp function with equivalent functionality instead.

The GeometricTransformer object applies a projective or affine transformation to an image.

    Note:   Starting in R2016b, instead of using the step method to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example, y = step(obj,x) and y = obj(x) perform equivalent operations.


H = vision.GeometricTransformer returns a geometric transformation System object, H. This object applies a projective or affine transformation to an image.

H = vision.GeometricTransformer(Name,Value) returns a geometric transformation object, H, with each specified property set to the specified value. You can specify additional name-value pair arguments in any order as (Name1, Value1,...,NameN,ValueN).

When you specify multiple transforms in a single matrix, each transform is applied separately to the original image. If the individual transforms produce an overlapping area, the result of the transform in the last row of the matrix is overlaid on top.

Code Generation Support
Supports MATLAB® Function block: Yes
Code Generation Support, Usage Notes, and Limitations



Method to specify transformation matrix

Specify as one of Property | Input port.

Default: Input port.


Transformation matrix

Specify the applied transformation matrix as a 3-by-2 or Q-by-6 affine transformation matrix, or a 3-by-3 or a Q-by-9 projective transformation matrix. Q is the number of transformations. This property applies when you set the TransformMatrixSource property to Property.

Default: [1 0 0; 0 1 0; 0 0 1]


Interpolation method

Specify as one of Nearest neighbor | Bilinear | Bicubic for calculating the output pixel value.

Default: Bilinear


Background fill value

Specify the value of the pixels that are outside of the input image. The value can be either scalar or a P-element vector, where P is the number of color planes.

Default: 0


Method to specify output image location and size

Specify the value of this property as one of Auto | Property. If this property is set to Auto, the output image location and size are the same values as the input image.

Default: Auto


Output image position vector

Specify the location and size of output image, as a four-element double vector in pixels, of the form, [x y width height]. This property applies when you set the OutputImagePositionSource property to Property.

Default: [1 1 512 512]


Enable the region of interest input port

Set this property to true to enable the input of the region of interest. When set to false, the whole input image is processed.

Default: false


Region of interest shape

Specify ROIShape as one of Rectangle ROI | Polygon ROI.This property applies when you set the ROIInputPort property to true.

Default:Rectangle ROI


Enable output of ROI flag

Set this property to true to enable the output of an ROI flag indicating when any part of the ROI is outside the input image. This property applies when you set the ROIInputPort property to true.



Projective transformation method

Method to compute the projective transformation. Specify as one of Compute exact values | Use quadratic approximation.

Default: Compute exact values


Error tolerance (in pixels)

Specify the maximum error tolerance in pixels for the projective transformation. This property applies when you set the ProjectiveTransformMethod property to Use quadratic approximation.

Default: 1


Enable clipping status flag output

Set this property to true to enable the output of a flag indicating if any part of the output image is outside the input image.

Default: false


cloneCreate geometric transformer object with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs from step method
isLockedLocked status for input attributes and nontunable properties
release Allow property value and input characteristics changes
stepApply geometric transform to input image


Apply a horizontal shear to an intensity image.

htrans1 = vision.GeometricTransformer(...
           'TransformMatrixSource', 'Property', ...
           'TransformMatrix',[1 0 0; .5 1 0; 0 0 1],...
           'OutputImagePositionSource', 'Property',...
           'OutputImagePosition', [0 0 400 750]);
img1 = im2single(rgb2gray(imread('peppers.png')));
transimg1 = step(htrans1,img1);

Apply a transform with multiple polygon ROI's.

htrans2 = vision.GeometricTransformer;
img2 = checker_board(20,10);
tformMat = [     1        0       30        0       1      -30; ...
            1.0204  -0.4082       70        0  0.4082       30; ...
            0.4082        0  89.1836  -0.4082       1  10.8164];
polyROI = [  1   101    99   101    99   199     1   199; ...
             1     1    99     1    99    99     1    99; ...
           101   101   199   101   199   199   101   199];
htrans2.BackgroundFillValue = [0.5 0.5 0.75];
htrans2.ROIInputPort = true;
htrans2.ROIShape = 'Polygon ROI';
transimg2 = step(htrans2,img2,tformMat,polyROI);
figure; imshow(img2);
figure; imshow(transimg2); 


This object implements the algorithm, inputs, and outputs described on the Apply Geometric Transformation block reference page. The object properties correspond to the block parameters.

Introduced in R2012a

Was this topic helpful?