k-means clustering is a method of vector quantization, originally from signal processing, that aims to partition n observations into k clusters in which each observation belongs to the cluster with the nearest mean (cluster centers or cluster centroid), serving as a prototype of the cluster.
- Code for K-means Algorithm implemented from scratch in Python 3 : Here
- Cases where K-means algorithm Fails : Here
- Application of K-means algorithm in Image Segmentation : Here
Using K-means algorithm, I have extracted the K most dominant colour of the image, Where k is the input received from User. It is a basic application of the K-Means algorithm, where, the algorithm tries to find out K-most dominant colours, in the pixel array, and then the new or modified picture is created by replacing the nearest colour value, among the k most dominant colours, to give a completely new image made up of, these colours.
NOTE :
I have used K (no. of dominant colours to extract) = 6 but the program is generic, and you can give any positive integer upto 255 to it.