Part 1: Depth Refocusing

In this part of the project, we want to simulate focusing on a captured scene at different based on lightfield data we have from the Stanford Light Field Archive . To do so, we need to shift the images ‘appropriately’ and average them to simulate focusing on an object at different depths. The depth of our focused point will be a decreasing function of our image shift. The more we shift the image, the closer the objects in focus will be.

To do this, I first calculated a central coordinate (center_x, center_y) for our 17x17 image grid. Then, I shift each image at (x, y) by (center_x - x, center_y - y)*scale, where scale is some constant scaling factor that specifies the depth at which the refocused object appears. When scale=0, no refocusing appears, so the background is more focused than the objects. Objects in the background do not change much as we shift the image, while the clarity of objects in the foreground change drastically as we increase our scaling factor.

Refocused Depth of Field (-1, 1)

Part 2: Aperture Adjustment

In this part of the project, I want to simulate changing aperture size on a camera. Aperture radius (size) and depth of field have an inverse relationship - as the radius grows, our depth of field decreases, which means that the background of our photo becomes blurrier (bokeh effect), though the objects in the foreground still remain sharp.

To simulate this, we know that using images from a smaller grid results in an image that mimics a smaller aperture. Taking a specified radius, I shift and average only the images that have coordinates where the distance between the coordinate of the image and the central coordinate are less than the specified radius - so we “select” only the images we shift and average that fill within the specified radius of our uniformly space grid. In the gif below, I vary radius from 0 to 50 and you can see a beautiful result below that resembles changing camera aperture.

Changing Aperture - Lego Pieces
Changing Aperture - Crystal Ball & Tarot Cards