HW3: Seam Carving for Image Retargeting

Due Nov 6 in EEE DropBox at 11:59 pm


Seam Carving for Image Retargeting


An image of a tree.



Vertical seam removal time map for the image of a tree. Black = early, white = late.



Animation of uniform scaling (top row) and seam removal (bottom row). Click to play.

In this assignment, prepared by David Martin, you implement the image retargeting algorithm of Avidan & Shamir . This is a very clever algorithm that was recently developed for resizing images in a manner that is adaptive to the image content. Typical image resizing, as is done in imresize, for example, scales the image uniformly. The Avidan & Shamir algorithm attempts to remove the boring bits of the image while retaining the important bits. The queue that is used for determining what is important is very low-level, however, and so the algorithm does not always produce good results. It is surprising, though, how well it does work. Apart from implementing the algorithm, your job is also to evaluate its utility.

Programming [20 points]

Implement a function with the following prototype:

function [M] = removalMap(I)

This function should take a grayscale image as input (not an image filename) and return a horizontal seam removal time map, as defined in the paper. The pixels should be valued between 1 and H, where H is the image height. The seam removal time map tells you which pixels to remove if you want to remove N seams: those pixels labeled 1 through N.

Here is a viewer program (show.m, written by David Martin) that takes an image and seam removal time map (horizontal or vertical), and lets you resize the image interctively by dragging the mouse or moving the mouse wheel. To use this code, you'll have to implement shrink and expand functions that shrink and expand an image by N horizontal seams given and image and a horizontal seam removal map.

Writeup [20 points]

  1. Show and discuss one interesting successful result of shrinking an image hoizontally, and one vertically. Use two different images.

  2. Show and discuss one interesting unsuccessful result of shrinking an image hoizontally, and one vertically. Use two different images.

  3. Show side-by-side comparison of 50% and 150% resizing using uniform scaling vs. seam removal/insertion for the 4 images from the first two questions.

  4. Show and discuss two interesting successful results of content amplification.

Matlab Tips

  1. You can't use transpose to transpose an RGB image. Instead, use the permute function to swap the first two dimensions: I = permute(I,[2,1,3]).

  2. Do not implement any vertical seam algorithms. The horizontal seam case is simpler to implement in matlab, and you can use horizontal seam code to create and manipulate vertical seams by transposing arguments and results.

  3. If you want to make movies of your results, use the avifile, addframe, and close functions as follows, making sure that each frame is the same size:
    mov = avifile('movie.avi');
    frame.colormap = [];
    for i = 1:nframes,
        frame.cdata = someImage;
        mov = addframe(mov,frame);
    end
    mov = close(mov);
    

    Note that the movies that matlab creates are enormous uncompressed AVI files. It is a good idea to transcode them into something like DivX or H.264 using something like Quicktime Pro or mencoder if you want to put them in your writeup or on the web.

  4. Use the sprintf function to construct output filenames based on input filenames. For example, sprintf('%s.avi',inputFileName) will create an AVI filename from some input file name.

Extra-credit

As detailed in the guidelines, any project handed by 11:59 pm on the previous day (Nov 5th), will recieve 10% (4 points) extra credit.