DEV Community

Discussion on: K-Means Clustering for Magic: The Gathering - Card Recommendation

Collapse
 
kenbellows profile image
Ken Bellows

Yeah, basically. We looked for centroids based on the three color channels, so the average Red, Green, and Blue values within each cluster. Then once the centroids converged and stopped shifting around, we rendered a new version of the image with each pixel replaced by the centroid value of its cluster. So essentially you compress the image by reducing it down to only k unique colors. So yes, it's definitely a lossy compression.

I was very surprised at how recognizable the pictures were even with k=5. I mean, it's very clearly compressed, but it still looks surprisingly good. Bump it up to k=16 or k=24 and it'll definitely take a lot longer to run, but the output is very nice.