k-means


This project explores the k-means clustering algorithm by compressing an image’s colours into k representative clusters. Each pixel is assigned to its nearest cluster centre and the image is reconstructed using only those k colours, producing painterly posterisation effects.
How k-means works
The algorithm first picks k random centroids from the data (here, pixel colours), and then iterates over two simple steps until convergence:
- Assignment: assign each point to the nearest centroid.
- Update: recompute each centroid as the mean of its assigned points.


Results
Yellowstone




Blue Mountains #1




Blue Mountains #2




Blue Mountains #3




Fjadrargljufur




Papercourt



