Products & Services Industries Academia Support User Community Company

Learn more about Video and Image Processing Blockset   

Rotate - Rotate image by specified angle

Library

Geometric Transformations

Description

Use the Rotate block to rotate an image by an angle specified in radians.

PortInput/OutputSupported Data TypesComplex Values Supported

Image

M-by-N matrix of intensity values or an M-by-N-by-P color video signal where P is the number of color planes

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point

  • 8-, 16-, 32-bit signed integer

  • 8-, 16-, 32-bit unsigned integer

No

Angle

Rotation angle

Same as Image port

No

Output

Rotated matrix

Same as Image port

No

If the data type of the input signal is floating point, the output signal is the same data type as the input signal.

Use the Output size parameter to 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.

Use the Rotation angle source parameter to specify how to enter your rotation angle. If you select Specify via dialog, the Angle (radians) parameter appears in the dialog box. Use it to enter a real, scalar value for your rotation angle.

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.

If, for the Output size parameter, you select Expanded to fit rotated input image, and, for Rotation angle source parameter, you select Input port, the Maximum angle (enter pi radians to accommodate all positive and negative angles) and Display rotated image in parameters appear in the dialog box. If, for the Output size parameter, you select Same as input image, and, for Rotation angle source parameter, you select Input port, the Maximum angle (enter pi radians to accommodate all positive and negative angles) and parameters appears in the dialog box.

For the Maximum angle (enter pi radians to accommodate all positive and negative angles) parameter, enter a scalar value,

radians, that represents the maximum angle by which you want to rotate the input image. The block determines which angle, , requires the largest output matrix and sets the dimensions of the output port accordingly. To accommodate all angles, enter

radians.

Use the Display rotated image in parameter to determine how the image is rotated in the display window. If you select Center, the image is rotated about its center point. If you select Top-left corner, the block rotates the image so that two corners of the image are always in contact with the top and left side of the Matrix Viewer window.

Use the Sine value computation method parameter to specify how much memory the Rotate block requires. 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.

Use the Interpolation method parameter to specify which interpolation method the block uses to rotate the image. If you select Nearest neighbor, the block uses the value of the nearest 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 nearest-neighbor 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 Geometric Transformation Interpolation Methods in the Video and Image Processing Blockset User's Guide.

The Rotate block uses the 3-pass shear rotation algorithm to compute its values, which is different than the algorithm used by the imrotate function in the Image Processing Toolbox. See page 208 of [1] for more information about this algorithm.

Fixed-Point Data Types

The following diagram shows the data types used in the Rotate block for bilinear interpolation of fixed-point 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.

Dialog Box

The Main pane of the Rotate dialog box appears as shown in the following figure.

Output size

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.

Rotation angle source

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.

Angle (radians)

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.

Maximum angle (enter pi radians to accommodate all positive and negative angles)

Enter the maximum angle by which to rotate the input image. This parameter is visible if you set the Rotation angle source parameter toInput port.

Display rotated image in

Specify how the image is rotated. If you select Center, the image is rotated about its center point. If you select Top-left corner, the block rotates the image so that two corners of the image are always in contact with the top and left side of the Matrix Viewer window. 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.

Sine 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.

Background fill value

Specify a value for the pixels that are outside the image.

Interpolation method

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 Fixed-point pane of the Rotate dialog box appears as shown in the following figure.

Rounding mode

Select the rounding mode for fixed-point operations.

Overflow mode

Select the overflow mode for fixed-point operations.

Angle values

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 binary-point 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 Video and Image Processing Blockset blocks is 0.

This parameter is only visible if, for the Rotation angle source parameter, you select Specify via dialog.

Product output

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 Video and Image Processing Blockset blocks is 0.

Accumulator

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 Video and Image Processing Blockset blocks is 0.

Output

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 Video and Image Processing Blockset blocks is 0.

References

[1] Wolberg, George. Digital Image Warping. Washington: IEEE Computer Society Press, 1990.

See Also

Resize

Video and Image Processing Blockset software

Translate

Video and Image Processing Blockset software

Shear

Video and Image Processing Blockset software

imrotate

Image Processing Toolbox software

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS