Filter löschen
Filter löschen

Divide connected regions in an image into sub-groups

8 Ansichten (letzte 30 Tage)
I have an image (attached as Picture1.png) where the multiple white thick lines are present both in horizontal and vertical directions.
The white lines (either vertical or horizontal) are not always straight and can be curved as shown in picture1. Now, I wish to divide these connected white regions into sub groups, as shown in picture 2. The vertical lines shouldnt undergo fragmentation when criss-crossed by the horizontal lines. Since all the white lines are interconnected to each other, I cannot use regionprops and other similar functions. The numbering of the sub-groups does not need to be in same order as shown in picture 2.
What can be done next? Thank you

Akzeptierte Antwort

Mann Baidi
Mann Baidi am 8 Mai 2024
I can see that you would like to classify the vertical and horizontal borders separately.
You can use the 'edges' fucntion with the 'Prewitt' method specifying the direction as 'vertical' or horizontal. Here is an example for the same.
verticalEdges = edge(grayImage, 'prewitt', [], 'vertical');
For avoiding the fragmentation in the vertical edges you can use the 'strel' function along with the 'imclose' like mentioned below.
se = strel('line', 25,90); % Adjust the size of the structuring element as needed
closedEdges = imclose(verticalEdges, se);
Finally you can use the 'visboundaries' function for highlighting the boundries in the original image.
imshow(originalImage)
hold on
x=visboundaries(closedEdges,'Color','r');
hold on
visboundaries(horizontalEdges,'Color','g')
You can learn more about these functions using the documentation links mentioned below.

Weitere Antworten (0)

Produkte


Version

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by