Você está na página 1de 11

Image segmentation

 Image Segmentation (IS): Identify groups of similar pixels.


 Separate image into coherent objects

M. Shahzad: CS862 - Advanced Image Processing Lecture 12: Clustering via K-means and Meanshift 1
Types of segmentations

M. Shahzad: CS862 - Advanced Image Processing Lecture 12: Clustering via K-means and Meanshift 2
Segmentation as clustering

 Segmentation as clustering

 Clustering: Identify group of similar pixels and


represent them with a single token

M. Shahzad: CS862 - Advanced Image Processing Lecture 12: Clustering via K-means and Meanshift 3
What will we learn today?

 K-means clustering

M. Shahzad: CS862 - Advanced Image Processing Lecture 12: Clustering via K-means and Meanshift 4
Image segmentation: Toy example
white
pixels
3

pixel count
black pixels
gray

1 2 pixels

input image
intensity

 These intensities define the three groups


 We could label every pixel in the image according to the
primary intensity it belongs to
► i.e., segment the image based on the intensity feature

M. Shahzad: CS862 - Advanced Image Processing Lecture 12: Clustering via K-means and Meanshift 5
Image segmentation: Toy example

pixel count
input image
intensity

pixel count

input image
intensity
M. Shahzad: CS862 - Advanced Image Processing Lecture 12: Clustering via K-means and Meanshift 6
Clustering

► If we knew the cluster centers, we could allocate


points to groups by assigning each to its closest
center

► If we knew the group memberships, we could get


the centers by computing the mean per group

M. Shahzad: CS862 - Advanced Image Processing Lecture 12: Clustering via K-means and Meanshift 7
Best cluster centers?

 Best cluster centers: Centers that minimize Sum of Square


Distance (SSD) between all points and their nearest cluster
center ci:

M. Shahzad: CS862 - Advanced Image Processing Lecture 12: Clustering via K-means and Meanshift 8
K-means clustering

1. K-means: Clustering method


2. Finds the center positions μi where i=1...k of the clusters
3. Clusters minimize the distance from the data points to
the cluster center

 K-means clustering solves

where ci is the set of points that belong to cluster i

M. Shahzad: CS862 - Advanced Image Processing Lecture 12: Clustering via K-means and Meanshift 16
K-means clustering
 Initialization:
► choose k cluster centers

 Repeat:
► assignment step:

- For every point, find closest center


► update step:

- Update every center as the mean of its points

 Until:
► The maximum number of iterations is reached

► OR

► No changes in assignment step

► OR

► The average distortion per point drops very little


M. Shahzad: CS862 - Advanced Image Processing Lecture 12: Clustering via K-means and Meanshift 17
K-means: Initialization

 k-means: extremely sensitive to initialization

 Bad initialization can lead to:


► poor convergence speed

► bad overall clustering

 How to initialize?
► randomly from data

► try to find K “spread-out” points (k-means++)

 Safeguarding measure:
► try multiple initializations and choose the best

M. Shahzad: CS862 - Advanced Image Processing Lecture 12: Clustering via K-means and Meanshift 18

Você também pode gostar