This project explores the use of Poisson Blending, an image blending technique that operates in the gradient domain, to achieve seamless image composition. Naive blending often produces visible seams, even when the source and target images have similar backgrounds. Therefore, this project adopts a more advanced method (Poisson Blending by Perez et al.) to improve the blending quality.
For this project, the following features has been implemented:
- toy problem
- poisson blending (can be solved as a least square problem v = argmin_v ||Av-b||^2)
For those j out of mask region:
A[e, im2var[y, x]] = 1
b[e] = t[y, x + 1] + s[y, x] - s[y, x+1]
- poisson blending with mixed gradient
The implementation of blending takes the advantage of scipy.sparse for solving least square problem.
This blending result is achieved by combing the following pictures together
Brief Explanation: I took these steps to create a seamless blending of two images:
Use the provided masking toolkit to generate a mask and a new source image.
Solved the blending constraints using the Poisson equation (overview section).
Reduced the image size by 50% to speed up the process.
I compared the results of native Poisson blending and mixed-gradient Poisson blending and found that the latter produced a better effect. The mixed-gradient method added some transparency to the blended image, making it more natural and realistic. Therefore, I chose to use the mixed-gradient Poisson blending for this image. You can see both results below.
Result (Mixed Blending)
Result (Poisson Blending)
Failure (Mixed Blending)
Okay-Quality Blending
Native Poisson Blending requires the source and target images to have similar textures in the background or non-object regions. Otherwise, it will produce visible seams. This method cannot generate consistent textures with the target images due to its constraints.
Using mixed gradients can mitigate the problem of native Poisson Blending, but it is not a perfect solution. It only works well when the source image has high contrast between objects and backgrounds (under this circumanstance, the algorithm will tend to keep the gradient of the object part of the source image). Otherwise, the mixed-gradient approach will create unwanted transparency (led by keep part of the gradient of the source image and part of the gradient of the target image) and visible seams in the blended image.
Mixed Gradient