Harvey Mudd College
Computer Science 182a, Project 2
Due Sunday, February 13, 2011

"Finding edge cases": Implementing seam carving



Goals

For this exercise, you will implement a version of the content-aware image resizing technique described in Shai Avidan and Ariel Shamir's SIGGRAPH 2007 paper, "Seam Carving for Content- Aware Image Resizing." The paper is available here: seamCarving.pdf. The goal is to implement the method, and then examine and explain its performance on different kinds of input images.

Tasks

First read through the paper, with emphasis on sections 3, 4.1, and 4.3. You might want to do this after Tuesday's lecture (2/1), because that will also present some of the context involved.

Then, write functions to do the following tasks. This assignment may be completed using either OpenCV or Matlab or PIL - the choice is yours. You may work on your own or in teams of up to 3.

Coding hints

Matlab pointers:

For OpenCV, you might try one of the built-in edge-detection functions in order to obtain edge energy, but it may be even easier to implement the paper's very simple edge-energy function from scratch. In addition, there are a number of plotting functions that work atop images (in addition to directly changing a pixel's value). See the CxCore library's cvLine and subsequent functions at this link. That said, it is perhaps easiest for this assignment to simply change the pixels along a seam to the appropriate color.

Demo and write-up

The write-up should be linked into the CS 182 wiki by 11:59pm on Sunday, 2/13. For your write-up, create another web- or wiki-page to hold the write-up from this assignment. As noted in the syllabus, the items below will be graded on a scale of up to B+. In order to extend that grading scale up to an A, you should implement an extension of your own choosing. For this project, that extension has to involve interacting with the physical environment with vision.

  1. Run your resizeH function on the provided ocean.jpg image with newWidth = 540. Display the output in your write-up.


  2. Display (a) the energy function output (total gradient magnitudes e1(I)) for the provided image ocean.jpg, and (b) the two corresponding cumulative minimum energy maps (M) for the seams in each direction - similar to the inset in the paper's Figure 1. Explain in a sentence or two why these outputs look the way they do given the original image's content.


  3. For the same image ocean.jpg, display the original image together with (a) the first selected horizontal seam and (b) the first selected vertical seam. Explain briefly why these were chosen as the optimal seams for this image.


  4. What if we were to modify the energy function to include only gradients in one direction, i.e., only one of the addends in equation 1? Explain in a setence or two how the output (selected seams) would qualitatively change? Choose any image where we might expect a difference, and show an illustrative example using the original and modified energy function.


  5. Examples and testing!    Now, for the real results! Use your system with different kinds of images and seam combinations, and see what kind of interesting results it can produce. The goal is to form some perceptually pleasing outputs where the resizing better preserves content than a blind resizing would, as well as some examples where the output looks unrealistic or has artifacts.

    Include results for at least one more of the four provided images, as well as at least two images of your own choosing. Include at least one new example of "good" outcomes and at least one new example of "bad" outcomes. Be creative in the images you choose! Try to predict types of images where you might see something interesting happen. It's certainly ok to fiddle with the parameters (seam sequence, number of seams, etc) to look for interesting good and/or "bad" outcomes.

    For each distinct image you use, include (a) the original input image, (b) your chosen resized image (using seam carving), (c) the result one would get if instead a simple resampling were used (Matlab and OpenCV have functions named imresize and cvResize for this - PIL has one, as well), (d) the input and output image dimensions, and (e) a brief qualitative explanation of what we're seeing in the output.

Extension possibilities

These are some ideas for possible extensions. Feel free to come up with your own instead... . However, remember that this week's extension should involve interacting with the physical world visually! Be sure to include a description of what you chose - and how it went - in your write-up.

Thanks to K. Grauman for this assignment, and to Avidan and Shamir for the algorithm!