Assignment 2 Vihaan Misra

1. Overview

This project explores gradient-domain processing, a technique widely used in image editing, computer graphics, and computer vision.

Source Image

Target Image

Naive Merging

Observing Figures 1, 2, and 3, we notice that directly cropping a region of interest and placing it onto a new background can lead to noticeable seams, detracting from the visual appeal. To address this, our approach focuses on modifying the gradients of pixels within an image instead of the pixel values themselves. This method yields subtler and more aesthetically pleasing outcomes.

Poisson Blending

One of the key techniques of gradient-domain processing is Poisson blending. This method allows for the seamless integration of an object or texture from one image into another by aligning the gradients of both images and reducing their differences. Initially, we demonstrate how an image can be reconstructed from its gradients using a simple example. Subsequently, we apply Poisson blending to flawlessly merge an object or texture from a source image into a target image.

Overcoming Limitations with Mixed Gradients

Despite its advantages, Poisson blending has certain limitations. To circumvent these, we employ mixed gradients, enhancing the algorithm's ability to merge images seamlessly.

2. Toy Problem

Through a simple illustrative example shown in the figure below, we demonstrate the process of reconstructing an image from its gradient values. The reconstruction process begins by setting the value of the first pixel as the boundary condition, which serves as a starting point for the entire image reconstruction.

3. Poisson Blending

To blend an object or texture from a source image into a target image, we utilize Poisson blending. This technique finds the optimal merge by minimizing the gradient differences between the two images. The steps are as follows:

  1. Select the region of interest 'S' from the source image.
  2. Create a binary mask to define the region 'S' within the source image.
  3. Determine the corresponding region 'v' in the target image for blending.
  4. Employ a linear system to reduce the gradient disparities between source and target, adhering to the mask's boundary conditions.
  5. Reconstruct the composite image from the gradients using the solutions from the linear system.

Mathematical Formulation

The mathematical representation of the Poisson blending process is as follows:

Poisson Blending Equation

This equation seeks to find the values of 'v' that minimize the sum of squared differences between the gradients of the source image 's' and the target image 't', across the region of interest 'S' and its boundary conditions.

For a more cohesive blending, we prefer images with analogous backgrounds, enhancing the gradient similarity and visual appeal of the blend. Below, we present the results of Poisson blending applied to various images.

Source

Blending Result

Source

Blending Result

Source

Blending Result

4. Failure Case

While Poisson blending is a powerful tool for image blending, it is not without its challenges. One notable limitation arises when the source and target images have substantial gradient disparities. Such differences can lead to less than desirable outcomes in the final blended image.

In the example provided below, we observe a source image featuring a hot air balloon with a gradient profile that is markedly distinct from that of the target image, which is a city skyline. The inherent differences in gradients between the two images mean that when we apply the linear system of the Poisson blending algorithm, the resulting boundary conditions and gradient constraints can cause an alteration in the color of the blended region, as shown.

Source

Blending Result

This example underscores the importance of gradient compatibility in Poisson blending to achieve a seamless and natural integration between source and target images.

5. Color2Gray

The following section details the process of leveraging mixed gradients to convert color images to grayscale effectively while preserving contrast.

  1. Begin by transforming the color image into the HSV (Hue, Saturation, Value) color space.
  2. Then, apply the mixed gradients method, utilizing the saturation channel as the 'source' and the value channel as the 'target' to create a grayscale image.
  3. The outcome of the linear solver, in this case, furnishes us with the final grayscale image, which retains the original contrast of the color image.

This approach ensures that the grayscale image maintains the contrast information from the color image, resulting in a more dynamic and detailed grayscale representation.

Source

Blending Result