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:
Specify —
Number of output rows and columns
Number of output rows and columns —
[400 400]
Interpolation method —
Bilinear
Select the Enable ROI processing parameter. This enables the ROI port. Specify the ROI value as
[180 78 100 100]
by using theConstant
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 theFlag
port. The value is visualised using theScope
and theDisplay
blocks.
Simulate and Display Results
Run the model and display the input and output images using the Video Viewer block.
sim(modelname);