Home > data-import > gaze > preprocess_check_image_size.m

preprocess_check_image_size

PURPOSE ^

SYNOPSIS ^

function imgsize_list = preprocess_check_image_size(sub_list, target_cam_list, is_check_all_frames)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function imgsize_list = preprocess_check_image_size(sub_list, target_cam_list, is_check_all_frames)
0002 
0003 if ~exist('is_check_all_frames', 'var')
0004     is_check_all_frames = false;
0005 end
0006 
0007 imgsize_list = cell(size(target_cam_list));
0008 
0009 if ~iscell(target_cam_list)
0010     tmpcam = target_cam_list;
0011     target_cam_list = cell(1,1);
0012     target_cam_list{1} = tmpcam;
0013 end
0014 
0015 for camidx = 1:length(target_cam_list)
0016     cam_one = target_cam_list{camidx};
0017     imgsize_one = nan(length(sub_list), 2);
0018     
0019     for sidx = 1:length(sub_list)
0020         sub_id = sub_list(sidx);
0021         trial_frames = get_trials(sub_id);
0022         
0023         subj_dir = get_subject_dir(sub_id);
0024         jpg_folder = fullfile(subj_dir, [cam_one '_frames_p']);
0025         
0026         if ~is_check_all_frames
0027             tmprn = nan(size(trial_frames));
0028 
0029             for tidx = 1:size(trial_frames, 1)
0030                 rindex = randi([trial_frames(tidx,:)], 1);
0031                 jpg_file = sprintf('img_%d.jpg', rindex);
0032                 jpg_file_path = fullfile(jpg_folder, jpg_file);
0033                 if ~exist(jpg_file_path, 'file')
0034                     warning('Subject %d missing %s frame %d wthin trial %d', sub_id, cam_one, rindex, tidx);
0035                 end
0036                 img = imread(jpg_file_path);
0037                 tmprn(tidx, :) = size(img(:,:,1));
0038             end
0039 
0040             tmpsize = unique(tmprn);
0041             if length(tmpsize) > 2
0042                 error('Inconsistent image sizes within one camera for subject %d', sub_id);
0043             end
0044         else
0045             jpg_list = dir(fullfile(jpg_folder, 'img_*.jpg'));
0046             tmpj = nan(length(jpg_list));
0047 
0048             for jidx = 1:length(jpg_list)
0049                 jpg_file = sprintf('img_%d.jpg', jidx);
0050                 img = imread(fullfile(jpg_folder, jpg_file));
0051                 tmpj(jidx, :) = size(img(:,:,1));
0052             end
0053 
0054             tmpsize = unique(tmpsz);
0055             if length(tmpsize) > 2
0056                 error(['Inconsistent image sizes within one camera for subject %d' ...
0057                     ', frames sizes are %s'], sub_id, num2str(tmpsize));
0058             end
0059         end
0060 
0061         imgsize_one(sidx, :) = tmpsize;
0062     end
0063     
0064     imgsize_list{camidx} = imgsize_one;
0065 end
0066 
0067 if length(target_cam_list) < 2
0068     imgsize_list = imgsize_list{1};
0069 end

Generated on Tue 23-May-2017 03:00:58 by m2html © 2005