CS 6501 - Computational Photography

Project 2

Optional Part: Seam Carving

Seam carving allows one to retarget an image, or change the aspect ratio, while preserving important content. Please read Sections 3-4.1 from the Seam Carving paper.

Your assignment is to implement a seam carving algorithm that will retarget an image horizontally from an initial size w x h to have a smaller size w' x h. Note this same algorithm can also retarget an image vertically simply by transposing the input. Optional extra credit: you can also implement enlarging the image and doing simultaneous retargeting in both horizontal and vertical directions (see Sections 4.2-4.).

The first step of seam carving is to compute an energy map e, as shown here:

We suggest to use the same energy map as in the paper which takes the L1 norm of the image gradient (you can convert the image to grayscale for this step):

The second step is to implement a function that finds the path of an optimal vertical seam through the image. To check your work, you can visualize this seam to verify that it passes through an area of low energy. This is the same dynamic programming problem as in image quilting.

The final step is to implement a function remove_vertical_seam that takes an input image, finds the optimal seam, and removes it, returning an image one smaller in width. You can repeatedly apply this function to implement the full seam carving, by iterating until the target width w' is reached.


For the optional part, place a subdirectory part2 in your submission zip file containing: