## Poisson Image Editing

The goal of *Poisson image editing* is to perform *seamless blending* of an *object* or a *texture* from a* source image* (captured by a *mask image*) to a *target image*. We want to create a photomontage by pasting an image region onto a new background using Poisson image editing. This idea is from the *P´erez et al*’s *SIGGRAPH 2003* paper Poisson Image Editing.

The following figures describe the basic theory. As can be seen, the problem is first expressed in the continuous domain as a ** constrained variational optimization **problem (

*is used to find a solution) and then can be solved using a discrete Poisson solver.*

**Euler-Lagrange equation**

As described in the paper and also in this assignment from this *MIT course* on *Computational Photography*, the main task of *Poisson image editing* is to solve a ** huge linear system** Ax = b (where I is the new unknown image and S and T are the known images).

## Seamless Cloning

The following images are taken from an *assignment* from the same MIT course, where the *Poisson image editing* had to be used to blend the source inside the mask inside the target image. The next few figures show the result obtained.

**Source Image**

**Mask Image**

**Target Image**

**Output Gray-Scale Image with Poisson Image Editing**

The next *animation* shows the solution gray-scale images obtained at different *iterations* using * Conjugate Gradient* method when

*solving*the

*.*

**linear system of equations****Output Color Image with Poisson Image Editing**

The next ** animation **shows the solution color images obtained at different

*iterations*using

*method to*

**Conjugate Gradient***solve*the

*, applying the discrete Poisson solver on each channel.*

**linear system of equations**

The following images are taken from this UNC course on *computational photography*. Again, the same technique is used to blend the octopus from the source image to the target image.

**Source Image**

**Mask Image**

**Target Image**

**Output Image**

The next ** animation **shows the solution color images obtained at different

*iterations*using

*method to*

**Conjugate Gradient***solve*the

*, applying the discrete Poisson solver on each channel.*

**linear system of equations**

Again, ** Poisson gradient domain seamless cloning** was used to blend the

*penguins’ image*inside the following target image with appropriate mask.

**Source Image**

**Target Image **

**Output Image**

The next ** animation **again shows the solution color images obtained at different

*iterations*using

*method to*

**Conjugate Gradient***solve*the

*, applying the discrete Poisson solver on each channel.*

**linear system of equations**

The next figures show how a *source bird* image is blended into the *target cloud* image with * seamless cloning*.

**Source Image**

**Target Image**

**Output gray-scale image**

The next *animation* shows the solution gray-scale images obtained at the first few i*terations* using * Conjugate Gradient* method when

*solving*the

*.*

**linear system of equations**

Finally, the next figures show how the *idol* of the *Goddess Durga* is blended into the *target *image of the *city of kolkata* with * seamless cloning*. As can be seen, since the source mask had its own texture and there is a lots of variations in the background texture, the seamless cloning does not work that well.

**Source Image
**

**Target Image
**

**Output Image
**

The next *animation* shows the solution gray-scale images obtained at the first few i*terations* using * Conjugate Gradient* method when

*solving*the

*.*

**linear system of equations**The next ** animation **again shows the solution color images obtained at different

*iterations*using

*method while*

**Conjugate Gradient***solving*the

*, applying the discrete Poisson solver on each channel.*

**linear system of equations**

## Feature Cloning: Inserting objects

The next figures are taken from the same paper, here the eyes, nose and lips from the source face image is going to be inserted into the target *monalisa* face.

** Source image Target image Output image**

The next ** animation **again shows the solution color images obtained at different

*iterations*using

*method while*

**Conjugate Gradient***solving*the

*, applying the discrete Poisson solver on each channel.*

**linear system of equations**

## Texture Swapping: Feature exchange with Seamless Cloning

As discussed in the paper, seamless cloning allows the user to replace easily certain features of one object by alternative features. The next figure shows how the texture of the other fruit was transferred to the orange, the images being taken from the same paper.

**Source Image Target Image Mask Image**

**Output Image**

The next ** animation **again shows the solution color images obtained at different

*iterations*using

*method while*

**Conjugate Gradient***solving*the

*, applying the discrete Poisson solver on each channel.*

**linear system of equations**

## Gradient Mixing: Inserting objects with holes

Again, the next figures are taken from the same paper, this time the source objects contain holes. As can be seen from the following results, the ** seamless cloning **does not work well in this case for inserting the object with holes into the target, the

*target texture*is lost inside the mask after blending.

**Source Image Target Image
**

**Output Image with Poisson Seamless Cloning**

The next ** animation **again shows the solution color images obtained at the first few

*iterations*using

*method while*

**Conjugate Gradient***solving*the

*for*

**linear system of equations***, applying the discrete Poisson solver on each channel.*

**seamless cloning**Using the * mixing gradients* method the blending result obtained is far better, as shown below, it preserves the target texture.

**Output Image with Poisson Mixing Gradients
**

The next ** animation **again shows the solution color images obtained at the first few

*iterations*using

*method while*

**Conjugate Gradient***solving*the

*for*

**linear system of equations***, applying the discrete Poisson solver on each channel.*

**mixing gradients**

## Mixing Gradients: Inserting transparent objects

The next example shows the insertion of a * rainbow *into a

*image, the images are taken from the paper again. As can be seen, the*

**target***wrongly places the rainbow in front of the coconut tree in the target image. Using*

**seamless cloning***, the stronger gradient is used as the image gradient and this solves the issue.*

**gradient mixing**

* Source Image Target Image Mask Image*

**Output Image with Seamless Cloning**

**Output Image with Mixing Gradients**

The next ** animation **again shows the solution color images obtained at the first few

*iterations*using

*method while*

**Conjugate Gradient***solving*the

*for*

**linear system of equations***, applying the discrete Poisson solver on each channel.*

**mixing gradients**

The next few figures show the results obtained using mixing gradients on another set of images, the * seamless cloning *does not work well in this case, but

*works just fine.*

**mixing gradient**

**Source Image**

**Target Image**

**Output Image with mixing gradients**

The next ** animation **again shows the solution color images obtained at the first few

*iterations*using

*method while*

**Conjugate Gradient***solving*the

*for*

**linear system of equations***, applying the discrete Poisson solver on each channel.*

**mixing gradients**## Texture Flattening: Creating Flat-texture Cartoon-like images

As illustrated in the paper, by retaining only the gradients at edge locations, before integrating with the Poisson solver, one washes out the texture of the selected region, giving its contents a flat aspect.

The following figures show the output *cartoon-like image* obtained using * texture flattening*, using the canny-edge detector to generate the mask.

**Source Image
**

**Mask Image created with Canny edge detector
**

**Output cartoon obtained with texture flattening from the source with the mask
**

The next ** animation **shows the solution color images obtained at the first few

*iterations*using

*method while*

**Conjugate Gradient***solving*the

*for*

**linear system of equations***, applying the discrete Poisson solver on each channel.*

**texture flattening**

Again, the next figures show the output *cartoon-like image* obtained using * texture flattening*, using the canny-edge detector to generate the mask on my image.

**Source Image
**

**Output image obtained with texture flattening
**

The next ** animation **again shows the solution color images obtained at the first few

*iterations*using

*method while*

**Conjugate Gradient***solving*the

*for*

**linear system of equations***, applying the discrete Poisson solver on each channel.*

**texture flattening**

Pingback: Sandipan Dey: Some Variational Image Processing: Possion Image Editing and its applications in Python | Adrian Tudor Web Designer and Programmer

Pingback: Sandipan Dey: Some Variational Image Processing: Poisson Image Editing and its applications in Python | Adrian Tudor Web Designer and Programmer

Great work! Is there someplace you have posted the code for all of your blog posts?

LikeLike

Thanks voxxie, no I have not, mainly because almost all of them are part of some online courses I took at some point in time and sharing the code will be violation of the honor code.

LikeLike