CS1674: Homework 2 - Programming

Due: 9/14/2016, 11:59pm

This assignment is worth 50 points.

Please post on Piazza if you have any questions, rather than emailing the instructor directly, unless you have a concern you wish to keep private. I will monitor Piazza daily.

You will implement one part 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", available here. The goal is to implement the method, and then examine its performance on different kinds of input images.

First read through the paper, with emphasis on sections 3, 4.1, and 4.3. Note: choosing the next pixel to add one at a time in a greedy manner will give sub-optimal seams; the dynamic programming solution ensures the best seam (constrained by 8-connectedness) is computed. Use the dynamic programming solution as given in the paper and explained in class.

You will need the following Matlab functions. Some of them will be provided for you, and some you will have to write. Put each function you write in a separate file called [function-name].m and submit all of them (excluding ones that were provided with the assignment). Matlab hints: Answer each of the following, and include image displays where appropriate. Save your code for each of the parts below as a separate .m script. Name the scripts part_a.m, part_b.m, part_c.m, and part_d.m. Submit the scripts along with the functions above. Also submit the image results, as indicated below. Your grader should be able to run your scripts and get the image results you submitted.
  1. [5 points] Run your reduceHeight function on the provided prague.jpg and shrink the height by 100 pixels. Then run your reduceWidth function on the provided mall.jpg and shrink the width by 100 pixels. Also show what standard image resizing would do (use B = imresize(A, [numrows numcols])). Display the outputs, save them, and submit them.
  2. [5 points] Display, save and submit (i) the energy_image function output for the provided images prague.jpg and mall.jpg, and (ii) the two corresponding cumulative minimum energy maps (M) for the seams in each direction (use the imagesc function).
  3. [5 points] For the same two images, display, save and submit the original image overlaid with (a) the first selected horizontal seam and (b) the first selected vertical seam.
  4. [15 points] 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 ("failure cases"). Include results for at least three images of your own choosing. Include an example or two of a "bad" outcome. Be creative in the images you choose, and in the amount of combined vertical and horizontal carvings you apply. Try to predict types of images where you might see something interesting happen. It's ok to fiddle with the parameters (seam sequence, number of seams, etc) to look for interesting and explainable outcomes. If you have a large image, try imresize to resize the image to a small size to make the computations faster and allow you to try more ways of transforming the image. For each result, include the following things, clearly labeled (see title function):
Acknowledgement: The author of this exercise is Kristen Grauman.