cpsc 425: computer visionlsigal/425_2018w2/lecture24a.pdf · 2019-04-04 · today’s “fun”...
TRANSCRIPT
![Page 1: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/1.jpg)
Lecture 24: Clustering (cont)
CPSC 425: Computer Vision
![Page 2: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/2.jpg)
Photo credit: reddit user Liammm
Pereidolia
2
Recall: Pareidolia
![Page 3: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/3.jpg)
3
Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia
![Page 4: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/4.jpg)
Menu for Today (April 2nd, 2019)
Topics:
— Grouping — Image Segmentation
Redings: — Today’s Lecture: Forsyth & Ponce (2nd ed.) 15.1, 15.2, 17.2 Introduction to Deep Learning
— Next Lecture: Convolutional Neural Networks
— Agglomerative Clustering with a Graph — Classification
Reminders: — Assignment 5: Scene Recognition with Bag of Words due April 4th — Some practice problems posted on Piazza, some more to come
![Page 5: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/5.jpg)
Detection scores in the deformable part model are based on both appearance and location
The deformable part model is trained iteratively by alternating the steps 1. Assume components and part locations given; compute appearance and
offset models 2. Assume appearance and offset models given; compute components and
part locations
An object proposal algorithm generates a short list of regions with generic object-like properties that can be evaluated by an object detector in place of an exhaustive sliding window search
5
Lecture 23: Re-cap
![Page 6: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/6.jpg)
Each data point starts as a separate cluster. Clusters are recursively merged.
Algorithm: Make each point a separate cluster Until the clustering is satisfactory Merge the two clusters with the smallest inter-cluster distance end
6
Lecture 23: Re-cap Agglomerative Clustering
![Page 7: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/7.jpg)
The entire data set starts as a single cluster. Clusters are recursively split.
Algorithm: Construct a single cluster containing all points Until the clustering is satisfactory Split the cluster that yields the two components with the largest inter-cluster distance end
7
Lecture 23: Re-cap Divisive Clustering
![Page 8: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/8.jpg)
How can we define the cluster distance between two clusters and in agglomerative and divisive clustering? Some common options:
the distance between the closest members of and
– single-link clustering
the distance between the farthest members of and a member of
– complete-link clustering
8
min d(a, b), a 2 C1, b 2 C2
max d(a, b), a 2 C1, b 2 C2
C1 C2
C1 C2
C1 C2
Lecture 23: Re-cap Divisive Clustering
![Page 9: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/9.jpg)
9
How can we define the cluster distance between two clusters and in agglomerative and divisive clustering? Some common options:
an average of distances between members of and
– group average clustering
C1 C2
1
|C1||C2|X
a2C1
X
b2C2
d(a, b)
C1 C2
Lecture 23: Re-cap Divisive Clustering
![Page 10: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/10.jpg)
The algorithms described generate a hierarchy of clusters, which can be visualized with a dendrogram.
10
Forsyth & Ponce (2nd ed.) Figure 9.15
Lecture 23: Re-cap Divisive Clustering
![Page 11: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/11.jpg)
A Short Exercise
A simple dataset is shown below. Draw the dendrogram obtained by agglomerative clustering with single-link (closest member) inter-cluster distance.
11
AB
C
D
E
![Page 12: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/12.jpg)
A Short Exercise
A simple dataset is shown below. Draw the dendrogram obtained by agglomerative clustering with single-link (closest member) inter-cluster distance.
12
A
C
D
E
A B C D E
B
![Page 13: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/13.jpg)
A Short Exercise
A simple dataset is shown below. Draw the dendrogram obtained by agglomerative clustering with single-link (closest member) inter-cluster distance.
13
A
C
D
E
A B C D E
B
![Page 14: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/14.jpg)
A Short Exercise
A simple dataset is shown below. Draw the dendrogram obtained by agglomerative clustering with single-link (closest member) inter-cluster distance.
14
C
D
E
A B C D E
AB
![Page 15: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/15.jpg)
A Short Exercise
A simple dataset is shown below. Draw the dendrogram obtained by agglomerative clustering with single-link (closest member) inter-cluster distance.
15
C
D
E
A B C D E
AB
![Page 16: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/16.jpg)
A Short Exercise
A simple dataset is shown below. Draw the dendrogram obtained by agglomerative clustering with single-link (closest member) inter-cluster distance.
16
C
D
E
A B C D E
AB
![Page 17: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/17.jpg)
K-Means Clustering
Assume we know how many clusters there are in the data - denote by K
Each cluster is represented by a cluster center, or mean
Our objective is to minimize the representation error (or quantization error) in letting each data point be represented by some cluster center
Minimize
17
X
i2clusters
8<
:X
j2ith cluster
||xj � µi||29=
;
![Page 18: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/18.jpg)
K-means clustering alternates between two steps:
1. Assume the cluster centers are known (fixed). Assign each point to the closest cluster center.
2. Assume the assignment of points to clusters is known (fixed). Compute the best center for each cluster, as the mean of the points assigned to the cluster.
The algorithm is initialized by choosing K random cluster centers
K-means converges to a local minimum of the objective function — Results are initialization dependent
18
K-Means Clustering
![Page 19: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/19.jpg)
Example 1: K-Means Clustering
19
−0.2 0 0.2 0.4 0.6 0.8
0.2
0.3
0.4
0.5
0.6
0.7
0.8
True Clusters
![Page 20: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/20.jpg)
20
Example 1: K-Means Clustering
−0.2 0 0.2 0.4 0.6 0.80.2
0.3
0.4
0.5
0.6
0.7
0.8
Clusters at iteration 1
![Page 21: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/21.jpg)
21
Example 1: K-Means Clustering
−0.2 0 0.2 0.4 0.6 0.80.2
0.3
0.4
0.5
0.6
0.7
0.8
Clusters at iteration 2
![Page 22: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/22.jpg)
22
Example 1: K-Means Clustering
−0.2 0 0.2 0.4 0.6 0.80.2
0.3
0.4
0.5
0.6
0.7
0.8
Clusters at iteration 3
![Page 23: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/23.jpg)
23
Example 1: K-Means Clustering
−0.2 0 0.2 0.4 0.6 0.80.2
0.3
0.4
0.5
0.6
0.7
0.8
Clusters at iteration 13
![Page 24: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/24.jpg)
Example 2: Mixed Vegetables
24
Original Image Segmentation Using Colour
K-means using colour alone, 11 segments
![Page 25: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/25.jpg)
25
Forsyth & Ponce (2nd ed.) Figure 9.18
K-means using colour alone, 11 segments
Example 2: Mixed Vegetables
![Page 26: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/26.jpg)
K-means using colour alone, 20 segments
26
Example 2: Mixed Vegetables
Forsyth & Ponce (2nd ed.) Figure 9.19
![Page 27: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/27.jpg)
An Exercise
Sketch an example of a 2D dataset for which agglomerative clustering performs well (finds the two true clusters) but K-means clustering fails.
27
![Page 28: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/28.jpg)
An Exercise
Sketch an example of a 2D dataset for which agglomerative clustering performs well (finds the two true clusters) but K-means clustering fails.
28
![Page 29: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/29.jpg)
Discussion of K-Means
Advantages: — Algorithm always converges — Easy to implement
Disadvantages: — The number of classes, K, needs to be given as input — Algorithm doesn’t always converge to the (globally) optimal solution — Limited to compact/spherical clusters
29
![Page 30: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/30.jpg)
Segmentation by Clustering
We just saw a simple example of segmentation based on colour and position, but segmentation typically makes use of a richer set of features. — texture — corners, lines, … — geometry (size, orientation, ...)
30
![Page 31: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/31.jpg)
Agglomerative Clustering with a Graph
Suppose we represent an image as a weighted graph.
Any pixels that are neighbours are connected by an edge.
Each edge has a weight that measures the similarity between the pixels — can be based on colour, texture, etc. — low weights → similar, high weights → different
We will segment the image by performing an agglomerative clustering guided by this graph.
31
![Page 32: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/32.jpg)
Recall that we need to define the inter-cluster distance for agglomerative clustering. Let
We also need to determine when to stop merging.
32
d(C1, C2) = minv12C1,v22C2,(v1,v2)2✏
w(v1, v2)
Agglomerative Clustering with a Graph
![Page 33: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/33.jpg)
Denote the ‘internal difference’ of a cluster as the largest weight in the minimum spanning tree of the cluster, M(C):
33
Agglomerative Clustering with a Graph
int(C) = max
e2M(C)w(e)
![Page 34: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/34.jpg)
Denote the ‘internal difference’ of a cluster as the largest weight in the minimum spanning tree of the cluster, M(C):
34
Agglomerative Clustering with a Graph
int(C) = max
e2M(C)w(e)
+⌧(C) =k
|C|
This is not going to work for small clusters: int(C) + ⌧(C) =k
|C|
where
![Page 35: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/35.jpg)
Make each point a separate cluster.Sort edges in order of non-decreasing weight so that For to If both ends of lie in the same cluster Do nothing Else
One end is in cluster and the other is in cluster If Merge and Report the remaining set of clusters.
Report the remaining set of clusters.35
Agglomerative Clustering with a Graph
w(e1) � w(e2) � · · · � w(er)
Algorithm: (Felzenszwalb and Huttenlocher, 2004)
ei
Cl Cm
d(Cl, Cm) MInt(Cl, Cm)
Cl Cm
i = 1 r
![Page 36: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/36.jpg)
36
Agglomerative Clustering with a Graph
Image credit: KITTI Vision Benchmark
![Page 37: CPSC 425: Computer Visionlsigal/425_2018W2/Lecture24a.pdf · 2019-04-04 · Today’s “fun” Example: Deep Dream — Algorithmic Pareidolia. Menu for Today (April 2nd, 2019) Topics:](https://reader030.vdocument.in/reader030/viewer/2022040415/5f3345d96fdaca7b9379c2cb/html5/thumbnails/37.jpg)
Summary
To use standard clustering techniques we must define an inter-cluster distance measure
A dendrogram visualizes a hierarchical clustering process
K-means is a clustering technique that iterates between 1. Assume the cluster centers are known. Assign each point to the
closest cluster center. 2. Assume the assignment of points to clusters is known. Compute
the best cluster center for each cluster (as the mean).
K-means clustering is initialization dependent and converges to a local minimum
37