Main Content
Remove Thin Lines Using Erosion
This example shows how to remove thin lines in a binary image by using morphological erosion with a neighborhood larger than the width of the lines.
Read and display a binary image. The white lines that represent wires are approximately four or five pixels wide. In some places, the wires are touching and the overall width is closer to ten or eleven pixels.
BW1 = imread('circbw.tif');
imshow(BW1)
Define a neighborhood larger than the width of the lines. This example uses a disk-shaped structuring element with a radius of 7 pixels so that the overall neighborhood size is 13-by-13 pixels.
SE = strel("disk",7)
SE = strel is a disk shaped structuring element with properties: Neighborhood: [13x13 logical] Dimensionality: 2
Erode the image, specifying the input image and the structuring element as arguments to the imerode
function.
BW2 = imerode(BW1,SE);
Display the eroded image.
imshow(BW2)