Removing components connected to an arbitrary border
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a binary image, which contains a border line.
Inside the border there are several objects.
I want to remove all objects how touch this border. Like imclearborder does with objects how touch the border of the image.
Please note that the border is not the same as the border of the image.
0 Kommentare
Antworten (1)
Puru Kathuria
am 27 Dez. 2020
You can use imclearborder to suppresses structures that are lighter than their surroundings and that are connected to the image border.
Also, you can specifiy the connectivity parameter in imclearborder according to your requirements.
Example:
conn = 4;
imclearborder(image,conn)
The above code uses 4-connected neighborhood and does not consider pixel at (5,2) to be connected with the border pixel at (4,1), so it will not be cleared whereas the below code uses 8-connected neighborhood and does consider pixel at (5,2) to be connected with the border pixel at (4,1).
conn = 4;
imclearborder(image,conn);
Otherwise, if you want to remove a region around the point (x,y).
idx = img(y, x);
img(img == ind) = 0;
And if you want to exclude objects that touch the a particular border (top/left/bottom/right) then consider using imclearborder after padding the particular edge of the image first so that they are not touching the border.
Hope it helps.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Image Segmentation and Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!