Message Boards Message Boards

0
|
4751 Views
|
3 Replies
|
6 Total Likes
View groups...
Share
Share this post:

[?] Calculate area of a maple leaf image?

Posted 7 years ago

Hi,

I want to calculate the area of the maple leaf in cm^2.

enter image description here

I have tried this

img = Binarize@
    Import["http://i37.ltalk.ru/22/85/298522/92/9427492/leave2.png"]~
   Erosion~1;
(m = MorphologicalComponents[img]) // Colorize

linecount = 
  2 /. (Binarize@
        Import["http://i37.ltalk.ru/22/85/298522/92/9427492/leave2.\
png"] // ColorNegate // Thinning // 
     ComponentMeasurements[#, "PerimeterCount"] &);
areacount = 
  2 /. ComponentMeasurements[MorphologicalComponents[img], "Count"];
areacount/linecount^2 // N

but I'm not sure which region is calculated and the unit given.

Can somebody help me? Thank you.

POSTED BY: Nurul Ainina
3 Replies
Anonymous User
Anonymous User
Posted 7 years ago

very useful. if you can plot an area, then you can obtain the area without complex integral - assuming you do not need a perfect accuracy, which in the real world is (often)

POSTED BY: Anonymous User
Posted 7 years ago

Thank you for your great help! :)

POSTED BY: Nurul Ainina

The way your image is displayed is misleading. It has an alpha channel. This is why the results from Binarize are weird.

Check this:

im = Import["http://i37.ltalk.ru/22/85/298522/92/9427492/leave2.png"]
ColorSeparate[im]

From the output it is clear that the alpha channel is already a good mask of the leaf.

To compute the area, use

comp = Binarize@AlphaChannel[im]

ComponentMeasurements[comp, "Area"]
(* {1 -> 82093.4} *)

As we're working with an image, the units are pixels.

To get the result in $\mathrm{cm}^2$, we would need to know the dimensions of the image or the leaf in centimetres. If you have the actual leaf, you could measure it with a ruler, then use that information to calculate the pixel/cm ratio.

POSTED BY: Szabolcs Horvát
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract