CS194-26 Final Project 1: Triangulation Matting and Compositing

Overview

In this project, I used triangulation matting to extract a semi-transparent object and an alpha matte, and then used the filters produced to composite a new image.

Images that I took

I took 4 images: a white background with the object (a bottle with a pen in it), a black background with the object, and the two backgrounds by themselves. The last image is a picture of Sather Gate, on which I'll composite the object.

White background with the object

Black background with the object

White background

Black background

Sather Gate

Triangulation Matting

Triangulation matting works by taking images of the same object against two different background. Then, we can form a system of equations to solve for the foreground image and the alpha matte. For each pixel, we have the following equations (this comes from slide 8)


This gives us a foreground image and alpha matte. Notice that the foreground image displayed here has already been premultiplied by the alpha matte.

Foreground image


Foreground image

Homography

I also used the homography technique we did in project 4 to warp the image so that the perspective aligns up between the object and Sather Gate.

Compositing

Upon compositing, I computed the background by multiplying by 1-alpha and stacked the foreground image on it. This creates the composite image. The composition was a success because the transparent part of the bottle is actually transparent and one can see the road behind it.

Composite image

CS194-26 Final Project 2: Lightfield Camera

Overview

In this project, I first worked on depth refocusing. Objects that are further away from camera shift less compared to ones that are closer to the camera. Thus, by shifting images proportionally to their distance to the center, I created this simulation of change in focus. Then in the second part, I simulated change in aperture while focusing on the same point on the image by averaging surrounding photos.

Depth Refocusing

Like mentioned in the overview, I simulated change in focus by averaging photos of different shifts. I calculated the u-v distance between two images and multiplied it by a scale factor to achieve this. The scale factor C is in the range from -2 to 2. Here're some examples.

C = -2

C = 0

c = 1


GIF

Bells and Whistles

I took some of my own images and tried to recreate the refocus with a C = 0. There is a sample image and the result. It did not work, probably because I took the images by hand rather than using a tripod and hands were naturally shaking too much.

Example image

The refocused image

Aperture Adjustment

Like mentioned in the overview, in this part simulated change in aperture by averaging photos at different radius. By changing the radius at which the average is taken, it looks like the aperture is changing. I used radius from 0 to 7. Here're some examples.

R = 0

R = 2

R = 6


GIF