Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based...

98
Image Segmentation Jianping Fan Dept of Computer Science UNC-Charlotte Course Website: http://webpages.uncc.edu/jfan/itcs5152.html

Transcript of Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based...

Page 1: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Image Segmentation

Jianping Fan

Dept of Computer Science

UNC-Charlotte

Course Website: http://webpages.uncc.edu/jfan/itcs5152.html

Page 2: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Outlines

Seeded Region Growing

K-Means Clustering

Graph Cut & Normalized Cut

Page 3: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Definitions

Based on sets.

Each image R is a set of regions Ri. Every pixel belongs

to one region.

One pixel can only belong to a single region.

S

i

iRR1

ji RR

R1

R3R2

R4

R6

R5

R7

Page 4: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

VC 14/15 - TP9 -

Region-Based

Segmentation

R1

R3

R2

R4

R6

R5

R7

Page 5: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Basic Formulation

Let R represent the entire image region. Segmentation partitions R into n subregions, R1, R2, ..., Rn, such that:

a)

b)

c)

d)

e)

a) Every pixel must be in a region

b) Points in a region must be connected.

c) Regions must be disjoint.

d) All pixels in a region satisfy specific properties.

e) Different regions have different properties.

n

i

i RR1

.21 region, connected a is , ..., n, i Ri

jijiRR ji , and allfor

.,...,2,1for )( niTRUERP i

.for )( jiFALSERRP ji

Page 6: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Region growing

Groups pixels into larger regions.

Starts with a seed region.

Grows region by mergingneighboring pixels.

Iterative process

How to start?

How to iterate?

When to stop?

Initial

RegionsIterations

Stop

Condition

Finish

Page 7: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Similarity Criteria

Homogeneity of regions is used as the main segmentation criterion in region growing.

gray level

color, texture

shape

model

etc.

Choice of criteria

affects segmentation

results dramatically!

Page 8: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Region Growing

Inter-Pixel Similarity Calculation

(a) Pixel Neighborhood Similarity Calculation

),( yx

)1,1( yx )1,( yx )1,1( yx

),1( yx ),1( yx

)1,1( yx )1,( yx )1,1( yx

Page 9: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Region Growing

Inter-Pixel Similarity Calculation

(1) Inter-Pixel Similarity

|)1,1(),(|)]1,1(),,[( yxIyxIyxyxD

(2) Binary Classification

TyxyxDdissimilar

TyxyxDsimilaryxS

)]1,1(),,[(,,0

)]1,1(),,[(,,1),(

Page 10: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Region Growing

Threshold Determination for Decision Making

Relationships among neighboring pixels can defined as:

similar versus dissimilar

0

1

1T

similar dissimilar

Page 11: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Region Growing

Threshold Determination for Decision Making

Entropy for similar and dissimilar pixels:

Page 12: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Region Growing

Threshold Determination for Decision Making

Page 13: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Gray-Level Criteria

Comparing to Original Seed Pixel

Very sensitive to choice of seed point.

Comparing to Neighbor in Region

Allows gradual changes in the region.

Can cause significant drift.

Comparing to Region Statistics

Acts as a drift dampener.

Other possibilities!

Page 14: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

VC 14/15 - TP9 -

Region-Based

Segmentation

Page 15: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Region merging

Algorithm

Divide image into an initial set of regions.

One region per pixel.

Define a similarity criteria for merging regions.

Merge similar regions.

Repeat previous step until no more merge operations are possible.

Page 16: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Region Growing

Region Growing Results

Page 17: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Region Growing Region Growing Results

Page 18: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Region Growing

Region Growing Results

Page 19: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Integrating Multi-modal Features for Region Growing

Image Segmentation

Page 20: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Image Segmentation

Integrating Multi-modal Features for Region Growing

Page 21: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Image Segmentation

Integrating Multi-modal Features for Region Growing

Page 22: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Image Segmentation

Integrating Multi-modal Features for Region Growing

Page 23: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Image Segmentation

Integrating Multi-modal Features for Region Growing

Page 24: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Observations

Only segmentation from visual information cannot support automatic image understanding & interpretation!

Image segmentation results may not make sense to human beings!

Integrating Multi-modal Features for Region Growing

Page 25: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

25

Seeded Image Segmentation

Color image segmentation polices:

Threshold

Boundary-based

Region-based

Hybrid techniques

Page 26: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

26

Hybrid techniques

Seeding region growing (SRG)

Different merging order possibility

SRG

Page 27: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

27

Automatic seed selection algorithm

Condition 1:

A seed pixel candidate must have the similarity higher than a threshold values.

Condition 2:

A seed pixel candidate must have the maximum relative Euclidean distance to its eight neighbors less than a threshold value.

Page 28: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

28

Automatic seed selection algorithm

Calculate the maximum distance to its neighbors as :

of the pixel, of its neighbors

Not on the boundary

0.05

ii

dd8

1max max

8...1,

222

222

i

CCY

CCCCYYd

rb

rrbbi

i

ii

rbCYCii rbi CCY

Condition 2:A seed pixel candidate must have the maximum relative Euclidean distance to its eight neighbors less than a threshold value.

Page 29: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

29

Automatic seed selection algorithm

Connected seeds are considered as one seed.

the detected seeds are shown in red colorOriginal color image

Page 30: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

30

Region growing

The pixels that are unclassified and neighbors of at least one region, calculate the distance:

222

222

ii

ii

rbi

rrbbi

i

CCY

CCCCYYd

Page 31: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

31

Region growing

1. red pixels are the seeds and the green pixels are the

pixels in the sorted list T in a decreasing order of

distances.

2. the white pixel is the pixel with the minimum distance

to the seed regions

3. check its 4-neighbors

Page 32: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

32

Region growing

1. If all labeled neighbors of p have a same label, set p to this label.

2. If the labeled neighbors of p have different labels, calculate the

distances between p and all neighboring regions and classify p to

the nearest region.

3. Then update the mean of this region, and add 4 neighbors of p,

which are neither classified yet nor in T, to T in a decreasing order

of distances.

4. Until the T is empty.

Page 33: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

33

Region merging

Consider the color different and size of regions :

Color different between two adjacent region Ri and Rj is defined as:

Size

select of the total number of pixels in an image as the threshold.

150

1

222222

222

,min

,

ijii

jiji

rbjrbi

rrbbji

CCYCCY

CCCCYYRjRid

Page 34: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

34

Region merging

We first examine the two regions having the smallest color differentamong others. If < threshold, merge the two

regions and re-compute the mean of the new region.

We repeat the process until no region has the distance less than the threshold.

Threshold=0.1

RjRid ,

Page 35: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

35

Region merging

If the size with number of pixels in a region is smaller than a threshold, the region is merged into its neighboring region with the smallest color difference.

This procedure is repeated until no region has size less than the threshold.

Page 36: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

36

Experimental results

JSEG algorithm.

Page 37: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

37

Experimental results

JSEG algorithm.

JSEG algorithm.

Page 38: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Bahadir K. Gunturk EE 7730 - Image Analysis I 38

K-Means Clustering

1. Partition the data points into K clusters

randomly. Find the centroids of each cluster.

2. For each data point:

Calculate the distance from the data point to

each cluster.

Assign the data point to the closest cluster.

3. Re-compute the centroid of each cluster.

4. Repeat steps 2 and 3 until there is no further

change in the assignment of data points (or in

the centroids).

Page 39: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Bahadir K. Gunturk EE 7730 - Image Analysis I 39

K-Means Clustering

Page 40: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Bahadir K. Gunturk EE 7730 - Image Analysis I 40

K-Means Clustering

Page 41: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Bahadir K. Gunturk EE 7730 - Image Analysis I 41

K-Means Clustering

Page 42: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Bahadir K. Gunturk EE 7730 - Image Analysis I 42

K-Means Clustering

Page 43: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Bahadir K. Gunturk EE 7730 - Image Analysis I 43

K-Means Clustering

Page 44: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Bahadir K. Gunturk EE 7730 - Image Analysis I 44

K-Means Clustering

Page 45: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Bahadir K. Gunturk EE 7730 - Image Analysis I 45

K-Means Clustering

Page 46: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Bahadir K. Gunturk EE 7730 - Image Analysis I 46

K-Means Clustering

Page 47: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Bahadir K. Gunturk EE 7730 - Image Analysis I 47

K-Means Clustering

Example

Duda et al.

Page 48: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Bahadir K. Gunturk EE 7730 - Image Analysis I 48

K-Means Clustering

RGB vector

x j i2

jelements of i' th cluster

iclusters

K-means clustering minimizes

Page 49: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Bahadir K. Gunturk EE 7730 - Image Analysis I 49

Clustering

Example

D. Comaniciu and P. Meer, Robust

Analysis of Feature Spaces:

Color Image Segmentation, 1997.

Page 50: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Bahadir K. Gunturk EE 7730 - Image Analysis I 50

K-Means Clustering

Example

Original K=5 K=11

Page 51: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Bahadir K. Gunturk EE 7730 - Image Analysis I 51

K-means, only color is used in segmentation, four clusters (out of 20) are shown here.

Page 52: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Bahadir K. Gunturk EE 7730 - Image Analysis I 52

K-means, color and position is used in segmentation, four clusters (out of 20) are shown here.

Each vector is (R,G,B,x,y).

Page 53: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Bahadir K. Gunturk EE 7730 - Image Analysis I 53

K-Means Clustering: Axis Scaling

Features of different types may have

different scales.

For example, pixel coordinates on a

100x100 image vs. RGB color values in

the range [0,1].

Problem: Features with larger scales

dominate clustering.

Solution: Scale the features.

Page 54: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Spectral Clustering for Image Segmentation

Page 55: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Graph-based Image Segmentation

Image (I)

Graph Affinities(W)

IntensityColorEdges

Texture

Slide from Timothee Cour (http://www.seas.upenn.edu/~timothee)

Page 56: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Graph-based Image Segmentation

Image (I)

)(

1

)(

1),(),(

BvolAvolBAcutBANcut

Slide from Timothee Cour (http://www.seas.upenn.edu/~timothee)

Graph Affinities(W)

IntensityColorEdges

Texture

Page 57: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Graph-based Image Segmentation

Image (I)

)(

1

)(

1),(),(

BvolAvolBAcutBANcut

Eigenvector X(W)

Aiif

AiifiX

DXXWD

A0

1)(

)(

Graph Affinities(W)

IntensityColorEdges

Texture

Page 58: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Graph-based Image Segmentation

Image (I)

)(

1

)(

1),(),(

BvolAvolBAcutBANcut

Eigenvector X(W)

Discretization

Slide from Timothee Cour (http://www.seas.upenn.edu/~timothee)

Aiif

AiifiX

DXXWD

A0

1)(

)(

Graph Affinities(W)

IntensityColorEdges

Texture

Page 59: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Graph-based Image Segmentation

V: graph nodesE: edges connection nodes

G = {V,E}

PixelsPixel similarity

Slides from Jianbo Shi

Page 60: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Graph terminology

Similarity matrix:

Slides from Jianbo Shi

2

2

2)()(

,X

ji XX

ji ew

jiwW ,

Page 61: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Affinity matrix

Similarity of image pixels to selected pixelBrighter means more similar

Reshape

N*M pixels

N*M pixels

M pixels

N pixels

Warningthe size of W is quadratic

with the numberof parameters!

Page 62: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Graph terminology

Degree of node:

Slides from Jianbo Shi

j

jii wd ,

……

Page 63: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Graph terminology

Volume of set:

Slides from Jianbo Shi

Ai

i VAdAvol ,)(

Page 64: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Graph terminology

AjAi

jiwAAcut,

,),(

Slides from Jianbo Shi

Cuts in a graph:

Page 65: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Representation

Partition matrix X:

Pair-wise similarity matrix W:

Degree matrix D:

Laplacian matrix L:

KXXX ,...,1

j jiwiiD ,),(

WDL

segments

pix

els

),(),( jiaffjiW

Page 66: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Pixel similarity functionsIntensity

Texture

Distance

2

2

2)()(

),( I

ji II

ejiW

2

2

2)()(

),( X

ji XX

ejiW

2

2

2)()(

),( c

ji cc

ejiW

Page 67: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Pixel similarity functionsIntensity

Texture

Distance

2

2

2)()(

),( I

ji II

ejiW

2

2

2)()(

),( X

ji XX

ejiW

2

2

2)()(

),( c

ji cc

ejiW

here c(x) is a vector of filter outputs. A natural thing to do is to square the outputs

of a range of different filters at different scales and orientations,

smooth the result, and rack these into a vector.

Page 68: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Definitions

Methods that use the spectrum of the affinity matrix to cluster are known as spectral clustering.

Normalized cuts, Average cuts, Average association make use of the eigenvectors of the affinity matrix.

Why these methods work?

Page 69: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Spectral Clustering

Data Similarities

* Slides from Dan Klein, Sep Kamvar, Chris Manning, Natural Language Group Stanford University

Page 70: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Eigenvectors and blocks

Block matrices have block eigenvectors:

Near-block matrices have near-block eigenvectors:

1 1 0 0

1 1 0 0

0 0 1 1

0 0 1 1

eigensolver

.71

.71

0

0

0

0

.71

.71

1= 2 2= 2 3= 0

4= 0

1 1 .2 0

1 1 0 -.2

.2 0 1 1

0 -.2 1 1

eigensolver

.71

.69

.14

0

0

-.14

.69

.71

1= 2.02 2= 2.02 3= -0.02

4= -0.02

* Slides from Dan Klein, Sep Kamvar, Chris Manning, Natural Language Group Stanford University

Page 71: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Spectral Space Can put items into blocks by eigenvectors:

Clusters clear regardless of row ordering:

1 1 .2 0

1 1 0 -.2

.2 0 1 1

0 -.2 1 1

.71

.69

.14

0

0

-.14

.69

.71

e1

e2

e1 e2

1 .2 1 0

.2 1 0 1

1 0 1 -.2

0 1 -.2 1

.71

.14

.69

0

0

.69

-.14

.71

e1

e2

e1 e2

Page 72: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

How do we extract a good cluster?

Simplest idea: we want a vector x giving the

association between each element and a cluster

We want elements within this cluster to, on the whole, have strong affinity with one another

We could maximize

But need the constraint

This is an eigenvalue problem - choose the eigenvector of W with largest eigenvalue.

WxxT

1xxT

Page 73: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Criterion for partition:

Minimum cut

BvAu

BAvuwBAcut

,,

),(min),(min

First proposed by Wu and Leahy

A

B

Ideal Cut

Cuts with

lesser weight

than the

ideal cut

Problem! Weight of cut is directly proportional to the number of edges in the cut.

Page 74: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Normalized Cut

)(

1

)(

1),(),(

BvolAvolBAcutBANcut

Normalized cut or balanced cut:

Finds better cut

Page 75: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Normalized Cut

Volume of set (or association):

VtAutuwVAassocAvol

,),(),()(

A

B

Page 76: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Normalized Cut

Volume of set (or association):

Define normalized cut: “a fraction of the total edge connections to all the nodes in the graph”:

),(

),(

),(

),(),(

VBassoc

BAcut

VAassoc

BAcutBANcut

VtAutuwVAassocAvol

,),(),()(

),(

),(

),(

),(),(

VBassoc

BBassoc

VAassoc

AAassocBANassoc

A

B

A

B

Define normalized association: “how tightly on average nodes within the cluster are connected to each other”

A

B

Page 77: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

01DyTSubject to:

Observations(I)

Maximizing Nassoc is the same as minimizing Ncut, since they are related:

How to minimize Ncut? Transform Ncut equation to a matricial form.

After simplifying:

),(2),( BANassocBANcut

Dyy

yWDyxNcut

T

T

yx

)(min)(min

Rayleigh quotient

jjiWiiD ),(),(

NP-Hard!y’s values are

quantized

Page 78: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Instead, relax into the continuous domain by solving generalized eigenvalue system:

Which gives:

Note that so, the first eigenvector is y0=1 with eigenvalue 0.

The second smallest eigenvector is the real valued solution to this problem!!

Observations(II)

DyyWD )(

01)( WD

max y yTDW y subject to y

TDy 1 min

Page 79: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Algorithm

1. Define a similarity function between 2 nodes. i.e.:

2. Compute affinity matrix (W) and degree matrix (D).

3. Solve

4. Use the eigenvector with the second smallest eigenvalue to bipartition the graph.

5. Decide if re-partition current partitions.

Note: since precision requirements are low, W is very sparse and only few eigenvectors are required, the eigenvectors can be extracted very fast using Lanczos algorithm.

DyyWD )(

2

2

2)()(

2

2

2)()(

,X

ji

I

ji XXFF

ji ew

Page 80: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Discretization Sometimes there is not a clear threshold to binarize

since eigenvectors take on continuous values.

How to choose the splitting point?

a) Pick a constant value (0, or 0.5).

b) Pick the median value as splitting point.

c) Look for the splitting point that has the minimum Ncut

value:

1. Choose n possible splitting points.

2. Compute Ncut value.

3. Pick minimum.

Page 81: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Use k-eigenvectors

Recursive 2-way Ncut is slow.

We can use more eigenvectors to re-partition the graph, however:

Not all eigenvectors are useful for partition (degree of smoothness).

Procedure: compute k-means with a high k. Then follow one of these

procedures:

a) Merge segments that minimize k-way Ncut criterion.

b) Use the k segments and find the partitions there using exhaustive search.

Compute Q (next slides).

1 1 .2 0

1 1 0 -.2

.2 0 1 1

0 -.2 1 1

.71

.69

.14

0

0

-.14

.69

.71

e1

e2

e1 e2

Page 82: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Example

Eigenvectors

Segments

Page 83: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Experiments

Define similarity:

for point sets.

for brightness images.

for HSV images.

in case of texture.

2

2

2)()(

2

2

2)()(

,X

ji

I

ji XXFF

ji ew

1iF

iIiF

)]cos(..),sin(..,[ hsvhsvviF

|]*|,|,*[| 1 nfIfIiF

Page 84: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Experiments (I)

Point set segmentation:

(a) Pointset generated by Poisson process. (b) Segmentation results.

Page 85: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Experiments (II)

Synthetic images:

Page 86: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Experiments (III)

Weather radar:

Page 87: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Experiments (IV)

Motion segmentation

Page 88: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Other methods

Average association

Use the eigenvector of W associated to the

biggest eigenvalue for partitioning.

Tries to maximize:

Has a bias to find tight clusters. Useful for Gaussian distributions.

B

BBassoc

A

AAassoc ),(),(

A

B

Page 89: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Other methods

Average cut Tries to minimize:

Very similar to normalized cuts.

We cannot ensure that partitions will have a a tight within-group similarity since this equation does not have the nice properties of the equation of normalized cuts.

B

BAcut

A

BAcut ),(),(

Page 90: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Other methods

Page 91: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Other methods

20 points are randomly distributed from 0.0 to 0.512 points are randomly distributed from 0.65 to 1.0

Normalized cut

Average cut

Average association

Page 92: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Other methods

20 points are randomly distributed from 0.0 to 0.512 points are randomly distributed from 0.65 to 1.0

Normalized cut

Average cut

Average association

Page 93: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Other methods

20 points are randomly distributed from 0.0 to 0.512 points are randomly distributed from 0.65 to 1.0

Normalized cut

Average cut

Average association

Page 94: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Spectral Clustering for Image Segmentation

Good news:

Simple and powerful methods to segment images.

Flexible and easy to apply to other clustering problems.

Bad news:

High memory requirements (use sparse matrices).

Very dependant on the scale factor for a specific problem.

2

2

2)()(

),( X

ji XX

ejiW

Page 95: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Examples

2

2

2)()(

,X

ji XX

ji ew

Spectral Clutering

Images from Matthew Brand (TR-2002-42)

Page 96: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Spectral clustering

Makes use of the spectrum of the similarity matrix of the data to cluster the points.

Solve clustering for

affinity matrix

w(i,j) distance node i to node j

Page 97: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Graph terminologySimilarity matrix: Degree of node:

j

jii wd , jiwW ,

Volume of set: Graph cuts:

Page 98: Principal Video Shot: Linking Low-level Perceptual ... · VC 14/15 - TP9 - Region-Based Segmentation R 1 R 3 R 2 R 4 R 6 R 5 R 7. Basic Formulation Let R represent the entire image

Normalized cuts results