Haim-Segal / Poisson-Blending

Blending images using Poisson’s equation and sparse matrices

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Poisson Blending

Blending images using Poisson’s equation and sparse matrices

Poisson Blending is an algorithm used in image processing for achieving a realistic looking composition of two images using Discrete Poisson equation. The key idea is to approach this challenge as Dirichlet problem. In particular, let us treat the overlapping region between the images (a source image being inserted into a destination image) as the potential field caused by a given density distribution of electric charge or mass which in our case will be related to the laplacian of the images, and as the fixed boundary condition we will take the values of the destination image on the boundary curve enclosing the source image patch.

Finally, we deal with a linear system of equations represented by Ax=b, where the size of the coefficient matrix A is NxN, where N is the number of the pixels in the source image. In order to construct and solve this system I use the great library of Algebraic Multigrid (AMG) solvers PyAMG.

Results

naive blending Naive Blended

Poisson blending Poisson Blended

original images links: source image, destination image

Installation and Usage

run Poisson Blending 2D.py and follow the instructions

Enjoy!

References

Patrick Perez, Michel Gangnet, Andrew Blake, "Poisson Image Editing".

About

Blending images using Poisson’s equation and sparse matrices

License:MIT License


Languages

Language:Python 100.0%