Perform Top-Hat Filtering of Binary Image
This example shows how to perform top-hat filtering on a binary image object.
Example Model
Open the Simulink® model.
modelname = 'ex_blockTophat.slx';
open_system(modelname);
The model reads an input binary image using the Image From File block. The Top-hat block performs top-hat filtering on the input image using a square-shaped structuring element of width 4. The Input image type parameter of the block is set to 'Binary'. The model displays the resulted filtered image using the Video Viewer block.
Simulate and Display Results
Run the model to visualize the filtered image. The Top-hat block first performs the opening operation on the input image and then subtracts the result of this operation from the input image. Here, the block removes the white objects that are larger than the structuring element and retains the smaller white objects, as can be seen.
sim(modelname);