how can we find the length of an irregular shape in matlab
Show older comments
I am here to ask a question. how can we find the length of an irregular shape in matlab.For example if we have so many objects(grains) in an image and want to get the length of each object. what will be the method to do. give me the right direction
2 Comments
Cedric
on 12 Aug 2015
If you have an image that you could provide as an example, please insert it into your question using the image tool/icon (don't forget to click on [Insert Image] after you have chosen it).
halima jamil
on 13 Aug 2015
Accepted Answer
More Answers (1)
Image Analyst
on 14 Aug 2015
1 vote
It seems as though you're up and running with major axis length (since you accepted that answer), but I'd do it differently. MajorAxisLength will give you the length of an ellipse fitted to your blob. If you want the actual length between the two farthest points, then you need to call bwboundaries() and compute all the distances and take the longest one. I do that in my attached demo. There is no built in function or option of MATLAB or regionprops() to do that, that's why I had to write it myself.
7 Comments
halima jamil
on 15 Aug 2015
Edited: halima jamil
on 15 Aug 2015
Image Analyst
on 15 Aug 2015
I need your adaptation of my code. Then I'll look at it later today.
halima jamil
on 29 Aug 2015
Edited: halima jamil
on 29 Aug 2015
Walter Roberson
on 29 Aug 2015
Post your current code
Image Analyst
on 29 Aug 2015
I'm not sure what or why you're asking. Did you run the code and notice the "maxDistance" variable in the code? That is the length of the red line. Is that what you want or not?
Jasleen Kaur
on 16 Nov 2018
sir can you send the code of this problem plz??
Image Analyst
on 16 Nov 2018
Who are you talking to? What code? I attached my code. Code that does what?
See the link below:
Categories
Find more on Region and Image Properties in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


