function [BoW_Features] = CompileBoW( imageFileList, dictionary)

fprintf('Building BoW Features...\n');

dictionarySize = size(dictionary, 1);
BoW_Features = zeros(length(imageFileList), dictionarySize);

for f = 1:length(imageFileList)
    if(mod(f, 20)==0)
        disp([num2str(f) ' of ' num2str(length(imageFileList))]);
    end
    
    imageFName = imageFileList{f};
    features = load(imageFName);
        
    dist_mat = sp_dist2(features.data, dictionary);
    [~, min_ind] = min(dist_mat, [], 2);
    BoW_Features(f, :) = hist(min_ind, 1:dictionarySize)./length(min_ind);
end

fprintf('Done!\n');