Image Blending
CS129 Computational Photography Project 2
Seamless image blending using poisson equation solving (Perez, et al.).
Goal
The goal of this project is to blend two images seamlessly. The algorithm used to blend images follows the paper Perez'03' (Perez, et al.). The algorithm uses Discrete Poisson Solver and Seamless Cloning to blend two images together. The following image gives more insight of what the project is about.
Algorithm
The algorithm takes source image, image mask and target image and blends the source image with the target image based on the mask. The final image pixels are computed by solving Poisson equation. The algorithm produces a linear equations for each image pixel under the mask. The system of linear equations is expressed in sparse matrix form (as most of the entries are 0). The algorithm is significantly faster as it computes the values and coordinates ahead of time i.e. before making call to the sparse command for creating sparse matrix.
From Airplane Window
|
|
Extra Credit : Mixing Gradient
There are situations that requires the texture of the target image in the final image. This can be done by mixing gradients from source image and target image. My algorithm uses a part of gradient from the source image and a part of gradient from target image. So for a pixel in final image, instead of taking gradient from either source image or from the target image (comparing absolute intensities) the algorithm takes some percentage from both. The percentage of gradient to take from source and target depends completely on image and it changes from image to image.
% Mixing Gradient
Final_Gradient = ( alpha* Source_Gradient + (1-alpha) Target_Gradient )
% "alpha" depends on the image
% for above image alpha=0.5
Results