CS1674: Homework 7 - Programming

Due: 11/2/2016, 11:59pm

This assignment is worth 50 points.

In this problem, you will develop two variants of a scene categorization system.
What you need to include in your submission:
  1. [15 points] function [pyramid] = computeSPMHistogram(im, means); which computes the Spatial Pyramid Match histogram as discussed above. im should be a grayscale image whose SIFT features you should extract, means should be the cluster centers from the bag-of-visual-words clustering operation, and pyramid should be a 1xd feature descriptor for the image. You're allowed to pass in optional extra parameters after the first two. Note that a draft of this code is provided for you.
  2. [15 points] function [labels] = findLabelsKNN(pyramids_train, pyramids_test, labels_train, k); which predicts the labels of the test images using the KNN classifier. pyramids_train, pyramids_test should be an Mx1 cell array and an Nx1 cell array, respectively, where M is the size of the training image set and N is the size of your test image set, and each pyramids{i} is the 1xd Spatial Pyramid Match representation of the corresponding training or test image. labels_train should be an Mx1 vector of training labels, and labels should be a Nx1 vector of predicted labels for the test images. k is the k in K-Nearest Neighbors, and you select the value (you will try different values).
  3. [20 pts] A script which get all images and their labels (feel free to reuse code from HW5P that shows how to get the contents of a directory, or see the provided getData for inspiration), extracts the features of training images, runs kmeansML to find the codebook centers, then computes SPM representations, and runs the KNN classifier, including computing accuracy. In this script, run the KNN classification with the following values for the k (different from the k-means k = 100): 1, 5, 25, 125. In other words, you have to run KNN 4 times and show 4 accuracy values.