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.
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.
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.