{"id":1095,"date":"2019-10-10T14:59:13","date_gmt":"2019-10-10T14:59:13","guid":{"rendered":"https:\/\/muthu.co\/?p=1095"},"modified":"2021-05-24T02:49:53","modified_gmt":"2021-05-24T02:49:53","slug":"reduce-the-number-of-colors-of-an-image-using-k-means-clustering","status":"publish","type":"post","link":"http:\/\/write.muthu.co\/reduce-the-number-of-colors-of-an-image-using-k-means-clustering\/","title":{"rendered":"Reduce the number of colors of an image using K-Means Clustering"},"content":{"rendered":"\n
This article presents a method for reducing the number of colors in an image using K-means clustering. This is a continuation of my previously posted color quantization using Uniform Quantization<\/a> and Median Cut Quantization<\/a>.<\/p>\n\n\n\n K-Means is one of the simplest unsupervised clustering algorithm used to cluster data into K clusters. The algorithm iteratively assigns the data points to one of the K clusters based on how near the point is to the cluster’s centroid.<\/p>\n\n\n\n In the case of color clustering, since our pixels are just 3-dimensional coordinates containing Red, Green, and Blue color space values, we can easily use the K-Means on this 3D coordinate system to find the required number of clusters. To understand more in detail about K-means algorithm, you can read my article here<\/a>.<\/p>\n\n\n\n If you have a set of data points 2D or 3D in a coordinate system, you can find the distance between any 2 data points using the euclidean distance formula given by:<\/p>\n\n\n\nIntroduction<\/h2>\n\n\n\n