Color threshold, auto threshold different number of particles

Hey there,
I want to Analyse the coulour and the mean intensity of particles from an image. First I copy that Image. Then I run(“Color Threshold…”); with the method IsoData and save the RBG values in a result table. With the same picture in grayscale with setAutoThreshold (“Isodata”); I want to set the mean gray value into the same result table.
My problem is that when I analyse the particles they count a different number of particals so the values do not match.

Can anybody help me with that?


Hi @Jani,
I’m not sure if I understand you right. I think that doing a color-auto-threshold and an auto-threshold on the image converted to grey are not supposed to have the same result. In the color case, 3 threshold values, one for each histogram of the three channels, are computed and used to create the mask. In the greyscale-case the average of the 3 channels is computed (depending on your options) when converting and the auto-threshold method works on the resulting histogram.
I guess you should decide on one method to threshold the image (color or greyscale) and then using the detected particles to report the RGB and mean grey-values.


So it’s not possible to automatically analyse the color and the brightness/gray value of an image with a macro?

Hi @Jani,

I think we need to dissect your question a little bit to first figure out, what you really want to do, then, how this can be done and if such an analysis gives you a valid output

On the contrary, it is perfectly possible to automate analyses based on a color threshold, but first to the definition of the problem:

The combination of the last two statement puzzle me (and I guess also @volker).

Is your purpose to:

  1. to measure intensity values from the image? Then what do you expect that the RGB and/or the mean intensity (which in your case is just a mathematical combination of the RGB values) will tell you. To this end it would be good if you can provide an example image (as PNG or TIF) and a clearly specified definition of what exactly you try to do or measure in that image.


  1. do you want to measure and count particles by thresholding them based on their color and intensity?


  1. do you need to threshold the particles based on color and intensity and then in addition to their number also measure intensity and/or color values.

I am asking so detailed, because depending on what kind of sample you have, analysis of a color value of a mean value from combined colors will not be a valid output. So, this depends on your sample, image and research question.

As @volker elaborated already the two methods are different and you should decide finally for one. The Auto Threshold in the Color Threshold plugin is only calculated for the brightness channel and the result is combined with your manual selections from the other 2 channels (e.g. Hue and Saturation in the HSB color space). So, it also matters in which color space (RGB, HSB, Lab, YUV) you do this and at which values you place the manual thresholds in the remaining 2 channels.
The Auto Threshold you choose from the AutoThreshold plugin or the manual Threshold… plugin works directly on the intensities of the input image and therefore needs a single gray scale channel.

That means for the first method your input is a color image and for the second the input is a grayscale image. This and the way the two thresholding methods work are two reasons why the results naturally will be differ in partical number and size.

Another thing to consider is that when you mention…

…please be aware that if you just convert an RGB image to grayscale (e.g. 8-bit) ImageJ has 2 possible ways in converting your image. In both you loose quite a lot of information because the color image can have over 16 million colors, while the 8-bit image can only store 256 intensity values. Therefore, colors will be combined in either weighted or unweighted fashion. This also influences the final intensity measurement. In most cases measuring intensities from converted images is not meaningful.

So, there are many parameters to consider to define the way in which you can do your analysis and not every one will give you results which scientifically make sense.

Best, post an image and the definition of the exact parameters you want to measure (intensity, particle number,…). This will enable people here to help you in a more specific way.


Okay, I try to explain what I want to achieve.
I take a photo of some luminous letters and symbols with the Pi camera modul.
My goal is it to analyse these shining particles. Which of them are more green ore more red and which are not bright enough. I want to compare these values with the values of a reference picture.
All that should be listed in a table.
That’s how I convert the RGB-image into a grayscale image and analyse the particles:

run("Split Channels");
run("Images to Stack")
run("Z Project...","projection=[Average Intensity]");
setAutoThreshold("IsoData dark");
run("Set Measurements…","mean limit Redirect=None decimal=1");
run("Analyse Particles…", "size=10-Infinity show=[Overlay Outlines] Display");

Hope that helps to understand what I want to measure.

Do you also have an example image? Because I think if you need info about the content of green, red and brightness in comparison to a reference, the strategy would look a little different to your macro

Hi @Jani,
here is how you can get the measurements you want starting from your macro:

  • move the roi from the overlay to the roi-manager
  • measure the rois on the grey-scale image (using the measure-command of the roi-manager)
  • activate your rgb-stack and for the red and green slice
    • set the slice and measure the rois (using the measure-command of the roi-manager)
      Now you got all the information you want in the results-table, however probably not in the form you want.
      What you can do is, after each measure-step, get the ‘mean’ column as an array (see the Table.* commands) and clear the results table. Then create your own table and add the columns.

I guess you are aware that your color and intensity measurements will probably strongly depend on the environment light, illumination, camera settings and so on. Depending on what you want to do you might need to standardize those and use reference objects with known red, green and intensity values within each image to get meaningful results.


I’m not able to send an example Image, sorry.