Rotate image by specified angle
H = vision.GeometricRotator returns a geometric rotator System object, H, that rotates an image by radians.
H = vision.GeometricRotator(Name,Value) returns a geometric rotator 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).
Output size as full or same as input image size
Specify the size of output image as one of Expanded to fit rotated input image | Same as input image. The default is Expanded to fit rotated input image. When you set this property to Expanded to fit rotated input image, the object outputs a matrix that contains all the rotated image values. When you set this property to Same as input image, the object outputs a matrix that contains the middle part of the rotated image.
Source of angle
Specify how to specify the rotation angle as one of Property | Input port. The default is Property.
Rotation angle value (radians)
Set this property to a real, scalar value for the rotation angle (radians). The default is pi/6. This property applies when you set the AngleSource property to Property.
Maximum angle by which to rotate image
Specify the maximum angle by which to rotate the input image as a numeric scalar value greater than 0. The default is pi. This property applies when you set the AngleSource property to Input port.
How the image is rotated
Specify how the image is rotated as one of Top-left corner | Center. The default is Center. When you set this property to Center, the object rotates the image about its center point. When you set this property to Top-left corner, the object rotates the image so that two corners of the input image are always in contact with the top and left side of the output image. This property applies when you set the OutputSize property to Expanded to fit rotated input image, and, the AngleSource property to Input port.
How to calculate the rotation
Specify how to calculate the rotation as one of Trigonometric function | Table lookup. The default is Table lookup. When you set this property to Trigonometric function, the object computes the sine and cosine values it needs to calculate the rotation of the input image. When you set this property to Table lookup, the object computes the trigonometric values it needs to calculate the rotation of the input image, and stores them in a table. The object uses the table, each time it calls the step method. In this case, the object requires extra memory.
Value of pixels outside image
Specify the value of pixels that are outside the image as a numeric scalar value or a numeric vector of same length as the third dimension of input image. The default is 0. This property is tunable.
Interpolation method used to rotate image
Specify the interpolation method used to rotate the image as one of Nearest neighbor | Bilinear | Bicubic. The default is Bilinear. When you set this property to Nearest neighbor, the object uses the value of one nearby pixel for the new pixel value. When you set this property to Bilinear, the object sets the new pixel value as the weighted average of the four nearest pixel values. When you set this property to Bicubic, the object sets the new pixel value as the weighted average of the sixteen nearest pixel values.
|clone||Create geometric rotator object with same property values|
|getNumInputs||Number of expected inputs to step method|
|getNumOutputs||Number of outputs from step method|
|isLocked||Locked status for input attributes and nontunable properties|
|release||Allow property value and input characteristics changes|
|step||Return rotated image|
Rotate an image 30 degrees ( radians)
img = im2double(imread('peppers.png')); hrotate = vision.GeometricRotator; hrotate.Angle = pi / 6; % Rotate img by pi/6 rotimg = step(hrotate,img); imshow(rotimg);
Rotate an image by multiple angles, specifying each rotation angle as an input. The angle can be changed during simulation.
hrotate = vision.GeometricRotator; hrotate.AngleSource = 'Input port'; img = im2double(imread('onion.png')); figure; % Rotate img by multiple angles for i = 1: 4 rotimg = step(hrotate,img,i*pi/16); subplot(1,4,i); imshow(rotimg); end
This object implements the algorithm, inputs, and outputs described on the Rotate block reference page. The object properties correspond to the block parameters.