Tutorial # 9

Download Report

Transcript Tutorial # 9

Tutorial # 9
Nov. 21, 2013
1
Segmentation
Isolating a region/regions of interest in an image
Useful for:






2
Collect more meaningful data from an image
Easier analysis
Locate objects
Locate boundaries
K-means clustering
Unsupervised clustering algorithm



Classifies input data points into K classes based on their inherent
distance to each other
Points are clustered around centroids/means
𝜇∀𝑖 = 1 … 𝐾
Which are obtained by minimizing:
𝐾
𝑉=
𝑥𝑗 − 𝜇𝑖
2
𝑖=1 𝑥𝑗 𝜖𝑆𝑖
Where there are K clusters 𝑆𝑖 , 𝑖 = 1, 2 … 𝐾 and 𝜇𝑖 is the centroid of all
points 𝑥𝑗 𝜖𝑆𝑖
Ref:
http://www.ics.uci.edu/~dramanan/teaching/ics273a_winter08/projects/avim
_report.pdf
3
Example – 1 Channel
Given a gray scale image, use K-means to segment the
image. Choose K = 2 (Cluster A and Cluster B)

4
1
5
3
2
6
2
5
5
1
1.) Calculate the histogram
3.5
3
2.5
2
Frequency
1.5
1
0.5
0
0
5
1
2
3
Intensity
4
5
6
2.) Initialize centroids
Randomly initialize centroids
𝜇𝐴 = 1
𝜇𝐵 = 3

3.5
3
2.5
2
Frequency
1.5
1
0.5
0
0
6
𝜇𝐵
𝜇𝐴
1
2
3
4
Intensity
5
6
3) Cluster intensities based on distance
1
2
3
5
6
Distance
with 𝜇𝐴
0
1
4
16
25
Distance
with 𝜇𝐵
4
1
0
4
9
Note: Points with intensity 2 can be classified as either, but our algorithm
chooses the first cluster.
7
4.) Recalculate centroids
New centroids

𝜇𝐴2 = 1.5
𝜇𝐵2 = 4.8
𝜇𝐴2
3.5
3
2.5
2
Frequency
1.5
1
0.5
0
0
8
1
𝜇𝐵2
2
3
4
Intensity
5
6
5.) Recluster intensities using new centroids
1
2
3
5
6
Distance
with 𝜇𝐴2
0.25
0.25
2.25
12.25
20.25
Distance
with 𝜇𝐵2
14.44
7.84
3.24
0.04
1.44
We have a new clustering!
Recalculate the centroid.
9

New centroids
𝜇𝐴3 = 1.8
𝜇𝐵3 = 5.25
𝜇𝐴3
3.5
3
2.5
2
Frequency
1.5
1
0.5
0
0
10
1
2
𝜇𝐵2
3
4
Intensity
5
6
1
2
3
5
6
Distance
with 𝜇𝐴3
0.64
0.04
1.44
10.24
17.64
Distance
with 𝜇𝐵3
18.063
10.56
5.063
0.63
0.56
Recalculate the means and we find:
𝜇𝐴3 = 𝜇𝐴4
𝜇𝐵3 = 𝜇𝐵4
This means we can stop and we have our final
clusters
11
Final Clustering/Segmentation
A
B
A
A
B
A
B
B
A
This answer would change if we chose K = 3. Also, the number of iterations
would change depending on the starting centroids.
12
Real example
13
Real example
14
Number of Clusters: K = 1
15
Number of Clusters: K = 3
16
Actual Segmentation
Cluster 1
17
Cluster 2
Cluster 3
Similar intensities
18
Number of Clusters: K = 5
Oversegmentation
– K is too high
19
What about colour segmentation?



Different regions of interest may have the same intensity
but different colours
Can use the colour information of an image to improve
segmentation
Let’s focus only on the colour and remove the intensity
by converting to a different colour space:



20
HSI (Hue Saturation Intensity)
YCbCr (Luma, Blue difference, Red difference)
L*a*b* (Lightness, a* - colour that falls on the red-green axis,
b* - colour that falls on the blue-yellow axis)
Using L*a*b* space


Our K-means problem becomes a 2D problem
Our centroid will now have two variables, one defining
the intensity of the a* channel and one defining the b*
channel
21
http://www.mathworks.com/help/releases/R201
3b/stats/kmeans.gif
K=1
22
K=3
K=5
Cluster 1
23
Cluster 2
Cluster 3