Pad Zeros to Image
This example shows you how to add rows and columns of zeros to an image by using a padding operation.
Example Model
Open the Simulink® model.
modelname = 'ex_blkImagePad.slx';
open_system(modelname)

This model reads an input image using an Image From File block with the File name parameter set to cameraman.tif.
The model pads zeros to all four sides of the input image by using an Image Pad block with these parameters:
Method —
ConstantPad value source —
Specify via dialogPad value —
0Specify —
Pad sizeAdd columns to —
Both left and rightNumber of added columns —
[10,10]Add rows to —
Both top and bottomNumber of added rows —
[10,10]
Simulate the Model
Run the model. The model displays the input image and the zero-padded output image by using a Video Viewer block. The padded zeros create the black border of the output image.
sim(modelname);

