Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm...

44
Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory

Transcript of Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm...

Page 1: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Graph-Cut Algorithm with Appli-cation to Computer VisionPresented by Yongsub Lim

Applied Algorithm Laboratory

Page 2: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 2

Contents

• Image Labeling Problem

• Maxflow-Mincut Theorem (remind)

• Energy Minimization Problem–Graph Construction

• Conclusion

• Our Related Work

Page 3: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 3

Image Labeling Problem

• We want to identify an object in an image

• It can be done by labeling a binary value, 0 or 1, to each pixel

• The goal is to find a labeling minimizing an energy function defined on an image, it is generally NP-Hard

Page 4: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 4

Image Labeling Problem

Page 5: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 5

Maxflow-Mincut Theorem

• Given a directed graph• Definition (Graph-Cut). Two disjoint sub-

sets of nodes such that• s-t cut has a node s in S and t in T• Min-cut is a cut minimizing the capacity

TS and

),( EVG

VTS

TvSu

vuwTSc,

),(),(

Page 6: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 6

Maxflow-Mincut Theorem

• Definition (Flow Network). A directed graph with a source and a sink where an edge has nonnegative capacity

• Definition (Flow). A real-valued function that satisfies the following constraints

–Capacity Constraint: for all –Skew Symmetry: for all–Flow Conservation: for all

),(),(,, vucvufVvu

),(),(,, uvfvufVvu

u ofneighbor

0),(},,{\v

vuftsVu where s is a source and t is a sink

f

Page 7: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 7

Maxflow-Mincut Theorem

• t• s

• 1/2

• 2/5

• 0/4

• 2/2

• 1/5

• 0/3

• 3/3

Page 8: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 8

Maxflow-Mincut Theorem

• The value of , , is

• Maxflow-Mincut Theorem. If is a maxi-mum flow, where is a s-t min-cut

• Thus, we can find a min-cut in graphs by solving the max-flow problem

f

f

sv

vsf of neighbors

),(

|| f

),(|| TScf ),( TS

Page 9: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 9

Maxflow-Mincut Theorem

s

t

100100

100

1

100

1

100100

3

This line deter-minesmin-cut and max-flow, too

Page 10: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 10

Energy Minimization Problem

• To minimize an energy function defined on a pixel-grid graph

• Definition (Submodular). is a submodular function if

Evu

vuuvVv

vv xxxxH),(

),()()(

2}1,0{:

)0,1()1,0()1,1()0,0(

Page 11: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 11

Energy Minimization Problem

• When all pairwise functions ‘s are sub-modular, we can find a labeling minimiz-ing by a Min-Cut of the graphH

uv

Evu

vuuvVv

vv xxxxH),(

),()()(

all of these are submodular

Page 12: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 12

Energy Minimization Problem

0 0 0

1 1 1

1 0 1

Min-Cut

Page 13: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 13

Energy Minimization Problem

• Our goal is to find a binary labeling minimiz-ing an energy function defined on a pixel-grid graph

• An labeling minimizing an energy function is found using a min-cut

• By Maxflow-Mincut theorem, we can com-pute a min-cut using the max-flow algorithm

Page 14: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 14

Graph Construction

• Remaining is how we construct a graph from given an energy function and an im-age

• We should define sets of nodes and edges, and weights of edges

Page 15: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 15

Graph Construction

• A set of nodes–Nodes each of which corresponds to each pixel, a

source and a sink

• A set of edges–If two pixels are adjacent, there is a bidirectional

edge between corresponding nodes–Edges from a source to all nodes except a sink–Edges from all nodes except a source to a sink

Page 16: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 16

Graph Constructions

t

Page 17: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 17

Graph Construction

• Defining weights

• Assume that there is a two-pixel image

4)1(,3)0(

2)1(,1)0(

22

11

xx

xx

7)1,1(,8)0,1(

5)1,0(,3)0,0(

2121

2121

xxxx

xxxx

Evu

vuuvVv

vv xxxxH),(

),()()(

Page 18: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 18

Graph Construction

21212121

221121

7385

432),(

xxxxxxxx

xxxxxxE

4)1(,3)0(

2)1(,1)0(

22

11

xx

xx

7)1,1(,8)0,1(

5)1,0(,3)0,0(

2121

2121

xxxx

xxxx

Page 19: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 19

Graph Construction

4)1(,3)0(

2)1(,1)0(

22

11

xx

xx

7)1,1(,8)0,1(

5)1,0(,3)0,0(

2121

2121

xxxx

xxxx

121 ),( xxxE

s

t

1x 2x

1

Page 20: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 20

Graph Construction

4)1(,3)0(

2)1(,1)0(

22

11

xx

xx

7)1,1(,8)0,1(

5)1,0(,3)0,0(

2121

2121

xxxx

xxxx

1121 2),( xxxxE

s

t

1x 2x

1

2

Page 21: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 21

Graph Construction

4)1(,3)0(

2)1(,1)0(

22

11

xx

xx

7)1,1(,8)0,1(

5)1,0(,3)0,0(

2121

2121

xxxx

xxxx

221121 432),( xxxxxxE

3

s

t

1x 2x

1

2 4

Page 22: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 22

Graph Construction

4)1(,3)0(

2)1(,1)0(

22

11

xx

xx

7)1,1(,8)0,1(

5)1,0(,3)0,0(

2121

2121

xxxx

xxxx

2121221121 85432),( xxxxxxxxxxE

s

t

1x 2x

1 3

2 45

8

Page 23: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 23

Graph Construction

4)1(,3)0(

2)1(,1)0(

22

11

xx

xx

7)1,1(,8)0,1(

5)1,0(,3)0,0(

2121

2121

xxxx

xxxx

Note that21221121

21221121

xxxxxxxx

xxxxxxxx

Now, we can embed all terms of an energy function to a graph as weights

Page 24: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 24

Graph Construction

• Finally we get the following graph

s

t

1x 2x

c d

a be

f

Page 25: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 25

Graph Construction

• We need two verifications

• We should verify that the capacity of a s-t min-cut is same with the minimum energy

• And that all weights are non-negative for the max-flow algorithm

Page 26: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 26

Graph Construction

s

t

1x 2x

)1(1x

)0(1x

)1(2x

)0(2x

)1,0(21xx

)0,1(21xx

21212121221121 7853432),( xxxxxxxxxxxxxxE

The graph, which we construct, has a s-t min-cut capacity same with the minimum of an energy function

Page 27: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 27

Graph Construction

s

t

1x 2x

)1(1x

)0(1x

)1(2x

)0(2x

)1,0(21xx

)0,1(21xx

21212121221121 7853432),( xxxxxxxxxxxxxxE

The graph, which we construct, has a s-t min-cut capacity same with the minimum of an energy function

Page 28: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 28

Graph Construction

s

t

1 1

)1(1x

)0(1x

)1(2x

)0(2x

)1,0(21xx

)0,1(21xx

21212121221121 7853432),( xxxxxxxxxxxxxxE

The graph, which we construct, has a s-t min-cut capacity same with the minimum of an energy function

Page 29: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 29

Graph Construction

s

t

1 1

)1(1x

)0(1x

)1(2x

)0(2x

)1,0(21xx

)0,1(21xx

21212121221121 7853432),( xxxxxxxxxxxxxxE

The graph, which we construct, has a s-t min-cut capacity same with the minimum of an energy function

7 where

)(

)(7

21

2122

211121

nn

xxxn

xxxnxx

Page 30: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 30

Graph Construction

s

t

1x 2x

)1(1x

)0(1x

)1(2x

)0(2x

)1,0(21xx

)0,1(21xx

21212121221121 7853432),( xxxxxxxxxxxxxxE

The graph, which we construct, has a s-t min-cut capacity same with the minimum of an energy function

Page 31: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 31

Graph Construction

s

t

0 1

)1(1x

)0(1x

)1(2x

)0(2x

)1,0(21xx

)0,1(21xx

21212121221121 7853432),( xxxxxxxxxxxxxxE

The graph, which we construct, has a s-t min-cut capacity same with the minimum of an energy function

Page 32: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 32

Graph Construction

s

t

0 1

)1(1x

)0(1x

)1(2x

)0(2x

)1,0(21xx

)0,1(21xx

21212121221121 7853432),( xxxxxxxxxxxxxxE

The graph, which we construct, has a s-t min-cut capacity same with the minimum of an energy function

Page 33: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 33

Graph Construction

• Are all weights non-negative?

• First, weights from unary terms may nega-tive

• It does not change a minimum labeling even if we add a constant term to the en-ergy function

4)1(,3)0(

2)1(,1)0(

22

11

xx

xx

7)1,1(,8)0,1(

5)1,0(,3)0,0(

2121

2121

xxxx

xxxx

Page 34: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 34

Graph Construction

s

t

1x 2x

c d

a be

f

)(xE

b or d is negative

Page 35: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 35

Graph Construction

• Second, weights from pairwise terms are always non-negative because of the sub-modularity

4)1(,3)0(

2)1(,1)0(

22

11

xx

xx

7)1,1(,8)0,1(

5)1,0(,3)0,0(

2121

2121

xxxx

xxxx

Page 36: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 36

Graph Construction

2122112121 xxkxxkxnxxxm

nnnmmm

xxxnxxxnxnx

xxxmxxxmxxm

2121

2122211121

2122211121

and where

)( )(

)( )(

2122221111 )()( xxnmkxxnmk

Page 37: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 37

Graph Construction

2122112121 xxkxxkxnxxxm

itysubmodularby 21 kknm

2122221111 )()( xxnmkxxnmk

2121 and where nnnmmm

11111 such that and fix We knmnm

222Then knm ∴ All of weights from pairwise terms are always non-negative

Page 38: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 38

Graph Construction

• All of weights are non-negative• We can compute a min-cut through

Maxflow-Mincut Theorem• And obtain a labeling minimizing an en-

ergy functions

t

1x 2x

c d

a be

f

Page 39: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 39

Conclusion

• Given an energy function defined on an image

• Minimizing is generally NP-Hard• For the class of energy functions whose

pairwise functions are all submodular, we can compute a minimum labeling through a graph min-cut in polynomial time

Evu

vuuvVv

vv xxxxH),(

),()()(

H

Page 40: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 40

Our Related Work

• We want a minimum labeling with fixed 1’s

–Label count = # of 1’s labeled

• Previous work computes minimum label-ing for some label counts

• Our recent work computes approximate minimum labeling for almost all label counts (submitted to CVPR10)

Page 41: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 41

Our Related Work

original Nodecomposition

3x3decomposition

5x5decomposition

Used image is of size 300x300. Results for label count 54118.

Page 42: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 42

Our Related Work

No decomposition 3x3 decomposition 5x5 decomposition

The average energy value 1 1.00141 1.00308

The number of label counts 0.176454 0.998678 0.9999944

Page 43: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 43

Q&A

Page 44: Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.

Applied Algorithm Laboratory, KAIST 44

Thanks