3

burn areaTrying to count colored pixels using GIMP and following the instructions here:

The image is part of a fire damage map. Dark red = severe burn, green=no burn. I need to count the pixels of each of major colors. I say 'major colors' because there are lots of blurred edges, need to have about four colors, green, yellow, orange and red.

So how to get total pixels in the jpg, and percent of each color?

1

1 Answer 1

5

The Histogram dialog is your friend.

When used "raw", if shows an alpha-weighted count of the pixels (in other words, it counts non-transparent pixels). For instance in this image:

enter image description here

  • Pixels is the count of opaque pixels (the image is 300K pixels)
  • Count and Percentile are the count and percentage of the pixels that are in the range defined by the two small handles under the graph. Shown here for completeness but I don't think you can make much use of this.

If there is a selection on the image, the same dialog restricts itself to the pixels in the selection, so Pixels becomes the count of selected pixels.

In your case this can be used with the "By color select" tool, and make the tool select pixels that have a similar hue (HSV Hue or LCH Hue), using the threshold to adjust the hue tolerance :

enter image description here

And the histogram will show you the count of pixels in the selection:

enter image description here

So 75478 / 133647 = 56.48%

Remarks:

  • You can keep the Histogram dialog "up", and it will auto-update if you change the selection (it also "follows" the active image).
  • You can use any selection tool. The "Freehand select"/"lasso" can for instance be more suitable to select a specific area
  • You can combine selections (add subtract, intersect). And these selections do not need to be done with the same tool.
  • You can save a selection to a channel, and then restore it later, or combine it with another selection (these channels are saved with the image if you save as XCF).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.