how can we find the length of an irregular shape in matlab

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

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).
this is the image of my problem. how we can find the length of each rice. as it is a irregular shape so which method will be better and how we can implement that. thanks

Sign in to comment.

 Accepted Answer

regionprops() requesting the Perimeter value?

6 Comments

i already used it but it doesn't solve my problem, thanks dear :)
You need to use some method such as Watershed that can tell the difference between two grains that are stuck together.
Once you have the grains separated, then you can use regionprops and request the Major Axis Length
NO gentleman.I already separated the grains but your mentioned method is not working. suggest me anything else if you can. :) thanks
The two grains in the top right are not separated -- not unless that is a single mutant rice grain, in which case you need to be more specific about what the length of it means .
check it out. now tell me how to find the length.
When you used the major axis length, what part did you find was "not working" ?

Sign in to comment.

More Answers (1)

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

Image Analyst it do not work i've attached the output. kindly give me the solution please. am waiting for your answer. Am new in matlab
I need your adaptation of my code. Then I'll look at it later today.
Image Analyst I hope you can solve my problem.Let me introduce my problem. Flow of work Question: i need to find length of a rice gain Process 1. RGB to binary conversion 2. Find Edges of rice grain in matlab 3. draw a red line between two largest distance points so the length of line will be the length of a rice. Now how we can get the length of that red line from a binary image. Outputs: check the image
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?
sir can you send the code of this problem plz??
Who are you talking to? What code? I attached my code. Code that does what?
See the link below:

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!