Machine Learning – Lecture 15

Slides:



Advertisements
Similar presentations
Algorithms for MAP estimation in Markov Random Fields Vladimir Kolmogorov University College London Tutorial at GDR (Optimisation Discrète, Graph Cuts.
Advertisements

1 LP, extended maxflow, TRW OR: How to understand Vladimirs most recent work Ramin Zabih Cornell University.
Linear Time Methods for Propagating Beliefs Min Convolution, Distance Transforms and Box Sums Daniel Huttenlocher Computer Science Department December,
Variational Methods for Graphical Models Micheal I. Jordan Zoubin Ghahramani Tommi S. Jaakkola Lawrence K. Saul Presented by: Afsaneh Shirazi.
Introduction to Markov Random Fields and Graph Cuts Simon Prince
Exact Inference in Bayes Nets
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:
The University of Ontario CS 4487/9687 Algorithms for Image Analysis Multi-Label Image Analysis Problems.
ICCV 2007 tutorial on Discrete Optimization Methods in Computer Vision part I Basic overview of graph cuts.
EE462 MLCV Lecture Introduction of Graphical Models Markov Random Fields Segmentation Tae-Kyun Kim 1.
Graph-Based Image Segmentation
1 s-t Graph Cuts for Binary Energy Minimization  Now that we have an energy function, the big question is how do we minimize it? n Exhaustive search is.
Graph-based image segmentation Václav Hlaváč Czech Technical University in Prague Faculty of Electrical Engineering Department of Cybernetics Prague, Czech.
Chapter 8-3 Markov Random Fields 1. Topics 1. Introduction 1. Undirected Graphical Models 2. Terminology 2. Conditional Independence 3. Factorization.
GS 540 week 6. HMM basics Given a sequence, and state parameters: – Each possible path through the states has a certain probability of emitting the sequence.
Perceptual and Sensory Augmented Computing Machine Learning, Summer’09 Machine Learning – Lecture 15 Applications of Bayesian Networks Bastian.
Optimal solution of binary problems Much material taken from :  Olga Veksler, University of Western Ontario
Robust Higher Order Potentials For Enforcing Label Consistency
P 3 & Beyond Solving Energies with Higher Order Cliques Pushmeet Kohli Pawan Kumar Philip H. S. Torr Oxford Brookes University CVPR 2007.
2010/5/171 Overview of graph cuts. 2010/5/172 Outline Introduction S-t Graph cuts Extension to multi-label problems Compare simulated annealing and alpha-
Stereo & Iterative Graph-Cuts Alex Rav-Acha Vision Course Hebrew University.
Announcements Readings for today:
Stereo Computation using Iterative Graph-Cuts
Comp 775: Graph Cuts and Continuous Maximal Flows Marc Niethammer, Stephen Pizer Department of Computer Science University of North Carolina, Chapel Hill.
What Energy Functions Can be Minimized Using Graph Cuts? Shai Bagon Advanced Topics in Computer Vision June 2010.
Measuring Uncertainty in Graph Cut Solutions Pushmeet Kohli Philip H.S. Torr Department of Computing Oxford Brookes University.
Graph-Cut Algorithm with Application to Computer Vision Presented by Yongsub Lim Applied Algorithm Laboratory.
Computer vision: models, learning and inference
Graph-based Segmentation
Michael Bleyer LVA Stereo Vision
Graph Cut & Energy Minimization
Perceptual and Sensory Augmented Computing Machine Learning, WS 13/14 Machine Learning – Lecture 14 Introduction to Regression Bastian Leibe.
Perceptual and Sensory Augmented Computing Machine Learning, Summer’10 Machine Learning – Lecture 16 Approximate Inference Bastian Leibe RWTH.
MRFs and Segmentation with Graph Cuts Computer Vision CS 543 / ECE 549 University of Illinois Derek Hoiem 02/24/10.
CS774. Markov Random Field : Theory and Application Lecture 13 Kyomin Jung KAIST Oct
Planar Cycle Covering Graphs for inference in MRFS The Typhon Algorithm A New Variational Approach to Ground State Computation in Binary Planar Markov.
Interactive Graph Cuts for Optimal Boundary & Region Segmentation of Objects in N-D Images (Fri) Young Ki Baik, Computer Vision Lab.
Object Stereo- Joint Stereo Matching and Object Segmentation Computer Vision and Pattern Recognition (CVPR), 2011 IEEE Conference on Michael Bleyer Vienna.
Graph Cuts Marc Niethammer. Segmentation by Graph-Cuts A way to compute solutions to the optimization problems we looked at before. Example: Binary Segmentation.
Probabilistic Inference Lecture 3 M. Pawan Kumar Slides available online
Algorithms for MAP estimation in Markov Random Fields Vladimir Kolmogorov University College London.
1 Markov Random Fields with Efficient Approximations Yuri Boykov, Olga Veksler, Ramin Zabih Computer Science Department CORNELL UNIVERSITY.
Fast and accurate energy minimization for static or time-varying Markov Random Fields (MRFs) Nikos Komodakis (Ecole Centrale Paris) Nikos Paragios (Ecole.
Perceptual and Sensory Augmented Computing Machine Learning WS 13/14 Machine Learning – Lecture 3 Probability Density Estimation II Bastian.
Lecture 19: Solving the Correspondence Problem with Graph Cuts CAP 5415 Fall 2006.
Approximate Inference: Decomposition Methods with Applications to Computer Vision Kyomin Jung ( KAIST ) Joint work with Pushmeet Kohli (Microsoft Research)
Presenter : Kuang-Jui Hsu Date : 2011/3/24(Thur.).
Gaussian Mixture Models and Expectation-Maximization Algorithm.
Perceptual and Sensory Augmented Computing Machine Learning, WS 13/14 Machine Learning – Lecture 21 Learning Bayesian Networks & Extensions
Lecture 2: Statistical learning primer for biologists
Machine Learning – Lecture 15
Exact Inference in Bayes Nets. Notation U: set of nodes in a graph X i : random variable associated with node i π i : parents of node i Joint probability:
Pushmeet Kohli. E(X) E: {0,1} n → R 0 → fg 1 → bg Image (D) n = number of pixels [Boykov and Jolly ‘ 01] [Blake et al. ‘04] [Rother, Kolmogorov and.
CS654: Digital Image Analysis Lecture 28: Advanced topics in Image Segmentation Image courtesy: IEEE, IJCV.
A global approach Finding correspondence between a pair of epipolar lines for all pixels simultaneously Local method: no guarantee we will have one to.
Graph Algorithms for Vision Amy Gale November 5, 2002.
MAP Estimation in Binary MRFs using Bipartite Multi-Cuts Sashank J. Reddi Sunita Sarawagi Sundar Vishwanathan Indian Institute of Technology, Bombay TexPoint.
Machine Learning – Lecture 18
Perceptual and Sensory Augmented Computing Machine Learning, Summer’09 Machine Learning – Lecture 13 Exact Inference & Belief Propagation Bastian.
Today Graphical Models Representing conditional dependence graphically
Photoconsistency constraint C2 q C1 p l = 2 l = 3 Depth labels If this 3D point is visible in both cameras, pixels p and q should have similar intensities.
Markov Random Fields in Vision
Energy minimization Another global approach to improve quality of correspondences Assumption: disparities vary (mostly) smoothly Minimize energy function:
Markov Random Fields with Efficient Approximations
Exact Inference Continued
Efficient Graph Cut Optimization for Full CRFs with Quantized Edges
Discrete Inference and Learning
Haim Kaplan and Uri Zwick
Expectation-Maximization & Belief Propagation
“Traditional” image segmentation
Presentation transcript:

Machine Learning – Lecture 15 Efficient MRF Inference with Graph Cuts 23.01.2014 Bastian Leibe RWTH Aachen http://www.vision.rwth-aachen.de leibe@vision.rwth-aachen.de TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAAAAAAAAAAAAAAAAAAAAAAAAAAA

Lecture Evaluation: Numerical Results Lecturer Lecture B. Leibe

Lecture Evaluation: Positive Comments “Very good lecture. Difficult topics presented in a good & comprehensible way. Good slides.” “Thanks a lot for the lecture – it gives a very good overview.” “Good slides. Good examples at whiteboard.” “Very interesting lecture! ” “This lecture finally enables me to understand probability theory – but of course it is quite hard to follow the lecture without having understood it beforehand.”  Glad to hear that! B. Leibe

Lecture Evaluation: Detailed Critique “At some points I would appreciate if the slides would be a bit more self contained for looking up things later.” “I think the course is way too hard to follow with only basic understanding in stochastics. A lot of formulae are on the slides but many of them are only explained very roughly.” “Less formulas, more examples.” “It is sometimes hard to follow the slides when you haven't been to the lecture (e.g., it is not always clear why different fonts are used in formulas – sometimes it means something, sometimes it doesn't.” “At the beginning of the semester the textbook wasn't available at the library (and it is very expensive).”

Lecture Evaluation: Exercises “Exercises are too long and are often referring to a lecture two weeks ago.” “The exercises are very helpful for understanding the contents of the lecture, and the slides in the exercise course are very well-structured and comprehensible.” B. Leibe

Lecture Evaluation: Exercises (cont'd) “The exercise course is lacking prior examples that own solutions can be based on. Often the idea is to implement something of which the basic understanding has not yet been established. I am disappointed.” “The only thing that in my opinion could be better are the exercises. The solving of the task normally mean that some algorithm has to be implemented. But the implementation does not require the understanding of the material but just writing down the formulas from slides in Matlab. It would be nice to have more theoretical tasks which really require deeper understanding of the problem and its solution.” B. Leibe

Lecture Evaluation: Varia “Hard to get fresh air inside with noise outside”  Unfortunately out of our control...  B. Leibe

Course Outline Fundamentals (2 weeks) Bayes Decision Theory Probability Density Estimation Discriminative Approaches (5 weeks) Linear Discriminant Functions Statistical Learning Theory & SVMs Ensemble Methods & Boosting Decision Trees & Randomized Trees Generative Models (4 weeks) Bayesian Networks Markov Random Fields Exact Inference Applications B. Leibe

Recap: Junction Tree Algorithm Motivation Exact inference on general graphs. Works by turning the initial graph into a junction tree and then running a sum-product-like algorithm. Intractable on graphs with large cliques. Main steps If starting from directed graph, first convert it to an undirected graph by moralization. Introduce additional links by triangulation in order to reduce the size of cycles. Find cliques of the moralized, triangulated graph. Construct a new graph from the maximal cliques. Remove minimal links to break cycles and get a junction tree.  Apply regular message passing to perform inference. B. Leibe

Recap: Junction Tree Example Without triangulation step The final graph will contain cycles that we cannot break without losing the running intersection property! B. Leibe Image source: J. Pearl, 1988

Recap: Junction Tree Example When applying the triangulation Only small cycles remain that are easy to break. Running intersection property is maintained. B. Leibe Image source: J. Pearl, 1988

Recap: MRF Structure for Images Basic structure Two components Observation model How likely is it that node xi has label Li given observation yi? This relationship is usually learned from training data. Neighborhood relations Simplest case: 4-neighborhood Serve as smoothing terms.  Discourage neighboring pixels to have different labels. This can either be learned or be set to fixed “penalties”. Noisy observations “True” image content B. Leibe

Recap: How to Set the Potentials? Unary potentials E.g. color model, modeled with a Mixture of Gaussians  Learn color distributions for each label B. Leibe

Recap: How to Set the Potentials? Pairwise potentials Potts Model Simplest discontinuity preserving model. Discontinuities between any pair of labels are penalized equally. Useful when labels are unordered or number of labels is small. Extension: “contrast sensitive Potts model” where Discourages label changes except in places where there is also a large change in the observations. B. Leibe

Energy Minimization Goal: Infer the optimal labeling of the MRF. Many inference algorithms are available, e.g. Simulated annealing Iterated conditional modes (ICM) Belief propagation Graph cuts Variational methods Monte Carlo sampling Recently, Graph Cuts have become a popular tool Only suitable for a certain class of energy functions. But the solution can be obtained very fast for typical vision problems (~1MPixel/sec). What you saw in the movie. Too simple. Last lecture Today! For more complex problems B. Leibe

Topics of This Lecture Solving MRFs with Graph Cuts Graph cuts for image segmentation s-t mincut algorithm Graph construction Extension to non-binary case Applications B. Leibe

Example: Image Segmentation E: {0,1}N → R 0 → fg 1 → bg N = number of pixels Image (D) Slide credit: Pushmeet Kohli B. Leibe

Example: Image Segmentation E: {0,1}N → R 0 → fg 1 → bg N = number of pixels Unary Cost (ci) Dark (negative) Bright (positive) Slide credit: Pushmeet Kohli B. Leibe

Example: Image Segmentation E: {0,1}N → R 0 → fg 1 → bg N = number of pixels Discontinuity Cost (cij) Slide credit: Pushmeet Kohli B. Leibe

Example: Image Segmentation E: {0,1}N → R 0 → fg 1 → bg N = number of pixels How to minimize E(x)? Global Minimum (x*) Slide credit: Pushmeet Kohli B. Leibe

Graph Cuts – Basic Idea E(x) Construct a graph such that: s t Any st-cut corresponds to an assignment of x The cost of the cut is equal to the energy of x : E(x) st-mincut t s Solution E(x) Slide credit: Pushmeet Kohli B. Leibe

Graph Cuts for Binary Problems Idea: convert MRF into source-sink graph s t a cut n-links hard constraint Minimum cost cut can be computed in polynomial time (max-flow/min-cut algorithms) Slide credit: Yuri Boykov B. Leibe [Boykov & Jolly, ICCV’01]

Simple Example of Energy unary potentials pairwise potentials t-links n-links s t a cut (binary object segmentation) Slide credit: Yuri Boykov B. Leibe

Adding Regional Properties a cut n-links t-link t-link Regional bias example Suppose are given “expected” intensities of object and background NOTE: hard constrains are not required, in general. Slide credit: Yuri Boykov B. Leibe [Boykov & Jolly, ICCV’01]

Adding Regional Properties a cut n-links t-link t-link “expected” intensities of object and background can be re-estimated EM-style optimization Slide credit: Yuri Boykov B. Leibe [Boykov & Jolly, ICCV’01]

Adding Regional Properties More generally, unary potentials can be based on any intensity/color models of object and background. a cut s t Object and background color distributions Slide credit: Yuri Boykov B. Leibe [Boykov & Jolly, ICCV’01]

Topics of This Lecture Solving MRFs with Graph Cuts Graph cuts for image segmentation s-t mincut algorithm Graph construction Extension to non-binary case Applications Source Sink v1 v2 2 5 9 4 1 B. Leibe

How Does it Work? The s-t-Mincut Problem Source Sink v1 v2 2 5 9 4 1 Graph (V, E, C) Vertices V = {v1, v2 ... vn} Edges E = {(v1, v2) ....} Costs C = {c(1, 2) ....} Slide credit: Pushmeet Kohli B. Leibe

The s-t-Mincut Problem What is an st-cut? An st-cut (S,T) divides the nodes between source and sink. Source 2 9 What is the cost of a st-cut? 1 Sum of cost of all edges going from S to T v1 v2 2 5 4 Sink 5 + 2 + 9 = 16 Slide credit: Pushmeet Kohli B. Leibe

The s-t-Mincut Problem What is an st-cut? An st-cut (S,T) divides the nodes between source and sink. Source 2 9 What is the cost of a st-cut? 1 Sum of cost of all edges going from S to T v1 v2 2 5 4 What is the st-mincut? Sink st-cut with the minimum cost 2 + 1 + 4 = 7 Slide credit: Pushmeet Kohli B. Leibe

How to Compute the s-t-Mincut? Solve the dual maximum flow problem Compute the maximum flow between Source and Sink Source Sink v1 v2 2 5 9 4 1 Constraints Edges: Flow < Capacity Nodes: Flow in = Flow out In every network, the maximum flow equals the cost of the st-mincut Min-cut/Max-flow Theorem Slide credit: Pushmeet Kohli B. Leibe

History of Maxflow Algorithms Augmenting Path and Push-Relabel n: #nodes m: #edges U: maximum edge weight Algorithms assume non-negative edge weights Slide credit: Andrew Goldberg B. Leibe

Augmenting Path Based Algorithms Maxflow Algorithms Flow = 0 Augmenting Path Based Algorithms Source Sink v1 v2 2 5 9 4 1 Find path from source to sink with positive capacity Push maximum possible flow through this path Repeat until no path can be found Algorithms assume non-negative capacity Slide credit: Pushmeet Kohli B. Leibe

Augmenting Path Based Algorithms Maxflow Algorithms Flow = 0 Augmenting Path Based Algorithms Source Sink v1 v2 9 4 2 1 2 Find path from source to sink with positive capacity Push maximum possible flow through this path Repeat until no path can be found 5 Algorithms assume non-negative capacity Slide credit: Pushmeet Kohli B. Leibe

Augmenting Path Based Algorithms Maxflow Algorithms Flow = 0 + 2 Augmenting Path Based Algorithms Source Sink v1 v2 9 4 2 1 Find path from source to sink with positive capacity Push maximum possible flow through this path Repeat until no path can be found 2-2 5-2 Algorithms assume non-negative capacity Slide credit: Pushmeet Kohli B. Leibe

Augmenting Path Based Algorithms Maxflow Algorithms Flow = 2 Augmenting Path Based Algorithms Source Sink v1 v2 9 4 2 1 Find path from source to sink with positive capacity Push maximum possible flow through this path Repeat until no path can be found 3 Algorithms assume non-negative capacity Slide credit: Pushmeet Kohli B. Leibe

Augmenting Path Based Algorithms Maxflow Algorithms Flow = 2 Augmenting Path Based Algorithms Source Sink v1 v2 3 9 4 2 1 Find path from source to sink with positive capacity Push maximum possible flow through this path Repeat until no path can be found Algorithms assume non-negative capacity Slide credit: Pushmeet Kohli B. Leibe

Augmenting Path Based Algorithms Maxflow Algorithms Flow = 2 Augmenting Path Based Algorithms Source Sink v1 v2 3 2 1 Find path from source to sink with positive capacity Push maximum possible flow through this path Repeat until no path can be found 9 4 Algorithms assume non-negative capacity Slide credit: Pushmeet Kohli B. Leibe

Augmenting Path Based Algorithms Maxflow Algorithms Flow = 2 + 4 Augmenting Path Based Algorithms Source Sink v1 v2 3 2 1 Find path from source to sink with positive capacity Push maximum possible flow through this path Repeat until no path can be found 5 Algorithms assume non-negative capacity Slide credit: Pushmeet Kohli B. Leibe

Augmenting Path Based Algorithms Maxflow Algorithms Flow = 6 Augmenting Path Based Algorithms Source Sink v1 v2 3 5 2 1 Find path from source to sink with positive capacity Push maximum possible flow through this path Repeat until no path can be found Algorithms assume non-negative capacity Slide credit: Pushmeet Kohli B. Leibe

Augmenting Path Based Algorithms Maxflow Algorithms Flow = 6 Augmenting Path Based Algorithms Source Sink v1 v2 2 Find path from source to sink with positive capacity Push maximum possible flow through this path Repeat until no path can be found 5 1 3 Algorithms assume non-negative capacity Slide credit: Pushmeet Kohli B. Leibe

Augmenting Path Based Algorithms Maxflow Algorithms Flow = 6 + 1 Augmenting Path Based Algorithms Source Sink v1 v2 2 Find path from source to sink with positive capacity Push maximum possible flow through this path Repeat until no path can be found 4 1-1 2 Algorithms assume non-negative capacity Slide credit: Pushmeet Kohli B. Leibe

Augmenting Path Based Algorithms Maxflow Algorithms Flow = 7 Augmenting Path Based Algorithms Source Sink v1 v2 2 4 Find path from source to sink with positive capacity Push maximum possible flow through this path Repeat until no path can be found Algorithms assume non-negative capacity Slide credit: Pushmeet Kohli B. Leibe

Augmenting Path Based Algorithms Maxflow Algorithms Flow = 7 Augmenting Path Based Algorithms Source Sink v1 v2 2 4 Find path from source to sink with positive capacity Push maximum possible flow through this path Repeat until no path can be found Algorithms assume non-negative capacity Slide credit: Pushmeet Kohli B. Leibe

Applications: Maxflow in Computer Vision Specialized algorithms for vision problems Grid graphs Low connectivity (m ~ O(n)) Dual search tree augmenting path algorithm [Boykov and Kolmogorov PAMI 2004] Finds approximate shortest augmenting paths efficiently. High worst-case time complexity. Empirically outperforms other algorithms on vision problems. Efficient code available on the web http://pub.ist.ac.at/~vnk/software.html Slide credit: Pushmeet Kohli B. Leibe

When Can s-t Graph Cuts Be Applied? s-t graph cuts can only globally minimize binary energies that are submodular. Submodularity is the discrete equivalent to convexity. Implies that every local energy minimum is a global minimum.  Solution will be globally optimal. unary potentials pairwise potentials t-links n-links [Boros & Hummer, 2002, Kolmogorov & Zabih, 2004] E(L) can be minimized by s-t graph cuts Submodularity (“convexity”) B. Leibe

Topics of This Lecture Solving MRFs with Graph Cuts Graph cuts for image segmentation s-t mincut algorithm Graph construction Extension to non-binary case Applications Source Sink v1 v2 2 5 9 4 1 B. Leibe

Recap: Simple Image Segmentation Model MRF Structure Example: simple energy function Smoothness term: penalty cij if neighboring labels disagree. Observation term: penalty ci if label and observation disagree. Noisy observations Observation process “True” image content “Smoothness constraints” Observation Smoothness ("Potts model") B. Leibe Image source: C. Bishop, 2006

Converting an MRF into an s-t Graph Conversion: Energy: Unary potentials are straightforward to set. How? Just insert xi = 1 and xi = 0 into the unary terms above... Source Sink xi xj B. Leibe

Converting an MRF into an s-t Graph Conversion: Energy: Unary potentials are straightforward to set. How? Pairwise potentials are more tricky, since we don’t know xi! Trick: the pairwise energy only has an influence if xi  xj. (Only!) in this case, the cut will go through the edge {xi,xj}. Source Sink xi xj B. Leibe

Example: Graph Construction Source (0) a1 a2 Sink (1) Slide credit: Pushmeet Kohli B. Leibe

Example: Graph Construction Source (0) 2 a1 a2 Sink (1) Slide credit: Pushmeet Kohli B. Leibe

Example: Graph Construction Source (0) 2 a1 a2 5 Sink (1) Slide credit: Pushmeet Kohli B. Leibe

Example: Graph Construction Source (0) 2 9 a1 a2 5 4 Sink (1) Slide credit: Pushmeet Kohli B. Leibe

Example: Graph Construction Source (0) 2 9 1 a1 a2 5 4 Sink (1) Slide credit: Pushmeet Kohli B. Leibe

Example: Graph Construction Source (0) 2 9 1 a1 a2 2 5 4 Sink (1) Slide credit: Pushmeet Kohli B. Leibe

Example: Graph Construction Source (0) 2 9 1 a1 a2 2 5 4 Sink (1) Slide credit: Pushmeet Kohli B. Leibe

Example: Graph Construction Source (0) 2 9 Cost of cut = 11 1 a1 a2 a1 = 1 a2 = 1 2 E (1,1) = 11 5 4 Sink (1) Slide credit: Pushmeet Kohli B. Leibe

Example: Graph Construction Source (0) 2 9 Cost of cut = 7 1 a1 a2 a1 = 1 a2 = 0 2 E (1,0) = 7 5 4 Sink (1) Slide credit: Pushmeet Kohli B. Leibe

How Does the Code Look Like? Graph *g; For all pixels p /* Add a node to the graph */ nodeID(p) = g->add_node(); /* Set cost of terminal edges */ set_weights(nodeID(p), fgCost(p), bgCost(p)); end for all adjacent pixels p,q add_weights(nodeID(p), nodeID(q), cost); g->compute_maxflow(); label_p = g->is_connected_to_source(nodeID(p)); // is the label of pixel p (0 or 1) Source (0) Sink (1) Slide credit: Pushmeet Kohli B. Leibe

How Does the Code Look Like? Graph *g; For all pixels p /* Add a node to the graph */ nodeID(p) = g->add_node(); /* Set cost of terminal edges */ set_weights(nodeID(p), fgCost(p), bgCost(p)); end for all adjacent pixels p,q add_weights(nodeID(p), nodeID(q), cost); g->compute_maxflow(); label_p = g->is_connected_to_source(nodeID(p)); // is the label of pixel p (0 or 1) Source (0) bgCost(a1) bgCost(a2) a1 a2 fgCost(a1) fgCost(a2) Sink (1) Slide credit: Pushmeet Kohli B. Leibe

How Does the Code Look Like? Graph *g; For all pixels p /* Add a node to the graph */ nodeID(p) = g->add_node(); /* Set cost of terminal edges */ set_weights(nodeID(p), fgCost(p), bgCost(p)); end for all adjacent pixels p,q add_weights(nodeID(p), nodeID(q), cost); g->compute_maxflow(); label_p = g->is_connected_to_source(nodeID(p)); // is the label of pixel p (0 or 1) Source (0) bgCost(a1) bgCost(a2) cost(p,q) a1 a2 fgCost(a1) fgCost(a2) Sink (1) Slide credit: Pushmeet Kohli B. Leibe

How Does the Code Look Like? Graph *g; For all pixels p /* Add a node to the graph */ nodeID(p) = g->add_node(); /* Set cost of terminal edges */ set_weights(nodeID(p), fgCost(p), bgCost(p)); end for all adjacent pixels p,q add_weights(nodeID(p), nodeID(q), cost); g->compute_maxflow(); label_p = g->is_connected_to_source(nodeID(p)); // is the label of pixel p (0 or 1) Source (0) bgCost(a1) bgCost(a2) cost(p,q) a1 a2 fgCost(a1) fgCost(a2) Sink (1) a1 = bg a2 = fg Slide credit: Pushmeet Kohli B. Leibe

Topics of This Lecture Solving MRFs with Graph Cuts Graph cuts for image segmentation s-t mincut algorithm Graph construction Extension to non-binary case Applications other labels  B. Leibe

Dealing with Non-Binary Cases Limitation to binary energies is often a nuisance.  E.g. binary segmentation only… We would like to solve also multi-label problems. The bad news: Problem is NP-hard with 3 or more labels! There exist some approximation algorithms which extend graph cuts to the multi-label case: -Expansion -Swap They are no longer guaranteed to return the globally optimal result. But -Expansion has a guaranteed approximation quality (2-approx) and converges in a few iterations. B. Leibe

-Expansion Move Basic idea: Break multi-way cut computation into a sequence of binary s-t cuts. other labels  Slide credit: Yuri Boykov B. Leibe

-Expansion Algorithm Start with any initial solution For each label “” in any (e.g. random) order: Compute optimal -expansion move (s-t graph cuts). Decline the move if there is no energy decrease. Stop when no expansion move would decrease energy. Slide credit: Yuri Boykov B. Leibe

Example: Stereo Vision Depth map ground truth Depth map Original pair of “stereo” images Slide credit: Yuri Boykov B. Leibe

-Expansion Moves In each -expansion a given label “” grabs space from other labels initial solution -expansion -expansion -expansion -expansion -expansion -expansion -expansion For each move, we choose the expansion that gives the largest decrease in the energy:  binary optimization problem Slide credit: Yuri Boykov B. Leibe

Topics of This Lecture Solving MRFs with Graph Cuts Graph cuts for image segmentation s-t mincut algorithm Extension to non-binary case Applications B. Leibe

GraphCut Applications: “GrabCut” Interactive Image Segmentation [Boykov & Jolly, ICCV’01] Rough region cues sufficient Segmentation boundary can be extracted from edges Procedure User marks foreground and background regions with a brush. This is used to create an initial segmentation which can then be corrected by additional brush strokes. Add interactive image segmentation slide Additional segmentation cues User segmentation cues Slide credit: Matthieu Bray

Global optimum of the energy GrabCut: Data Model Obtained from interactive user input User marks foreground and background regions with a brush Alternatively, user can specify a bounding box Foreground color Background color Global optimum of the energy Slide credit: Carsten Rother B. Leibe

Color model (Mixture of Gaussians) Energy after each iteration Iterated Graph Cuts Foreground Background G R Foreground & Background Background G R Color model (Mixture of Gaussians) 1 2 3 4 Result Energy after each iteration Slide credit: Carsten Rother B. Leibe

GrabCut: Example Results This is included in the newest version of MS Office! B. Leibe Image source: Carsten Rother

Applications: Interactive 3D Segmentation Slide credit: Yuri Boykov B. Leibe [Y. Boykov, V. Kolmogorov, ICCV’03]

Bayesian Networks What we’ve learned so far… We know they are directed graphical models. Their joint probability factorizes into conditional probabilities, We know how to convert them into undirected graphs. We know how to perform inference for them. Sum/Max-Product BP for exact inference in (poly)tree-shaped BNs. Loopy BP for approximate inference in arbitrary BNs. Junction Tree algorithm for converting arbitrary BNs into trees. But what are they actually good for? How do we apply them in practice? And how do we learn their parameters? B. Leibe Image source: C. Bishop, 2006

References and Further Reading A gentle introduction to Graph Cuts can be found in the following paper: Y. Boykov, O. Veksler, Graph Cuts in Vision and Graphics: Theories and Applications. In Handbook of Mathematical Models in Computer Vision, edited by N. Paragios, Y. Chen and O. Faugeras, Springer, 2006. Try the GraphCut implementation at http://pub.ist.ac.at/~vnk/software.html B. Leibe