This section asks you to create an object-recognition system (based on the color distribution of objects) and test it out on the images gathered (and to be gathered) by the group as a whole. (I'll contribute some spam images.)
In the directory
/cs/cs153/Images/a3/ModeledObjectsare a number of objects, 12 of which should be modeled by your object recognition system; 12 is a lower bound; feel free to model more objects if you like.) The fifteen objects you need to model are listed in the MustModel.txt file. The objects are in files named as follows:
parrot1.jpg parrot2.jpg vac1.jpg vac2.jpg ...There will be two or more images of each object. For each file, there is an accompanying file named
<imagename>.infoThat file contains the following information, line by line
parrot1.jpg parrot 1 1 165 224 outdoor, man-made by Ross LuengenTo read the values in this file in you can use the following code:
fid = fopen('/cs/cs153/Images/a3/ModeledObjects/parrot1.info','r');
filename = fgetl(fid); % fgetl gets a line w/o the '\n'
objectType = fgetl(fid);
boundingboxline = fgetl(fid);
bbox = sscanf(boundingboxline,'%d'); % gets a matrix of the values present
fclose(fid);
The following paragraphs describe some of the steps to think about
(and to document with at least one image) in order to build a histogram-based
object recognition system for the above database of images.
Generating Histograms You'll need to decide two things to start off: the color space in which you'd like to histogram the objects, and how you want to divide up that color space into bins. You might use RGB, HSV, some combination of the two, or a homemade approach. Once you decide on a colorspace and a strategy for binning it, create and plot at least one histogram of an image using that division of colorspace; include the results (and a brief explanation) here. Keep in mind that you may not want to divide colorspace uniformly along its axes.
Object Models Next, you'll need to decide exactly what will constitute the model of an object. This problem is based around histograms, yes, but there are a variety of ways to use histograms to model, say, a "parrot." The simplest would be to take a single parrot image and use its histogram as the model for parrots in general. Or, you may want to combine the information available from additional images -- for example, by averaging. Alternatively, there may be information you don't want to use in your model of an object: for example, you might considering a more careful hand-segmentation of the objects when creating your object model.
Ultimately, you should have a function or script that will create an object model, given an image/images or, if you prefer, a list of pixels (or several lists of pixels, coming from several images). Include your object-modeling code, along with a brief explanation and description, below:
Model matching The final piece to your system is a means for comparing two object models to determine how similar they are. For this you might use histogram intersection (higher match scores then indicate better matches), perhaps with a scale factor used to eliminate any effect from the image size of the objects matched against. A second approach we considered was a histogram distance function, perhaps using a weighting matrix to allow partial matches among similar colors. In this case, low distance (small match scores) would indicate close matches of models. Again, consider a scale factor to eliminate any dependence on absolute image size.
Still another option is to investigate the Earth-Movers' Distance as a measure of the similarity or differences between two color distributions. This would constitute the extension to assignment 3, if you wanted to pursue it. A link to a C version of the code is at this site. Yossi Rubner's papers (including the one introducing the EMD) are available from here. See the Possible Extensions section for additional suggestions.
Regardless of how you choose to match object models, you will want to try matching several to see how it performs. In addition to the ModeledObjects directory, there is also a sibling UnmodeledObjects directory you may want to use to test histogram comparison. Don't use the UnmodeledObjects, however, to build the object representations, as there needs to be some independent data for use in testing the final system. As you test, you may want to consider a criterion for a "reject class," i.e., a class for objects that do not match any of the 12 modeled ones well.
Once you have a strategy for creating object models and comparing them to each other, create and store models of your 12 (or more) objects in
/cs/cs153/Images/a3/ModeledObjectsThen, with those object representations, for each image in the directory
/cs/cs153/Images/a3/UnmodeledObjectscreate a row in a three-column list with
In addition to these results, comment briefly on the strengths and shortcomings of your object recognition system. Include at least one misclassified image and how the system might be changed to prevent at least that type of misclassification.
For this extension, you may want to use whole-image histograms, rather than the histograms of only the prominant objects in those images.