Main Content

Resize ROI in Image

This example shows how to resize a region of interest (ROI) in the input image.

Example Model

Open the Simulink® model.

modelname = "ex_resize_ROI.slx";
open_system(modelname)

This model reads an input image using the Image From File block with the File name parameter set to peppers.png.

To resize the ROI in input image, you must

  • Enable ROI processing

  • Specify the ROI

The model resizes the ROI in the input image by using the Resize block with these parameters:

  • SpecifyNumber of output rows and columns

  • Number of output rows and columns[400 400]

  • Interpolation methodBilinear

  • Select the Enable ROI processing parameter. This enables the ROI port. Specify the ROI value as [180 78 100 100] by using the Constant block.

  • Select the Output flag indicating if ROI is within the image bounds parameter. This enables the Flag port. The boolean value as the result of the simulation is indicated by the Flag port. The value is visualised using the Scope and the Display blocks.

Simulate and Display Results

Run the model and display the input and output images using the Video Viewer block.

sim(modelname);