How to get a percentage of 'each colour' (or segment) in an image?

I am a new ‘imageJ user’ (and already hooked). Can someone please tell me how I would get % purple vs % green vs % red in the attached image?

Thank you!
134B_1.5cm_WTjpg

Welcome to this forum @ramorri. Maybe the following hint will guide your first steps.

Without knowing the background of your use case and how your image has been created I have to assume that the image is a RGB color image and only contains 3 colors (and the original image doesn’t show JPEG compression artefacts like in your example).

If such an image is converted from RGB to 8bit (ImageJ menu: Image>Type>8-bit) the 8bit gray scale image only contains 3 different gray values.
Then you can simply get the number of pixels for each of the 3 classes from the histogram (Analyze>Histogram).

Here is such an 8bit example image (with a color LUT):
3color_example
(This is NOT the image you have posted!)

If you use Analyze>Histogram and click the ‘List’ button
grafik

you get a histogram like this:

0	26192
1	0
...
89	0
90	3543
91	0
...
224	0
225	2127
226	0
..
255	0

The ratio of red/purple/green is: 26192 / 3543 / 2127.

There are other method (i.e. thresholding and particle analysis).
But the above one is an easy way to get what you want.

Make sure that your image fulfill the requirements:

  • no JPEG or other compression artefacts
  • unique gray values for each of the colors
    (The RGB_to_8bit conversion of different colors should not lead to identical gray values.)

Hope this helps to start.

3 Likes

@phaub

Just to say it’s a great method.
Thanks for the “tip”.

1 Like

Yes! That is very helpful, thank you @phaub !

1 Like

Hello! I am very new to image J and I want to calculate the area of different colors in the following photo. Could you please give me a hint? thank you very much!

Hi @Shirins Welcome to the image.sc forum.

Your example image contains 79555 different colors.
Here is a zoomed area of your image:
grafik

What you can visually recognize as ‘area’ or ‘region’ with similar color is in fact a mix of hundreds of different colors.
The different areas can not be segmented reliably in this low quality image.

Your image seems to be a scan and shows strong scanning artifacts (stripes).

And the illumination is very uneven in your image:
grafik

And finally the image is saved in JPEG format which introduces additional compression artifacts.

To obtain a reasonable result you better should improve your image quality.

Maybe you can explain the background (Where is this image coming from? What does it show? …) and somebody can help you a little further.