unsupervised segmentation/supervised...

53
Unsupervised Segmentation/Supervised Segmentation

Upload: others

Post on 26-Jun-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Unsupervised Segmentation/SupervisedSegmentation

Page 2: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Unsupervised Segmentation andGrouping

• Motivation: Many computervision problems would be easy,except for backgroundinterference.

• Unsupervised Segmentation: notraining data

• Use: Obtain a compactrepresentation from animage/motion sequence/set oftokens

• Should support application• Broad theory is absent at

present

• Grouping (or clustering)– collect together tokens that

“belong together”• Fitting

– associate a model with tokens– issues

• which model?• which token goes to which

element?• how many elements in the

model?

Page 3: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

General ideas

• Features (tokens)– whatever we need to group

(pixels, points, surfaceelements, etc., etc.)

• top down segmentation (modelbased)– features belong together

because they lie on the sameobject.

– Supervised segmentation• bottom up segmentation (image

based)– features belong together

because they are locallycoherent

– Unsupervised segmentation• These two are not mutually

exclusive

Page 4: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Why do these features belong together?

Page 5: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we
Page 6: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Basic ideas of grouping in humans

• Figure-ground discrimination– grouping can be seen in terms

of allocating some elements toa figure, some to ground

– impoverished theory

• Gestalt properties– elements in a collection of

elements can have propertiesthat result from relationships(Muller-Lyer effect)

• gestaltqualitat– A series of factors affect

whether elements should begrouped together

• Gestalt factors

Page 7: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we
Page 8: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we
Page 9: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we
Page 10: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we
Page 11: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we
Page 12: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we
Page 13: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we
Page 14: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Are Gestalt laws the result of observedregularity in scenes?

Page 15: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we
Page 16: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we
Page 17: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Collect statistics on local curvature andadjacency for natural contours.

Page 18: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Sampled boundaries from learning probability model.

Page 19: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Technique: Shot Boundary Detection

• Find the shots in a sequence ofvideo– shot boundaries usually result

in big differences betweensucceeding frames

• Strategy:– compute interframe distances– declare a boundary where these

are big

• Possible distances– frame differences– histogram differences– block comparisons– edge differences

• Applications:– representation for movies, or

video sequences• find shot boundaries• obtain “most

representative” frame– supports search

Page 20: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Technique: Background Subtraction

• If we know what thebackground looks like, it is easyto identify “interesting bits”

• Applications– Person in an office– Tracking cars on a road– surveillance

• Approach:– use a moving average to

estimate background image– subtract from current frame– large absolute values are

interesting pixels• trick: use morphological

operations to clean uppixels

Page 21: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we
Page 22: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we
Page 23: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we
Page 24: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Segmentation as clustering

• Cluster together (pixels, tokens,etc.) that belong together

• Agglomerative clustering– attach closest to cluster it is

closest to– repeat

• Divisive clustering– split cluster along best

boundary– Repeat

• Point-Cluster distance– single-link clustering– complete-link clustering– group-average clustering

• Dendrograms– yield a picture of output as

clustering process continues

Page 25: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we
Page 26: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

K-Means

• Choose a fixed number ofclusters

• Choose cluster centers andpoint-cluster allocations tominimize error

• can’t do this by search, becausethere are too many possibleallocations.

• Algorithm– fix cluster centers; allocate

points to closest cluster– fix allocation; compute best

cluster centers• x could be any set of features

for which we can compute adistance (careful about scaling)

!

x j " µ i

2

j#elements of i'th cluster

$% & '

( ) * i#clusters

$

Page 27: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Simple k-means algorithm

• n sample feature vectors x1, x2, ..., xn• Assume they fall into k compact clusters, k < n.• Let mi be the mean of the vectors in cluster i.• Classify x in cluster i if || x - mi || is minimum of all the k distances.• This suggests the following procedure for finding the k means:

– Make initial guesses for the means m1, m2, ..., mk– DO until no changes in any mean

classify the samples into clusters by assigning each point to theclosest mean

For i=1:kReplace mi mean of all of points in cluster i

end end_DO

Page 28: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

K-means clustering using intensity alone and color alone

Image Clusters on intensity Clusters on color

Page 29: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

K-means using color alone, 11 segments

Image Clusters on color

Page 30: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

K-means usingcolor alone,11 segments.

Page 31: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

K-means using colour andposition, 20 segments

Page 32: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Graph theoretic clustering

• Represent tokens using aweighted graph.– affinity matrix

• Cut up this graph to getsubgraphs with strong interiorlinks

Page 33: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Clustering code

im=imread('squaresorig.jpg');im2 = double(im(1:4:end,1:4:end,:));Dm = size(im2);X =reshape(im2, [Dm(1)*Dm(2), 3]);[IDX,C]=kmeans(X,6);X2 = C(IDX,:);Clusterim = uint8(reshape(X2, [Dm(1), Dm(2), 3]));image(Clusterim)

Assign mean colorTo each cluster and display

Page 34: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we
Page 35: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we
Page 36: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we
Page 37: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we
Page 38: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Measuring AffinityIntensity

Texture

Distance

!

aff x, y( ) = exp " 12# i

2

$ %

& ' I x( )" I y( )

2( )( ) *

+ , -

!

aff x, y( ) = exp " 12# d

2

$ %

& ' x " y

2( )( ) *

+ , -

!

aff x, y( ) = exp " 12# t

2

$ %

& ' c x( )" c y( )

2( )( ) *

+ , -

c(x) denotes a histogram,for instance

Page 39: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Scale affects affinity

Page 40: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Eigenvectors and cuts

• Simplest idea: we want avector a giving the associationbetween each element and acluster

• We want elements within thiscluster to, on the whole, havestrong affinity with one another

• We could maximize

• But need the constraint

• This is an eigenvalue problem -choose the eigenvector of Awith largest eigenvalue

!

aTa = 1

!

Let wij = aff (xi,x j ) for pixels xi & x j

!

E = aTWa

!

Maximize :

E = aTWa+ "(1# a

Ta)

Set : $E

$a= 0

= 2Wa # 2"a%Wa = "a

Page 41: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Example eigenvector

points

matrix

eigenvector

Page 42: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

More than two segments

• Many options– Recursively split each side to get a tree, continuing till the

eigenvalues are too small– Use the other eigenvectors

Page 43: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Normalized cuts

• Current criterion evaluateswithin cluster similarity, but notacross cluster difference

• Instead, we’d like to maximizethe within cluster similaritycompared to the across clusterdifference

• Write graph as V, one cluster asA and the other as B

• Maximize

• i.e. construct A, B such thattheir within cluster similarity ishigh compared to theirassociation with the rest of thegraph

!

assoc(A,A)

assoc(A,V )

"

# $

%

& ' +

assoc(B,B)

assoc(B,V )

"

# $

%

& '

!

cut(A,B) =

assoc(A,B) = W (i, j)i"A , j"B

#

!

Nassoc(A,B) =

Page 44: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Normalized cuts

• Write a vector y whose elementsare :1 if item is in A,-b if it’s in B(b = fraction(in)/fraction(out))

• Write the affinity matrix of thegraph as W, and the matrix whichhas the row sums of W on itsdiagonal as D, 1 is the vector withall ones.

• Criterion becomes

• and we have a constraint

• This is hard to do, because y’svalues are quantized

!

minyyT D "W( )y

yTDy

#

$ %

&

' (

!

yTD1 = 0

Binary CaseIf 10 of 100 in AThen 90 in Bb = 10/90

Page 45: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Normalized cuts

• Instead, solve the generalized eigenvalue problem

• which gives

• Now look for a quantization threshold that maximises the criterion ---i.e all components of y above that threshold go to one,

• all below go to -b

!

maxy yTD "W( )y( ) subject to y

TDy = 1( )

!

D "W( )y = #Dy

Page 46: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we
Page 47: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Shi & Malik(1997) show:

This is Equivalent to:

!

D"1

2DD"1

2z "D"1

2WD"1

2z = #z

Iz "D"1

2WD"1

2z = #zBut solutions to above are solutions to :

D"1

2WD"1

2z = #z

Page 48: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Using IntensityFig. 3. Subplot(a) plots thesmallesteigenvectors ofthe generalizedeigenvaluesystem (11).Subplots (b)-(i)show theeigenvectorscorrespondingthe secondsmallest to theninth smallesteigenvalues ofthe system. Theeigenvectorsare reshaped tobe the size ofthe image.

Page 49: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Figure from “Image and video segmentation: the normalised cut framework”, by Shi and Malik, copyright IEEE, 1998

Page 50: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

Ng,Jordan,Weiss, 2002

Page 51: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we
Page 52: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we
Page 53: Unsupervised Segmentation/Supervised Segmentationvision.psych.umn.edu/users/schrater/schrater_lab/courses/... · 2007-03-06 · General ideas • Features (tokens) –whatever we

F igure from “Normalized cuts and image segmentation,” Shi and Malik, copyright IEEE, 2000