260 likes | 279 Views
Understand and implement a Poisson seamless cloning image editing tool for smooth completion and cloning. Use Euler-Lagrange equations and sparse algebraic systems to solve for unknown areas. Guide completion using gradients from another image. Program generates output images.
E N D
Advanced Topics in Computer Graphics Exercise 1 Poisson Image Editing Due date: 17.05.05 Presentation by: Tommer Leyvand
General Description The purpose of this exercise is to understand and implement a Poisson seamless cloning image editing tool. Part 1: Smooth image completion Part 2: Poisson seamless cloning
Input Images source image target image
Some More Results target image source images
Some More Results simple cloning source images
Some More Results Poisson seamless cloning source images
Part 1 Smooth Completion
Smooth Image Completion What if there is a missing area ? f* – the known image Scalar 2D function from (x,y) to grayscale value. f - the image in the unknown area Ω– the unknown area (domain of f) Will complete the area as smoothly as possible.
Smooth Image Completion(Cont.) Finding the minimum: Euler-Lagrange Discrete Aprx:
Discrete Derivate in 1D • Given a discrete function f(xi)=fi f f(xi) f(xj) x
Smooth Image Completion(Solving) • Each fx,y is an unknown variable xi, total of N variables (covering the unknown pixels) • Reduces to the sparse algebraic system: fx,y-1+fx-1,y-4fx,y+fx+1,y+fx,y+1=0 => xi-w+xi-1-4xi+xi+1+xi+w=0 x1 x2 … xN 0 0 b1 b2 0 0 0 b3 0 1 1 -4 1 1 Known values of f() contribute to the left side 1 1 -4 1 1 xi-w+xi-1-4xi+xi+1=-f(x,y+1) 1 1 -4 1 1 = N x N
Program Usage The program generates one output image • Ex1 –complete <input image> R G B <output> Where R,G,B are the RGB values [0..255] of the unknown color (usually best as black 0,0,0) • Example: • Ex1 –complete in1.bmp 0 0 0 out1.bmp
Wow result ground truth result input
Part 2 Poisson Cloning
Poisson Cloning:“Guiding” the completion • We can guide the completion from part1 to fill the hole using gradients from another source image • Reverse: Seek a function f whose gradients are closest to the gradients of the source image
Poisson Cloning (forward difference) (backward difference)
Poisson Cloning (Solving) • Each fx,y is a variable xi as before, solving • As before this reduces to a sparse algebraic system fx,y-1+fx-1,y-4fx,y+fx+1,y+fx,y+1=divG(x,y) => xi-w+xi-1-4xi+xi+1+xi+w=divG(x,y)
Program Usage The program generates one output image • Ex1 –clone <source image> <source mask> <target image> x y <output> Where x y are the offset for the paste
Important Remarks • You should write the programs in C or C++ or Matlab. • Document your program thoroughly. • In this assignment there is no need to open a window or use OpenGL in any way. • Visit the exercise web-page http://www.cs.tau.ac.il/~tommer/adv-graphics/ex1.htm
Important Remarks • The work can be done in pairs. • Submit your work on diskettes (or CD’s). Hardcopy of the documentation. • Do not print the source-code • In the documentation: Answer the questions from exercise website • Points will be rewarded for nice and original images.
More Important Remarks • Don't forget to check the number of parameters that your program receives. • Don't forget to check memory allocations, if they succeeded or failed. • Pay attention to the borders of the image. • Visualize the gradients/div to better understand what is going on
A Little Help • IrfanView – An image viewer, editor. • FreeImage/CxImage – Open source libraries (C/C++) for working with images. • TAUCS – Sparse solver • See links on the exercise webpage • Important questions: • Email me tommer -a--t- tau.ac.il http://www.cs.tau.ac.il/~tommer/adv-graphics/ex1.htm