CS194-26

Image Manipulation and Computational Photography

Final Project 1: Seam Carving for Content-Aware Image Resizing

Morad Shefa

Parsa Fereydouni



Overview

For this project we implement the content aware image resizing algorithm suggested by a SIGGRAPH paper by Shai Avidan and Ariel Shamir that can be found here. The algorithm finds seams of low enerrgy, defined by an energy function, and removes them horizontally or vertically one by one until a desired size is reached.

Process

This is a rough overview of the image processing done :

  1. Find the energy of every pixel. In our algorithm we use the magnitude of horizontal and vertical gradient over the RGB channels as our energy function.
  2. Use dynamic programming to find the lowest energy seam. This can be done very easily. For example when trying to find the lowest energy path from top to bottom the following is the idea behind the dp problem:
    1. We start from the first row and work our way down finding the lowest energy path to every pixel
    2. The lowest energy path up to a given pixel in the first row is just the pixel itself and the total cost is its energy
    3. The lowest energy path up to a given pixel in any other row is the minimum lowest energy path of all of its 3 possible parents (one left, same column, or one right in the row above it) plus itself
    4. Once we have all the lowest energy paths we find the lowest energy path of the last row. This must be the endpoint of the lowest energy path from top to bottom
    5. We now backtrack our way back up finding the previous endpoint of this path by checking the values of all its 3 parents until we have the starting point in the first row and have found the seam
  3. Remove this seam
  4. Repeat until desired size is reached

Results


Beach before cutting
Beach after cutting

Brick wall before cutting
Brickwall after cutting

Landscape before cutting
Landscape after cutting

Sky before cutting
Sky after cutting

My cat Jack before cutting
Jack after cutting

Tahoe before cutting
Tahoe after cutting

Example of a failed case

In this example we see the artifacts that are resulted from shapes and angles being distorted.


Massachusetts before cutting
Massachusetts after cutting

Bells and Whistles:

Here we dazzle you with amazing videos demonstrating the content-aware image resizing process. The seam being carved in each iteration is highlighted.

My favorite part during this project was finding the seam using dynamic programming!