how to measure the wide of object in binary image ?

i have a binary image, and i want to measure the wide of object ( white pixel). how to measure it ? please help. thanks

 Accepted Answer

See my Image Segmentation Tutorial and see how I get the bounding box. http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862

11 Comments

thank you, but i am so confused read your code =="
It's very heavily commented. What lines require more explanation?
Please read this
i am sorry, thank you for your code that very helping me.. i have a question, it's possible that the wide of object in binary image is calculate with sum(sum(image)) ?? i am sorry that my english is not enough thanks :)
No - that would be the "area" or total number of pixels. The "width" (not wide), which is how wide the blob is, can be determined in several different ways. (By the way, width is the noun and wide is the adjective. Like "This blob is wide - it's width is 1000. This other blob is narrow - it's width is 50.") If you want the width and height of the bounding box (aligned with the edges of the image), you can use the BoundingBox measurement of regionprops(). Or you could use MinorAxisLength. Or do something custom. You might like to run the attached demo where I determine what points are farthest from each other, and which points are perpendicular to that.
You might also like to check out this from John D'Errico http://www.mathworks.com/matlabcentral/fileexchange/34767-a-suite-of-minimal-bounding-objects where he can get several different bounding shapes - not just boxes but boxes at tilted angles, circles, triangles, etc.
thank you very much for your answare and explanation. So, if i want to calculate the wide of object, i must find the bounding box of the object ?
Pedantic mode: "This blob is wide - its width is 1000"
Thanks for the correction. eliz, you can. Like I said, that's one definition. Have you run my Image Segmentation Tutorial yet? It shows you exactly how to do it.
i have to run the segmentation tutorial. what the meaning of "blobMeasurements = regionprops(labeledImage, originalImage, 'all')" can you explan it ? thanks
At the matlab prompt, type
doc regionprops
to see the documentation of regionprops where it's all explained.
It gives you a structure array. Each structure in the array is a structure with field that correspond to the measurements you asked regionprops() to make. For example measurements(7) has all the measurements for blob #7, like Area, Centroid and BoundingBox: measurements(7).Area, measurements(7).Centroid, and measurements(7).BoundingBox.
ooohhh i see.. okay thank you so much @Image Analyst, @Guillaume GBU :D

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!