g radient d omain
play

G RADIENT D OMAIN I MAGE P ROCESSING CS 89.15/189.5, Fall 2015 - PowerPoint PPT Presentation

G RADIENT D OMAIN I MAGE P ROCESSING CS 89.15/189.5, Fall 2015 Wojciech Jarosz wojciech.k.jarosz@dartmouth.edu Problems with direct copy/paste http://www.irisa.fr/vista/Papers/2003_siggraph_perez.pdf CS 89/189: Computational Photography,


  1. G RADIENT D OMAIN 
 I MAGE P ROCESSING CS 89.15/189.5, Fall 2015 Wojciech Jarosz wojciech.k.jarosz@dartmouth.edu

  2. Problems with direct copy/paste http://www.irisa.fr/vista/Papers/2003_siggraph_perez.pdf CS 89/189: Computational Photography, Fall 2015 2

  3. Solution: paste gradient http://www.irisa.fr/vista/Papers/2003_siggraph_perez.pdf hacky visualization of gradient CS 89/189: Computational Photography, Fall 2015 3

  4. http://fstoppers.com/proof-viral-hurricane-shark-photo-in-street-is-fake CS 89/189: Computational Photography, Fall 2015 4

  5. Photoshop healing brush Slightly smarter version of what we learn today - higher-order derivative in particular - See also 
 http://www.petapixel.com/2011/03/02/how-to-use- the-healing-brush-and-patch-tool-in-photoshop/ CS 89/189: Computational Photography, Fall 2015 5

  6. What is a gradient? Derivative of a multivariate function; for � d example, for f(x,y) ⇥ dx, d f f � f = dy For a discrete image, can be approximated with finite differences d f dx ≈ f ( x + 1 , y ) − f ( x, y ) d f dy ≈ f ( x, y + 1) − f ( x, y ) CS 89/189: Computational Photography, Fall 2015 6

  7. Gradient: intuition CS 89/189: Computational Photography, Fall 2015 7

  8. Gradients and grayscale images Grayscale image: n × n scalars Gradient: n × n 2D vectors Two many numbers! What’s up with this? - Not all vector fields are the gradient of an image! - Only if they are curl-free (a.k.a. conservative) - But we’ll see it does not matter for us CS 89/189: Computational Photography, Fall 2015 8

  9. Text Escher, Maurits Cornelis Ascending and Descending 1960 Lithograph 35.5 x 28.5 cm (14 x 11 1/4 in.) CS 89/189: Computational Photography, Fall 2015 9

  10. Color images 3 gradients, one for each channel We’ll sweep this under the rug for this lecture In practice, treat each channel independently CS 89/189: Computational Photography, Fall 2015 10

  11. Questions? CS 89/189: Computational Photography, Fall 2015 11

  12. Key gradient domain idea 1. Construct a vector field that we wish was the gradient of our output image 2. Look for an image that has that gradient 3. That won’t work, so look for an image that has approximately the desired gradient Gradient domain image processing is all about clever choices for (1) and efficient algorithms for (3) CS 89/189: Computational Photography, Fall 2015 12

  13. Solution: paste gradient http://www.irisa.fr/vista/Papers/2003_siggraph_perez.pdf hacky visualization of gradient CS 89/189: Computational Photography, Fall 2015 13

  14. Seamless Poisson cloning Paste source gradient into target image inside a selected region Make the new gradient as close as possible to the source gradient while respecting pixel values at the boundary keep target values here paste 
 source 
 gradient 
 here CS 89/189: Computational Photography, Fall 2015 14

  15. Seamless Poisson cloning Given vector field v (pasted gradient), find the value of f in unknown region that optimizes: Pasted gradient Mask unknown 
 region Background CS 89/189: Computational Photography, Fall 2015 15

  16. Discrete 1D example: minimization boundary • Copy to 6 6 +2 -1 5 5 -1 -1 +1 4 4 3 3 2 unknowns 2 1 1 ? ? ? ? 0 0 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 orange: pixel outside the mask red: source pixel to be pasted blue: boundary conditions (in background)

  17. Discrete 1D example: minimization • Copy to 6 6 +2 -1 5 5 -1 -1 +1 4 4 3 3 2 2 1 1 ? ? ? ? 0 0 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 Min [(f 2 -f 1 )-1] 2 + [(f 3 -f 2 )-(-1)] 2 With 
 + [(f 4 -f 3 )-2] 2 f 1 =6 
 + [(f 5 -f 4 )-(-1)] 2 f 6 =1 + [(f 6 -f 5 )-(-1)] 2

  18. 1D example: minimization • Copy to 6 6 +2 -1 5 5 -1 -1 +1 4 4 3 3 2 2 1 1 ? ? ? ? 0 0 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 Min [(f 2 -f 1 )-1] 2 ==> f 22 +49-14f 2 + [(f 3 -f 2 )-(-1)] 2 ==> f 32 +f 22 +1-2f 3 f 2 +2f 3 -2f 2 + [(f 4 -f 3 )-2] 2 ==> f 42 +f 32 +4-2f 3 f 4 -4f 4 +4f 3 + [(f 5 -f 4 )-(-1)] 2 ==> f 52 +f 42 +1-2f 5 f 4 +2f 5 -2f 4 + [(f 6 -f 5 )-(-1)] 2 ==> f 52 +4-4f 5

  19. 1D example: big quadratic • Copy to 6 6 +2 -1 5 5 -1 -1 +1 4 4 3 3 2 2 1 1 ? ? ? ? 0 0 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 • Min (f 22 +49-14f 2 + f 32 +f 22 +1-2f 3 f 2 +2f 3 -2f 2 + f 42 +f 32 +4-2f 3 f 4 -4f 4 +4f 3 + f 52 +f 42 +1-2f 5 f 4 +2f 5 -2f 4 + f 52 +4-4f 5 ) 
 Denote it Q

  20. 1D example: derivatives • Copy to 6 6 +2 -1 5 5 -1 -1 +1 4 4 3 3 2 2 1 1 ? ? ? ? 0 0 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 Min (f 22 +49-14f 2 + f 32 +f 22 +1-2f 3 f 2 +2f 3 -2f 2 + f 42 +f 32 +4-2f 3 f 4 -4f 4 +4f 3 + f 52 +f 42 +1-2f 5 f 4 +2f 5 -2f 4 + f 52 +4-4f 5 ) 
 Denote it Q

  21. 1D example: set derivatives to zero • Copy to 6 6 +2 -1 5 5 -1 -1 +1 4 4 3 3 2 2 1 1 ? ? ? ? 0 0 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 =0 =0 =0 =0 ==>

  22. 1D example recap • Copy to 6 6 +2 -1 5 5 -1 -1 +1 4 4 3 3 2 2 1 1 0 0 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 ==>

  23. Questions?

  24. Membrane interpolation • What if v is null? • Laplace equation (a.k.a. membrane equation )

  25. 1D example: minimization • Minimize derivatives to interpolate 6 5 4 3 2 1 ? ? ? ? 0 0 1 2 3 4 5 6 7 Min (f 2 -f 1 ) 2 + (f 3 -f 2 ) 2 + (f 4 -f 3 ) 2 With 
 f 1 =6 
 + (f 5 -f 4 ) 2 f 6 =1 + (f 6 -f 5 ) 2

  26. 1D example: derivatives • Minimize derivatives to interpolate 6 5 4 3 2 1 ? ? ? ? 0 0 1 2 3 4 5 6 7 Min (f 22 +36-12f 2 + f 32 +f 22 -2f 3 f 2 + f 42 +f 32 -2f 3 f 4 + f 52 +f 42 -2f 5 f 4 + f 52 +1-2f 5 ) 
 Denote it Q

  27. 1D example: set derivatives to zero • Minimize derivatives to interpolate 6 5 4 3 2 1 ? ? ? ? 0 0 1 2 3 4 5 6 7 ==>

  28. 1D example • Minimize derivatives to interpolate • Pretty much says that second 
 6 5 derivative should be zero 4 3 (-1 2 -1) 
 2 1 is a second derivative filter 0 0 1 2 3 4 5 6 7

  29. Intuition • In 1D; just linear interpolation! • Locally, if the second derivative was not zero, this would mean that the first derivative is varying, which is bad since we want ( ∇ f) 2 to be minimized • Note that, in 1D: by setting f'', we leave two degrees of freedom. This is exactly what we need to control the boundary condition at x 1 and x 2 x 1 x 2

  30. In 2D: membrane interpolation Not as simple x 1 x 2

  31. Questions?

  32. What if v is not null?

  33. What if v is not null? • 1D case target f* source g Seamlessly paste onto Just add a linear function so that the boundary condition is respected ^ solution f=f+g ^ correction f gap gap 
 f(x2)-g(x2) f(x1)-g(x1) x 1 x 2

  34. Matrix structure       f 2 4 − 2 0 0 16 f 3 − 2 4 − 2 0 − 6        =       f 4 0 − 2 4 − 2 6      f 5 0 0 − 2 4 2 denote this matrix A A is large! - (# cols = num pixels) x (# rows = num pixels) but system is sparse! - most coefficients will be zero CS 89/189: Computational Photography, Fall 2015 34

  35. Solution methods Direct solve (pseudoinverse) - can be numerically unstable and inefficient for large systems Orthogonal decomposition methods - more stable, but can be slower. e.g. QR decomp. Iterative methods - e.g. steepest descent, conjugate gradients - efficient for sparse matrices - needs to be symmetric, positive-definite CS 89/189: Computational Photography, Fall 2015 35

  36. Convergence gradient 
 descent conjugate 
 gradients CS 89/189: Computational Photography, Fall 2015 36

  37. Bells and whistles

  38. Contrast problem • Contrast is a multiplicative quantity • With Poisson, we try to reproduce linear differences • Loss of contrast if pasting from dark to bright

  39. Contrast preservation: use the log Poisson in linear color space Poisson in log color space • see A Perception-based Color Space for Illumination-invariant Image Processing 
 http://www.eecs.harvard.edu/~hchong/thesis/color_siggraph08.pdf • Or use covariant derivatives (next slides)

  40. Covariant derivatives & Photoshop • Photoshop Healing brush • Developed independently from Poisson editing by Todor Georgiev (Adobe) From Todor Georgiev's slides http://photo.csail.mit.edu/posters/todor_slides.pdf

  41. Eye candy

  42. Result (eye candy)

  43. Manipulate the gradient • Mix gradients of g & f: take the max

  44. Questions?

  45. Slide credits Frédo Durand Steve Marschner Matthias Zwicker CS 89/189: Computational Photography, Fall 2015 50

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend