Computational Photography lecture 8 – segmentation CS 590-134 (future 572) Spring 2016 Prof. Alex Berg (Credits to many other folks on individual slides)

Slides:



Advertisements
Similar presentations
SOFT SCISSORS: AN INTERACTIVE TOOL FOR REALTIME HIGH QUALITY MATTING International Conference on Computer Graphics and Interactive Techniques ACM SIGGRAPH.
Advertisements

Cutting Images: Graphs and Boundary Finding Computational Photography Derek Hoiem, University of Illinois 09/15/11 “The Double Secret”, Magritte.
Fitting a transformation: feature-based alignment Wed, Feb 23 Prof. Kristen Grauman UT-Austin.
Image Blending and Compositing : Computational Photography Alexei Efros, CMU, Fall 2010 © NASA.
Blending and Compositing Computational Photography Connelly Barnes Many slides from James Hays, Alexei Efros.
The University of Ontario CS 4487/9587 Algorithms for Image Analysis Segmentation (2D) Acknowledgements: Alexei Efros, Steven Seitz.
Recap from Monday Frequency domain analytical tool computational shortcut compression tool.
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:
Recap from Monday Fourier transform analytical tool computational shortcut.
GrabCut Interactive Image (and Stereo) Segmentation Carsten Rother Vladimir Kolmogorov Andrew Blake Antonio Criminisi Geoffrey Cross [based on Siggraph.
GrabCut Interactive Foreground Extraction using Iterated Graph Cuts Carsten Rother Vladimir Kolmogorov Andrew Blake Microsoft Research Cambridge-UK.
GrabCut Interactive Foreground Extraction using Iterated Graph Cuts Carsten Rother Vladimir Kolmogorov Andrew Blake Microsoft Research Cambridge-UK.
A Gimp Plugin that uses “GrabCut” to perform image segmentation
Graph-Based Image Segmentation
Stephen J. Guy 1. Photomontage Photomontage GrabCut – Interactive Foreground Extraction 1.
Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.
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.
GrabCut Interactive Image (and Stereo) Segmentation Joon Jae Lee Keimyung University Welcome. I will present Grabcut – an Interactive tool for foreground.
CS 691 Computational Photography Instructor: Gianfranco Doretto Cutting Images.
Fitting a transformation: feature-based alignment
Lecture 6 Image Segmentation
CS448f: Image Processing For Photography and Vision Graph Cuts.
Agenda Seam-carving: finish up “Mid-term review” (a look back) Main topic: Feature detection.
Blending and Compositing : Rendering and Image Processing Alexei Efros.
Image Pyramids and Blending
Image Segmentation Today’s Readings Intelligent Scissors, Mortensen et. al, SIGGRAPH 1995Intelligent Scissors From Sandlot ScienceSandlot Science.
An Iterative Optimization Approach for Unified Image Segmentation and Matting Hello everyone, my name is Jue Wang, I’m glad to be here to present our paper.
Image Compositing and Blending : Computational Photography Alexei Efros, CMU, Fall 2007 © NASA.
Image Segmentation Today’s Readings Forsyth & Ponce, Chapter 14
Announcements Mailing list: –you should have received messages Office hours onlineonline –start next week.
Image Pyramids and Blending : Computational Photography Alexei Efros, CMU, Fall 2005 © Kenneth Kwan.
Image Pyramids and Blending
Graph-based Segmentation
Image Segmentation Rob Atlas Nick Bridle Evan Radkoff.
MRFs and Segmentation with Graph Cuts Computer Vision CS 543 / ECE 549 University of Illinois Derek Hoiem 03/31/15.
Cutting Images: Graphs and Boundary Finding Computational Photography Derek Hoiem, University of Illinois 09/14/10 “The Double Secret”, Magritte.
Graph-based Segmentation. Main Ideas Convert image into a graph Vertices for the pixels Vertices for the pixels Edges between the pixels Edges between.
MRFs and Segmentation with Graph Cuts Computer Vision CS 543 / ECE 549 University of Illinois Derek Hoiem 02/24/10.
Interactive Graph Cuts for Optimal Boundary & Region Segmentation of Objects in N-D Images (Fri) Young Ki Baik, Computer Vision Lab.
Lecture 2: Edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science.
Intelligent Scissors for Image Composition Anthony Dotterer 01/17/2006.
Lecture 4: Image Resampling and Reconstruction CS4670: Computer Vision Kavita Bala.
Graph Cuts Marc Niethammer. Segmentation by Graph-Cuts A way to compute solutions to the optimization problems we looked at before. Example: Binary Segmentation.
Brent M. Dingle, Ph.D Game Design and Development Program Mathematics, Statistics and Computer Science University of Wisconsin - Stout Edge Detection:
CS654: Digital Image Analysis Lecture 28: Advanced topics in Image Segmentation Image courtesy: IEEE, IJCV.
Image Stitching II Linda Shapiro CSE 455. RANSAC for Homography Initial Matched Points.
Cutting Images: Graphs and Boundary Finding Computational Photography Derek Hoiem, University of Illinois 09/20/12 “The Double Secret”, Magritte.
Hebrew University Image Processing Exercise Class 8 Panoramas – Stitching and Blending Min-Cut Stitching Many slides from Alexei Efros.
MRFs and Segmentation with Graph Cuts Computer Vision CS 543 / ECE 549 University of Illinois Derek Hoiem 03/27/12.
Graph-based Segmentation
Image Stitching II Linda Shapiro EE/CSE 576.
Image Blending : Computational Photography
Cutting Images: Graphs and Boundary Finding
Digital Visual Effects, Spring 2009 Yung-Yu Chuang 2009/5/21
Announcements CS accounts Project 1 is out today
GrabCut Interactive Foreground Extraction using Iterated Graph Cuts Carsten Rother Vladimir Kolmogorov Andrew Blake Microsoft Research Cambridge-UK.
Image Blending and Compositing
CS4670/5670: Image Scissors Noah Snavely Today’s Readings
Fitting a transformation: Feature-based alignment May 2nd, 2017
Image Stitching II Linda Shapiro CSE 455.
Announcements Reader is in the BOOK STORE (not Comm Bldg.)
Lecture 31: Graph-Based Image Segmentation
Seam Carving Project 1a due at midnight tonight.
Announcements Project 1 is out today
Image Stitching II Linda Shapiro EE/CSE 576.
Announcements Project 1 is out today help session at the end of class.
Photometric Processing
Presentation transcript:

Computational Photography lecture 8 – segmentation CS (future 572) Spring 2016 Prof. Alex Berg (Credits to many other folks on individual slides)

Assignment 2 – on the course page, note comments about using “sparse” matrices and lscov (works for sparse matrices) to solve least squares problem. Test/debug on small version or small crops of an image (e.g. 5x5 pixels) and on toy images (like a white square on a black background, or the Japanese flag). Lecture today on segmentation Next part of assignment will be announced in next class. Today

Reminder Compositing 1. Extract Sprites (e.g using Intelligent Scissors in Photoshop) Composite by David Dewey 2. Blend them into the composite (in the right order)

Big Picture Compositing images –Have a clever blending function Feathering Center-weighted blend different frequencies differently Gradient based blending –Choose the right pixels from each image Dynamic programming – optimal seams Graph-cuts

Big Picture Compositing images –Have a clever blending function Feathering Center-weighted blend different frequencies differently Gradient based blending –Choose the right pixels from each image Dynamic programming – optimal seams Graph-cuts

Need blending

Affect of Window Size 0 1 left right 0 1

Affect of Window Size

Good Window Size 0 1 “Optimal” Window: smooth but not ghosted

Don’t blend, CUT! So far we only tried to blend between two images. What about finding an optimal seam?

min. error boundary Minimal error boundary overlapping blocksvertical boundary _ = 2 overlap error

Graphcuts What if we want similar “cut-where-things- agree” idea, but for closed regions? –Dynamic programming can’t handle loops

Graph cuts (simple example à la Boykov&Jolly, ICCV’01) n-links s t a cut hard constraint hard constraint Minimum cost cut can be computed in polynomial time (max-flow/min-cut algorithms)

Kwatra et al, 2003 Actually, for this example, dynamic programming will work just almost as well… why?

In more detail… Segmentation

Example application: Stitching

This Lecture: Finding seams and boundaries Fundamental Concept: The Image as a Graph Intelligent Scissors: Good boundary = short path Graph cuts: Good region has low cutting cost

Semi-automated segmentation User provides imprecise and incomplete specification of region – your algorithm has to read his/her mind. Key problems 1.What groups of pixels form cohesive regions? 2.What pixels are likely to be on the boundary of regions? 3.Which region is the user trying to select?

What makes a good region? Contains small range of color/texture Looks different than background Compact

What makes a good boundary? High gradient along boundary Gradient in right direction Smooth

The Image as a Graph Node: pixel Edge: cost of path or cut between two pixels

Intelligent Scissors Mortenson and Barrett (SIGGRAPH 1995)

Intelligent Scissors A good image boundary has a short path through the graph. Mortenson and Barrett (SIGGRAPH 1995) Start End

Intelligent Scissors Formulation: find good boundary between seed points Challenges – Minimize interaction time – Define what makes a good boundary – Efficiently find it

Intelligent Scissors: method 1.Define boundary cost between neighboring pixels 2.User specifies a starting point (seed) 3.Compute lowest cost from seed to each other pixel 4.Get path from seed to cursor, choose new seed, repeat

Intelligent Scissors: method 1.Define boundary cost between neighboring pixels a)Lower if edge is present (e.g., with edge(im, ‘canny’)) b)Lower if gradient is strong c)Lower if gradient is in direction of boundary

Gradients, Edges, and Path Cost Gradient Magnitude Edge Image Path Cost

Intelligent Scissors: method 1.Define boundary cost between neighboring pixels 2.User specifies a starting point (seed) – Snapping

Intelligent Scissors: method 1.Define boundary cost between neighboring pixels 2.User specifies a starting point (seed) 3.Compute lowest cost from seed to each other pixel – Djikstra’s shortest path algorithm

Djikstra’s shortest path algorithm Initialize, given seed s: Compute cost 2 (q, r) % cost for boundary from pixel q to neighboring pixel r cost(s) = 0 % total cost from seed to this point A = {s} % set to be expanded E = { } % set of expanded pixels P(q) % pointer to pixel that leads to q Loop while A is not empty 1.q = pixel in A with lowest cost 2.Add q to E 3.for each pixel r in neighborhood of q that is not in E a)cost_tmp = cost(q) + cost 2 (q,r) b)if (r is not in A) OR (cost_tmp < cost(r)) i.cost(r) = cost_tmp ii. P(r) = q iii.Add r to A

Intelligent Scissors: method 1.Define boundary cost between neighboring pixels 2.User specifies a starting point (seed) 3.Compute lowest cost from seed to each other pixel 4.Get new seed, get path between seeds, repeat

Intelligent Scissors: improving interaction 1.Snap when placing first seed 2.Automatically adjust to boundary as user drags 3.Freeze stable boundary points to make new seeds

Where will intelligent scissors work well, or have problems?

Grab cuts and graph cuts Grab cuts and graph cuts User Input Result Magic Wand (198?) Intelligent Scissors Mortensen and Barrett (1995) GrabCut Region s Boundary Regions & Boundary Source: Rother

Segmentation with graph cuts Source (Label 0) Sink (Label 1) Cost to assign to 1 (attraction to 0) Cost to assign to 0 Cost to split nodes

Segmentation with graph cuts Source (Label 0) Sink (Label 1) Cost to assign to 1 Cost to assign to 0 Cost to split nodes

Graph cuts segmentation 1.Define graph – usually 4-connected or 8-connected 2.Set weights to foreground/background – Color histogram or mixture of Gaussians for background and foreground 3.Set weights for edges between pixels 4.Apply min-cut/max-flow algorithm 5.Return to 2, using current labels to compute foreground, background models

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

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

What is easy or hard about these cases for graphcut-based segmentation?

Easier examples GrabCut – Interactive Foreground Extraction 10

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

Lazy Snapping (Li et al. SG 2004)

Limitations of Graph Cuts Requires associative graphs – Connected nodes should prefer to have the same label Is optimal only for binary problems

Applied to image stitching Graphcut Textures – Kwatra et al. SIGGRAPH 2003

Other Applied to image stitching: stitching + Graphcut Textures – Kwatra et al. SIGGRAPH 2003 Ideal boundary: 1.Similar color in both images 2.High gradient in both images

Summary of big ideas Treat image as a graph – Pixels are nodes – Between-pixel edge weights based on gradients – Sometimes per-pixel weights for affinity to foreground/background Good boundaries are a short path through the graph (Intelligent Scissors, Seam Carving) Good regions are produced by a low-cost cut (GrabCuts, Graph Cut Stitching)

For next class Work on assignment 2. Read back over things: Szeliski Book 5.5: Graph cuts and energy based segmentation methods Szeliski Book 4.2 and 4.3: edges

EXTRA SLIDES

Lazy Snapping Interactive segmentation using graphcuts

Gradient Domain Image Blending In Pyramid Blending, we decomposed our image into 2 nd derivatives (Laplacian) and a low-res image Let’s look at a more direct formulation: –No need for low-res image captures everything (up to a constant) –Idea: Differentiate Composite Reintegrate

Gradient Domain blending (1D) Two signals Regular blending Blending derivatives bright dark

Gradient Domain Blending (2D) Trickier in 2D: –Take partial derivatives dx and dy (the gradient field) –Fidle around with them (smooth, blend, feather, etc) –Reintegrate But now integral(dx) might not equal integral(dy) –Find the most agreeable solution Equivalent to solving Poisson equation Can use FFT, deconvolution, multigrid solvers, etc.

Perez et al., 2003

Perez et al, 2003 Limitations: –Can’t do contrast reversal (gray on black -> gray on white) –Colored backgrounds “bleed through” –Images need to be very well aligned editing