% Please keep the faces_4 folder in the current directory. It should have
% the files whos filenames are mentioned in the 
% faces_training_list_cellarray.m and 
% faces_test_list_cellarray.m
% Author: Aravindh Mahendran
% aravindh.mahendran@new.ox.ac.uk

faces_training_list_cellarray; % Script loads filenames 
X = zeros(30, 32, 1, numel(filenames), 'single');
Y = 0.1 * ones(1, 1, 4, numel(filenames), 'single');
for i=1:numel(filenames)
    if(~isempty(strfind(filenames{i}, 'left')))
        Y(1,1,1,i) = 0.9;
    elseif(~isempty(strfind(filenames{i}, 'right')))
        Y(1,1,2,i) = 0.9;
    elseif(~isempty(strfind(filenames{i}, 'up')))
        Y(1,1,3,i) = 0.9;
    else
        Y(1,1,4,i) = 0.9;
    end
    X(:,:,1,i) = im2single(imread(filenames{i}));
end

faces_training_list_cellarray;
X_test = zeros(30, 32, 1, numel(test_filenames), 'single');
Y_test = zeros(numel(test_filenames), 1, 'int32');
for i=1:numel(test_filenames)
    if(~isempty(strfind(test_filenames{i}, 'left')))
        Y_test(i) = 1;
    elseif(~isempty(strfind(test_filenames{i}, 'right')))
        Y_test(i) = 2;
    elseif(~isempty(strfind(test_filenames{i}, 'up')))
        Y_test(i) = 3;
    else
        Y_test(i) = 4;
    end
    X_test(:,:,1,i) = im2single(imread(test_filenames{i})); 
end

save facedata.mat X Y X_test Y_test;

