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.
     
  2. Papabravo

    Expert

    Feb 24, 2006
    10,144
    1,790
    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
    17,747
    4,795
    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
    17,747
    4,795
    Translation: "Do my work for me."
     
  6. Papabravo

    Expert

    Feb 24, 2006
    10,144
    1,790
    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,144
    1,790
    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,144
    1,790
    ??? What does that mean?
    Did we just get slammed?
     
  10. WBahn

    Moderator

    Mar 31, 2012
    17,747
    4,795
    I was wondering the same thing, but does it really matter? We've all been slammed before. :D
     
  11. Papabravo

    Expert

    Feb 24, 2006
    10,144
    1,790
    "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
    17,747
    4,795
    No problem. Glad you got it figured out.
     
  14. Papabravo

    Expert

    Feb 24, 2006
    10,144
    1,790
    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?
     
  15. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,046
    3,813
    Chirp...
    Chirp....
     
  16. Papabravo

    Expert

    Feb 24, 2006
    10,144
    1,790
    Damn!....crickets again.
     
  17. WBahn

    Moderator

    Mar 31, 2012
    17,747
    4,795
    And people call ME heartless! :rolleyes:
     
  18. Papabravo

    Expert

    Feb 24, 2006
    10,144
    1,790
    Colder than the heart of a Philadelphia ambulance chaser.
     
  19. WBahn

    Moderator

    Mar 31, 2012
    17,747
    4,795
    That implies that there is a heart involved -- has anyone ever been able to do an existence proof on that one?
     
Loading...