Assignment 2 : Gradient Domain Fusion
Poisson Blending: Mathematical Framework
The Poisson blending process involves solving an optimization problem that aims to blend the source and target images seamlessly. The optimization function can be described as follows:
v = argminv Σi∈S,j∈Ni∩S ((vi - vj) - (si - sj))2 + Σi∈S,j∈Ni∩¬S ((vi - tj) - (si - sj))2
vrepresents the pixel values in the blended image we are trying to find.Sis the set of pixels in the source image's region we wish to blend.Niis the set of neighboring pixels around pixeli.viandvjare the pixel values in the blended image at positionsiandj, respectively.siandsjare the pixel values in the source image at positionsiandj, respectively.tjis the pixel value in the target image at positionj.¬Srepresents the region outside ofS, the complement of the source region.
- The first term ensures that the difference in gradients between neighboring pixels within the source region in the blended image (
vi - vj) is similar to that in the source image (si - sj). - The second term ensures that the pixel values at the boundary of the source region in the blended image match the corresponding pixel values in the target image, allowing for a seamless transition.
Toy Problem
Poisson Blending
The overall process of Poisson Blending is as follows:
- Preparation of the Mask: Convert the mask to a boolean array to indicate which pixels to blend.
- Mapping Pixels to Variables: Each pixel within the mask is mapped to a variable in a linear system.
- Setting Up the System of Equations: A sparse matrix system is created to solve for pixel values.
- Calculating the Divergence: The divergence of the gradient at each pixel is calculated and set in the system.
- Boundary Conditions: Target image values are used for boundary pixels to ensure a seamless blend.
- Solving the Linear System: The sparse system is solved to find the optimal blended pixel values.
- Reconstructing the Image: The solved pixel values are inserted back into the target image.
- Result: The final blended image with a smooth transition is produced.
Some of the results are as follows:
Example Image
Source Image
Target Image
Favorite Image
Source Image
Target Image
Source Image
Target Image
Failed Image
Source Image
Target Image
Unsuccessful Poisson Blending: Potential Causes
Several factors could contribute to the unsuccessful blending observed in Poisson Blending:
- Incorrect Masking: Poisson blending requires an accurate mask that defines the region of the source image to be blended. If the mask is not correctly defined, the algorithm may not interpret which gradients to match correctly, leading to a poor blend.
- Gradient Mismatch: The Poisson algorithm relies on the assumption that the gradients of the source and target can be matched smoothly. Significant differences in gradient fields due to lighting or texture might prevent the algorithm from finding a solution that blends the images naturally.
- Boundary Conditions: If boundary conditions are not correctly enforced or if the region where the source and target meet is not well-defined, the algorithm may fail to produce a result that aligns well with the target image.
- Image Content and Complexity: The content of the images being blended can affect the outcome. Blending a complex object into a complex background may not be as seamless as blending a simple object into a uniform background.
- Algorithm Limitations: Poisson blending may struggle with scenarios where there is a vast difference in color intensity ranges between the source and target images, potentially causing blending artifacts or color distortions.
