I need help with setting an appropriate threshold in my image

Hi Guys,
I am new to imagej.
I took several images from grey particles covering a green surface.
I d like to compare those images for particle coverage.

The images were taken with suboptimal lighting conditions.
That means the brightness is not equal in the image.
This appears to hinder my analysis to some degree: very subtle particle coverage issues are not detectable.

I want to give an example:
Here is one image with some coverage of grey particles.

Two things stand out here:

  1. At the bottom left area, the green surface is visible through the particles (green indication). The remaining area seems covered.
  2. The left side is brighter than the right side of the image. the middle seems to be reddish.

When I use a threshold on the 8 bit Version I get the following binary result.

The bottom left area (yellow indication) is detected as “not perfectly covered” but also -unwantedly- the right area of the image (yellow indication).

Is there anyone out there who might know what to do to obtain a threshold which is sensible to the green surface and not so much to the overall brightness of the image after conversion to 8-bit.

The raw data is a png.
I tried using 8-32 bit, Lab and HSB stack types with the same issue.
I tried the 3D color inspector but couldn’t find any useful depth/rotation setting.

Any help apprechiated.

Regards

Hi @symbolinsight,

I’m not sure if the green region you see at the bottom left is actually there, or if it’s an illumination artifact (similar to the pink-ish region towards the center of the image).

If you’ve taken several images with the same illumination, it would be easy to assess.

You can try to correct for uneven illumination with some basic flat field corrrection. The closer your illumination estimate to the actual flat field (which you can take during the imaging session in a region with no sample), the better the results.

In the case of this image, this small macro could work:

title = getTitle();
flatfield = "flatfield_estimate";
run("Duplicate...", "title=&flatfield");
run("Gaussian Blur...", "sigma=50");
mean = getValue("Mean");
run("Calculator Plus", "i1=&title i2=&flatfield operation=[Divide: i2 = (i1/i2) x k1 + k2] k1=&mean k2=0 create");
// close(flatfield) // un-comment to close the estimate once done correcting


The problem here is that the particles do not seem to be well resolved, so I’m unsure if this approach will actually help you with your original goal.

Can you test this with other images an see if it seems to work? Does the flat field images look similar for different images?
There are more sofisticated ways of coming up with an estimate based on a whole image set, but the success of one particular approach will depend on the variability within that set.

Let me know if this helps,
Nico

2 Likes

Thank you so much for your reply!
The green is basically the surface where the particles sit on
See here in this example:
examplegreensurface
The particles (~35µm) are ok resolved for my current standard i guess. What do u think?

I incooperated this makro kind in my python based code (a mess)

        gauss = gausssubimp.crop() #image2
	gausssharp = gauss.duplicate() #image1

        #apply blur
	IJ.run(gauss, "Gaussian Blur...", "sigma=250") #helps to define the brightness condition
       #set titles for calculator plus syntax
	i1title = gausssharp.getTitle()
	i2title = gauss.getTitle()
       # use some work around to get the mean value of image i think you need float here
	ipgauss = gauss.getProcessor().convertToFloat()
	pixelofgauss=ipgauss.getPixels()
	gaussval = sum(pixelofgauss) / len(pixelofgauss)  
        #divide the images
	IJ.run("Calculator Plus", "i1="+str(i1title)+ " i2="+str(i2title)+ " operation=[Divide: i2 = (i1/i2) x k1 + k2]         k1="+str(gaussval)+ " k2=0 create")

But as you mentioned there is no obvious benefit from it.
I will look further into this correction method.
Maybe it is suitable for a general comparison in a qualitative way.

I tried to play around with the blur size (gauss 5 to 250) but i am not sure wether this has any true effect.
Top left is gauss5, bottom right is gauss250.

I might try to enhance the illumination procedure to get better results in general.

Out of curiosity: If i had true .Tif files (and not a flattend Png as raw data) do you think i could use a specific channel to get what i want?

I mark this solved now i guess.

Thank you again for the help!

Regards