# Finding area, length, width, Height of leaf

#### Mannipuccho

Joined Nov 6, 2014
24
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.

#### Attachments

• 6.7 KB Views: 42
• 8.8 KB Views: 35

#### Papabravo

Joined Feb 24, 2006
17,299
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.

#### WBahn

Joined Mar 31, 2012
26,398
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.
First, you need to define your terms better. When used together, "height", "width", and "length" imply a three-dimensional volume of some type.

#### Mannipuccho

Joined Nov 6, 2014
24
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.
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.

#### WBahn

Joined Mar 31, 2012
26,398
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.
Translation: "Do my work for me."

#### Papabravo

Joined Feb 24, 2006
17,299
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?

#### Papabravo

Joined Feb 24, 2006
17,299
Translation: "Do my work for me."
True, but I'm not quite ready to drink the Kool-aid just yet.

#### Mannipuccho

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

#### Papabravo

Joined Feb 24, 2006
17,299
Got it sorted guys, spent a lot for your help.
??? What does that mean?
Did we just get slammed?

#### WBahn

Joined Mar 31, 2012
26,398
??? What does that mean?
Did we just get slammed?
I was wondering the same thing, but does it really matter? We've all been slammed before.

#### Papabravo

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

#### Mannipuccho

Joined Nov 6, 2014
24
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.

#### WBahn

Joined Mar 31, 2012
26,398
No problem. Glad you got it figured out.

#### Papabravo

Joined Feb 24, 2006
17,299
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?

#### GopherT

Joined Nov 23, 2012
8,012
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?
Chirp...
Chirp....

#### Papabravo

Joined Feb 24, 2006
17,299
Damn!....crickets again.

#### WBahn

Joined Mar 31, 2012
26,398
And people call ME heartless!

#### Papabravo

Joined Feb 24, 2006
17,299
Colder than the heart of a Philadelphia ambulance chaser.

#### WBahn

Joined Mar 31, 2012
26,398
Colder than the heart of a Philadelphia ambulance chaser.
That implies that there is a heart involved -- has anyone ever been able to do an existence proof on that one?