how to fix damaged lines in a binary image?
1 view (last 30 days)
Show older comments
My binary image has 4 objects that they should be horizontal lines in the original image. I detected the boundaries of the objects (damaged lines) with bwboundaries and the middle point of the objects with regionprops so i could find the thickness of the original lines but i don't know how to proceed. Was a bad idea to find the center points of the lines with regionprops? is there a better way?
By "fixing" the lines i mean i need to restore them. They should be horizontal in the original image.
3 Comments
Matt J
on 12 Oct 2012
What was your idea for 'restoring' them? How does finding the center point and thickness lead you to a way to straighten the lines? Do you just want to erase the bent ones from the image and redraw them straight? If so, how would you choose the position and length of the restored line?
Answers (2)
Image Analyst
on 11 Oct 2012
Edited: Image Analyst
on 11 Oct 2012
What do you mean by "fix the damaged lines"? Do you mean to extend them to connect gaps? If so, look up edge linking: http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/#edgelink Otherwise you can try a morphological closing with imclose().
When you say "supposed to be lines" do you mean that you want the blobs to be a single pixel wide, instead of many pixels wide? If so, use
skeletonImage = bwmorph(binaryImage, 'skel', inf);
Please clarify the ambiguous/unclear wording.
0 Comments
Matt J
on 11 Oct 2012
Edited: Matt J
on 11 Oct 2012
I don't see how finding the center point helps you get the thickness of the lines.
Depending on how exact you need to be, it looks like the thicknesses could be obtained pretty closely by
R=regionprops(...,'Perimeter','Area')
thickness(i) = R(i).Area/(R(i).Perimeter/2); %thickness of i-th line
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!