Divide connected regions in an image into sub-groups
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Arnab Samaddar-Chaudhuri
el 6 de Mayo de 2024
Comentada: Arnab Samaddar-Chaudhuri
el 8 de Mayo de 2024
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
0 comentarios
Respuesta aceptada
Mann Baidi
el 8 de Mayo de 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.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!