Max Flow. Lecture 4. Optimization on graphs. C25 Optimization Hilary 2013 A. Zisserman. Max-flow & min-cut. The augmented path algorithm



Similar documents
Lecture 3. Linear Programming. 3B1B Optimization Michaelmas 2015 A. Zisserman. Extreme solutions. Simplex method. Interior point method

Network Flow I. Lecture Overview The Network Flow Problem

Proximal mapping via network optimization

5.1 Bipartite Matching

Lecture 2: The SVM classifier

Max Flow, Min Cut, and Matchings (Solution)

Dynamic Programming and Graph Algorithms in Computer Vision

Algorithm Design and Analysis

Class One: Degree Sequences

Approximation Algorithms

Social Media Mining. Graph Essentials

The Binary Blocking Flow Algorithm. Andrew V. Goldberg Microsoft Research Silicon Valley goldberg/

Distributed Computing over Communication Networks: Topology. (with an excursion to P2P)

An Experimental Comparison of Min-Cut/Max-Flow Algorithms for Energy Minimization in Vision

CS 598CSC: Combinatorial Optimization Lecture date: 2/4/2010

Linear Programming I

Automatic Reconstruction of Parametric Building Models from Indoor Point Clouds. CAD/Graphics 2015

Minimum cost maximum flow, Minimum cost circulation, Cost/Capacity scaling

Data Structures and Algorithms Written Examination

Solving NP Hard problems in practice lessons from Computer Vision and Computational Biology

DATA ANALYSIS II. Matrix Algorithms

Image Segmentation and Registration

Linear Programming Problems

Social and Technological Network Analysis. Lecture 3: Centrality Measures. Dr. Cecilia Mascolo (some material from Lada Adamic s lectures)

The Binary Blocking Flow Algorithm. Andrew V. Goldberg Microsoft Research Silicon Valley goldberg/

Outline. NP-completeness. When is a problem easy? When is a problem hard? Today. Euler Circuits

SPERNER S LEMMA AND BROUWER S FIXED POINT THEOREM

A Practical Scheme for Wireless Network Operation

Euler Paths and Euler Circuits

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. !-approximation algorithm.

Lecture 4: BK inequality 27th August and 6th September, 2007

Linear Programming. Widget Factory Example. Linear Programming: Standard Form. Widget Factory Example: Continued.

Why? A central concept in Computer Science. Algorithms are ubiquitous.

Lecture 7: NP-Complete Problems

The Goldberg Rao Algorithm for the Maximum Flow Problem

NP-Completeness I. Lecture Overview Introduction: Reduction and Expressiveness

Chapter 10: Network Flow Programming

Binary Image Reconstruction

Step 3: Go to Column C. Use the function AVERAGE to calculate the mean values of n = 5. Column C is the column of the means.

A Network Flow Approach in Cloud Computing

Scheduling Shop Scheduling. Tim Nieberg

Social Media Mining. Network Measures

2.3 Convex Constrained Optimization Problems

Graph Cuts in Vision and Graphics: Theories and Applications

Graph Mining and Social Network Analysis

Seminar. Path planning using Voronoi diagrams and B-Splines. Stefano Martina

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. #-approximation algorithm.

LABEL PROPAGATION ON GRAPHS. SEMI-SUPERVISED LEARNING. ----Changsheng Liu

BOUNDARY EDGE DOMINATION IN GRAPHS

Lecture 15 An Arithmetic Circuit Lowerbound and Flows in Graphs

Arrangements And Duality

SYSM 6304: Risk and Decision Analysis Lecture 5: Methods of Risk Analysis

Equilibrium computation: Part 1

Linear Programming Notes V Problem Transformations

Environmental Remote Sensing GEOG 2021

Linear programming and reductions

Algorithms and Data Structures

Zeros of Polynomial Functions

Network Design with Coverage Costs

ALGEBRA 2 CRA 2 REVIEW - Chapters 1-6 Answer Section

Labeling outerplanar graphs with maximum degree three

Introduction to Deep Learning Variational Inference, Mean Field Theory

NP-Hardness Results Related to PPAD

JUST-IN-TIME SCHEDULING WITH PERIODIC TIME SLOTS. Received December May 12, 2003; revised February 5, 2004

Signature Segmentation from Machine Printed Documents using Conditional Random Field

Probabilistic Latent Semantic Analysis (plsa)

Blind Deconvolution of Barcodes via Dictionary Analysis and Wiener Filter of Barcode Subsections

Robert Collins CSE598G. More on Mean-shift. R.Collins, CSE, PSU CSE598G Spring 2006

Machine vision systems - 2

On the effect of forwarding table size on SDN network utilization

Performance of networks containing both MaxNet and SumNet links

COUNTING INDEPENDENT SETS IN SOME CLASSES OF (ALMOST) REGULAR GRAPHS

Complexity Theory. IE 661: Scheduling Theory Fall 2003 Satyaki Ghosh Dastidar

How To Solve The Line Connectivity Problem In Polynomatix

Distributed Structured Prediction for Big Data

(67902) Topics in Theory and Complexity Nov 2, Lecture 7

Lecture 17 : Equivalence and Order Relations DRAFT

How To Cluster Of Complex Systems

EE602 Algorithms GEOMETRIC INTERSECTION CHAPTER 27

A Branch and Bound Algorithm for Solving the Binary Bi-level Linear Programming Problem

Bandwidth Allocation in a Network Virtualization Environment

APPROXIMATION OF FRAME BASED MISSING DATA RECOVERY

Colour Image Segmentation Technique for Screen Printing

Lecture 2.1 : The Distributed Bellman-Ford Algorithm. Lecture 2.2 : The Destination Sequenced Distance Vector (DSDV) protocol

The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge,

Follow the Perturbed Leader

Lecture 1: Course overview, circuits, and formulas

3. Evaluate the objective function at each vertex. Put the vertices into a table: Vertex P=3x+2y (0, 0) 0 min (0, 5) 10 (15, 0) 45 (12, 2) 40 Max

8.1 Min Degree Spanning Tree

Fairness in Routing and Load Balancing

Line and Polygon Clipping. Foley & Van Dam, Chapter 3

Proceedings of International Conference on Computer Vision (ICCV), Sydney, Australia, Dec p.1. GrabCut in One Cut

Transcription:

Lecture 4 C5 Optimization Hilary 03 A. Zisserman Optimization on graphs Max-flow & min-cut The augmented path algorithm Optimization for binary image graphs Applications Max Flow Given: a weighted directed graph with two distinguished nodes: source s, sink (destination) t B reminder Interpret edge weights (all positive) as capacities Goal: Find maximum flow from s to t Flow does not exceed capacity in any edge Flow at every vertex satisfies equilibrium [ flow in equals flow out ] e.g. oil flowing through pipes, internet routing

Example 3 cont. B reminder Slide: Robert Sedgewick and Kevin Wayne Example cont. B reminder

Max flow example 3 S T max flow is unique = but there may be multiple paths (solutions) that achieve it Matlab LP function linprog for max-flow >> f = [ -; -; 0; 0; 0 ]; >> A = [ e e e 3 e 4 e 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ]; >> b = [; ; ; 3; ]; >> Aeq = [ >> beq = [ 0; 0 ]; >> lb = zeros(5,); 0 - - 0 0 0 -]; >> x = linprog( f, A, b, Aeq, beq, lb ); 3 e e 4 S e 3 T e e 5 >> Optimization terminated. >> x x =.0.0 0.0.0.0 >> flow = - x * f flow =.0

Another example 9 / 5/9 / v v 5 4 v v 3/5 3 4/4 Max Flow = 7 The st-mincut Problem An st-cut (S,T) divides the nodes between source and sink 9 The cost of the cut is the sum of costs of all edges going from S to T v v 5 4 The st-min-cut is the cut with lowest cost Each node is either assigned to the source S or sink T The cost of the edge (i, j) is taken if (i S) and (j T) Slides from Pushmeet Kohli

The st-mincut Problem An st-cut (S,T) divides the nodes between source and sink 9 The cost of the cut is the sum of costs of all edges going from S to T v v 5 4 The st-min-cut is the cut with lowest cost Each node is either assigned to the source S or sink T 5 + + 9 = 6 The cost of the edge (i, j) is taken if (i S) and (j T) The st-mincut Problem An st-cut (S,T) divides the nodes between source and sink 9 The cost of the cut is the sum of costs of all edges going from S to T v v 5 4 The st-min-cut is the cut with lowest cost Each node is either assigned to the source S or sink T + + 4 = 7 The cost of the edge (i, j) is taken if (i S) and (j T)

Min-cut\Max-flow Theorem 9 v v 5 4 In every network, the maximum flow equals the cost of the st-mincut Max flow = min cut = 7 Next: the augmented path algorithm for computing the max-flow/min-cut Maxflow Algorithms v v 5 Flow = 0 9 4 Augmenting Path Based Algorithms. Find path from source to sink with positive capacity. Push maximum possible flow through this path 3. Repeat until no path can be found Algorithms assume non-negative capacity

Maxflow Algorithms v v 5 Flow = 0 9 4 Augmenting Path Based Algorithms. Find path from source to sink with positive capacity. Push maximum possible flow through this path 3. Repeat until no path can be found Algorithms assume non-negative capacity Maxflow Algorithms - 9 v v 5- Flow = 0 + 4 Augmenting Path Based Algorithms. Find path from source to sink with positive capacity. Push maximum possible flow through this path 3. Repeat until no path can be found Algorithms assume non-negative capacity

Maxflow Algorithms 0 9 v v 3 Flow = 4 Augmenting Path Based Algorithms. Find path from source to sink with positive capacity. Push maximum possible flow through this path 3. Repeat until no path can be found Algorithms assume non-negative capacity Maxflow Algorithms 0 9 v v 3 Flow = 4 Augmenting Path Based Algorithms. Find path from source to sink with positive capacity. Push maximum possible flow through this path 3. Repeat until no path can be found Algorithms assume non-negative capacity

Maxflow Algorithms 0 9 v v 3 Flow = 4 Augmenting Path Based Algorithms. Find path from source to sink with positive capacity. Push maximum possible flow through this path 3. Repeat until no path can be found Algorithms assume non-negative capacity Maxflow Algorithms 0 5 v v 3 Flow = + 4 0 Augmenting Path Based Algorithms. Find path from source to sink with positive capacity. Push maximum possible flow through this path 3. Repeat until no path can be found Algorithms assume non-negative capacity

Maxflow Algorithms 0 5 v v 3 Flow = 6 0 Augmenting Path Based Algorithms. Find path from source to sink with positive capacity. Push maximum possible flow through this path 3. Repeat until no path can be found Algorithms assume non-negative capacity Maxflow Algorithms 0 5 v v 3 Flow = 6 0 Augmenting Path Based Algorithms. Find path from source to sink with positive capacity. Push maximum possible flow through this path 3. Repeat until no path can be found Algorithms assume non-negative capacity

Maxflow Algorithms 0 4 - v v Flow = 6 + + 0 Augmenting Path Based Algorithms. Find path from source to sink with positive capacity. Push maximum possible flow through this path 3. Repeat until no path can be found Algorithms assume non-negative capacity Maxflow Algorithms 0 4 0 v v Flow = 7 3 0 Augmenting Path Based Algorithms. Find path from source to sink with positive capacity. Push maximum possible flow through this path 3. Repeat until no path can be found Algorithms assume non-negative capacity

Maxflow Algorithms Flow = 7 Min cut = 7 0 4 9 0 v v 3 0 v v 5 4 + + 4 = 7 Image Graphs many loops very large number of nodes (variables) millions dynamic programming can t be used Consider binary graphs (h = ) pixels

Example: noise removal in an image N (i) i j n is the number of pixels in the image, e.g. n = M Graph structure: each vertex is connected to four neighbours noisy data z i = x i + w i where x i {0, } w i N(0, σ ) and φ(x i,x j ) = ( 0 ifxi = x j ifx i 6= x j. 0 i f(x) = X i (z i x i ) +dφ(x i,x i ) Graph cut algorithms Binary optimization: each variable x has one of two possible values f(x) = nx {m i (x i )+ X φ i (x i,x j )} i= j N (i) x i {0, } N (i) is the neighbourhood of node i i The cost function f(x) issub-modularif φ(0, 0) + φ(, ) <= φ(0, ) + φ(, 0) If f(x) is sub-modular, then it can be optimized by the Min-Cut algorithm Complexity of minimization: exhaustive search O( n ) min cut O(n 3 )

d = 0 original 0 40 60 0 40 60 80 00 0 40 60 80 00 0 original plus noise 0 40 60 0 40 60 80 00 0 40 60 80 00 0 Min x 0 40 60 0 40 60 80 00 0 40 60 80 00 0 d = 60 original 0 40 60 0 40 60 80 00 0 40 60 80 00 0 original plus noise 0 40 60 0 40 60 80 00 0 40 60 80 00 0 Min x 0 40 60 0 40 60 80 00 0 40 60 80 00 0 n 0 K

Optimization using graph cuts Stage : map the cost function f(x) onto a flow network so that a cut of the network corresponds to the cost f(x) Stage : compute the min-cut of the network using an augmented path algorithm Map f(x) onto network flow Construct a network so that a cut corresponds to an assignment of x i m () D Label m () C B Label 0 m (0) m A (0) s n-links w pq = 0 a cut x x t = f(x) = nx {m i (x i )+ X φ i (x i,x j )} i= j N (i)

m () D m () C B m (0) m A (0) x x For unary terms only: m () x m (0) (0) m () m (0) () x (0) m () m () cut x =,x = x x m (0) m (0) f(x) =m () + m () () Now, include pair wise term D m () m () C B m (0) m (0) A (0) m () + C - A m () + D - C B+C-A-D x x x x m (0) m (0) x () 0 0 0 0 x 0 A C B D = A + B+C 0 0 0 0 0 D-C 0 0 -A-D + + C-A C-A 0 D-C 0 0 add C-A if x = add D-C if x = Sub-modular constraint: flows must be positive. So, B+C-A-D >= 0

m () m (0) C D A B x x (0) m () + C - A m () + D - C cut B+C-A-D x x x =,x = m (0) m (0) () f(x) =m () + m () + D A m () m (0) C D A B x x (0) m () + C - A m () + D - C cut x =0,x = B+C-A-D x x f(x) = m (0) + m () m (0) m (0) () +D C + B + C A D = m (0) + m () + B A

Summary: optimization using graph cuts Stage : map the cost function f(x) onto a flow network so that a cut of the network corresponds to the cost f(x) Stage : compute the min-cut of the network using an augmented path algorithm Applications Optimization of binary image graph using graph-cuts:. Image cut-out and editing. Image quilting 3. Interactive Digital Photo-montage

. Image cut-out by binary segmentation Object - white, Background - green/grey Graph G = (V,E) Each vertex corresponds to a pixel Edges define a 4-neighbourhood grid graph Assign a label to each vertex from L = {obj,bkg}

Object - white, Background - green/grey Cost of a labelling f : V L Cost of label obj low Graph G = (V,E) Per Vertex Cost Cost of label bkg high Object - white, Background - green/grey Cost of a labelling f : V L Graph G = (V,E) Per Vertex Cost Cost of label obj high UNARY COST Cost of label bkg low

Object - white, Background - green/grey Cost of a labelling f : V L Graph G = (V,E) Per Edge Cost Cost of same label low Cost of different labels high Object - white, Background - green/grey Cost of a labelling f : V L Graph G = (V,E) Per Edge Cost Cost of different labels low PAIRWISE COST

Object - white, Background - green/grey Graph G = (V,E) Problem: Find the labelling with minimum cost f* N (i) i j f(x) = nx {m i (x i )+ X φ i (x i,x j )} i= j N (i) x i = for foreground pixels, x i = 0 for background m i (x i ) is likelihood that pixel at i is foreground (if x i =),orbackground (if x i = 0 ), e.g. using colour histogram of seed regions φ(x i,x j ) penalizes a change of state: φ i (x i,x j ) = ( 0 ifxi = x j γe β(i i I j ) ifx i 6= x j.

Application: foreground/background image segmentation foreground Seed Pixels Background Seed Pixels use seed pixels to learn colour distribution Image editing Available in Microsoft Office

Image Quilting Example: Texture Synthesis Goal of Texture Synthesis: create new samples of a given texture Many applications: virtual environments, hole-filling, texturing surfaces

block Input texture B B B B B B Random placement of blocks Neighboring blocks constrained by overlap Minimal error boundary cut Algorithm Pick size of block and size of overlap Synthesize blocks in raster order Search input texture for block that satisfies overlap constraints (above and left) Paste new block into resulting texture > use graph cuts to compute minimal error boundary cut Efros & Freeman 00, Kwatra et al. 003

Minimal error boundary overlapping blocks vertical boundary _ = overlap error min. error boundary

Interactive Digital Photomontage

Agarwala et al. 004 Use graph-cuts to quilt images