# How to find “approximate most common” value from a list of RGB values

I have about 50 equally sized photos of magazine covers, which I'm attempting to blend into one composite image that shows the "average" cover. Each of the covers has a single face on it, so the result should look pretty cool.

Each photo is 400 x 525 pixels, and for each pixel I have 50 RGB values (e.g. (100, 140, 255), one from each source photo.

I initially averaged the values to get the resulting image. It was a good start but very muddy. Then I simplified the pixels to 256-color and took the mode for each set. This was very pixelated and tended to favor black and white.

I think what I need here is, for each vector of 50 RGB values, find the largest cluster of values with a minimum density of X, then take the centroid of that cluster. But I don't know if this is a sensical solution, or the most expedient way to find that value. It's a sort of "average approximate mode", I guess.

Expedience is key because I'd like to be able to do this for 20,000 photos at some point, so computationally heavy K-means algos and so forth will not be feasible.

Thank you!

• Would it make any sense to bin the R values in each picture, I am guessing that they cluster in a way similar to G and B values in a given picture . Then "reset" the range of R as required for your project.It seems to me that you are lost in RGB space with only 50 samples per picture. – Alan Nov 12 '13 at 22:41
• Just tried that. Tends to produce some weird values when there are two dominant colors far apart in the spectrum. Good thinking though! – Chris Wilson Nov 13 '13 at 20:23