CS 194-26 Final Undergraduate Project by David Hahn

Introduction

I had a great time in CS 194-26 and I'm sad that this is going to be my final pair of projects for the semester. However, fake miniatures (also known as tilt shift) ended up being one of my favorite projects for the year. The effect is convincing yet fairly simple to do in post (despite there being lots of fancy lenses you can buy to achieve the same effect). The dolly zoom was also interesting and my only reservation with it is wishing I had some sort of actual dolly to hold my camera so I could record a smooth video example. So without further ado, here are my two final projects: fake miniatures and dolly zoom.

grand_canyon
A Miniature Version of the Grand Canyon

Part 1: Fake Miniatures

Fake miniatures is quite simple in concept but the effect is surprisingly convincing. The overall idea is to mimic how our eyes perceive small miniature objects. When you look at a small object up close (for example the tip of your pencil), the point of focus remains in detail while the rest of the object and background blur and become out of focus. This is how the eye sees objects at close distances. We can create a similar effect artificially to trick our eyes into believing the objects we are looking at are miniature.

In order to accomplish this, I used user defined points to determine where the region of sharpness should be. Everything outside that region is blurred. A simple blurring of the exterior region may suffice for certain images but the best results are attained when the exterior region is increasingly blurred depending on the distance from the sharp region. This is because the increased blurring will add a sense of depth to the photo.

point_selection
Original Image with Points Selected Marked by Red Crosses

In order to effectively blur the image, we first create a structure similar to a Gaussian stack. We don't need to double the sigma for every level of the stack, however, since we will quickly completely blur out the image in doing so. This is not favorable because higher levels of the stack will be used in the parts of the output image that are further away from the sharp region and lower levels will be used for parts that are closer to the sharp region. We still want to be able to see the blurred portions of the photo and aggressively blurring does not seem to increase the effect. I found that instead of doubling the sigma value, adding 1.5 at every level of the stack was sufficient. I started with an initial sigma value of 1.

blurred_images
The Blurred Versions of the Images
Sigma Values = [1, 2.5, 4, 5.5, 7, 8.5, 10]

I limited my stack to a length of 7 as this many levels was sufficient for the image sizes (mostly 1500px x 1000px) I was working with and increasing sigma inevitably slows down the Gaussian blur portion of the code. I found that with larger and smaller photos the size of the stack must be increased and decreased, respectively, in order to make the progression of blurred regions granular enough to not be noticeable but not too granular that distortion is introduced (which I experienced with smaller images).

Next, I split up my image into 7 evenly spaced and equal size horizontal masks (as seen below) to construct a stack of masks.

masks
Masks

I then blurred the masks using the same sigma values as my image stack.

blurred_masks
Blurred Masks
Sigma Values = [1, 2.5, 4, 5.5, 7, 8.5, 10]

In order to reconstruct the blurred image, I took a weighted average for every given mask and image pair. I multiplied the mask against its corresponding image while dividing by the sum of all the masks. This results in a well blended image that blurs increasingly as distance from the sharp region increases. As a side note, the sharp region and a corresponding mask (which will be unblurred) should also be considered with the rest of the stack levels pictured above to ensure a clean blend.

pre_saturation
Blended and Blurred Image

Finally, saturating the colors of the image will make the objects within the image appear more toy-like due to their bright color. This is the finishing touch to the effect that really ties the effect together as you can see below with the rooftops of the buildings appearing to be painted.

post_saturation
Saturated Image




Below are some of my favorite results. Many of the shots came from on top of Berkeley's own Campanile tower with a few from the tops of the Eshleman and Martin Luther King Jr. buildings on campus. Please feel free to click the images to enlarge to inspect them more closely.

output_17
The World's Smallest Swimming Pool
input_17
Original



output_2
Miniature Memorial Glade
input_2
Original



output_18
Off-Campus Housing Options
input_18
Original



output_18
Very Expensive Toy Cars
input_10
Original



output_15
Students and Truck on their Way to Class
input_15
Original



I additionally chose some interesting images online, taking inspiration from some tilt shift photos I found via Google, and ran them through my code. Below are some results on photos taken by photographers more talented than myself:

city
Tiny Skyscrapers
city_original
Original



grand_canyon
My Model of the Grand Canyon Complete with Fully Functional Running River
grand_canyon_original
Original



market
Mini Night Market in Thailand
market_original
Original



planes
More Expensive Toys (planes this time)
planes_original
Original



train
Elevated Train Tracks because Land is Pricey
train_original
Original




I also tried to use a few photos for vertical regions but it does not seem to have as good of an effect. I suspect this occurs because objects on the same horizontal line are more likely to be at the same depth but including a vertical section that is sharp involves objects at many different depths and thus the eye is not as easily tricked.

We can apply the same principles as the horizontal region tilt-shift as long as we rotate the input image by 90 degrees counter-clockwise prior to blurring and blending and then rotating it back before outputting it. Here are some results:

output_21 output_8 output_11
Vertically Miniatured
Vertically Miniatured
Vertically Miniatured
input_21 input_8 input_11
Original
Original
Original

Part 2: Dolly Zoom

The dolly zoom creates an effect of a shrinking or growing background with a subject that appears to be the same size. This is achieved via a camera with an optical zoom lens where the photographer moves towards the subject while zooming out or moves away from the subject while zooming in. In doing so, the photographer must keep the subject the same size within the image frame for the best results.

camera
I used a Sony A7 with a 28mm - 70mm kit lens to accomplish this but
the images can be captured with any camera with an optical zoom.

Because zooming in will narrow the field of view of the camera, the background will appear to shrink while zooming in as the focal length of the lens becomes larger. Likewise, zooming out will widen the field of view of the camera and cause the background to appear to grow as the focal length of the lens becomes smaller. Below are some of my early attempts converted into animated gif files. They are looped to go forward and backward so you can see both effects in motion.

My Blue Elephant with the East Asian Library in the Background
My Blue Mudkip with Doe Library in the Background

By making the progression more granular and taking more photos with amounts of zoom between each photo, the stop motion gif can be made more convincing.

My Friend Michelle's Cat Pencil Case with Kresge Library and
a Few Tormented Students during Dead Week in the Background

Conclusion: What I Learned

Like I mentioned in the introduction, 194-26 has been an awesome experience and a truly enlightening class. It allows you to not only implement some simpler and some more complex algorithms but also gives you some creative freedom in your choice of images and artistic direction. I highly recommend this class to anyone who is even slightly interested in photography or image manipulation and I hope it eventually grows out of being part of the 194 series to become a fully supported class.

Thank you Professor Efros and our staff, Tinghui and Jun-Yan, for running this course!