Top Python Libraries

Top Python Libraries

K-Means (Part 2): How to Use K-Means for Image Segmentation?(Practical Data Analysis 21)

Learn how to apply K-Means clustering for image segmentation, including data processing, feature selection, and visualization of clustered images using Python and scikit-learn.

Meng Li's avatar
Meng Li
Jan 25, 2025
∙ Paid
K-Means Clustering – Harini Jayaraman

Welcome to the "Practical Data Analysis" Series.

Table of Contents

Table of Contents

Meng Li
·
July 12, 2024
Read full story

In the last lesson, I explained the principle of K-means clustering and used K-means to cluster 20 Asian football teams into three tiers.

Today, we will continue with a practical application of K-means clustering. A common scenario for clustering is image segmentation.

Image segmentation is the process of dividing an image into different regions based on features such as color, texture, and shape. Each segmented region is essentially a cluster of pixels from the image.

The similarity between pixels within a single region is high, while the difference between pixels in different regions is significant.

This property aligns perfectly with the nature of clustering, so you can think of image segmentation as clustering the information within an image.

Of course, clustering is just one method of image segmentation. Other methods include thresholding based on image color or using edge information to segment the image.

Segmenting the WeChat Splash Screen

In the last class, I introduced the K-Means algorithm from the sklearn package. Now, we will use the K-Means algorithm to segment the WeChat splash screen.

This post is for paid subscribers

Already a paid subscriber? Sign in
© 2025 Meng Li
Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture