K-Nearest Neighbours Implementation for Image Color Segmentation
What is K-Nearest Neighbour?
K-Nearest Neighbors is a supervised machine learning algorithm that classifies data points based on the majority class among their 'K' nearest neighbors. It's simple, intuitive, and powerful.
What my project does
This project uses the KNN algorithm to transform an image into a simplified version that highlights its most prominent colors. Think of it like turning a photo into a stylized palette-driven version of itself.
How it works
- 1. Read the image and treat each pixel as a data point based on its RGB color values.
- 2. Use KNN to group pixels into K color clusters—each representing a dominant color in the image.
- 3. Recolor the image by assigning each pixel to the center color of its respective cluster.
- 4. The result? A segmented image composed of K distinct colors, revealing the essence of the original in a stylized way.
Demo