Multimedia & Machine Learning Algorithms · Multimedia Algorithms
Image Segmentation & k-means Clustering — Region Partitioning as WCSS Minimization
Explanation
Image Segmentation — What and Why?
Segmentation partitions an image into meaningful regions — each pixel receives a label indicating which region it belongs to. The mathematical goal: find a partition of all pixels such that similar pixels belong to the same cluster.
k-means: Lloyd's Algorithm
Given points (pixels, color vectors, …) , partition them into clusters.
Objective function (WCSS):
where is the centroid of cluster . k-means seeks .
The algorithm (Lloyd):
1. Initialize: choose initial centroids (often at random).
2. Assignment step: assign each point to its nearest centroid:
3. Update step: compute new centroid for each cluster:
4. Repeat from step 2 until no assignment changes.
Why does it converge? Both steps cannot increase :
- Assignment step: each point moves to a closer cluster does not increase.
- Update step: the mean minimizes (provable by differentiation) does not increase.
Since the number of possible partitions of points into clusters is finite (), and strictly decreases with each partition change (no two distinct partitions share the same under general position), the algorithm must terminate in finitely many steps. (The claim "a positive decreasing sequence must stabilize" is false — e.g., never stabilizes in finite steps.)
Otsu Thresholding — Threshold Segmentation
For a grayscale image with intensity levels, find threshold that splits into foreground (: intensity ) and background (: intensity ).
Otsu's approach: maximize between-class variance:
where:
- — fraction of pixels in
- — mean intensity in
Connection to total variance: (always constant), so maximizing is equivalent to minimizing (within-class variance).
Interactive Visualization
Loading visualization
Worked Examples
Practice
Exercise 1 of 6
1
Five pixels with centroids , .
After the assignment step, which pixels belong to ?
★After the assignment step, which pixels belong to ?
Quiz
Test your knowledge from this lesson
A mix of questions from the lesson — each attempt varies slightly
Answer at least 4 out of 5 questions correctly to pass (70%)