Image Reduction with K-Means

TeeTracker
2 min readAug 28, 2022

Use K-Means to find centroids that represent all clusters.

Replace the value of color channels of images with cluster representations(centroids), in other word that we can use K-means to reduce the size of high-quality images by just keeping the important information and grouping the colors with the right number of clusters.

Goal: Reduction of images, save the information needed to transfer large objects, such as images, and avoid unit-by-unit or pixel-by-pixel.

Details of K-Means https://en.wikipedia.org/wiki/K-means_clustering

Additional reading is PCA(Principal Component Analysis) which is a more general unsupervised learning method and is used in many fields of Dimensionality Reduction. Similarly the Autoencoder is very challenging as a deep learning method.

Use case, transfer image

Instead of transferring full image, we can reduce the size of subject(image) with clusters. With KMeans we can find the centroids of all the color channels and use centroids to represent the color channels.

Although we sacrifice the intensities of the images, we simplify the information that needs to be transferred, which is very useful in certain AI application, such as image track or object detection in traffic monitoring systems for moving objects on the road and their bounding box.

intensities before K-Means
intensities after K-Means

However the size of image we have to transfer has been reduced:

Lab

--

--