Butterfly Image Segmentation Using K-means Clustering
In digital image processing and computer vision, image segmentation is the process of partitioning a digital image into multiple segments (sets of pixels, also known as image objects). (Wikipedia)
One commonly used image segmentation technique is K-means clustering. K-means clustering is a machine learning technique that separates an image into segments by clustering or grouping together data points that have similar traits.
In a nutshell, here's what K-means clustering is all about. In the context of computer vision, where we can represent and plot an image on 3d space, where each of the axes corresponds to one of the three color channels (RGB).
- Choose k random center points. Here we simply opt for 3 center points.
- We then assign every data point in the cluster based on the nearest center point as shown below
- Repeat until convergence.
Now that we have a brief idea of how the algorithm works, let's start with an image of a pretty butterfly.
We import it using the following code:
Comments
Post a Comment