Get Area from an Image via Color




i like to get the area from a surface. this surface is an image. only black or white. no grayscale. i need the area of just the black or just the white. since i have alot pictures i want to analyse, i like to use grasshopper.
i saw there are different options in rhino to analyse an area.
what do you think is the most promising approach?

(Aris Nikolopoulos) #2

Is there a specific reason why this should happen in grasshopper? photoshop can do this (as a percentage of the image’s pixels)

(Andrew Heumann) #3

Do you actually need the shape of the area, or just its measure? It’s always a little tough to translate bitmap to vector information. I’d use the image value to displace a mesh in the Z direction, then cut a contour through the resulting mesh at a height corresponding to the brightness value you want. Here’s a super simplistic approach. If you need closed regions you’ll need to get a little more sophisticated:


thanks for the answer.
well if photoshop can give me an excelfile i would gladly do it with PS. i couldnt find it with PS as well.

(Andrew Heumann) #5

And if you just want the area, in pixels, you could do something like this:

(Aris Nikolopoulos) #6

well, It is not a GH related answer but l hope the admins won’t be too strict with me!

Look for this:
Percentile: Displays the cumulative number of pixels at or below the level underneath the pointer. This value is expressed as a percentage of all the pixels in the image, from 0% at the far left to 100% at the far right.

edit: …or you can do what @andheum said! (my god! you never know what you will learn in this forum!!!)


thanks. ill try to wrap my head around it. :smiley:


thanks. any idea how to get those infos as data?

(Andrew Heumann) #9

oh and that panel that says “black pixels” should just say total pixels :slight_smile: my mistake

(Aris Nikolopoulos) #10

No, and after seeing Andrew’s script I wouldn’t even bother!


perfect, thanks

(Andrew Heumann) #12

One more approach - I like this one because it shows how to do many images at the same time, and allows you to set a sample resolution (by changing the slider going into X + Y of the IMG component)

(Aris Nikolopoulos) #13

since you did it, why don’t you upload it?
I wanted to experiment with it just out of curiosity :slight_smile:

(Andrew Heumann) #14

Sure. Requires Human for the Directory Contents component. Image (12.0 KB)
Human.gha (414 KB)