added k-means clustering to reduce the number of colors