Main Content

Perform Closing of Binary Image

This example shows how to eliminate small holes in a binary image by using closing operation.

Example Model

Open the Simulink® model.

modelname = 'ex_blockClosing.slx';

The model reads an input binary image by using the Image From File block. The Closing block performs the closing operation on the input image. The model uses a disk-shaped structuring element with a radius of 4. The model displays the output image by using the Video Viewer block.

Simulate and Display Results

Run the model and display the result. You can see that the closing operation reduced the size of the leftmost intrusion on the boundary of the white object and smoothed the sections of the contour.