View this page on my blog for moving GIFs.

1. Plenoptic image

The plenoptic image is restructured as a matrix of size \((U, V, S, T, C) = (16, 16, 700, 400, 3)\).

Sub-aperture views

This data has 16x16 “viewpoints” or sub-apertures. Each viewpoint is depicted here, in a grid of 16x16 images.

Alt text

Refocusing / Focal stack simulation

\(\iint_{(u,v) \in A} L(u, v, s, t, c) \text{d}v \text{d}u\) Alt text

Depth from focus

Using \(\sigma_1=1, \sigma_2=4\), we recover the following depth image and all-in-focus image. Alt text Alt text

Focus-Aperture stack

The aperture size varies horizontally and focal distance varies vertically along the grid in the following image. Alt text

Aperture-focus images

Aperture-focus image at the following pixel locations. From left:
x=60, y=240
x=90, y=360
x=150, y=120
x=200, y=125
Horizontal axis represents aperture size and vertical axis represents change in depth.or focus

Depth from Focus-Aperture stack

Alt text

2. Unstructured lightfield

Capturing unstructured lightfield

Alt text

Data used for unstructured lightfield.
Top: the full-length GIF shows how the camera was moved.
Bottom: three cuts from different heights.

Calculating shifts

Top Left: template patch
Top Center: frame taken from bottom right camera position
Top Right: frame taken from top left camera position
The red box refers to the search window.
Bottome Left: A plot of all points where the template patch was found.
Bottom Right: A refocused image on the template
  1. I employ a coarse-to-fine search to save computation. I slide the template by step_size across the search window and find the position where NCC is highest.

  2. When such initial position is found, I search within a smaller search window within step_size distance from the initial position by sliding the template by a single pixel at a time.

  3. To calculate NCC (Normalized Cross Correlation),
    • center both template and image patch at zero mean.
    • apply box filter on image patch
    • divide by l2 norm
    • take sum of correlation scipy.signal.correlate2d
  4. The position found in step 2 offset by shifting the same amount in the negative direction, in order to align all the frames on the same patch.

  5. Average all aligned frames and crop to attain the refocused image.

Top: refocused on "protein" box
Bottom: refocused on door