**16-726
Gradient Domain Fusion** **Anish Jain (anishaja)** Overview =============================================================================== This assignment delves into methods and uses of gradient domain blending, particularly emphasizing "Poisson blending." The goal is to smoothly merge an object from a source image into a target image while retaining the distinctive features of the source object. The fundamental idea is that the gradient of an image holds more significance for viewers than its overall intensity. Therefore, the technique involves blending a source image into a target image by preserving the gradients of the source image while aligning with the intensity values of the target image. Toy problem =============================================================================== I implemented optimization-based image reconstruction using gradient domain with examplar toy image. The logic is implemented in the "toy_recon" method in proj2_starter.py. The method takes in the input image and returns the constructed image. This is done by solving the following optimization problem where v is the constructed image and s is the input image: $$ f_{obj, 1} = ((v(x+1, y) - v(x, y)) - (s(x+1, y) - s(x, y)))^2 $$ $$ f_{obj, 2} = ((v(x, y+1) - v(x, y)) - (s(x, y+1) - s(x, y)))^2 $$ $$ f_{obj, 3} = (v(1, 1) - s(1, 1))^2 $$ The given image is of dimensions 119*110. Thus, the size of A is ((119-1)*(110-1)*2 + 2 + 1 = 25727, 119*110 = 13090) and the size of B is (25727, 1). The size of the constructed image is (119, 110). The optimization problem is solved using the scipy.sparse.linalg.lqsr method. The constructed image is shown below: ![Toy problem](submissions/toy_recon.png) Poison Blending =============================================================================== In poison blending, we formulate the problem as a least squares problem. The objective function is given by: ![](submissions/poison_eq.png) Given the input pixel values for source and target images, we want to solve for intensity values v that minimize the objective function within the source image. Results ------------------------------------------------------------------------------- We create the masks for the source and target images using the given script and then solve for the intensity values using the "poisson_blend" method in proj2_starter.py. The constructed image is shown below: ![](submissions/statue_newsource_blended.png) ![](submissions/house_newsource_blended.png) ![](submissions/balloon_newsource_blended.png) Failure Cases ------------------------------------------------------------------------------- The poison blending fails when the color values of the source and target images are different. This is evident in the following image: ![](submissions/obama_newsource_blended.png) Bells and Whistles =============================================================================== Mixed Blending ------------------------------------------------------------------------------- I extend the poison blending to mixed blending by using the larger gradient from source and target image. Below are a few results: ![](submissions/obama_newsource_mixed.png) ![](submissions/mickey_newsource_mixed.png) Color2Gray ------------------------------------------------------------------------------- In this section, we explore an alternative to rgb2gray using gradient blending. Below are the color images from the color blind test data. | RGB | RGB2Gray and Gradient Mixed blending | |-------------------------------------|------------------------------------------------| | ![](submissions/color_blind_16.png) | ![](submissions/color2gray_color_blind_16.png) | | ![](submissions/color_blind_35.png) | ![](submissions/color2gray_color_blind_35.png) |