Area calculation of different shades of grey


First of all, I apologize if I’m posting in the wrong section or if a similar post is already out there. I’m a very new user of ImageJ and I’ve tried to look for similar questions on this forum, but I could’nt find exactly what I was looking for.

So for my question: I have an image of different grey shades, and I want to calculate the area of these different grey shades. I’ve found a similar post (Calculating Area of Different colors) and I’ve tried the described methods (using image-adjust-color threshold), but the problem is that my image does not have clear cut edges like the example image. So when I set my threshold to a certain value, I’m always missing out on pixels or having extra pixels. To illustrate the problem, I’ve added an image I want to analyse (there’s 4 shades of grey) and an attempt to set the threshold. So I want to measure the area of the red selected part on the left, but it also selects some lighter grey pixels that are edges between lighter and darker shades of grey in the right part of the image. So measuring this gives more pixels than there actaully are. Is there a better way to do this?

Like I said, I’m very new so any help is appreciated, thanks!


YZL01-1_ij.tif (2.9 MB)

Hi @marjolein
welcome to the forum. No worries, you posted in the right section.

As a first simple method I would

  • convert your RGB color image to greyscale (IJ menu Image>Type>8bit).
  • show histogram (IJ menu Analyze>Histogram)


You can already see your different fractions in the histogram.

If you now click to the List button, you will see the histogram values.


You can export this numbers to Excel and sum the histogram values for all fractions by defining a min and max value for each fraction.
The sum of the histogram bins is the number of pixels and therefore the area of this fraction.

As said … a first simple approach.

1 Like

Hi Peter,

Thank you for your reply! This is certainly more efficient than what I was doing, thanks!


You can also have a look at k-means clustering, i.e. build in here Daniel Sage>ColorSeg