Sample Average Colour

This simple plugin was created in response to a request here.

It simply samples the entire image colour, and allows you to either:
- Display the RGB or grey values
- Set the foregound colour
- Set the background colour
- Add it to the current palette (if editable)

There is a toggle to sample just the layer, or the merged image.

It registers in the Colour menu as "Sample Average Colour..." and should work for RGB, indexed, or greyscale images.

UPDATE: Version 1.1 of the script now respects image/layer transparency and selections.

-Rob A>

AttachmentSize
sample_avg_colour.scm3.49 KB
sample_avg_colour1.1.scm3.9 KB

Comments

For more info

I made a short writeup with an overview of what the script does:

http://planetfs.blogspot.com/2009/06/i-was-interested-to-see-sample-aver...

Thanks for writing it!

Marc
http://planetfs.blogspot.com

layer colour average vs colour picker average

Hi Rob

Awesome, I was looking for a way of getting average colour of layers with transparent areas. The Colour picker seems to have a bias as the colours it gives are darker than would be expected - almost like it treats transparent areas as black.

The script works beautifully. Just a small note, don't use it on an area selection - then nothing happens....
Maybe add a line to deselect all.

I'm fidling with ways of dithering images to be more perceptually correct.

RiaanR

sampling colour of transparent layers

I had a lot of thinking about this. Unfortunately even transparent layers have colour. You just don't see the colour. The script only looks at the RGB channels (or value for greyscale) when determining the average colour.

If you do a transparency threshold you will see the image as the script see's it.

There was a recent discussion on gimtalk about "unerasing" which works because the eraser tool (when you have a layer with alpha) just changes the alpha channel without changing the RGB.

So the idea of an average colour with alpha is rather ambiguous. Possibly, you could interpret it to mean the average colors, weighted at each pixel by the alpha.... but there is no easy way to do that short of sampling every pixel individually. Really, average colour only has a meaning without transparency.

BTY - it seems to work for me with a selection. The script only returns the average for the selection.

SO after this ramble, I have updated the script to it does respect transparency (i.e. histogram weighted by the transparency), and confirmed it also returns the colour sample from selections.

-Rob A>