Get Area from an Image via Color

Hello,

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?

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

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.

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

1 Like

well, It is not a GH related answer but l hope the admins won’t be too strict with me!
https://helpx.adobe.com/photoshop/using/viewing-histograms-pixel-values.html

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?

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

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

perfect, thanks

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)

1 Like

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

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

Hi there i am trying to do the same but with an image where i have analysed different components in the photo with colours. I have overlaid and simplified the images with 4 different colours. is there a way to express values for each colour in the image rather than just black and white? thanks!