Final Project

Author:Tianrui Guo <aab>

Project Spec: https://inst.eecs.berkeley.edu/~cs194-26/fa18/hw/final-project/index.html

_images/berkeley2.jpg

Fake Miniatures

Project Overview

The goal of this project is to simulate the tilt shift effect. The idea is to select a region of interest to preserve, and then blur the rest of the image. This has the effect of narrowing the perceived depth of field, making it seem like the photograph was taken from a close distance. To blur the image, we use a Gaussian filter, and we increase the blur (\(\sigma\)) for pixels further from the region of interest. Additionally, we increase the saturation of the final image to make the effect more convincing.

Bells & Whistles

I implemented complex depth of field regions. First, we can select the region of interest from a target image, which will create an object mask. Then, I used skimage.morphology.binary_dilation to grow the masked region in order to use differently blurred images for different pixels. Here is an example image, and what the different sized masks look like:

_images/mountain.jpg _images/mountain_debug.jpg

And here is what the resulting image looks like, after increasing saturation.

_images/mountain1.jpg

More Results

Berkeley Campus

Original vs Fake miniature

_images/berkeley.jpg _images/berkeley1.jpg

Homes

_images/homes.jpg _images/homes1.jpg

School

_images/school.jpg _images/school1.jpg

Police Car

_images/nypd.jpg _images/nypd1.jpg

Lessons Learned

In this project, I learned how to simulate the tilt-shift effect by using simple Gaussian blurring.

Seam Carving

Project Overview

The goal of this project is to implement the seam carving algorithm, a method of resizing images that is an alternative to cropping. The high level idea behind seam carving is that we want to delete the “least important” pixels to resize an image. In this case, we score the importance of each pixel by summing the absolute values of the horizontal and vertical gradients. Then, to reduce the width of an image by 1 pixel, we find a minimum cost path from the top of an image to the bottom, passing through 1 pixel on each row. Deleting the pixels in this path and shifting the rest of the pixels yields an image that is one pixel narrower. Repeating this process multiple times allows us to shrink an image’s width by any arbitrary amount, and we can apply this same algorithm to the transpose of an image to shrink its height.

Results

Mountain

Original
_images/rock.jpg
Seam Carved vs Cropped
_images/rock1.jpg _images/rock_cropped.jpg

The image on the right is the result of cropping, as we can see how the two gray rocks in the lower right corner are partially cut off by the cropping. Meanwhile, the seam carved result preserves those two rocks entirely. Careful inspection does reveal that the trees look a bit distorted and unnatural in the right image, but the mountain itself is relatively unchanged.

Plane (Vertical Cropping Example)

Original
_images/southwest.jpg
Seam Carved vs Cropped
_images/southwest1.jpg _images/southwest_cropped.jpg

This photograph was taken in challenging lighting conditions, with the foreground overexposed. As a result, this area has has a lot of pixels that are considered to have low energy, so the seam carving algorithm removed a lot of seams in this area.

SF Fed (Vertical Cropping Example)

Original
_images/fed.jpg
Seam Carved vs Cropped
_images/fed1.jpg _images/fed_cropped.jpg

Seam carving squished the sidewalk markings together, but the SF Fed sign is relatively untouched.

Fountain

Original
_images/fountain.jpg
Seam Carved vs Cropped
_images/fountain1.jpg _images/fountain_cropped.jpg

Plant

Original
_images/plant.jpg
Seam Carved vs Cropped
_images/plant1.jpg _images/plant_cropped.jpg

Berkeley Marina

Original
_images/marina.jpg
Seam Carved vs Cropped
_images/marina1.jpg _images/marina_cropped.jpg

Failure Cases

Here we see some cases where seam carving does not produce very good results

Car

Original
_images/bmw.jpg
Seam Carved vs Cropped
_images/bmw1.jpg _images/bmw_cropped.jpg

We can see here that the car has been squished by the algorithm. This is likely because the background in this picture has a lot of different textures, so the algorithm ends up finding seams that go through the car.

Bridge

Original
_images/bridge.jpg
Seam Carved vs Cropped
_images/bridge1.jpg _images/bridge_cropped.jpg

This example is challenging for seam carving because of the power lines that span horizontally across the image. Any vertical seam likely has to go through the power line, which will end up making it look weird.

Lessons Learned

In this project, I learned about how to apply a simple dynamic programming algorithm to solve the problem of image rescaling. Through testing my code on a variety of different images, I was able to get a better sense of what types of images this algorithm works well on, and what images this approach has troubles with.

Acknowledgements

CS194-26 Fall 2018, Professor Efros

All images (for both projects) were taken by me.