CS 180: Final Project

Albert Wang

For the Final Project, there will be two separate subprojects: Lightfield Camera and Gradient Domain Fusion


Lightfield Camera

This project explores how lightfield data can be processed to simulate visual effects like depth refocusing and aperture adjustment. Using a dataset of sub-aperture images arranged in a 17x17 grid, we demonstrate how simple image manipulations like shifting and averaging allow us to produce different effects on the overall image. This lightfield data is taken from Stanford's Light Field Archive.

Part 1: Depth Refocusing

Depth refocusing leverages the variation in how objects appear across the lightfield grid based on their distance from the camera. Objects closer to the camera shift more significantly between images compared to distant objects when the camera's optical axis remains unchanged.

To refocus: Each sub-aperture image (u,v) is shifted by C × (v - vc, u - uc), where (uc, vc) is the center image coordinate. These shifted images are averaged together, creating a new image focused at a specific depth determined by the constant C. I used C ranging from -2 to 1.6 to generate the GIFs below. As C changes, the apparent focus plane shifts, creating a refocusing effect.

Chess set depth refocus GIF Lego set depth refocus GIF

Part 2: Aperture Adjustment

We can simulate readjusting the aperture by averaging different subsets of images in the dataset. Aperture adjustment simulates changes in the camera's aperture size by controlling how many images from the lightfield are averaged. Larger apertures result in more focused images at a specific depth, while smaller apertures create a broader focus.

To adjust the aperture, A radius r defines the maximum allowable distance from the center image for sub-aperture inclusion. Images within this radius are shifted using the same method as depth refocusing and then averaged.

Here is the GIF is generated by using r from range 0 to 15, with a constant C value of -0.15. The result shows the gradual effect of increasing aperture size on focus depth.

Chess set aperture adjustment GIF Lego set aperture adjustment GIF

Summary

This project helped me understand how lightfields capture rich information about light in a scene, enabling the simulation of camera effects like adjusting focus and aperture. It was fascinating to see how simple operations created multiple different effects.


Gradient Domain Fusion

This project explores gradient-domain image processing, a powerful technique for blending images together. Unlike in project 2, which focused on pixel intensity, this project focuses on matching gradients.

Part 1: Toy Problem

Before implementing Poisson Blending, we tackled a toy problem to verify our understanding of gradient reconstruction. The objective was to reconstruct an image using only its gradients in the x and y directions and a single known pixel value.

Here is the original toy image and the reconstructed image:

Original toy image Reconstructed toy image

The max error between the two images is 0.0010002051356807207.

Part 2: Poisson Blending

Poisson Blending enables seamless blending of a source image region (e.g., an object) into a target image (e.g., a background) by preserving the gradients of the source region while matching the intensities of the target region around the boundary. The process follows these steps:

Here are some results:

Poisson blending result 1 Poisson blending result 2 Poisson blending result 3

My favorite result, which shows Goku charging up a Smash Ball:

Poisson blending result 4 - Goku with Smash Ball

Bells and Whistles: Mixed Gradients

Mixed Gradients is similar to Poisson blending, but we use the gradient in source or target with the larger magnitude as the guide, rather than always using the source gradient:

Equation 2

Here "dij" is the value of the gradient from the source or the target image with larger magnitude. Specifically, if |si - sj| > |ti - tj|, then dij = si - sj; else dij = ti - tj. This ensures that the gradients in the blended result maintain the most visually significant changes, whether from the source or the target.

Here's the result of using mixed blending:

Mixed gradients result

Reflection

I was able to create some really cool blends by preserving image gradients. The blends were pretty seamless for certain image pairs.