dictionarySize = 256;

input_folder = 'descriptors/';
output_file = ['dictionary_' num2str(dictionarySize) '.mat'];

classes = {'badminton', 'rowing', 'sailing', 'snowboarding'};
input_files = cell(0, 1);
output_files = cell(0, 1);


for i=1:length(classes)
    files = arrayfun(@(x) x.name, dir([input_folder classes{i} '/train/*.mat']), 'UniformOutput', false);
    input_files(end+1:end+length(files), 1) = cellfun(@(x) [input_folder classes{i} '/train/' x], files, 'UniformOutput', false);
end

dictionary = CalculateDictionary(input_files, dictionarySize);
save(output_file, 'dictionary');