Segmentation of interconnected lines
3 views (last 30 days)
Show older comments
Hi!
I'm working on a project that require to segment shapes or features from an image. My actual approach is to first detect all lines with Hough Transform and after try to segment each line by its slope, hower I've tried k-means, DBSCAN, and I didn't get the result that I would like to achieve.
I would like to know if someone can help me with a idea or documentation.
Thank You!

5 Comments
Accepted Answer
Image Analyst
on 10 Nov 2022
Moved: Image Analyst
on 10 Nov 2022
You can get all the angles like this:
lines = houghlines(BW,T,R,P,'FillGap',50,'MinLength',0.5)
allAngles = [lines.theta]
If you want to get each segment individually find crossing points and delete them, then label the image. Untested code:
% Find branchpoints
bpImage = bwmorph(BW, 'branchpoints');
% Erase branchpoints from main binary image.
BW(bpImage) = false;
% Label what's left.
[labeledImage, numSegments] = bwlabel(BW, 4);
% Show them all one at a time.
for k = 1 : numSegments
thisImage = ismember(labeledImage, k);
imshow(thisImage);
drawnow;
% Delay a bit so we can see it.
pause(0.5);
end
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!