How to create a line that goes through a specific point?
9 views (last 30 days)
Show older comments
Hello everybody, I have a binary image of edges of a shape, a closed shape and I would like to find the minimum and maximum diameter of that shape. meaning the max and min line (from edge to edge) but it has to go through the point of center of mass. so I have found this point but now I have to draw lines that go through this point and find the min and max. I hope this makes sense... Help someone?? Tnx, Hadas
Answers (1)
Matt J
on 26 May 2014
Edited: Matt J
on 26 May 2014
If the shape is convex, one thing you could is fill in the edges to get a binary image of the whole shape
Image=imfill(Image,'holes');
Then, use radon to get the lengths of lines through the shape and find the min/max, over rays passing through the center of mass.
5 Comments
Matt J
on 26 May 2014
Edited: Matt J
on 26 May 2014
You have to isolate the outer edges of the shape, but if you can do that and if (ic,jc) is the coordinate of the center of mass, then it is just
[I,J]=find(edges);
Distances=sqrt((I-ic).^2+(J-jc).^2);
maxDiameter=2*max(Distances);
minDiameter=2*min(Distances);
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!