Depth of field experiment

Tilt-shift photography

Tilt-shifting is a photographic technique involving the physical rotation (tilt) and translation (shift) of a lens with respect to the imaging plane. The result is a picture with warped perspective or selective focus. A particularly cool use of lens tilting lets us simulate a miniature scene from a photograph of real-world scenery.

Faking it

Lacking a tilt-capable lens, we can use digital post-processing techniques to emulate this effect. I found an article that gave an example on how to do this with a blurring function:

  1. Blur the original (in-focus) image
  2. Identify image regions that are in or out of focus (in the article, the GPU Z-buffer is used)
  3. For each pixel in the output, linearly interpolate between a focused and blurred pixel
A tilt lens
 blah blah blah MATLAB code
            newline tests Dear Qifan: finish this 

The result

Original image

Fully blurred version

Selectively blended