Miniature Images and Seam Carving

by Marisa Liang

Miniature Images

Objective

The objective of this project was to manipulate a real photo to make it look like a miniature version of itself, by imitating the "tilt shift" ability on a camera. We can achieve this through 4 steps:

  1. Setting a focus line in the image
  2. Creating a depth of field to be in focus around this line
  3. Blurring the area around the DOF, with the blur increasing as we move further
  4. Saturate the image to make it look "fake"

Algorithm

To create our miniature image, we first set the focus line by prompting the user to pick two points on the image. We then set out DOF to be a user-specified number of pixels away from this line (or, if no number is specified, a default of 20 pixels). We then blur the image outside of this area by recursively applying a Gaussian filter, where the further an area is from the DOF, the more gaussian filters it will go through. Finally, we stitch these blurred areas back together with the focused DOF, and then saturate the image slightly by converting to HSV and back. Below are some our the final results.

Original (Source)

Miniature

Original (Source)

Miniature

Original

Miniature

Original

Miniature

Original (Source)

Miniature

Original (Source)

Miniature

Conclusion

My favorite part of this project was being able to manipulate each picture by choosing specific lines of focus, changing the sigma of the Gaussian filter, and specifying the DOF size, to play with what worked best in achieving the "miniature" look. I found it especially interesting that just increasing saturation by a little helped to improve the effect by a lot.

Seam Carving

Objective

The objective of this project was to be able to resize and image not by cropping or by scaling, but through seam carving. A big advantage of seam carving is that all the "important" parts of the photo are preserved, while less noticeable areas are shortened to make the image smaller, either vertically or horizontally. Our steps for seam-carving an image are as follows:

  1. Determine the "importance" of each pixel using an energy function
  2. Determine the least important "seam" (line that has only one pixel in each row or column (depending on orientation) in the image
  3. Remove the seam from the image
  4. Repeat steps 2 and 3 until desired size is reached.

Algorithm

We defined our energy function to be the gradient of the pixel both horizontally and vertically, with the gradient being extremely large at the edges. From this, we can then choose our line of least importance, by finding the next step with the smallest energy value. We do this using dynamic programming, by choosing the smallest energy value at the bottom of the image, and working our way up. This seam is then removed from the image, and the energy matrix. We then repeat this process a given number of times until our final image is complete. During implementation, I was able to only implement vertical seam carving, and then accomodate horizontal seam carving by simply rotating the image by 90 degrees before and after running the same algorithm. Below are some results I achieved using this algorithm.

Original

Horizontal seams removed

Original

Horizontal seams removed

Original

Vertical seams removed

Original

Vertical seams removed

Original

Horizontal seams removed

Original

Vertical seams removed

Failures

I found that in some cases, certain images were not as successfully carved as others, especially in the case where faces were being manipulated. In addition, when the shape of an object in the image is especially regular or smooth, artifacts tend to show more easily than in other photos.

Original

Vertical seams removed

Original

Vertical seams removed

Original

Vertical seams removed

Conclusion

This project was probably my favorite of the semester. I never knew a feature like this even existed, so it was amazing to actually see my results for the first time. A common realization I had throughout this class was that it really only takes one or two simple algorithms to make really impactful changes on an image that are both realistic and super cool!!! I really enjoyed being able to push the limits of how much I could manipulate these images and comparing them to their original counterparts.