Rotate image by specified angle
Geometric Transformations
visiongeotforms
Use the Rotate block to rotate an image by an angle specified in radians.
This block supports intensity and color images on its ports.
Port  Description 

Image  MbyN matrix of intensity values or an MbyNbyP color video signal where P is the number of color planes 
Angle  Rotation angle 
Output  Rotated matrix 
The Rotate block uses the 3pass shear rotation
algorithm to compute its values, which is different than the algorithm
used by the imrotate
function
in the Image Processing
Toolbox™.
The following diagram shows the data types used in the Rotate block for bilinear interpolation of fixedpoint signals.
You can set the angle values, product output, accumulator, and output data types in the block mask.
The Rotate block requires additional data types. The Sine table value has the same word length as the angle data type and a fraction length that is equal to its word length minus one. The following diagram shows how these data types are used inside the block.
If overflow occurs, the rotated image might appear distorted.
Specify the size of the rotated matrix. If you select
Expanded to fit rotated input image
, the
block outputs a matrix that contains all the rotated image values. If you
select Same as input image
, the block outputs a
matrix that contains the middle part of the rotated image. As a result, the
edges of the rotated image might be cropped. Use the Background
fill value parameter to specify the pixel values outside the
image.
Specify how to enter your rotation angle. If you select
Specify via dialog
, the Angle
(radians) parameter appears in the dialog box.
If you select Input port
, the Angle port
appears on the block. The block uses the input to this port at each time
step as your rotation angle. The input to the Angle port must be the same
data type as the input to the I port.
Enter a real, scalar value for your rotation angle. This parameter is
visible if, for the Rotation angle source parameter,
you select Specify via dialog
.
When the rotation angle is a multiple of pi/2, the block uses a more efficient algorithm. If the angle value you enter for the Angle (radians) parameter is within 0.00001 radians of a multiple of pi/2, the block rounds the angle value to the multiple of pi/2 before performing the rotation.
Enter the maximum angle by which to rotate the input image.
Enter a scalar value, between 0
and $$\pi $$ radians.
The block determines which angle, $$0\le angle\le \mathrm{max}angle$$,
requires the largest output matrix and sets the dimensions of the
output port accordingly.
This parameter is visible if you set the Output size parameter, to
Expanded to fit rotated input image
, and the
Rotation angle source parameter
toInput port
.
Specify how the image is rotated. If you select
Center
, the image is rotated about its center
point. If you select Topleft corner
, the block
rotates the image so that two corners of the rotated input image are always
in contact with the top and left sides of the output image.
This parameter is visible if, for the Output size
parameter, you select Expanded to fit rotated input
image
, and, for the Rotation angle
source parameter, you select Input
port
.
Specify the value computation method. If you select
Trigonometric function
, the block computes
sine and cosine values it needs to calculate the rotation of your image
during the simulation. If you select Table
lookup
, the block computes and stores the trigonometric values
it needs to calculate the rotation of your image before the simulation
starts. In this case, the block requires extra memory.
Specify a value for the pixels that are outside the image.
Specify which interpolation method the block uses to rotate the image. If
you select Nearest neighbor
, the block uses the
value of one nearby pixel for the new pixel value. If you select
Bilinear
, the new pixel value is the weighted
average of the four nearest pixel values. If you select
Bicubic
, the new pixel value is the weighted
average of the sixteen nearest pixel values.
The number of pixels the block considers affects the complexity of the
computation. Therefore, the Nearestneighbor
interpolation is the most computationally efficient. However, because the
accuracy of the method is proportional to the number of pixels considered,
the Bicubic
method is the most accurate. For more
information, see Nearest Neighbor, Bilinear, and Bicubic Interpolation Methods in the
Computer
Vision Toolbox™ User's Guide.
Select the rounding mode for fixedpoint operations.
Select the overflow mode for fixedpoint operations.
Choose how to specify the word length and the fraction length of the angle values.
When you select Same word length as
input
, the word length of the angle values match
that of the input to the block. In this mode, the fraction length of
the angle values is automatically set to the binarypoint only
scaling that provides you with the best precision possible given the
value and word length of the angle values.
When you select Specify word length
,
you can enter the word length of the angle values, in bits. The
block automatically sets the fraction length to give you the best
precision.
When you select Binary point scaling
,
you can enter the word length and the fraction length of the angle
values, in bits.
When you select Slope and bias scaling
,
you can enter the word length, in bits, and the slope of the angle
values. The bias of all signals in the Computer
Vision Toolbox blocks is 0.
This parameter is only visible if, for the Rotation angle source
parameter, you select Specify via dialog
.
As depicted in the previous figure, the output of the multiplier is placed into the product output data type and scaling. Use this parameter to specify how to designate this product output word and fraction lengths.
When you select Same as first input
,
these characteristics match those of the input to the block.
When you select Binary point scaling
,
you can enter the word length and the fraction length of the product
output, in bits.
When you select Slope and bias scaling
,
you can enter the word length, in bits, and the slope of the product
output. The bias of all signals in the Computer
Vision Toolbox blocks is 0.
As depicted in the previous figure, inputs to the accumulator are cast to the accumulator data type. The output of the adder remains in the accumulator data type as each element of the input is added to it. Use this parameter to specify how to designate this accumulator word and fraction lengths.
When you select Same as product output
,
these characteristics match those of the product output.
When you select Same as first input
,
these characteristics match those of the first input to the
block.
When you select Binary point scaling
,
you can enter the word length and the fraction length of the
accumulator, in bits.
When you select Slope and bias scaling
,
you can enter the word length, in bits, and the slope of the
accumulator. The bias of all signals in the Computer
Vision Toolbox blocks is 0.
Choose how to specify the word length and fraction length of the output of the block:
When you select Same as first input
,
these characteristics match those of the first input to the
block.
When you select Binary point scaling
,
you can enter the word length and the fraction length of the output,
in bits.
When you select Slope and bias scaling
,
you can enter the word length, in bits, and the slope of the output.
The bias of all signals in the Computer
Vision Toolbox blocks is 0.
Select this parameter to prevent the fixedpoint tools from
overriding the data types you specify on the block mask. For more
information, see fxptdlg
,
a reference page on the FixedPoint Tool in the Simulink^{®} documentation.
Port  Supported Data Types 

Image 

Angle  Same as Image port 
Output  Same as Image port 
If the data type of the input signal is floating point, the output signal is the same data type as the input signal.
[1] Wolberg, George. Digital Image Warping. Washington: IEEE Computer Society Press, 1990.