function [im, disp_im] = imreadx(ex)
% Read a training example image.
%   im = imreadx(ex)
%
% Return value
%   im    The image specified by the example ex
%
% Argument
%   ex    An example returned by pascal_data.m

if nargout > 1
    S=cv.FileStorage(ex.imdisp);
    
    disp_im = double(S.disparity_image);
    disp_im = repmat(disp_im,[1 1 3]);
    
    if ex.flip
      disp_im = disp_im(:,end:-1:1,:);
    end
end

im = im2double(imread(ex.im));
im = color(im);
if ex.flip
  im = im(:,end:-1:1,:);
end
