Documentation Center

  • Trial Software
  • Product Updates

Resize an Image

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:

  1. Create a new Simulink® model, and add to it the blocks shown in the following table.

    Block

    Library

    Quantity

    Image From File

    Computer Vision System Toolbox™ > Sources

    1

    Resize

    Computer Vision System Toolbox > Geometric Transformations

    1

    Video Viewer

    Computer Vision System Toolbox > Sinks

    2

  2. Use the Image From File block to import the intensity image. Set the File name parameter to moon.tif. The tif file is a 537-by-358 matrix of 8-bit unsigned integer values.

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

  4. Use the Resize block to shrink the image. Set the Resize factor in % parameter to 50. This shrinks the image to half its original size.

  5. Use the Video Viewer1 block to display the modified image. Accept the default parameters.

  6. Connect the blocks as shown in the following figure.

  7. 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 time = 0

    • Solver pane, Type = Fixed-step

    • Solver pane, Solver = Discrete (no continuous states)

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

Was this topic helpful?