[PD] Can GEM select a color from an image?

Mathieu Bouchard matju at artengine.ca
Sun Sep 11 04:24:06 CEST 2011


On Sat, 10 Sep 2011, Sebastian Valenzuela wrote:

> I am in the process of writing an algorithmic piece where I take 
> pictures, determine the most prevalent color in that picture, then store 
> that as a number in an array. I would then call on these numbers to 
> determine the triggering of samples. Is there an object in Pure Data 
> that can determine the most common color in an image? If so, how does it 
> work?

To be able to do this, you need to be defining how to clusterise your 
colours. For example, if you just classify them by their exact value, 
you might get a lot of a very specific shade, and select that, and miss 
the fact that there is another shade that looks very close to a lot of 
other shades in the picture, and so, by different criteria, it would be 
the most common.

What would match the perception of the human eye and most people's 
expectation, is something that picks the average of a bunch of very 
similar shades. That's not very obvious to do.

[cv/#KMeans] (from GridFlow's OpenCV wrappers) does something like that : 
it categorises the pixels in your image to make a palette (among multiple 
possible uses). Then you can use GridFlow's [#cluster_avg] to find the 
average colour of each palette item.

However, the palette items are not the best that can possibly be chosen, 
because it's impossible to guarantee it, and it's hard to do a good job in 
a short time. So sometimes it could pick too many palette items for the 
same kind of colours, and mislead you in finding the most used kind of 
colour.

  _______________________________________________________________________
| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC


More information about the Pd-list mailing list