Computer vision: models, learning and inference

Slides:



Advertisements
Similar presentations
Basic Steps 1.Compute the x and y image derivatives 2.Classify each derivative as being caused by either shading or a reflectance change 3.Set derivatives.
Advertisements

Bayesian Belief Propagation
Linear Time Methods for Propagating Beliefs Min Convolution, Distance Transforms and Box Sums Daniel Huttenlocher Computer Science Department December,
Introduction to Algorithms
Introduction to Markov Random Fields and Graph Cuts Simon Prince
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
Exact Inference in Bayes Nets
Online Social Networks and Media. Graph partitioning The general problem – Input: a graph G=(V,E) edge (u,v) denotes similarity between u and v weighted.
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:
CS774. Markov Random Field : Theory and Application Lecture 17 Kyomin Jung KAIST Nov
The University of Ontario CS 4487/9687 Algorithms for Image Analysis Multi-Label Image Analysis Problems.
EE462 MLCV Lecture Introduction of Graphical Models Markov Random Fields Segmentation Tae-Kyun Kim 1.
Graph-Based Image Segmentation
Foreground/Background Image Segmentation. What is our goal? To label each pixel in an image as belonging to either the foreground of the scene or the.
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.
Contextual Classification by Melanie Ganz Lecture 6, Medical Image Analysis 2008.
Chapter 8-3 Markov Random Fields 1. Topics 1. Introduction 1. Undirected Graphical Models 2. Terminology 2. Conditional Independence 3. Factorization.
Optimal solution of binary problems Much material taken from :  Olga Veksler, University of Western Ontario
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-
1 Computer Vision Research  Huttenlocher, Zabih –Recognition, stereopsis, restoration, learning  Strong algorithmic focus –Combinatorial optimization.
Stereo & Iterative Graph-Cuts Alex Rav-Acha Vision Course Hebrew University.
EDA (CS286.5b) Day 6 Partitioning: Spectral + MinCut.
MRF Labeling With Graph Cut CMPUT 615 Nilanjan Ray.
Announcements Readings for today:
Belief Propagation Kai Ju Liu March 9, Statistical Problems Medicine Finance Internet Computer vision.
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 Chapter 10 Graphical Models.
Computer vision: models, learning and inference Chapter 6 Learning and Inference in Vision.
Computer vision: models, learning and inference
MRFs and Segmentation with Graph Cuts Computer Vision CS 543 / ECE 549 University of Illinois Derek Hoiem 03/31/15.
Presenter : Kuang-Jui Hsu Date : 2011/5/23(Tues.).
Michael Bleyer LVA Stereo Vision
MRFs and Segmentation with Graph Cuts Computer Vision CS 543 / ECE 549 University of Illinois Derek Hoiem 02/24/10.
Interactive Shortest Path Part 3 An Image Segmentation Technique Jonathan-Lee Jones.
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.
Undirected Models: Markov Networks David Page, Fall 2009 CS 731: Advanced Methods in Artificial Intelligence, with Biomedical Applications.
Graph Cuts Marc Niethammer. Segmentation by Graph-Cuts A way to compute solutions to the optimization problems we looked at before. Example: Binary Segmentation.
Markov Random Fields Probabilistic Models for Images
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.
CS774. Markov Random Field : Theory and Application Lecture 02
Data Structures & Algorithms Graphs
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
Lecture 19: Solving the Correspondence Problem with Graph Cuts CAP 5415 Fall 2006.
1 Network Models Transportation Problem (TP) Distributing any commodity from any group of supply centers, called sources, to any group of receiving.
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.).
Tractable Higher Order Models in Computer Vision (Part II) Slides from Carsten Rother, Sebastian Nowozin, Pusohmeet Khli Microsoft Research Cambridge Presented.
Probabilistic Graphical Models seminar 15/16 ( ) Haim Kaplan Tel Aviv University.
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:
A global approach Finding correspondence between a pair of epipolar lines for all pixels simultaneously Local method: no guarantee we will have one to.
Markov Random Fields in Vision
Markov Random Fields Tomer Michaeli Graduate Course
Markov Random Fields with Efficient Approximations
Exact Inference Continued
Markov Networks.
Efficient Graph Cut Optimization for Full CRFs with Quantized Edges
CSCI 5822 Probabilistic Models of Human and Machine Learning
Lecture 31: Graph-Based Image Segmentation
Exact Inference Continued
Presentation transcript:

Computer vision: models, learning and inference Chapter 12 Models for Grids

Models for grids Consider models with one unknown world state at each pixel in the image – takes the form of a grid. Loops in the graphical model, so cannot use dynamic programming or belief propagation Define probability distributions that favor certain configurations of world states Called Markov random fields Inference using a set of techniques called graph cuts Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Binary Denoising Before After Image represented as binary discrete variables. Some proportion of pixels randomly changed polarity. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Multi-label Denoising Before After Image represented as discrete variables representing intensity. Some proportion of pixels randomly changed according to a uniform distribution. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Denoising Goal Observed Data Uncorrupted Image Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Denoising Goal Most of the pixels stay the same Observed Data Uncorrupted Image Most of the pixels stay the same Observed image is not as smooth as original Now consider pdf over binary images that encourages smoothness – Markov random field Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Markov random fields This is just the typical property of an undirected model. We’ll continue the discussion in terms of undirected models Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Returns positive number Markov random fields Normalizing constant (partition function) Potential function Returns positive number Subset of variables (clique) Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Markov random fields Normalizing constant Cost function (partition function) Cost function Returns any number Subset of variables (clique) Relationship Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Smoothing Example Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Smoothing Example Smooth solutions (e.g. 0000,1111) have high probability Z was computed by summing the 16 un-normalized probabilities Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Smoothing Example Samples from larger grid -- mostly smooth Cannot compute partition function Z here - intractable Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Denoising Goal Observed Data Uncorrupted Image Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Denoising overview Bayes’ rule: Likelihoods: Probability of flipping polarity Prior: Markov random field (smoothness) MAP Inference: Graph cuts Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Denoising with MRFs MRF Prior (pairwise cliques) Original image, w Likelihoods Observed image, x Inference : Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

MAP Inference Unary terms (compatability of data with label y) Pairwise terms (compatability of neighboring labels) Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Graph Cuts Overview Graph cuts used to optimise this cost function: Unary terms (compatability of data with label y) Pairwise terms (compatability of neighboring labels) Three main cases: Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Graph Cuts Overview Graph cuts used to optimise this cost function: Unary terms (compatability of data with label y) Pairwise terms (compatability of neighboring labels) Approach: Convert minimization into the form of a standard CS problem, MAXIMUM FLOW or MINIMUM CUT ON A GRAPH Polynomial-time methods for solving this problem are known Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Max-Flow Problem Goal: To push as much ‘flow’ as possible through the directed graph from the source to the sink. Cannot exceed the (non-negative) capacities cij associated with each edge. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Saturated Edges When we are pushing the maximum amount of flow: There must be at least one saturated edge on any path from source to sink (otherwise we could push more flow) The set of saturated edges hence separate the source and sink Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Augmenting Paths Two numbers represent: current flow / total capacity Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Augmenting Paths Choose any route from source to sink with spare capacity, and push as much flow as you can. One edge (here 6-t) will saturate. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Augmenting Paths Choose another route, respecting remaining capacity. This time edge 6-5 saturates. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Augmenting Paths A third route. Edge 1-4 saturates Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Augmenting Paths A fourth route. Edge 2-5 saturates Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Augmenting Paths A fifth route. Edge 2-4 saturates Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Augmenting Paths There is now no further route from source to sink – there is a saturated edge along every possible route (highlighted arrows) Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Augmenting Paths The saturated edges separate the source from the sink and form the min-cut solution. Nodes either connect to the source or connect to the sink. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Graph Cuts: Binary MRF Graph cuts used to optimise this cost function: Unary terms (compatability of data with label w) Pairwise terms (compatability of neighboring labels) First work with binary case (i.e. True label w is 0 or 1) Constrain pairwise costs so that they are “zero-diagonal” Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Graph Construction One node per pixel (here a 3x3 image) Edge from source to every pixel node Edge from every pixel node to sink Reciprocal edges between neighbours Note that in the minimum cut EITHER the edge connecting to the source will be cut, OR the edge connecting to the sink, but NOT BOTH (unnecessary). Which determines whether we give that pixel label 1 or label 0. Now a 1 to 1 mapping between possible labelling and possible minimum cuts Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Graph Construction Now add capacities so that minimum cut, minimizes our cost function Unary costs U(0), U(1) attached to links to source and sink. Either one or the other is paid. Pairwise costs between pixel nodes as shown. Why? Easiest to understand with some worked examples. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Example 1 Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Example 2 Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Example 3 Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

35 Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Graph Cuts: Binary MRF Graph cuts used to optimise this cost function: Unary terms (compatability of data with label w) Pairwise terms (compatability of neighboring labels) Summary of approach Associate each possible solution with a minimum cut on a graph Set capacities on graph, so cost of cut matches the cost function Use augmenting paths to find minimum cut This minimizes the cost function and finds the MAP solution Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

General Pairwise costs Modify graph to Add P(0,0) to edge s-b Implies that solutions 0,0 and 1,0 also pay this cost Subtract P(0,0) from edge b-a Solution 1,0 has this cost removed again Similar approach for P(1,1) Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Reparameterization The max-flow / min-cut algorithms require that all of the capacities are non-negative. However, because we have a subtraction on edge a-b we cannot guarantee that this will be the case, even if all the original unary and pairwise costs were positive. The solution to this problem is reparamaterization: find new graph where costs (capacities) are different but choice of minimum solution is the same (usually just by adding a constant to each solution) Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Reparameterization 1 The minimum cut chooses the same links in these two graphs Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Reparameterization 2 The minimum cut chooses the same links in these two graphs Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Submodularity Subtract constant b Add constant, b Adding together implies Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Submodularity If this condition is obeyed, it is said that the problem is “submodular” and it can be solved in polynomial time. If it is not obeyed then the problem is NP hard. Usually it is not a problem as we tend to favour smooth solutions. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Denoising Results Original Pairwise costs increasing Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Plan of Talk Denoising problem Markov random fields (MRFs) Max-flow / min-cut Binary MRFs – submodular (exact solution) Multi-label MRFs – submodular (exact solution) Multi-label MRFs - non-submodular (approximate) Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Multiple Labels Construction for two pixels (a and b) and four labels (1,2,3,4) There are 5 nodes for each pixel and 4 edges between them have unary costs for the 4 labels. One of these edges must be cut in the min-cut solution and the choice will determine which label we assign. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Constraint Edges The edges with infinite capacity pointing upwards are called constraint edges. They prevent solutions that cut the chain of edges associated with a pixel more than once (and hence given an ambiguous labelling) Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Multiple Labels Inter-pixel edges have costs defined as: Superfluous terms : For all i,j where K is number of labels Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Example Cuts Must cut links from before cut on pixel a to after cut on pixel b. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Pairwise Costs Must cut links from before cut on pixel a to after cut on pixel b. Costs were carefully chosen so that sum of these links gives appropriate pairwise term. If pixel a takes label I and pixel b takes label J Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Reparameterization Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Submodularity We require the remaining inter-pixel links to be positive so that or By mathematical induction we can get the more general result Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

If not submodular, then the problem is NP hard. Submodularity If not submodular, then the problem is NP hard. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Convex vs. non-convex costs Quadratic Convex Submodular Truncated Quadratic Not Convex Not Submodular Potts Model Not Convex Not Submodular Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

What is wrong with convex costs? Observed noisy image Denoised result Pay lower price for many small changes than one large one Result: blurring at large changes in intensity Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Plan of Talk Denoising problem Markov random fields (MRFs) Max-flow / min-cut Binary MRFs - submodular (exact solution) Multi-label MRFs – submodular (exact solution) Multi-label MRFs - non-submodular (approximate) Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Alpha Expansion Algorithm break multilabel problem into a series of binary problems at each iteration, pick label a and expand (retain original or change to a) Initial labelling Iteration 1 (orange) Iteration 3 (red) Iteration 2 (yellow) Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Alpha Expansion Ideas For every iteration For every label Expand label using optimal graph cut solution Co-ordinate descent in label space. Each step optimal, but overall global maximum not guaranteed Proved to be within a factor of 2 of global optimum. Requires that pairwise costs form a metric: Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Alpha Expansion Construction Binary graph cut – either cut link to source (assigned to a) or to sink (retain current label) Unary costs attached to links between source, sink and pixel nodes appropriately. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Alpha Expansion Construction Graph is dynamic. Structure of inter-pixel links depends on a and the choice of labels. There are four cases. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Alpha Expansion Construction Case 1: Adjacent pixels both have label a already. Pairwise cost is zero – no need for extra edges. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Alpha Expansion Construction Case 2: Adjacent pixels are a,b. Result either a,a (no cost and no new edge). a,b (P(a,b), add new edge). Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Alpha Expansion Construction Case 3: Adjacent pixels are b,b. Result either b,b (no cost and no new edge). a,b (P(a,b), add new edge). b,a (P(b,a), add new edge). Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Alpha Expansion Construction Case 4: Adjacent pixels are b,g. Result either b,g (P(b,g), add new edge). a,g (P(a,g), add new edge). b,a (P(b,a), add new edge). a,a (no cost and no new edge). Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Example Cut 1 Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Example Cut 1 Important! Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Example Cut 2 Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Example Cut 3 Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Denoising Results Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Conditional Random Fields Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Directed model for grids Cannot use graph cuts as three-wise term. Easy to draw samples. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Applications Background subtraction Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Applications Grab cut Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Applications Stereo vision Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Applications Shift-map image editing Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Computer vision: models, learning and inference. ©2011 Simon J. D Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Applications Shift-map image editing Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Applications Super-resolution Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Applications Texture synthesis Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Image Quilting Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Synthesizing faces Computer vision: models, learning and inference. ©2011 Simon J.D. Prince

Graphical models Computer vision: models, learning and inference. ©2011 Simon J.D. Prince