Tutorial # 9 Nov. 21, 2013 1. Segmentation Isolating a region/regions of interest in an image ...

23
Tutorial # 9 Nov. 21, 2013 1

Transcript of Tutorial # 9 Nov. 21, 2013 1. Segmentation Isolating a region/regions of interest in an image ...

1

Tutorial # 9

Nov. 21, 2013

2

Segmentation Isolating a region/regions of interest in an

image Useful for:

Collect more meaningful data from an image Easier analysis Locate objects Locate boundaries

3

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

Which are obtained by minimizing:

Where there are K clusters and is the centroid of all points

Ref: http://www.ics.uci.edu/~dramanan/teaching/ics273a_winter08/projects/avim_report.pdf

4

Example – 1 Channel Given a gray scale image, use K-means to

segment the image. Choose K = 2 (Cluster A and Cluster B)

1 5 3

2 6 2

5 5 1

5

1.) Calculate the histogram

0 1 2 3 4 5 60

0.5

1

1.5

2

2.5

3

3.5

Intensity

Frequency

6

2.) Initialize centroids Randomly initialize centroids

0 1 2 3 4 5 60

0.51

1.52

2.53

3.5

Intensity

Fre-quency

𝜇𝐴 𝜇𝐵

7

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

A A B B B

Note: Points with intensity 2 can be classified as either, but our algorithm chooses the first cluster.

8

4.) Recalculate centroids New centroids

0 1 2 3 4 5 60

0.51

1.52

2.53

3.5

Intensity

Fre-quency

𝜇𝐴2 𝜇𝐵 2

9

5.) Recluster intensities using new centroids

1 2 3 5 6

Distance with 0.25 0.25 2.25 12.25 20.25

Distance with 14.44 7.84 3.24 0.04 1.44

A A A B BWe have a new clustering!

Recalculate the centroid.

10

New centroids

0 1 2 3 4 5 60

0.51

1.52

2.53

3.5

Intensity

Fre-quency

𝜇𝐴3 𝜇𝐵 2

11

Recalculate the means and we find:

This means we can stop and we have our final clusters

1 2 3 5 6

Distance with 0.64 0.04 1.44 10.24 17.64

Distance with 18.063 10.56 5.063 0.63 0.56

A A A B B

12

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.

13

Real example

14

Real example

15

Number of Clusters: K = 1

16

Number of Clusters: K = 3

17

Actual Segmentation

Cluster 1 Cluster 2 Cluster 3

18

Similar intensities

19

Number of Clusters: K = 5

Oversegmentation – K is too high

20

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: 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)

21

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

http://www.mathworks.com/help/releases/R2013b/stats/kmeans.gif

22

K = 1 K = 3 K = 5

23

Cluster 1 Cluster 2 Cluster 3