Markov Random Fields and Segmentation with Graph Cuts

Similar documents
Markov Random Fields and Segmentation with Graph Cuts

MRFs and Segmentation with Graph Cuts

Markov/Conditional Random Fields, Graph Cut, and applications in Computer Vision

ECE 6504: Advanced Topics in Machine Learning Probabilistic Graphical Models and Large-Scale Learning

Segmentation with non-linear constraints on appearance, complexity, and geometry

Segmentation in electron microscopy images

10708 Graphical Models: Homework 4

Analysis: TextonBoost and Semantic Texton Forests. Daniel Munoz Februrary 9, 2009

Prof. Feng Liu. Spring /17/2017. With slides by F. Durand, Y.Y. Chuang, R. Raskar, and C.

Clustering web search results

Image Segmentation Using Iterated Graph Cuts Based on Multi-scale Smoothing

intro, applications MRF, labeling... how it can be computed at all? Applications in segmentation: GraphCut, GrabCut, demos

Grouping and Segmentation

Segmentation. Separate image into coherent regions

ECE 5424: Introduction to Machine Learning

Segmentation. Bottom up Segmentation Semantic Segmentation

Announcements. Image Segmentation. From images to objects. Extracting objects. Status reports next Thursday ~5min presentations in class

Energy Minimization for Segmentation in Computer Vision

Measuring Uncertainty in Graph Cut Solutions - Efficiently Computing Min-marginal Energies using Dynamic Graph Cuts

Regularization and Markov Random Fields (MRF) CS 664 Spring 2008

Discrete Optimization Methods in Computer Vision CSE 6389 Slides by: Boykov Modified and Presented by: Mostafa Parchami Basic overview of graph cuts

Introduction to Machine Learning CMU-10701

Clustering Lecture 5: Mixture Model

Clustering K-means. Machine Learning CSEP546 Carlos Guestrin University of Washington February 18, Carlos Guestrin

Generative and discriminative classification techniques

Models for grids. Computer vision: models, learning and inference. Multi label Denoising. Binary Denoising. Denoising Goal.

Image Segmentation Using Iterated Graph Cuts BasedonMulti-scaleSmoothing

Approximate decoding: ICM, block methods, alpha-beta swap & alpha-expansion

Content-based image and video analysis. Machine learning

Fall 09, Homework 5

Colorado School of Mines. Computer Vision. Professor William Hoff Dept of Electrical Engineering &Computer Science.

Learning CRFs using Graph Cuts

Chapter 8 of Bishop's Book: Graphical Models

Expectation Maximization: Inferring model parameters and class labels

Lecture 7: Segmentation. Thursday, Sept 20

IMPROVED FINE STRUCTURE MODELING VIA GUIDED STOCHASTIC CLIQUE FORMATION IN FULLY CONNECTED CONDITIONAL RANDOM FIELDS

Markov Networks in Computer Vision

Applied Bayesian Nonparametrics 5. Spatial Models via Gaussian Processes, not MRFs Tutorial at CVPR 2012 Erik Sudderth Brown University

Image Segmentation. April 24, Stanford University. Philipp Krähenbühl (Stanford University) Segmentation April 24, / 63

Markov Networks in Computer Vision. Sargur Srihari

Lecture 11: E-M and MeanShift. CAP 5415 Fall 2007

CS448f: Image Processing For Photography and Vision. Graph Cuts

Algorithms for Markov Random Fields in Computer Vision

Problem Set 4. Assigned: March 23, 2006 Due: April 17, (6.882) Belief Propagation for Segmentation

Multi-Label Moves for Multi-Label Energies

Clustering K-means. Machine Learning CSEP546 Carlos Guestrin University of Washington February 18, Carlos Guestrin

Simultaneous Multi-class Pixel Labeling over Coherent Image Sets

Detection of Man-made Structures in Natural Images

Computer Vision : Exercise 4 Labelling Problems

Learning and Inferring Depth from Monocular Images. Jiyan Pan April 1, 2009

Reduce, Reuse & Recycle: Efficiently Solving Multi-Label MRFs

Mathematics in Image Processing

Image Segmentation. Computer Vision Jia-Bin Huang, Virginia Tech. Many slides from D. Hoiem

Probabilistic Graphical Models

ECE521: Week 11, Lecture March 2017: HMM learning/inference. With thanks to Russ Salakhutdinov

K-Means and Gaussian Mixture Models

Segmentation Computer Vision Spring 2018, Lecture 27

Supervised texture detection in images

CS6670: Computer Vision

Comparison of Graph Cuts with Belief Propagation for Stereo, using Identical MRF Parameters

CAP5415-Computer Vision Lecture 13-Image/Video Segmentation Part II. Dr. Ulas Bagci

A Feature Point Matching Based Approach for Video Objects Segmentation

Belief propagation and MRF s

Image Pyramids and Applications

Machine Learning. Topic 5: Linear Discriminants. Bryan Pardo, EECS 349 Machine Learning, 2013

18 October, 2013 MVA ENS Cachan. Lecture 6: Introduction to graphical models Iasonas Kokkinos

SPM-BP: Sped-up PatchMatch Belief Propagation for Continuous MRFs. Yu Li, Dongbo Min, Michael S. Brown, Minh N. Do, Jiangbo Lu

CS 229 Midterm Review

Overview Citation. ML Introduction. Overview Schedule. ML Intro Dataset. Introduction to Semi-Supervised Learning Review 10/4/2010

Part-based and local feature models for generic object recognition

Undirected Graphical Models. Raul Queiroz Feitosa

Discrete Optimization of Ray Potentials for Semantic 3D Reconstruction

Geometric Registration for Deformable Shapes 3.3 Advanced Global Matching

Image Segmentation with a Bounding Box Prior Victor Lempitsky, Pushmeet Kohli, Carsten Rother, Toby Sharp Microsoft Research Cambridge

Principal-channels for One-sided Object Cutout

CS839: Probabilistic Graphical Models. Lecture 10: Learning with Partially Observed Data. Theo Rekatsinas

human vision: grouping k-means clustering graph-theoretic clustering Hough transform line fitting RANSAC

Multiple cosegmentation

Lecture 13 Segmentation and Scene Understanding Chris Choy, Ph.D. candidate Stanford Vision and Learning Lab (SVL)

Generative and discriminative classification techniques

A discriminative view of MRF pre-processing algorithms supplementary material

Unsupervised Learning

Structured Models in. Dan Huttenlocher. June 2010

CSE 473/573 Computer Vision and Image Processing (CVIP) Ifeoma Nwogu. Lectures 21 & 22 Segmentation and clustering

Extracting Smooth and Transparent Layers from a Single Image

CIS 520, Machine Learning, Fall 2015: Assignment 7 Due: Mon, Nov 16, :59pm, PDF to Canvas [100 points]

Unsupervised Learning. Clustering and the EM Algorithm. Unsupervised Learning is Model Learning

Machine Learning and Data Mining. Clustering (1): Basics. Kalev Kask

Machine Learning. Unsupervised Learning. Manfred Huber

10-701/15-781, Fall 2006, Final

Note Set 4: Finite Mixture Models and the EM Algorithm

Grundlagen der Künstlichen Intelligenz

Computer Vision Group Prof. Daniel Cremers. 4a. Inference in Graphical Models

Image Segmentation continued Graph Based Methods. Some slides: courtesy of O. Capms, Penn State, J.Ponce and D. Fortsyth, Computer Vision Book

Inference and Representation

Introduction to object recognition. Slides adapted from Fei-Fei Li, Rob Fergus, Antonio Torralba, and others

Segmentation and Grouping

Robust Higher Order Potentials for Enforcing Label Consistency

What have we leaned so far?

Segmentation: Clustering, Graph Cut and EM

Transcription:

Markov Random Fields and Segmentation with Graph Cuts Computer Vision Jia-Bin Huang, Virginia Tech Many slides from D. Hoiem

Administrative stuffs Final project Proposal due Oct 27 (Thursday) HW 4 is out Due 11:59pm on Wed, November 2nd, 2016

Today s class Review EM and GMM i Markov Random Fields j w ij Segmentation with Graph Cuts HW 4

Missing Data Problems: Segmentation Challenge: Segment the image into figure and ground without knowing what the foreground looks like in advance. Three sub-problems: 1. If we had labels, how could we model the appearance of foreground and background? MLE: maximum likelihood estimation 2. Once we have modeled the fg/bg appearance, how do we compute the likelihood that a pixel is foreground? Probabilistic inference 3. How can we get both labels and appearance models at once? Hidden data problem: Expectation Maximization Foreground Background

EM: Mixture of Gaussians 1. Initialize parameters 2. Compute likelihood of hidden variables for current parameters 3. Estimate new parameters for each component, weighted by likelihood ),,, ( ) ( ) 2 ( ) ( t t t n n nm x m z p π σ μ n n nm n nm t m x 1 ˆ 1) ( n m n nm n nm t m x 2 1) 2 ( ˆ 1 ˆ N n nm t m 1) ( ˆ k k n k n n m n m n n k z p k z x p m z p m z x p,, Given by normal distribution

Gaussian Mixture Models: Practical Tips Number of components Select by hand based on knowledge of problem Select using cross-validation or sample data Usually, not too sensitive and safer to use more components Covariance matrix Spherical covariance: dimensions within each component are independent with equal variance (1 parameter but usually too restrictive) Spherical Diagonal covariance: dimensions within each component are not independent with difference variances (N parameters for N-D data) Full covariance: no assumptions (N*(N+1)/2 parameters); for high N might be expensive to do EM, to evaluate, and may overfit Typically use Full if lots of data, few dimensions; Use Diagonal otherwise Can get stuck in local minima Use multiple restarts Choose solution with greatest data likelihood σ 2 0 0 σ 2 σ x 2 0 0 σ y 2 a c c b Spherical Diagonal Full

Hard EM Same as EM except compute z* as most likely values for hidden variables K-means is an example Advantages Simpler: can be applied when cannot derive EM Sometimes works better if you want to make hard predictions at the end But Generally, pdf parameters are not as accurate as EM

EM Demo GMM with images demos

function EM_segmentation(im, K) x = im(:); N = numel(x); minsigma = std(x)/numel(x); % prevent component from getting 0 variance % Initialize GMM parameters prior = zeros(k, 1); mu = zeros(k, 1); sigma = zeros(k, 1); prior(:) = 1/K; minx = min(x); maxx = max(x); for k = 1:K mu(k) = (0.1+0.8*rand(1))*(maxx-minx) + minx; sigma(k) = (1/K)*std(x); end % Initialize P(component_i x_i) (initial values not important) pm = ones(n, K); oldpm = zeros(n, K);

maxiter = 200; niter = 0; % EM algorithm: loop until convergence while (mean(abs(pm(:)-oldpm(:)))>0.001) && (niter < maxiter) niter = niter+1; oldpm = pm; % estimate probability that each data point belongs to each component for k = 1:K pm(:, k) = prior(k)*normpdf(x, mu(k), sigma(k)); end pm = pm./ repmat(sum(pm, 2), [1 K]); % compute maximum likelihood parameters for expected components for k = 1:K prior(k) = sum(pm(:, k))/n; mu(k) = sum(pm(:, k).*x) / sum(pm(:, k)); sigma(k) = sqrt( sum(pm(:, k).*(x - mu(k)).^2) / sum(pm(:, k))); sigma(k) = max(sigma(k), minsigma); % prevent variance from going to 0 end end

What s wrong with this prediction? P(foreground image)

Solution: Encode dependencies between pixels P(foreground image) Normalizing constant called partition function 1 P( y;, data) f ( y ;, data) f ( y, y ;, data Z i1.. N 1 i 2 i j ) i, jedges Labels to be predicted Individual predictions Pairwise predictions

Writing Likelihood as an Energy 1 P( y;, data) p ( y ;, data) p ( y, y ;, data Z i1.. N 1 i 2 i j ) i, jedges -log Energy( y;, data) ( y ;, data) ( y, y ;, data i 1 i 2 i j ) i, jedges Cost of assignment y i Cost of pairwise assignment y i,y j

Notes on energy-based formulation Energy( y;, data) ( y ;, data) ( y, y ;, data i Primarily used when you only care about the most likely solution (not the confidences) 1 i 2 i j ) i, jedges Can think of it as a general cost function Can have larger cliques than 2 Clique is the set of variables that go into a potential function

Markov Random Fields Node y i : pixel label Edge: constrained pairs Cost to assign a label to each pixel Energy( y;, data) i Cost to assign a pair of labels to connected pixels 1 ( yi;, data) 2( yi, y j;, data) i, jedges

Markov Random Fields Example: label smoothing grid Unary potential 0: -logp(y i = 0 data) 1: -logp(y i = 1 data) Pairwise Potential 0 1 0 0 K 1 K 0 K>0 Energy( y;, data) i 1 ( yi;, data) 2( yi, y j;, data) i, jedges

Solving MRFs with graph cuts Source (Label 0) Cost to assign to 1 Cost to split nodes Cost to assign to 0 Sink (Label 1) Energy( y;, data) i 1 ( yi;, data) 2( yi, y j;, data) i, jedges

Solving MRFs with graph cuts Source (Label 0) Cost to assign to 1 Cost to split nodes Cost to assign to 0 Sink (Label 1) Energy( y;, data) i 1 ( yi;, data) 2( yi, y j;, data) i, jedges

GrabCut segmentation User provides rough indication of foreground region. Goal: Automatically provide a pixel-level segmentation.

Colour Model R Foreground & Background Background G Gaussian Mixture Model (typically 5-8 components) Source: Rother

Graph cuts Boykov and Jolly (2001) Image Foreground (source) Min Cut Background (sink) Cut: separating source and sink; Energy: collection of edges Min Cut: Global minimal energy in polynomial time Source: Rother

Colour Model R Foreground & Background Iterated graph cut R Foreground Background G Background G Gaussian Mixture Model (typically 5-8 components) Source: Rother

GrabCut segmentation 1. Define graph usually 4-connected or 8-connected Divide diagonal potentials by sqrt(2) 2. Define unary potentials Color histogram or mixture of Gaussians for background and foreground unary _ 3. Define pairwise potentials edge _ potential( x) log P( c( x); P( c( x); c( x) c( y) potential( x, y) k1 k2 exp 2 2 4. Apply graph cuts 5. Return to 2, using current labels to compute foreground, background models foreground background 2 ) )

What is easy or hard about these cases for graphcutbased segmentation?

Easier examples GrabCut Interactive Foreground Extraction 10

More difficult Examples Fine structure Harder Case Initial Rectangle Camouflage & Low Contrast Initial Result GrabCut Interactive Foreground Extraction 11

Lazy Snapping (Li et al. SG 2004)

Graph cuts with multiple labels Alpha expansion Repeat until no change For α = 1.. M Assign each pixel to current label or α (2-class graphcut) Achieves strong local minimum Alpha-beta swap Repeat until no change For α = 1.. M, β = 1.. M (except α) Re-assign all pixels currently labeled as α or β to one of those two labels while keeping all other pixels fixed

Using graph cuts for recognition TextonBoost (Shotton et al. 2009 IJCV)

Using graph cuts for recognition Unary Potentials from classifier (note: edge potentials are from input image also; this is illustration from paper) Alpha Expansion Graph Cuts TextonBoost (Shotton et al. 2009 IJCV)

Limitations of graph cuts Associative: edge potentials penalize different labels Must satisfy If not associative, can sometimes clip potentials Graph cut algorithm applies to only 2-label problems Multi-label extensions are not globally optimal (but still usually provide very good solutions)

Graph cuts: Pros and Cons Pros Very fast inference Can incorporate data likelihoods and priors Applies to a wide range of problems (stereo, image labeling, recognition) stereo stitching recognition Cons Not always applicable (associative only) Need unary terms (not used for bottom-up segmentation, for example) Use whenever applicable

More about MRFs/CRFs Other common uses Graph structure on regions Encoding relations between multiple scene elements Inference methods Loopy BP or BP-TRW Exact for tree-shaped structures Approximate solutions for general graphs More widely applicable and can produce marginals but often slower

Further reading and resources Graph cuts http://www.cs.cornell.edu/~rdz/graphcuts.html Classic paper: What Energy Functions can be Minimized via Graph Cuts? (Kolmogorov and Zabih, ECCV '02/PAMI '04) Belief propagation Yedidia, J.S.; Freeman, W.T.; Weiss, Y., "Understanding Belief Propagation and Its Generalizations, Technical Report, 2001: http://www.merl.com/publications/tr2001-022/ Comparative study Szeliski et al. A comparative study of energy minimization methods for markov random fields with smoothness-based priors, PAMI 2008 Kappes et al. A comparative study of modern inference techniques for discrete energy minimization problems, CVPR 2013

HW 4 Part 1: SLIC (Achanta et al. PAMI 2012) http://infoscience.epfl.ch/record/177415/files/superpixel_pami2011-2.pdf 1. Initialize cluster centers on pixel grid in steps S - Features: Lab color, x-y position 2. Move centers to position in 3x3 window with smallest gradient 3. Compare each pixel to cluster center within 2S pixel distance and assign to nearest 4. Recompute cluster centers as mean color/position of pixels belonging to each cluster 5. Stop when residual error is small

HW 4 Part 1: SLIC Graduate credits (up to 15 points) Improve your results on SLIC Color space, gradient features, edges (up to 15 points) Implement Adaptive-SLIC d c : Color difference d s : Spatial difference maximum observed spatial and color distances (m s, m c )

HW 4 Part 2: EM algorithm The false scores come from a uniform distribution The true scores for each image have a Gaussian distribution Annotators are always bad or always good The good/bad label of each annotator is the missing data

HW 4 Part 3: GraphCut Define unary potential Define pairwise potential Contrastive term Solve segementation using graph-cut Read GraphCut.m

HW 4 Part 3: GraphCut Graduate credits (up to 15 points) try two more images (up to 10 points) image composition

Things to remember Markov Random Fields Encode dependencies between pixels w ij i Likelihood as energy j Segmentation with Graph Cuts

Next module: Object Recognition Face recognition Image categorization Machine learning Object category detection Tracking objects