**Gradient Domain Fusion**
Student name: Abhishek Pavani
(#) Project Description
In this project, I explored gradient domain fusion techniques. In particular, I implemented poisson blending, to
blend 2 images.
The goal is to seamlessly blend an object or texture from a source image into a target image, without creating noticeable seams.
The approach is to preserve the gradient of the source region while ignoring the overall intensity, using a least squares problem to solve for new intensity values within the source region.
The method presented is one example of a more general set of gradient-domain processing techniques, with applications including blending, tone-mapping, and non-photorealistic rendering.
The project involves implementing the Poisson blending technique and potentially exploring additional techniques as well.
The reason why "Poisson Blending" produces a more realistic composition than simply pasting two similarly
colored images together is that our visual system is more responsive to changes in contrast rather than variations in intensity.
(#) Toy Problem
(##) Reconstructed and Original Images
We were asked to implement a toy version of the actual problem, where we compute the x and y gradients in the source image and then use all gradients and one
pixel intensity to reconstruct the original image
The objective function that we are trying to minimize is given below
$minimize$ $[((v(x+1,y)−v(x,y))−(s(x+1,y)−s(x,y)))^{2}$
$+$ $((v(x,y+1)−v(x,y))−(s(x,y+1)−s(x,y)))^{2}$
$+$ $(v(1,1)−s(1,1))^{2}$]
| Original Image | Reconstructed Image|
|----------|---------|---|
| | |
(#) Poisson blending
The goal of poisson blending should preserve gradients of source region without changing the background.
We treat the pixels in the output image as variables to be solved which we get can get by minimizing the
equation below.
The Poisson blending algorithm involves generating a mask that indicates the overlapping region
between the source and target images, and padding both images to the same size as the target image.
The images are then translated using parameterized row/column offsets, and a 1-pixel symmetric buffer
is added to the images if the valid pixels in the mask are on the edge of the source image.
A linear system of equations represented by AX=B is required to compute the resulting image from the
source and target gradients.
The size of sparse matrix A is N x N, where N is the target image rows multiplied by target image columns.
For pixels outside the masked region, the output image pixel is simply the same as the target image,
and the row in the sparse matrix A is the same as the identity matrix. For pixels inside the masked region,
the output image pixel x at (row, col) depends on its neighbors according to a specific equation,
and the row in the sparse matrix A contains coefficients at the corresponding indices.
The value of the desired pixel gradient is in matrix B and changes according to Mixing Gradients.
The blending problem is phrased as a least-squares problem, which requires solving AX = B for every pixel
under the mask. Once we have the coefficient matrix A and B, we can find our output image.
(###) Tricks to keep in mind:
Before blending make sure that the relative size of the source and target images are similar. If the scale and pose
of images is different then the blending result wont look realistic.
(##) Source and Target Images
| Source Image | Target Image|
|----------|---------|---|
| | |
(##) Naive and Poisson blending result
(#) Other Blending Results
(##) 1. Moon and Lake Images
| Source Image | Target Image|
|----------|---------|---|
| | |
(##) 2. Penguin and People walking in snow Images
| Source Image | Target Image|
|----------|---------|---|
| | |
(#) Failure case
As seen from this image that, if the background colors dont match the foreground color, the masked region looks weird. Here I tried pasting
a person's hairstyle on another person. The target image has a light colored background, so the blending takes in that color information and spoils
the blending result.
| Source Image | Target Image|
|----------|---------|---|
| | |