Main Content

Resize RGB Image Using Block Processing

This example shows how to resize an RGB image using block processing.

Example Model

Open the Simulink® model.

modelname = "ex_blkresizeblockprocessing.slx";

The model reads an input image of size 384-by-512-by-3 using an Image From File block and resizes it to generate an output image of size 192-by-256-by-3 using a Block Processing block with these parameters:

  • Number of inputs3

  • Add port to supply subsystem parametersoff

  • Number of outputs3

  • Block size{[16 16]}

  • Overlap{[0 0]}

  • Traverse orderRow-wise

  • Subsystem — Consists of three Resize blocks that resize blocks of the individual color channels of the input image.

The Block Processing block receives the individual R, G, and B channels as three inputs. It divides each color channel of size 384-by-512 into blocks of size 16-by-16. The subsystem uses three Resize blocks with the Output size set as a percentage of input size parameter set to [50 50], and all other parameters with default values. The Resize blocks resize the 16-by-16 input blocks to 8-by-8. The Block Processing block then reassembles the resized blocks to form three outputs, each of size 192-by-256, corresponding to the resized R, G, and B channels.

Simulate the Model

Run the model. The model uses two Matrix Concatenate (Simulink) blocks to concatenate the color channels of the input and output images. It then displays the input image and the resized output image using Video Viewer blocks.