Poisson Texture Synthesis (Image Blending)
Language: Matlab
Overview of the project
Motivation
- How to transfer the key feature of texture(image) to other textures.
Problem which I had
- Simple copying and pasting approach does not work because it derives visible boundary in between.
Which features are included in this project
- Filling the gap in the area where the gradient is transfered (Setting up base colour before the gradient is copied).
- Combining the gradient of source and target image to preserve both characteristics (distinctive textures in the image).
How to solve the problem
- Used Poisson solver (based on P. Perez's paper) to transfer the gradient to another image rather than copying colour value.
Limitation
- If the colour of source image and target image are different, the result may not be unsatisfactory.
Detail of the project
I was interested in local image modification so that it makes possible to change desired region rather than affecting the entire image. Compared to global change, slow gradient change is required for seamlessness in that region and Laplacian is used to replicate the gradient of source image to the destination. In order to achieve this goal, Poisson equation has been used, which is mathematical tool to solve the problem for boundary and unknown function (region).
1. Solving Poisson
In order to apply local change, we have to consider which information is known or unknown. The boundary condition (Dirichlet) between the source image and destination can be solve by Laplacian’s equation, which is
I was interested in local image modification so that it makes possible to change desired region rather than affecting the entire image. Compared to global change, slow gradient change is required for seamlessness in that region and Laplacian is used to replicate the gradient of source image to the destination. In order to achieve this goal, Poisson equation has been used, which is mathematical tool to solve the problem for boundary and unknown function (region).
1. Solving Poisson
In order to apply local change, we have to consider which information is known or unknown. The boundary condition (Dirichlet) between the source image and destination can be solve by Laplacian’s equation, which is
This condition is very important because the known boundary becomes reference for the unknown region when the unknown region is constructed. For the 2D image which is discrete information, neighbouring pixels are considered to calculate Laplacian.
We need the fill the gap to construct basis before transferring. In order to fill the gap, we need to solve following equation.
Np is the number of neibouring pixels and fp is the intensity of current pixel. Vqp is the gradient between pixel q and p. Then, we can fill unknown pixels in the image like below.
2. Mixing gradients
If we just transfer gradient from source to target image, the original gradient of target image will be lost. It can be undesirable effect when we use it for texture synthesis. For example, when a designer copies a mountain in the height map to another height map, transferred mountain will not get along with original terrain like below on the left.
In order to mix gradient, we use following condition.
Following is the core part of source code.
- Another Result