# Codebooks ## K-means codebook A common technique for codebook generation involves utilising K-means clustering on a sample of the image descriptors. In this way descriptors may be mapped to *visual* words which lend themselves to binning and therefore the creation of bag-of-words histograms for the use of classification. In this courseworok 100-thousand descriptors have been selected to build the visual vocabulary from the Caltech dataset. ## Vocabulary size The number of clusters or the number of centroids determine the vocabulary size. ![Bag-of-words Training histogram](fig/km-histogram.pdf) ![Bag-of-words Testing histogram](fig/km-histtest.pdf) ## Bag-of-words histograms of example training/testing images ## Vector quantisation process # RF classifier Train and test Random Forest using the training and testing data set in the form of bag-of-words obtained in Q1. Change the RF parameters (including the number of trees, the depth of trees, the degree of randomness parameter, the type of weak-learners: e.g. axis-aligned or two-pixel test), and show and discuss the results: ## recognition accuracy, confusion matrix, ## example success/failures, ## time-efficiency of training/testing, ## impact of the vocabulary size on classification accuracy. # RF codebook In Q1, replace the K-means with the random forest codebook, i.e. applying RF to 128 dimensional descriptor vectors with their image category labels, and using the RF leaves as the visual vocabulary. With the bag-of-words representations of images obtained by the RF codebook, train and test Random Forest classifier similar to Q2. Try different parameters of the RF codebook and RF classifier, and show/discuss the results in comparison with the results of Q2, including the vector quantisation complexity. # Pictures \begin{figure}[H] \begin{center} \includegraphics[width=18em]{fig/256t1_e200D5_cm.pdf} \caption{Part 3 confusion matrix e100k256d5cm} \label{fig:rerank} \end{center} \end{figure} \begin{figure}[H] \begin{center} \includegraphics[width=18em]{fig/Depth_Trees_P2.pdf} \caption{DepthTreesP2} \label{fig:rerank} \end{center} \end{figure} \begin{figure}[H] \begin{center} \includegraphics[width=18em]{fig/Depth_Trees_P3.pdf} \caption{DepthTreesP3} \label{fig:rerank} \end{center} \end{figure} \begin{figure}[H] \begin{center} \includegraphics[width=18em]{fig/Depth_Trees_P3_fixedestimators.pdf} \caption{DepthTreesP3fixedestimators} \label{fig:rerank} \end{center} \end{figure} \begin{figure}[H] \begin{center} \includegraphics[width=18em]{fig/e100k256d5_cm.pdf} \caption{e100k256d5cm Kmean Confusion Matrix} \label{fig:rerank} \end{center} \end{figure} \begin{figure}[H] \begin{center} \includegraphics[width=18em]{fig/error_depth_kmean100.pdf} \caption{errordepthkmean100} \label{fig:rerank} \end{center} \end{figure} \begin{figure}[H] \begin{center} \includegraphics[width=18em]{fig/error_depth_p3.pdf} \caption{errordepthp3} \label{fig:rerank} \end{center} \end{figure} \begin{figure}[H] \begin{center} \includegraphics[width=18em]{fig/kmean_rand.pdf} \caption{kmeanrand} \label{fig:rerank} \end{center} \end{figure} \begin{figure}[H] \begin{center} \includegraphics[width=18em]{fig/kmeans_vocsize.pdf} \caption{kmeansvocsize} \label{fig:rerank} \end{center} \end{figure} \begin{figure}[H] \begin{center} \includegraphics[width=18em]{fig/new_kmean_random.pdf} \caption{newkmeanrandom} \label{fig:rerank} \end{center} \end{figure} \begin{figure}[H] \begin{center} \includegraphics[width=18em]{fig/p3_colormap.pdf} \caption{p3colormap} \label{fig:rerank} \end{center} \end{figure} \begin{figure}[H] \begin{center} \includegraphics[width=18em]{fig/p3_rand.pdf} \caption{p3rand} \label{fig:rerank} \end{center} \end{figure} \begin{figure}[H] \begin{center} \includegraphics[width=18em]{fig/p3_time.pdf} \caption{p3time} \label{fig:rerank} \end{center} \end{figure} \begin{figure}[H] \begin{center} \includegraphics[width=18em]{fig/p3_vocsize.pdf} \caption{p3vocsize} \label{fig:rerank} \end{center} \end{figure} \begin{figure}[H] \begin{center} \includegraphics[width=18em]{fig/time_kmeans.pdf} \caption{timekmeans} \label{fig:rerank} \end{center} \end{figure} \begin{figure}[H] \begin{center} \includegraphics[width=18em]{fig/trees_kmean.pdf} \caption{treeskmean} \label{fig:rerank} \end{center} \end{figure} \begin{figure}[H] \begin{center} \includegraphics[width=18em]{fig/trees_p3.pdf} \caption{treesp3} \label{fig:rerank} \end{center} \end{figure} \begin{figure}[H] \begin{center} \includegraphics[width=10em]{fig/success_km.pdf} \includegraphics[width=10em]{fig/fail_km.pdf} \caption{Kmean: Success on the left; Failure on the right} \label{fig:rerank} \end{center} \end{figure} \begin{figure}[H] \begin{center} \includegraphics[width=10em]{fig/success_3.pdf} \includegraphics[width=10em]{fig/fail_3.pdf} \caption{Part3: Success on the left; Failure on the right} \label{fig:rerank} \end{center} \end{figure} # References