Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Average colour in GIMP - one click
#1
I’ve published a new plugin that generates the average colour for any RGB or greyscale image. It sits at the end of the Colors menu: “Average colour” (after you install it properly of course).

I was surprised that average colour wasn’t a thing in GIMP. I did a lot of research and discovered the topic generated various solutions that were all challenging in one way or another.

Then I found a thread from 2014 where someone suggested a really simple manual approach. So I took that as inspiration and automated it.

You can read more about it and download it here:

https://www.chuckhenrich.com/average-col...mp-plugin/

Also, I wrote a follow-up blog post on the wider topic of the importance of using industry standards in GIMP, with average colour as an example:

https://www.chuckhenrich.com/average-col...-standard/

The plug-in is available in the following languages:

Dutch (Nederlands)
English (English)
French (Français)
German (Deutsch)
Italian (Italiano)
Hungarian (Magyar)
Japanese (日本語)
Polish (Polski)
Portuguese (Português)
Spanish (Español)
Ukrainian (Українська)
Chinese (Simplified) (简体中文)
Chinese (Traditional) (繁體中文)

Feedback and suggestions welcome and encouraged!
Reply
#2
I consider your plugin as an essential from now on. Thanks for your work, and the explanations. And for sure, I'll use the method in some of my plugins where I used some ugly hacks to achieve a less than ideal result.

You rely on the histogram for your calculations. It would be interesting to know how GIMP's histogram calculates its means, and which color space it uses, sRGB or the color profile of the image. The API function Gimp.Drawable.histogram() documentation is not very clear about it, and  it would validate the method "scientifically".

Thanks a lot for sharing!

P.S: just a small note: I think it's generally considered good practice to put a personal prefix in front of one's plugin's name, to avoid possible naming collisions in the future.
Reply
#3
(12-01-2025, 12:06 PM)Scallact Wrote: I consider your plugin as an essential from now on. Thanks for your work, and the explanations. And for sure, I'll use the method in some of my plugins where I used some ugly hacks to achieve a less than ideal result.

You rely on the histogram for your calculations. It would be interesting to know how GIMP's histogram calculates its means, and which color space it uses, sRGB or the color profile of the image. The API function Gimp.Drawable.histogram() documentation is not very clear about it, and  it would validate the method "scientifically".

Thanks a lot for sharing!

P.S: just a small note: I think it's generally considered good practice to put a personal prefix in front of one's plugin's name, to avoid possible naming collisions in the future.

Thank you very much, happy to help! 

Interesting question about how GIMP calculates histogram means. My guess is that it's industry standard (whatever that is, I'm not that sciency) because calculations based on the mean values correlate with Photoshop.

I didn't know about the personal prefix convention. I'll use it going forward. Thanks for the tip!
Reply
#4
Czym jest kodowanie gamma i dlaczego moje obliczenia kolorów są błędne?
https://www.gimp-forum.net/Thread-What-i...ions-wrong
16.07.2024
Reply
#5
As of January 9, 2017. There is Ofnuts for GIMP 2.10 ofn-average-fill.py, which works reliably on an available basis.

However, it is appropriate to mention that since 2009, there is a simple script sample_avg_color.scm created in by Rob Antonishen in response to requests. 
It takes a medium color and allows you to set a medium color in the foreground, background, or add it to the active palette. 
Its purpose is to determine the average color of the area of our selection (this can be the entire image).
With me in GIMP 2.10.38 it still works today
The script was in the repository: 
http://registry.gimp.org/node/16678

(12-01-2025, 05:25 PM)Zbyma72age Wrote: What is gamma coding and why are my color calculations wrong?
https://www.gimp-forum.net/Thread-What-i...ions-wrong
16.07.2024


Attached Files
.zip   sample_avg_colour.zip (Size: 1.62 KB / Downloads: 11)
Reply
#6
For me definition of "average" is whatever Gimp picks when you use the color picker with the Sample average option. On a B&W checkerboard, Gimp 2.8 picks #808080, and Gimp 2.10/Gimp 3.x pics #bcbcbc.

The acid test is to paint over the area using the picked color,  normally it should hardly be visible.
Reply


Forum Jump: