Blending and Compositing

download Blending and Compositing

If you can't read please download the document

description

Blending and Compositing. Computational Photography Connelly Barnes, Fall 2013. Many slides from James Hays, Alexei Efros. Blending + Compositing. Previously: Color perception in humans, cameras Bayer mosaic Color spaces (L*a*b*, RGB, HSV). Blending + Compositing. Today. - PowerPoint PPT Presentation

Transcript of Blending and Compositing

Blending and Compositing

Blending and CompositingComputational Photography

Connelly BarnesMany slides from James Hays, Alexei EfrosBlending + CompositingPreviously:Color perception in humans, camerasBayer mosaicColor spaces (L*a*b*, RGB, HSV)

Blending + CompositingToday

david dmartin (Boston College)Compositing Procedure1. Extract Sprites (e.g using Intelligent Scissors in Photoshop)

Composite by David Dewey2. Blend them into the composite (in the right order)Need blending

Alpha Blending / Feathering

0101+

=Iblend = aIleft + (1-a)Iright

Setting alpha: simple averaging

Alpha = .5 in overlap regionSetting alpha: center seam

Alpha = logical(dtrans1>dtrans2)

DistanceTransformbwdist(MATLAB)

Setting alpha: blurred seam

Alpha = blurred

Distancetransform

Setting alpha: center weighting

Alpha = dtrans1 / (dtrans1+dtrans2)

Distancetransform

Ghost!Effect of Window Size

01leftright01Affect of Window Size0101

Good Window Size

01Optimal Window: smooth but not ghostedBand-pass filteringLaplacian Pyramid (subband images)Created from Gaussian pyramid by subtraction

Gaussian Pyramid (low-pass images)Laplacian PyramidHow can we reconstruct (collapse) this pyramid into the original image?

Need this!OriginalimagePyramid Blending

010101Left pyramidRight pyramidblendPyramid Blending

laplacianlevel4

laplacianlevel2laplacianlevel0left pyramidright pyramidblended pyramidLaplacian Pyramid: BlendingGeneral Approach:Build Laplacian pyramids LA and LB from images A and BBuild a Gaussian pyramid GR from selected region RForm a combined pyramid LS from LA and LB using nodes of GR as weights:LS(i,j) = GR(I,j,)*LA(I,j) + (1-GR(I,j))*LB(I,j)Collapse the LS pyramid to get the final blended imageLaplacian Pyramid: ExampleShow ongoing research projectBlending Regions

Horror Photo

david dmartin (Boston College)

Chris CameronSimplification: Two-band BlendingBrown & Lowe, 2003Only use two bands: high freq. and low freq.Blends low freq. smoothlyBlend high freq. with no smoothing: use binary alpha

Dont blendcutSo far we only tried to blend between two images. What about finding an optimal seam?

Moving objects become ghostsDavis, 1998Segment the mosaicSingle source image per segmentAvoid artifacts along boundriesDijkstras algorithm

min. error boundary

Dynamic programming cuts

overlapping blocksvertical boundary

_=2overlap error

Graph cutsWhat if we want similar cut-where-things-agree idea, but for closed regions?

Dynamic programming cant handle loops

Graph cuts (simple example la Boykov&Jolly, ICCV01)n-links

sta cuthard constrainthard constraintMinimum 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 as wellLazy Snapping

Interactive segmentation using graph cutsGradient Domain Image BlendingIn Pyramid Blending, we decomposed our image into 2nd derivatives (Laplacian) and a low-res imageLets look at a more direct formulation:No need for low-res image captures everything (up to a constant)Idea: DifferentiateCompositeReintegrate

Gradient Domain blending (1D)

TwosignalsRegularblendingBlendingderivativesbrightdarkGradient Domain Blending (2D)Trickier in 2D:Take partial derivatives dx and dy (the gradient field)Fiddle around with them (smooth, blend, feather, etc)ReintegrateBut now integral(dx) might not equal integral(dy)Find the most agreeable solutionEquivalent to solving Poisson equationCan use FFT, deconvolution, multigrid solvers, etc.

Gradient Domain: Math (1D)f(x)f(x) = [-1 0 1] f f(x)Gradient Domain: Math (1D)f(x)f(x) = [-1 0 1] f f(x)Gradient Domain: Math (1D)f(x)g(x)Modify f to get target gradients gGradient Domain: Math (1D)g(x)Solve for g that has g as its gradients

Plus any boundary constraints on g(write on board)Gradient Domain: Math (1D)Sparse linear system (after differentiating)Solve with conjugate-gradientor direct solverMATLAB A \ b, or Python scipy.sparse.linalg

Gradient Domain: Math (2D)Solve for g that has gx as its x derivative,And gy as its y derivative

Slide from Pravin BhatGradient Domain: Math (2D)Slide from Pravin Bhat

Gradient Domain: Math (2D)Output filtered image fSpecify desired pixel-differences (gx, gy)Specify desired pixel-values dSpecify constraints weights (wx, wy, wd)min wx(fx gx)2 + wy(fy gy)2 + wd(f d)2 fEnergy function (derive on board)From Pravin BhatGradient Domain: ExampleGradientShop by Pravin Bhat:

GradientShop

Gradient Domain: ExampleGradient domain painting by Jim McCann:

Real-Time Gradient-Domain Painting

Thinking in Gradient DomainJames McCann Real-Time Gradient-Domain Painting, SIGGRAPH 2009

Perez et al., 2003

Perez et al, 2003Limitations:Cant do contrast reversal (gray on black -> gray on white)Colored backgrounds bleed throughImages need to be very well aligned

editingPutting it all togetherCompositing imagesHave a clever blending functionFeatheringCenter-weightedBlend different frequencies differentlyGradient based blendingChoose the right pixels from each imageDynamic programming optimal seamsGraph-cuts

Now, lets put it all together:Interactive Digital Photomontage, 2004 (video)