Threshold with colour by bins

Hello,

I have an application where I am interested in looking at the uniformity in an image by colouring regions that fall into various bins. I have included an example with a raw image, an image where there is a different colour from -5% to 5% in 1% increments, and an image where there is a different colour from -10% to 10% in 2% increments. In this case they are all taken as deviations from the mean.

I am relatively new to ImageJ, but I have done a little bit of scripting and I believe that this application will require something custom. I would like to be able to define the nominal as either the mean or a known value. I would also like to be able to choose different bin widths (as in the example), such as every 1%, 5%, 10%.

Regards,

Luke

2618-8-2.tif (428.9 KB)
2618-8-2_1%.BMP (1.3 MB)
2618-8-2_2%.BMP (1.3 MB)

Hi @labixler, welcome to the forum.

Maybe a solution could be to

  1. measure the mean color (first you segment your image and measure the mean)
  2. Do some thresholdings (mean-5%, mean-4%…mean+5%)
  3. Combine the resulting images and applying the ad hoc look up table ?

Best

Nico

Hi Nico,

That’s exactly what I imagined doing. I know how to get the mean value (these are grey scale images), but I don’t know how to do the rest. I can apply a threshold to a value, but I’m not sure how to save that with different colours. I also don’t know how to merge the resulting images. Can each threshold be done as a layer, or something like that?

Hi,

I was thinking to something like this

run("Blobs (25K)");
step = 0.2; //every 20 pc
nbStep = 3; //nbStep below the threshold and nbStep above

th = 125; //or compute the mean...

for (i = -nbStep; i <=nbStep+1 ; i++)
{
   selectImage("blobs.gif");
   run("Duplicate...", "title=toBThresholded");
   if (i<nbStep+1)
      setThreshold(0, th + i*step*th); //thresholding of ascending values
   else
      setThreshold(0, 255); //thresholding of the remaining pixels
   setOption("BlackBackground", true);
   run("Convert to Mask");
   run("Divide...", "value=255");
   if (i == -nbStep)
      rename("Result");
   else
   {
      imageCalculator("Add", "Result","toBThresholded");//every level of thresholding will have a specific value
      selectImage("toBThresholded"); close();
   }
}
      
selectImage("Result");
run("Fire");
setMinAndMax(0, 2*(nbStep+1)); // total nb of values : 2*(nbStep+1)

Nico