You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
hi, please help me to find perimeter, area, aspect ratio, form factor, rectangularity, narrow factor from an binary object of leaf ?
1 view (last 30 days)
Show older comments
I using regionprops() for perimeter and area but can't. I don't understand how to define it and put it in each formula, cause I confused with the code I see in matlab and some example. please help me
Accepted Answer
Image Analyst
on 29 Sep 2018
See my Image Segmentation Tutorial: https://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862&sort=downloads_desc
If you still don't understand it, explain why.
17 Comments
Image Analyst
on 30 Sep 2018
No, you haven't shared your image but I'd bet you don't need edge detection. It's almost never required. Even though beginners think every image processing algorithm starts with an edge detection, in actual practice it's almost never needed and usually a simple thresholding will work fine. It probably will for you also. But again, I haven't seen your image. Search for the tag "leaf" - I have posted leaf algorithms many times. Also see attached demo.
Oman Wisni
on 30 Sep 2018
Edited: Oman Wisni
on 30 Sep 2018
this sir, I have example binary image. what should I do to count the area, Perimeter, etc ? I already see your code in https://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862&sort=downloads_desc, but I don't understand the with this code 'blobArea = blobMeasurements(k).Area;'
Oman Wisni
on 30 Sep 2018
sir, this is another question, I thresholding using im2bw, can you explain the range of values used in determining the binary? is im2bw the global otsu thresholding?
And using code imfill, what the difference imfill with closing ? is that same for fills holes in the binary image BW?
thanks sir
Oman Wisni
on 30 Sep 2018
Edited: Oman Wisni
on 30 Sep 2018
sir, this is another question, I thresholding using im2bw, can you explain the range of values used in determining the binary? is im2bw the global otsu thresholding? I use imbinarize but I get error
And using code imfill, what the difference imfill with closing ? is that same for fills holes in the binary image BW?
thanks sir
Image Analyst
on 30 Sep 2018
im2bw() is the older, deprecated version of imbinarize(). They both do Otsu thresholding, though imbinarize() can change the threshold to adapt spatially to varying background in the image. imbinarize() was introduced in R2016a. im2bw() does only global thresholding.
The range of values used in determining the threshold are all the values in the image. If you use imbinarize() and choose locally adaptive thresholding then it will use only the values within the sliding window.
imfill() will fill all holes in a white/true/1 blob. It does not change the shape of outer boundaries - they remain exactly the same as before the fill.
If you use imclose(), it will dilate the blob which will fill in little bays in the outline and possible fill in some interior holes. Then it will erode the blob to try to bring it back to roughly the same size. The end result is that the blob will have a more rounded shape because all the little nooks and crannies and bays are filled in. It won't necessarily fill all interior holes unless you used a big enough kernel such that those holes were covered up during the dilation phase of the closing.
Oman Wisni
on 30 Sep 2018
Yes sir. Now I understand. Thanks!
But sir, I still not yet know how to create to find the perimeter and area, count the around of the image and how to save the result in Ms.excel for continue clasification?
I still in my last project in university, and there are no same topic for every students so only I'm get this topic, I really new in matlab so Im new learning. So I need some explain and example can help me. It will great and helpfull if you can help me.
Image Analyst
on 30 Sep 2018
I don't understand why you don't understand 'blobArea = blobMeasurements(k).Area;'
You do know that blobMeasurements is a structure array, don't you? So, each structure in the array has fields, Area, Perimeter, and whatever you ask for. So when I do 'blobArea = blobMeasurements(k).Area;' I'm just assigning the Area measurement (the area of the k'th blob) to its own variable called blobArea. Same for perimeter. Just like you'd save any variable into MATLAB into a new variable. If A was a vector and I did B=A(7) then I'm taking the 7th element of A and assigning it to B. It's the same here, it's just that I'm taking the field of a structure instead of an element from an array, but it's still a single number.
If you looked at my tutorial, you would have seen that you can also get all the values into a single array with brackets
allAreas = [blobMeasurements.Area]
allPerimeters = [blobMeasurements.Perimeter]
Oman Wisni
on 2 Oct 2018
Sir, how to find the length and width of the object leaf ? here I have formula (slimness = Lp/Wp) where :
Lp = length of the leaf and
Wp = width of the leaf,
how to find and create the code slimness/aspect ratio ?
should I use majorAxisLength to find length? or have another way ?
thanks
Oman Wisni
on 2 Oct 2018
thanks sir, I new understand your code in BlobsDemo, it is work. But Perimeter I not get result, only in Perimeter. What wrong sir ?
Image Analyst
on 2 Oct 2018
I don't understand what "Perimeter I not get result, only in Perimeter." means. Did you get the perimeter from regionprops() or not? It DOES return it if you ask for it.
Oman Wisni
on 2 Oct 2018
Edited: Image Analyst
on 3 Oct 2018
yes, I not get perimeter from regionprops()
Oman Wisni
on 3 Oct 2018
this my file and the image sir, please save all the value from regionprops and momen in Ms.Excel and make new folder for save all image sir. In code to find invariant moment I get problem, please fix it too sir. thanks
Oman Wisni
on 3 Oct 2018
Sir, I need find length leaf, width leaf and diameter of leaf too sir. To find aspect ratio, roundness and rectangularity. Thanks sir
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)