You can use the Resize block to change the size of your image or video stream. In this example, you learn how to use the Resize block to reduce the size of an image:
Create a new Simulink® model, and add to it the blocks shown in the following table.
Image From File
Computer Vision System Toolbox™ > Sources
Computer Vision System Toolbox > Geometric Transformations
Computer Vision System Toolbox > Sinks
Use the Image From File block
to import the intensity image. Set the File name parameter
moon.tif. The tif file is a 537-by-358 matrix
of 8-bit unsigned integer values.
Use the Video Viewer block to display the original image. Accept the default parameters. This block automatically displays the original image in the Video Viewer window when you run the model.
Use the Resize block to
shrink the image. Set the Resize factor in % parameter
50. This shrinks the image to half its original
Use the Video Viewer1 block to display the modified image. Accept the default parameters.
Connect the blocks as shown in the following figure.
Set the configuration parameters. Open the Configuration dialog box by selecting Model Configuration Parameters from the Simulation menu. Set the parameters as follows:
Solver pane, Stop
Solver pane, Type =
Solver pane, Solver =
(no continuous states)
Run the model.
The original image appears in the Video Viewer window.
The reduced image appears in the Video Viewer1 window.
In this example, you used the Resize block to shrink an image. For more information about this block, see the Resize block reference page. For more information about other geometric transformation blocks, see the Rotate, Apply Geometric Transformation, Estimate Geometric Transformation, and Translate block reference pages.