Extracting Key Colors from Images Using K-Means for Palette Generation
Introduction
It’s been a while since we last discussed the clustering technique in machine learning systems. We mentioned that clustering can be used for image processing. Today, we’re continuing our discussion on K-means clustering in the field of image processing.
In this article, we have two sections:
Section 1
In this section, we will use K-means for color quantization to extract the key or dominant colors from the given image. This process is also known as color palette extraction.
Section 2
We’ll show some examples of what can be achieved by using the extracted palette.
What You’ll Need
Please ensure you have access to Google Colab, as it will be our Python coding environment.
You will also need a few image files in PNG or JPEG format to test the color extraction code. Demo images are provided if you don’t have your own.
Let’s get started.
