How can i find longest axis from mango shape object?

In this image i want to crop only mango part.After then find the longest axis from mango shape and draw longest line from mango and calculate the length of the line.Based on the longest line value i can grade mango in large ,medium and small..Please help me as soon as possible.

 Accepted Answer

See my image segmentation tutorial: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 Adapt it to use your image and to segment the mango somehow. Then call regionprops and ask for MajorAxisLength.

8 Comments

There is nothing in regionprops to give you the length between the two points farthest away from each other on the perimeter. You could do that yourself though, if you use bwboundaries() and calculate all the distances.
The tutorial is meant for beginners like you and is well commented. Just take it one line at a time and you'll be able to follow it. Don't look at the thing as a whole or else it looks like a ton of code that you won't understand, but taken one line at a time it is quite understandable and easy to follow. Let me know of any lines that need to be better commented.
Sir,In mango image first mango region is covered by bounding box and then it get cropped from image.From Cropped image,using property of regionprops like area cover by mango,major axis of mango and minor axis and eccentricity will display with color edge.Then after ellipse should be drwan on to mango image.so i could judge my results which are not getting from regionprops
Thanks in advance
See Steve's blog http://blogs.mathworks.com/steve/2010/07/30/visualizing-regionprops-ellipse-measurements/ for how to visualize the ellipses over the gray scale blobs. Attach your image if you want any more advice. Otherwise, please Accept the answer.
Yaa.. i have done..thanks sir...
Sir,I have one question related to centroid? In regionprops,for centroid which equation is used to find centroid?..Actually i ahve read the file but not concluded to write which algorithm is used for calculating centroid? Have in matlab Green's theorem is used to calculate centroid?
There are two - one based on the binary image, and one that takes into account the gray levels of the gray scale image that are inside the "true" parts of the binary image. You can get both of them if you pass in the gray scale image
measurements = regionprops(labeledImage, grayImage, 'Centroid', 'WeightedCentroid');
Please accept the answer if we're done.
Yaa..Got ur Point..Thanks sir
Good. Please accept the answer if we're done.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!