Images as graphs

54
i Images as graphs Fully-connected graph node for every pixel link between every pair of pixels, p,q similarity w ij for each link j w ij c Source: Seitz

description

Images as graphs. Fully-connected graph node for every pixel link between every pair of pixels, p , q similarity w ij for each link. i. w ij. c. j. Source: Seitz. Segmentation by Graph Cuts. w. Break Graph into Segments Delete links that cross between segments - PowerPoint PPT Presentation

Transcript of Images as graphs

Page 1: Images as graphs

i

Images as graphs

• Fully-connected graph– node for every pixel– link between every pair of pixels, p,q– similarity wij for each link

j

wijc

Source: Seitz

Page 2: Images as graphs

Segmentation by Graph Cuts

• Break Graph into Segments– Delete links that cross between segments– Easiest to break links that have low cost (low similarity)

• similar pixels should be in the same segments• dissimilar pixels should be in different segments

w

A B C

Source: Seitz

Page 3: Images as graphs
Page 4: Images as graphs

Cuts in a graph

• Link Cut– set of links whose removal makes a graph disconnected– cost of a cut:

A B

One idea: Find minimum cut• gives you a segmentation• fast algorithms exist for doing this

Source: Seitz

Page 5: Images as graphs

But min cut is not always the best cut...

Page 6: Images as graphs

Cuts in a graph

A B

Normalized Cut• a cut penalizes large segments• fix by normalizing for size of segments

• volume(A) = sum of costs of all edges that touch A

Source: Seitz

Page 7: Images as graphs

7

Finding Minimum Normalized-Cut• Finding the Minimum Normalized-Cut is NP-Hard.• Polynomial Approximations are generally used for

segmentation

* Slide from Khurram Hassan-Shafique CAP5415 Computer Vision 2003

Page 8: Images as graphs

8

Finding Minimum Normalized-Cut

wherematrix, symmetric NNW

otherwise0 if,

22

iNjeejiWXjiFji XXFF

Proximity Spatial

similarity feature Image

ji

ji

XX

FF

wherematrix, diagonal NND j

jiWiiD ,,

* From Khurram Hassan-Shafique CAP5415 Computer Vision 2003

Page 9: Images as graphs

9

• It can be shown that

such that

• If y is allowed to take real values then the minimization can be done by solving the generalized eigenvalue system

Finding Minimum Normalized-Cut

Dyy

yWDyT

T

y

minmin cutN

0 and ,10 ,,1 D1yTbbiy

DyyWD

* Slide from Khurram Hassan-Shafique CAP5415 Computer Vision 2003

Page 10: Images as graphs

10

Algorithm

• Compute matrices W & D• Solve for eigen vectors with the smallest eigen

values• Use the eigen vector with second smallest eigen value to

bipartition the graph• Recursively partition the segmented parts if necessary.

DyyWD

* Slide from Khurram Hassan-Shafique CAP5415 Computer Vision 2003

Page 11: Images as graphs

Recursive normalized cuts1. Given an image or image sequence, set up a weighted

graph: G=(V, E)– Vertex for each pixel– Edge weight for nearby pairs of pixels

2. Solve for eigenvectors with the smallest eigenvalues: (D − W)y = λDy

– Use the eigenvector with the second smallest eigenvalue to bipartition the graph

– Note: this is an approximation

4. Recursively repartition the segmented parts if necessary

http://www.cs.berkeley.edu/~malik/papers/SM-ncut.pdfDetails:

Page 12: Images as graphs

Normalized cuts results

Page 13: Images as graphs

Graph cuts segmentation

Page 14: Images as graphs
Page 15: Images as graphs
Page 16: Images as graphs
Page 17: Images as graphs
Page 18: Images as graphs
Page 19: Images as graphs
Page 20: Images as graphs
Page 21: Images as graphs
Page 22: Images as graphs
Page 23: Images as graphs

Markov Random Fields

edgesji

jii

i datayydataydataEnergy,

21 ),;,(),;(),;( y

Node yi: pixel label

Edge: constrained pairs

Cost to assign a label to each pixel

Cost to assign a pair of labels to connected pixels

Page 24: Images as graphs

Solving MRFs with graph cuts

edgesji

jii

i datayydataydataEnergy,

21 ),;,(),;(),;( y

Source (Label 0)

Sink (Label 1)

Cost to assign to 0

Cost to assign to 1

Cost to split nodes

Page 25: Images as graphs

Solving MRFs with graph cuts

edgesji

jii

i datayydataydataEnergy,

21 ),;,(),;(),;( y

Source (Label 0)

Sink (Label 1)

Cost to assign to 0

Cost to assign to 1

Cost to split nodes

Page 26: Images as graphs
Page 27: Images as graphs
Page 28: Images as graphs

Graph cuts Boykov and Jolly (2001)

Image Min Cut

Cut: separating source and sink; Energy: collection of edges

Min Cut: Global minimal enegry in polynomial time

Foreground (source)

Background(sink)

Source: Rother

Page 29: Images as graphs

Optimization Formulation - Boykov & Jolly ‘01

A – Proposed Segmentation

E(A) – Overall Energy R(A) – Degree to which

pixels fits model B(A) – Degree to which

the cuts breaks up similar pixels

- Balance A() and B()• Goal: Find Segmentation,

A, which minimizes E(A) 30

Page 30: Images as graphs

Link Weights

• Pixel links based on color/intensity similarities

• Source/Target links based on histogram models of fore/background

31

Page 31: Images as graphs
Page 32: Images as graphs

Grab cuts and graph cuts

User Input

Result

Magic Wand (198?)

Intelligent ScissorsMortensen and Barrett (1995)

GrabCut

Regions Boundary Regions & Boundary

Source: Rother

Page 33: Images as graphs
Page 34: Images as graphs
Page 35: Images as graphs
Page 36: Images as graphs
Page 37: Images as graphs
Page 38: Images as graphs
Page 39: Images as graphs
Page 40: Images as graphs

Colour Model

Gaussian Mixture Model (typically 5-8 components)

Foreground &Background

Background

Foreground

BackgroundG

R

G

RIterated graph cut

Source: Rother

Page 41: Images as graphs
Page 42: Images as graphs
Page 43: Images as graphs
Page 44: Images as graphs
Page 45: Images as graphs

Moderately straightforward

examples

… GrabCut completes automatically GrabCut – Interactive Foreground Extraction 10

Page 46: Images as graphs

Difficult Examples

Camouflage & Low Contrast Harder CaseFine structure

Initial Rectangle

InitialResult

GrabCut – Interactive Foreground Extraction 11

Page 47: Images as graphs

Border Matting

Hard Segmentation Automatic Trimap Soft Segmentation

GrabCut – Interactive Foreground Extraction 23

to

Page 48: Images as graphs

Input Bayes MattingChuang et. al. (2001)

Knockout 2Photoshop Plug-In

Comparison

GrabCut – Interactive Foreground Extraction 24

With no regularisation over alpha

Shum et. al. (2004): Coherence matting in “Pop-up light fields”

Page 49: Images as graphs

Solve

Mean Colour Foreground

Mean ColourBackground

GrabCut – Interactive Foreground Extraction 25

Natural Image Matting

Ruzon and Tomasi (2000): Alpha estimation in natural images

Page 50: Images as graphs
Page 51: Images as graphs

Noisy alpha-profile

Border Matting

GrabCut – Interactive Foreground Extraction 26

1

0

Foreground

Mix

Back-ground

Foreground Mix Background

Fit a smooth alpha-profile with parameters

Page 52: Images as graphs

Result using DP Border Matting

DP

t

Dynamic Programming

GrabCut – Interactive Foreground Extraction 27

Noisy alpha-profile Regularisation

t+1

Page 53: Images as graphs

GrabCut Border Matting - Colour

Compute MAP of p(F|C,alpha) (marginalize over B)

To avoid colour bleeding use colour stealing (“exemplar based inpainting” – Patches do not work)

[Chuang et al. ‘01] Grabcut Border Matting

GrabCut – Interactive Foreground Extraction 28

Page 54: Images as graphs

Results

GrabCut – Interactive Foreground Extraction 29