How to create a line that goes through a specific point?

9 views (last 30 days)
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
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
Hadas
Hadas on 26 May 2014
actually your way is much better! I think I will go with it. but then I will have to take into account the edge of each shape, right? so if we take the example above and I can create an edge image (attached) so how can I find the circles for min and max diameter for each shape? probably the minimum diameter will be easier to find using the largest circle that can be inscribed inside the shape as you suggested but how can I find the smallest circle (centered at the center of mass) that can enclose the shape? for each shape? tnx!!!! Hadas
Matt J
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);

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!