Harvey Mudd College
Computer Science 153
Assignment 1
Solutions by Hormel Foods

Back to Assignment 1 top-level page

Back to Assignment 1, Section 1: Matlab

Back to Assignment 1, Section 2: Images


Section 3: Solving the Vision Problem

(Actually, this is just an important subproblem... .)



Finding food

The problem is to write a matlab function findspam that takes in an image and outputs the location of the spam in the image. You can assume that the image does contain, somewhere, a can of spam. (But see "Possible Extensions" for the unfortunate situations in which no spam is available!)

To be precise, your findspam should

In addition to your code, please include a paragraph or two to explain the technique(s) you developed. Also, indicate the kinds of images on which your technique(s) do well and the kinds of images on which they don't do well, and why. Provide at least two example images on which your algorithm worked, and at least two on which it did not. Highlight the point at which your algorithm "found" the spam in each image. (You can do this with any image-altering tool, but might want to try it in matlab.) Basically, be sure to evaluate your solution after developing it.


Results:

Here is a link to the code.

Explanation and Evaluation

Our code works from an exhaustive analysis of how spam can look in an image. (I emphasize an image here.) I explored variations in lighting, background, pose of the can of spam (requiring numerous trips to the library reserves), and possible camera conditions.

In this case, it was probably a bug in Solaris that's corrupting my results; I can't come up with any reason why this algorithm wouldn't work. Upon investigating this possibility, I did find that Libby's (the manufacturer of Vienna Sausages) was a major Sun stakeholder. It's more than a bit suspicious, in my opinion... . Because of this, however, I did find only one successful run of my algorithm. I also show two unsuccessful runs. The location of the spam is marked by a white cross in each image.

Successful run





Unsuccessful runs





This excellent algorithm was suggested by M. Calendar.



Resources for developing/testing your algorithm

There are (or will be) 21 test images containing spam available in the directory /cs/cs153/Images/a1/spamResource. You may find imframe (or xv, or photoshop, etc.) helpful in analyzing those images in order to develop a findspam function.

You are welcome to try any idea in writing your function. The only strategy not permitted is somehow to encode the location of the spam (found by a person) and then output that remembered location. For example, the following function works extremely well for the testimage.jpg:

function [row,col] = findspam(A);
%
% The vision problem, solved!
%
col = 196;
row = 288;



Evaluation

Your code will be evaluated on the 21 resource images, along with 21 trial images. This assignment is not really intended to be "solved" (though that's not to discourage you from doing so!) As a result, grading will be very lenient. In particular, you don't need to work on any extensions; after all, this assignment could be considered a superset of the rest of the course! The extensions in the following section are here just to give you a sense of what they might be like in future assignments. Also, you can always explore in a direction of your own choosing (in fact, are encouraged to do so), rather than trying a suggested extension. Remember that the principal goal of this assignment is simply to provide an introduction to using matlab for handling images... .



Possible Extensions

This project differs from the next four scripted projects in that simply writing the findspam function is challenging enough that no extensions are necessary. However, the following are possible extensions which you should feel free to incorporate, if you like. (They will certainly be considered for extra credit.)



Back to Assignment 1 index