Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
81 lines (69 sloc) 2.68 KB
addpath('gbvs');
addpath('eyetrackingstory_01/pilot_data/free_ebooks');
addpath('eyetrackingstory_01/stimuli/free_ebooks/young/withbackground');
addpath('eyetrackingstory_01/stimuli/free_ebooks/old/withbackground');
output_root_blank = 'Output/NoImage/';
output_root_image = 'Output/WithImage/';
% gaze dispersion
data = readtable('samplereport_pilotdata.xlsx');
image = char('');
blank_img = repmat(255, 1, 1, 1);
file = char('');
eye = char('');
output_filename = '';
matrix = zeros(1, 1);
matrices = containers.Map;
first = true;
%height(data)
for row_index = 1:500
disp(row_index);
try
row = data(row_index, :);
string_array = table2array(row(1, {'DATA_FILE', 'image', 'EYE_TRACKED'}));
[current_file, current_image, current_eye] = string_array{:};
if(~isKey(matrices, current_image))
image_object = imread(current_image);
[img_height, img_width, img_dim] = size(image_object);
blank_img = repmat(255, img_height, img_width, img_dim);
matrices(current_image) = zeros(img_height, img_width);
end
matrix = matrices(current_image);
if(strcmp(current_eye, 'Right'))
number_array = table2array(row(1, {'RIGHT_GAZE_X', 'RIGHT_GAZE_Y'}));
else
number_array = table2array(row(1, {'LEFT_GAZE_X', 'LEFT_GAZE_Y'}));
end
if(any(isnan(number_array)))
continue
end
number_array_cell = num2cell(number_array);
[x_coord, y_coord] = number_array_cell{:};
x_coord = int16(x_coord);
y_coord = int16(y_coord);
if(x_coord > 0 && x_coord <= img_width && y_coord > 0 && y_coord <= img_height)
matrix(y_coord, x_coord) = matrix(y_coord, x_coord) + 1;
matrix(5, 5) = matrix(5, 5) + 1;
matrices(current_image) = matrix;
end
catch error
disp('Error');
disp('\n');
end
end
image_keys = keys(matrices);
for key_index = 1:length(image_keys)
current_image_cell = image_keys(key_index);
current_image = current_image_cell{:};
matrix = matrices(current_image);
image_object = imread(current_image);
matrix = imgaussfilt(matrix, 2);
matrix = rescale(matrix);
hist_blank = heatmap_overlay(blank_img, matrix);
hist_image = heatmap_overlay(image_object, matrix);
output_filename = strcat('output-', current_image, '.png');
output_filename = erase(output_filename, {'.jpg', '.edf'});
output_filename_image = strcat(output_root_image, output_filename);
output_filename_blank = strcat(output_root_blank, output_filename);
imwrite(hist_image, output_filename_image);
imwrite(hist_blank, output_filename_blank);
end
You can’t perform that action at this time.