K-Means Clustering and Art
0xfe.blogspot.com
0xfe.blogspot.com
This includes a readable 36-line implementation of k-means clustering that could be shorter if one wanted to play some code golf :) I used a pie chart layout, with pie slices proportional to their corresponding cluster sizes.
Code: https://github.com/tylerneylon/imghist/blob/master/imghist.p...
Sample images: http://blog.zillabyte.com/post/11193458776/color-as-data http://blog.zillabyte.com/post/13141231882/hue-histograms
If anyone else is interested in this stuff, Austin A made a great suggestion on the original post to use the Lab colorspace.
Here was the quick k-means implementation I threw together if anyone wants to play with it (my whole library licensed GPL).
https://github.com/gburtini/Learning-Library-for-PHP/blob/ma...
It could definitely use some serious cleaning up (and I will probably OO-ize it when I get a chance -- or I'll take pull requests), but it definitely works.
PCA can be the same way. You toss images or whatever in, and out come either eigenvectors or principal components of the images. Either way it's often interesting to domain experts.
The net result would be a live image like you suggest, but one with much less detail. Still very interesting though.
In other words, you can maintain the detail in RGB space (as this author has) while reorganizing things in location space by their k-means clusters.