Picture Segmentation With Okay-Means Clustering | by James Wilkins | Sep, 2024

Wanting on the photographs above, we see an instance of a picture posterization filter that offers photographs a cartoon-like look, however behind the scenes, this filter is definitely utilizing a machine studying algorithm referred to as clustering.

Earlier than exploring into how this course of works and seeing how we are able to implement it in Python, let’s check out why we’d need to do that within the first place.

Picture Segmentation

In a traditional {photograph}, a pixel can take considered one of roughly 16.7 million completely different colors. On this processed picture, nevertheless, there are solely 5 completely different colors. We’ve cut up all the pixels into 5 completely different teams, segmenting the picture into these completely different colour-regions.

We’ve additionally lower down on the quantity of noise and variation inside the picture. So, if this have been for use in another machine studying utility, we’ve simply massively diminished the quantity of information that must be processed, particularly if this have been utilized to a complete library of photographs.

Although we’ve simplified this picture, we’ve nonetheless retained a lot of the necessary structural information. We’re nonetheless in a position to establish shapes and varieties, shadows and…