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

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

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

Image Segmentation Using Iterated Graph Cuts BasedonMulti-scaleSmoothing

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

Algorithms for Markov Random Fields in Computer Vision

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

Image Restoration using Markov Random Fields

Statistical and Learning Techniques in Computer Vision Lecture 1: Markov Random Fields Jens Rittscher and Chuck Stewart

Fast Approximate Energy Minimization via Graph Cuts

Undirected Graphical Models. Raul Queiroz Feitosa

CS6670: Computer Vision

Graphs, graph algorithms (for image segmentation),... in progress

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

Dr. Ulas Bagci

MEDICAL IMAGE COMPUTING (CAP 5937) LECTURE 10: Medical Image Segmentation as an Energy Minimization Problem

Mathematics in Image Processing

CS4670 / 5670: Computer Vision Noah Snavely

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

Mesh segmentation. Florent Lafarge Inria Sophia Antipolis - Mediterranee

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

MEDICAL IMAGE COMPUTING (CAP 5937) LECTURE 10: Medical Image Segmentation as an Energy Minimization Problem

Markov Random Fields and Segmentation with Graph Cuts

Supervised texture detection in images

Quadratic Pseudo-Boolean Optimization(QPBO): Theory and Applications At-a-Glance

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

Markov Random Fields with Efficient Approximations

Energy Minimization for Segmentation in Computer Vision

Digital Image Processing Laboratory: Markov Random Fields and MAP Image Segmentation

Computer Vision : Exercise 4 Labelling Problems

Maximum flows and minimal cuts. Filip Malmberg

10708 Graphical Models: Homework 4

MULTI-REGION SEGMENTATION

s-t Graph Cuts for Binary Energy Minimization

Graph Cuts in Vision and Graphics: Theories and Applications

Multi-Label Moves for Multi-Label Energies

Graph Cuts vs. Level Sets. part I Basics of Graph Cuts

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

MRFs and Segmentation with Graph Cuts

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

What have we leaned so far?

Supplementary Material: Adaptive and Move Making Auxiliary Cuts for Binary Pairwise Energies

ADAPTIVE GRAPH CUTS WITH TISSUE PRIORS FOR BRAIN MRI SEGMENTATION

Markov Random Fields and Segmentation with Graph Cuts

A Feature Point Matching Based Approach for Video Objects Segmentation

Exact optimization for Markov random fields with convex priors

CS4670: Computer Vision

Integrating Intensity and Texture in Markov Random Fields Segmentation. Amer Dawoud and Anton Netchaev. {amer.dawoud*,

Markov Networks in Computer Vision. Sargur Srihari

UNSUPERVISED CO-SEGMENTATION BASED ON A NEW GLOBAL GMM CONSTRAINT IN MRF. Hongkai Yu, Min Xian, and Xiaojun Qi

Super Resolution Using Graph-cut

Parallel constraint optimization algorithms for higher-order discrete graphical models: applications in hyperspectral imaging

Clustering Lecture 5: Mixture Model

GiRaF: a toolbox for Gibbs Random Fields analysis

OPPA European Social Fund Prague & EU: We invest in your future.

Combinatorial optimization and its applications in image Processing. Filip Malmberg

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

Markov Networks in Computer Vision

IMAGE SEGMENTATION. Václav Hlaváč

Neighbourhood-consensus message passing and its potentials in image processing applications

Expectation Propagation

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

Markov Random Fields and Gibbs Sampling for Image Denoising

3 : Representation of Undirected GMs

Interactive segmentation, Combinatorial optimization. Filip Malmberg

Texture Modeling using MRF and Parameters Estimation

CS 5540 Spring 2013 Assignment 3, v1.0 Due: Apr. 24th 11:59PM

An Integrated System for Digital Restoration of Prehistoric Theran Wall Paintings

Human Head-Shoulder Segmentation

Fast Approximate Energy Minimization via Graph Cuts

2D image segmentation based on spatial coherence

Segmentation. Separate image into coherent regions

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

Computer Vision I - Filtering and Feature detection

Graphical Models, Bayesian Method, Sampling, and Variational Inference

Tracking in image sequences

Lecture 16 Segmentation and Scene understanding

Chapter 8 of Bishop's Book: Graphical Models

Iterated Graph Cuts for Image Segmentation

Optimization. Intelligent Scissors (see also Snakes)

Computer Vision and Virtual Reality. Introduction

Interactive Image Segmentation

Semantic Segmentation. Zhongang Qi

Bioimage Informatics

Computer vision: models, learning and inference. Chapter 10 Graphical Models

GRMA: Generalized Range Move Algorithms for the Efficient Optimization of MRFs

Image analysis. Computer Vision and Classification Image Segmentation. 7 Image analysis

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

FMA901F: Machine Learning Lecture 6: Graphical Models. Cristian Sminchisescu

A Principled Deep Random Field Model for Image Segmentation

Image segmentation. Václav Hlaváč. Czech Technical University in Prague

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

Detection of Man-made Structures in Natural Images

Tri-modal Human Body Segmentation

Segmentation with non-linear regional constraints via line-search cuts

Estimation of Distribution Algorithm for the Max-Cut Problem

Iterative MAP and ML Estimations for Image Segmentation

Lecture 3: Conditional Independence - Undirected

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

CS664 Lecture #21: SIFT, object recognition, dynamic programming

INTRODUCTION TO IMAGE PROCESSING (COMPUTER VISION)

Transcription:

Image as Markov Random Field and Applications 1 Tomáš Svoboda, svoboda@cmp.felk.cvut.cz Czech Technical University in Prague, Center for Machine Perception http://cmp.felk.cvut.cz Talk Outline Last update: July 14, 2010 intro, applications MRF, labeling... how it can be computed at all? Applications in segmentation: GraphCut, GrabCut, demos 1 Please note that the lecture will be accompanied be several sketches and derivations on the blackboard and few live-interactive demos in Matlab

few notes before we start About this very lecture 2/50 MRF is a complicated topic this lecture is introductory some simplifications in order not to lose the whole picture most important references provided many accessible explanations on the web (wikipedia... )

From wikipedia 2 : Markov Random Field MRF 3/50 A Markov random field, Markov network or undirected graphical model is a graphical model in which a set of random variables have a Markov property described by an undirected graph. More formal definition, which we follow, can be found in the first chapter 3 of the book [4]. 2 http://en.wikipedia.org/wiki/markov_random_field 3 freely available at: http://www.nlpr.ia.ac.cn/users/szli/mrf_book/mrf_book.html

From wikipedia 2 : Markov Random Field MRF 3/50 A Markov random field, Markov network or undirected graphical model is a graphical model in which a set of random variables have a Markov property described by an undirected graph. More formal definition, which we follow, can be found in the first chapter 3 of the book [4]. Let think about images: 2 http://en.wikipedia.org/wiki/markov_random_field 3 freely available at: http://www.nlpr.ia.ac.cn/users/szli/mrf_book/mrf_book.html

From wikipedia 2 : Markov Random Field MRF 3/50 A Markov random field, Markov network or undirected graphical model is a graphical model in which a set of random variables have a Markov property described by an undirected graph. More formal definition, which we follow, can be found in the first chapter 3 of the book [4]. Let think about images: image intensities are the random variables the values depend only on their immediate spatial neighborhood which is the Markov property images are organized in a regular grid which can be seen as an undirected graph 2 http://en.wikipedia.org/wiki/markov_random_field 3 freely available at: http://www.nlpr.ia.ac.cn/users/szli/mrf_book/mrf_book.html

Labeling for image analysis Many image analysis and interpretation problems can be posed as labeling problems. Assign a label to image pixel (or to features in general). Image intensity can be considered as a label (think about pallete images). Sites S index a discrete set of m sites. Site could be: individual pixel image region S = {1,..., m} corner point, line segment, surface patch... 4/50

Labels and sites A label is an event that may happen to a site. 5/50 Set of labels L. We will discuss disrete labels: L = {l 1,..., l M } shortly L = {1,..., M}

Labels and sites A label is an event that may happen to a site. 5/50 Set of labels L. We will discuss disrete labels: L = {l 1,..., l M } shortly L = {1,..., M} What can be a label? intensity value object label in edge detection binary flag L = {edge, nonedge}...

Ordering of labels Some labels can be ordered some not. 6/50 Ordered labels can be used to measure distance between labels.

The Labeling Problem Assigning a label from the label set L to each of the sites S. 7/50 Example: edge detection in an image Assign a label f i from the set L = {edge, nonedge} to site i S where the elements in S index the image pixels. The set is called a labeling. Unique labels f = {f 1,..., f m } When each site is assigned a unique label, labeling can be seen as mapping from S to L. f : S L A labeling is also called a coloring in mathematical programming.

How many possible labelings? Assuming all m sites have the same label set L 8/50 F = L L... L }{{} m times = L m Imagine the image restoration problem [3]. The the m is the number of pixels in the image and L equals to number of intensity levels. Many, many possible labelings. Usually only few are good.

Labeling problems in image analysis image restoration 9/50 region segmentation edge detection object detection and recognition stereo...

Labeling with contextual analysis In images, site neighborhood matters. 10/50 A probability P (f i ) does not depend only on the site but also on the labeling around. Mathematically speaking we must consider conditional probability P (f i {f i }) where {f i } denotes the set of other labels. no context: P (f) = i S P (f i ) Markov Random Field - MRF P (f i f S {i} ) = P (f i f Ni ) where f Ni stands for the labels at the sites neighboring i.

MRF a Gibbs Random Fields How to specify an MRF: in terms of conditional probabilities P (f i f Ni ) or joint probability P (f)? Hammersley Clifford theorem about equivalence between MRF and Gibbs distribution. A set of random variables F is said to be a Gibbs Random Fields on S with respect to N iff its configurations obey a Gibbs distribution 11/50 P (f) = Z 1 e 1 T U(f) 1 0.9 0.8 P = e U where 0.7 0.6 0.5 Z = f F e 1 T U(f) 0.4 0.3 0.2 0.1 is a normalizing constant. 0 0 2 4 6 8 10 energy term U

Gibbs distribution 12/50 P (f) = Z 1 e 1 T U(f) T is tempertature, T = 1 unless stated otherwise U(f) is the energy function 1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 P = e 1 T U T=0.5 T=1.0 T=2.0 T=5.0 0 0 2 4 6 8 10 energy term U

Energy function 13/50 U(f) = c C V c (f) is a sum of clique potentials V c (f) over all possible cliques C. 4 4 Illustration from the book [4]

Simple cliques, Auto models Contextual constraints on two labels U(f) = V 1 (f i ) + i S i S V 2 (f i, f i ) i N i 14/50 This can be interpreted as U(f) = U data (f) + U smooth (f)

Neighborhood and cliques on a regular lattices 15/50 5 5 Illustration from the book [4]

Energy minimization What is to be computed? Gibbs distribution: 16/50 P (f) = Z 1 e T 1 U(f) Remind that f is the desired labeling f : S L In MAP formulation we seek the most probable labeling P (f). The best labeling minimizes energy U(f) It is a combinatorial problem. The next explanation follows mainly [2].

Energy data term and smoothness term 17/50 U(f) = U data (f) + U smooth (f) The data term measures how well a label f p fits the particular pixel (site) p. Globally, U data (f) = p P D p (f p ) Example: in Image restoration D p (f p ) = (f p I p ) 2, where I p is the observed intensity and f p is the label (assigned intensity). Smoothness term Expresses the context. Setting a proper smoothness term is much more tricky. smooth but not everywhere (think about object boundary) discontinuity preserving

Interacting pixels We consider the energy U(f) = D p (f p ) + p P {p,q} N V p,q (f p, f q ) 18/50 where N is the set of interacting pixels, typically adjacent pixels. D p is assumed to be nonnegative. Interaction of adjacent pixels may have long range impact! V p,q is called interaction penalty.

labels α, β, γ L (reasonable) interaction penalties 19/50 V (α, β) = 0 α = β, (1) V (α, β) = V (β, α) 0, (2) V (α, β) V (α, γ) + V (γ, β) (3) Penalty is metric if all hold and semimetric if only (2,3) is satisfied. Examples of discontinutity preserving penalties truncated quadratic V (α, β) = min(k, (α β)2) truncated absolute distance V (α, β) = min(k, α β ) Potts model V (α, β) = KT (α β), where T () = 1 if argument is true, otherwise 0.

towards the best labeling (minimum energy) Catch: finding global minimum is NP complete even for the simple Potts model. 20/50 local minimum is sought. Problem If the solution is poor poor choice of energy funtion local minimum is far from the global one

Local minimum a labeling f is a local minimum of the energy U if 21/50 U(f) U(f ) for any f near to f. In case of discrete labeling near means withing single move of f. Many local minimization method use standard moves, where only one pixel (site) may change label at a time. Example: greedy optimization for each pixel, the label which gives the largest descrease of the energy is chosen.

Fast approximate energy minimization via graph cuts We only sketch the main ideas from the seminal work [2] 6 22/50 Allow more than just one label change at a time 7 α-β swap and α-expansion. 6 Freely available implementation. Many difficult problems in computer vision were solved by using this method and implementation. 7 image from [2]

Algorithm 23/50

Algorithm 24/50

Algorithm 25/50

α-β swap 26/50 How many iterations in each cycle? A cycle is successful if a strictly better labeling is found in any iteration. Cycling stops after first unsuccessful cycle.

α-β swap 27/50 The best α-β swap is found by composing a graph and finding min-cut. min-cut is equivalent to max-flow (Ford-Fulkerson theorem) Max-flow between terminals is a standard problem in Combinatorial Optimization. Algorithms with low-order polynomial complexities exist.

Finding optimal α-β swap 28/50 8 8 illustration from [2]

Finding optimal α-β swap, min-cut 29/50

Finding optimal α-β swap, re-labeling 30/50

Finding optimal α-β swap, re-labeling 31/50

MRF in image segmentation 32/50

Zkouška 33/50 Pátek 4.6.

Segmentation with seeds Interactive GraphCuts Idea: denote few pixels that trully belongs to object or background and than refine (grow) by using soft constraints. 34/50

Segmentation with seeds Interactive GraphCuts Idea: denote few pixels that trully belongs to object or background and than refine (grow) by using soft constraints. 34/50

Segmentation with seeds Interactive GraphCuts Idea: denote few pixels that trully belongs to object or background and than refine (grow) by using soft constraints. 34/50

Segmentation with seeds Interactive GraphCuts Idea: denote few pixels that trully belongs to object or background and than refine (grow) by using soft constraints. 34/50

Segmentation with seeds Interactive GraphCuts Idea: denote few pixels that trully belongs to object or background and than refine (grow) by using soft constraints. 34/50 data term boundary penalties and/or pixel interactions how to find the optimal boundary between object and background

Segmentation with seeds graph 35/50 9 9 illustration from [1]

Explained on the blackboard. Edges, cuts, segmentation 36/50 See [1] for details.

What data term? 37/50 U data (obj, bck) = p obj D(obj) + p bck D(bck) The better match between pixel and obj or bck model the lower energy (penalty).

What data term? 37/50 U data (obj, bck) = p obj D(obj) + p bck D(bck) The better match between pixel and obj or bck model the lower energy (penalty). How to model? for simplicity, you may think about the opposite case, the better match the higher value background, foreground (object) pixels intensity or color distributions histograms parametric models: GMM Gaussian Mixture Model

Image intensities - 1D GMM 0.015 relative frequency of intensities 38/50 relative frequency 0.01 0.005 0 50 0 50 100 150 200 250 300 intensity 10 10 Demo codes from [6]

Image intensities - 1D GMM 0.018 individual Gaussians 39/50 relative frequency 0.016 0.014 0.012 0.01 0.008 0.006 0.004 0.002 0 50 0 50 100 150 200 250 300 intensity

Image intensities - 1D GMM 0.018 Gaussian mixture 40/50 relative frequency 0.016 0.014 0.012 0.01 0.008 0.006 0.004 0.002 0 50 0 50 100 150 200 250 300 intensity

2D GMM 41/50 40 30 20 10 0 10 20 30 40 50 40 30 20 10 0 10 20 30 40 50

2D GMM 42/50 40 30 20 10 0 10 20 30 40 50 40 30 20 10 0 10 20 30 40 50

2D GMM 43/50 40 30 20 10 0 10 20 30 40 50 40 30 20 10 0 10 20 30 40 50

Data term by GMM math summary p(x f i ) = K k=1 w f i k 1 (2π) d 2 Σ f i k 1 2 exp ( 1 ) 2 (x µf i k )T Σ f 1 i k (x µ f i k ), 44/50 where d is the dimension. K number of Gaussians. User defined. for each label L = {obj, bck} different wk, µk, Σk estimated from the data (seeds) x pixel value, can be intensity, color vector,... Data term 5 4.5 D(obj) = ln p(x obj) D(bck) = ln p(x bck) data term 4 3.5 3 2.5 2 1.5 1 0.5 0 0 0.2 0.4 0.6 0.8 1 probability

See the live demo 11 Results data term only 45/50 11 Demo codes courtesy of V. Franc and A. Shekhovtsov

What boundary (interaction) term? The Potts model: V (p, q) = λt (p q), where T () = 1 if argument is true, otherwise 0. Effect of λ, see the live demo. Results for data and interaction terms 46/50

GrabCut going beyond the seeds The main idea: Iterate the graphcut and refine the data terms in each iteration. Stop if the energy (penalty) does not decrease. [5] 47/50 The practical motivation

GrabCut going beyond the seeds The main idea: Iterate the graphcut and refine the data terms in each iteration. Stop if the energy (penalty) does not decrease. [5] 47/50 The practical motivation Further reduce the user interaction. 12 12 images from [5]

GrabCut algorithm 48/50 Init: Specify background pixels T B. T F = 0; T U = T B Iterative minimization: 1. assign GMM components to pixels in T U 2. learn GMM parameters from data 3. segment by using min-cut (graphcut algorithm) 4. repeat from step 1 until convergence Optional: edit some pixels and repeat the min-cut.

References 49/50 [1] Yuri Boykov and Marie-Pierre Jolly. Interactive graph cuts for optimal boundary & region segmentation of objects in N-D images. In Proceedings of International Conference on Computer Vision (ICCV), 2001. [2] Yuri Boykov, Olga Veksler, and Ramin Zabih. Fast approximate energy minimization via graph cuts. IEEE Transactions on Pattern Analysis and Machine Intelligence, 23(11):1222 1239, November 2001. [3] S. Geman and D. Geman. Stochastic relaxation, gibbs distributions, and the bayesian restoration of images. IEEE Transactions on Pattern Analysis and Machine Intelligence, 6(6):721 741, 1984. [4] Stan Z. Li. Markov Random Field Modeling in Image Analysis. Springer, 2009. [5] Carsten Rother, Vladimir Kolomogorov, and Andrew Blake. GrabCut: Interactive foreground extraction isong iterated graph cuts. ACM Transactions on Graphics (SIGGRAPH 04), 2004. [6] Tomáš Svoboda, Jan Kybic, and Václav Hlaváč. Image Processing, Analysis and Machine Vision. A MATLAB Companion. Thomson, 2007. Accompanying www site http://visionbook.felk.cvut.cz.

End 50/50

1 P = e U 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 0 2 4 6 8 10 energy term U

1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 P = e 1 T U T=0.5 T=1.0 T=2.0 T=5.0 0 0 2 4 6 8 10 energy term U

0.015 relative frequency of intensities relative frequency 0.01 0.005 0 50 0 50 100 150 200 250 300 intensity

0.018 individual Gaussians 0.016 0.014 relative frequency 0.012 0.01 0.008 0.006 0.004 0.002 0 50 0 50 100 150 200 250 300 intensity

0.018 Gaussian mixture 0.016 0.014 relative frequency 0.012 0.01 0.008 0.006 0.004 0.002 0 50 0 50 100 150 200 250 300 intensity

40 50 40 30 20 10 0 10 20 30 40 50 30 20 10 0 10 20 30 40

40 50 40 30 20 10 0 10 20 30 40 50 30 20 10 0 10 20 30 40

40 50 40 30 20 10 0 10 20 30 40 50 30 20 10 0 10 20 30 40

5 4.5 4 3.5 data term 3 2.5 2 1.5 1 0.5 0 0 0.2 0.4 0.6 0.8 1 probability