%Flip im if not properly oriented

%Load dataset lists
if ~exist('mpd')
    mpd=uigetdir(pwd,['Select the main project folder']);
end
load([mpd '\dataset.mat']);

for s=1:size(imgpth,1);
    c_data=dataset(s,:);
    c_imgpth=imgpth(s,:);
    c_resfol=resfol(s,:);
    if str2num(c_data(end))>0
        disp(['Processing ' c_data '...']);
        im=imread(c_imgpth);
        
        % Display image
        im=imread(c_imgpth);
        close all; fo=figure;
        warning('off','images:imshow:magnificationMustBeFitForDockedFigure')
        imshow(im); hold on; set(gcf,'NumberTitle','off','Name',c_data)
        
        % Decide if flip needed
        ok=input('Press enter if okay, x to flip: ','s');
        if ~isempty(ok)
            im=flipdim(im,1);
            imshow(im)
            imwrite(im,c_imgpth,'jpg');
        end
    end
end