How do I select all shades of gray

Hello,

I have to process about a thousand photos of the evolution of a blob and for each photo I have to measure the area and the perimeter of the surface of the blob (in yellow on the photo).

I tried for example to select the color yellow but it doesn’t work very well, I think maybe it would be better to select the shades of gray but I don’t know how to do it.
I would also like to recover by a script the number of pixels selected for the surface and the border.

Could someone help me how to do it with gimp ?

Hi @olimat and welcome to the forum!

You can select yellow with select by colour tool.
You can see the settings I used for this in snapshot:

Select1

With this setting you go over the yellow area with the left mouse button pressed until the whole yellow area is selected:

Then copy the selection:

Select3

And paste it:

Select4

From this floating selection you then make a new layer by clickin on that green icon:

You can then switch off or delete the lower layer and on the upper layer you only have the yellow area with a transparent background:

I didn’t really understand what you meant here.

4 Likes

In GIMP Colors → Components → Decompose → LCH seems to work with the image provided: light areas are the blob, dark areas are the gray.

Note that this won’t be precise because of the specular highlights on the blob (they show up as black)

After extracting the C channel, auto-stretching and applying as an alpha, I get this; is it what you’re looking for?


EDIT: It’s actually the C channel, not the L channel

3 Likes

Thank you for your answer. I don’t know “auto-stretching” , how do you make it?

Thank you for your answer.

For the number of pixels, I want to know how many pixels are yellow . This value can give me the surface area , I see this valeur in the histogram but I don’t know how to copy/paste it automatically into a spreadsheet with a script for example ( there are almost a thousand images !!! )

Colors → Auto → Stretch Contrast or Colors → Auto → Stretch HSV

You can also use the Levels tool (Colors → Levels) and hit “Auto Input Levels”

In that case I don’t think GIMP is the correct tool. I’d look at using something scriptable by design, like Imagemagick or GraphicsMagick to convert/extract the data you want (eg. ImageMagick’s histogram: and info: operators.)

1 Like

Just to add - if you’ve got to do this to around 1,000 photos then you definitely want to leverage a scripting option like imagemagick or g’mic.

Are all of the images going to be similar to this one (ie: yellow vs. black/white background?

1 Like

yes !

How essential is the “area” and the “perimeter” measurements? That might be a little more work to accomplish vs. a pixel count of yellow vs. not-yellow.

It is to study the morphology of the blob.
For one photo it is easy to write the number of pixels with Select by color (to detremine the area) and Select Border (to determine the perimeter) .
Then it is enough to know the area of a pixel to calculate these two values.