Seam Carving for Image Retargeting

Part I: Due Oct. 12
Part II: Due Oct. 19

Your task is to implement the seam carving algorithm of Avidan & Shamir. This is a very clever algorithm that was developed for resizing images in a manner that is adaptive to the image content. Typical image resizing scales the image uniformly. The Avidan & Shamir algorithm attempts to remove the boring bits of the image while retaining the important bits. The cue that is used for determining what is important is very low-level, so the algorithm does not always produce good results. It is surprising, however, how well it does work. Apart from implementing the algorithm, your job is also to evaluate its utility.

Programming Part I [10 points]

Implement a function that shrinks an image using seam removal:

function [J] = seamRemove(I,n,isVertical)

where n is the number of seams to remove. isVertical=1 if seams are vertical and otherwise 0.

Writeup Part I [10 points]

  1. Show and discuss one interesting successful result of shrinking an image horizontally, and one vertically. Use two different images. Show side-by-side comparisons with scaling. Also show the seam removal maps.

  2. Same as (1), but show interesting unsuccessful results.

Programming Part II [10 points]

  1. Modify your retarget function from Part I so that in the case of expanding an image. Follow the suggestion in the last paragraph of §4.3.

  2. Implement a content amplification function with the following prototype:

    function [J] = seamInsert(I,n,isVertical)
    

    where the arguments of the function are the same as seamRemove.

  3. Write a content removal program to remove a specific region in an image. Use matlab function roipoly to select the region. You can also protect regions that you want to keep.

Writeup Part II [10 points]

  1. Show results for your retargeting for the case of enlarging images.

  2. Show two interesting object removal / preservation examples.

Extra Credit

Implement and discuss one of the various extensions described in the paper, such as:

  1. Retargeting in both dimensions with optimal order (§4.2). Compare to the simpler methods.

Matlab Tips

  1. You can't use transpose to transpose an RGB image. Instead, use the permute function to swap the first two dimensions: 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.