This project implements the k-means clustering algorithm to perform image segmentation, also known as image compression or quantization. Image segmentation involves partitioning an image into sets of pixels, called segments or image objects, and assigning a label to each set. This helps in identifying regions with common characteristics such as similar color, texture, or intensity.
The k-means clustering algorithm, also known as Lloyd’s algorithm, is used for this purpose. The implementation involves initializing cluster assignments, iteratively updating cluster centers, computing distances between cluster centers and points, and reassigning each point to its nearest cluster.
Original Image:
Reconstruction with k=2:
Reconstruction with k=5:
Reconstruction with k=10:
Reconstruction with k=20:
Reconstruction with k=40:
Reconstruction Process - k=2:
Reconstruction Process - k=5:
Reconstruction Process - k=10:
Reconstruction Process - k=20:
Reconstruction Process - k=40: