# Finding area, length, width, Height of leaf

Discussion in 'Programmer's Corner' started by Mannipuccho, Nov 30, 2014.

1. ### Mannipuccho Thread Starter New Member

Nov 6, 2014
24
1
Hi guys,

Please I want to calculate the area, height, width and length of these binary leaf in Matlab. Can anyone please help me out on how to do this, thanks.

File size:
6.7 KB
Views:
42
File size:
8.8 KB
Views:
35
2. ### Papabravo Expert

Feb 24, 2006
10,340
1,850
Sure. You know the total size of the image in pixels. The area of the leaf is the number of white pixels times a constant of proportionality to convert to actual units of length^2.
Then you count the white pixels in each row and in each column. You can use the maximum of the row counts and the column counts or you can average them.

3. ### WBahn Moderator

Mar 31, 2012
18,085
4,917
First, you need to define your terms better. When used together, "height", "width", and "length" imply a three-dimensional volume of some type.

4. ### Mannipuccho Thread Starter New Member

Nov 6, 2014
24
1
Hi Papabravo,

I am not good with matlab as I am still finding my way through it, is it possible to put your explanation in a MATLAB code for please so that I can understand it much better.

5. ### WBahn Moderator

Mar 31, 2012
18,085
4,917
Translation: "Do my work for me."

6. ### Papabravo Expert

Feb 24, 2006
10,340
1,850
I'm sorry but I do not have a licensed copy of Matlab. I had a student copy back in 2001-2004 when I went back to graduate school, but that expired when I graduated and the laptop it was installed on has gone to the rainbow bridge. So you're just SOL. PS I was never very good with it either.

Suppose I give you a single dimension array representing a line from your image and say that any value less than 20 is black and any value greater than 220 is white.
a = [4,5,5,5,6,7,240,241,244,245,10,9,8,7] ;
and ask "what is the length of the white section?"
Could you do that?

7. ### Papabravo Expert

Feb 24, 2006
10,340
1,850
True, but I'm not quite ready to drink the Kool-aid just yet.

8. ### Mannipuccho Thread Starter New Member

Nov 6, 2014
24
1
Got it sorted guys, spent a lot for your help.

9. ### Papabravo Expert

Feb 24, 2006
10,340
1,850
??? What does that mean?
Did we just get slammed?

10. ### WBahn Moderator

Mar 31, 2012
18,085
4,917
I was wondering the same thing, but does it really matter? We've all been slammed before.

11. ### Papabravo Expert

Feb 24, 2006
10,340
1,850
"I think we're lost!"
"Why do you say that, Glenn?"​
"I've been lost before, and this is what it looks like."

12. ### Mannipuccho Thread Starter New Member

Nov 6, 2014
24
1
Ooh nooo, I didn't mean to write that, it was a typo from my phone, I meant thanks a lot for the help. I spent last night figuring it out and finally got what I needed. My bad Whan and Papabravo if I sounded harsh earlier on.

13. ### WBahn Moderator

Mar 31, 2012
18,085
4,917
No problem. Glad you got it figured out.

14. ### Papabravo Expert

Feb 24, 2006
10,340
1,850
That's a relief. We're all glad you figured it out. If I could ask a small favor. Could you write a paragraph on how you feel about the process of figuring things out for yourself as opposed to having a solution handed to you?

Nov 23, 2012
6,303
4,026
Chirp...
Chirp....

16. ### Papabravo Expert

Feb 24, 2006
10,340
1,850
Damn!....crickets again.

17. ### WBahn Moderator

Mar 31, 2012
18,085
4,917
And people call ME heartless!

18. ### Papabravo Expert

Feb 24, 2006
10,340
1,850
Colder than the heart of a Philadelphia ambulance chaser.

19. ### WBahn Moderator

Mar 31, 2012
18,085
4,917
That implies that there is a heart involved -- has anyone ever been able to do an existence proof on that one?