You can use the Rotate block to rotate your image or video stream by a specified angle. In this example, you learn how to use the Rotate block to continuously rotate an image.
I = checker_board;
I is a 100-by-100-by-3 array of double-precision values. Each plane of the array represents the red, green, or blue color values of the image.
Image From Workspace
Computer Vision System Toolbox™ > Sources
Computer Vision System Toolbox > Geometric Transformations
Computer Vision System Toolbox > Sinks
Simulink > Math Operations
DSP System Toolbox > Sinks
DSP System Toolbox > Signal Management > Switches and Counters
Use the Image From Workspace block to import the RGB image from the MATLAB workspace. On the Main pane, set the Value parameter to I. Each plane of the array represents the red, green, or blue color values of the image.
The Video Viewer block automatically displays the original image in the Video Viewer window when you run the model. Because the image is represented by double-precision floating-point values, a value of 0 corresponds to black and a value of 1 corresponds to white.
Rotation angle source = Input port
Sine value computation method = Trigonometric function
The Angle port appears on the block. You use this port to input a steadily increasing angle. Setting the Output size parameter to Expanded to fit rotated input image ensures that the block does not crop the output.
Count event = Free running
Counter size = 16 bits
Output = Count
Clear the Reset input check box.
Sample time = 1/30
The Counter block counts upward until it reaches the maximum value that can be represented by 16 bits. Then, it starts again at zero. You can view its output value on the Display block while the simulation is running. The Counter block's Count data type parameter enables you to specify it's output data type.
Solver pane, Stop time = inf
Solver pane, Type = Fixed-step
Solver pane, Solver = Discrete (no continuous states)
The original image appears in the Video Viewer window.
The rotating image appears in the Video Viewer1 window.
In this example, you used the Rotate block to continuously rotate your image. For more information about this block, see the Rotate block reference page in the Computer Vision System Toolbox Reference. For more information about other geometric transformation blocks, see the Resize and Shear block reference pages.