anthra.norell at bluewin.ch
Thu Oct 15 10:26:35 CEST 2009
Dylan Palmboom wrote:
> Does anyone know what python libraries are available to do the following:
> 1. I would like to take a photograph of an object with a colour. In this
> case, it is a sheet of sponge.
> 2. Feed this image into a function in a python library and let the function
> "automatically scan" this image's
> pixel colours, and return an average of all the pixels' colours in the
> 3. I could then use the rgb values to set a colour swatch for the object's
> Please let me know if you have any ideas. It would be appreciated.
> In the meantime, I will search Google and see what I can find.
image.histogram () returns a list of pixel counts: red: index 0 - 255,
green: 256 - 511, blue: 512 - 767. Figure out the median for each color
and there you go.
This would obviously not work well with pictures containing a wide
range of colors, such as a landscape, but then color-averaging a
colorful picture wouldn't make much sense anyway. You seem to be working
with uniformly colored objects for which the method should work well, as
you'll get a narrow range of values with high counts in each color band.
More information about the Python-list