% This file reads the RGB image and depth data provided in the assignment
% and displays them side by side. Note that for displat purposes depth
% data is rescaled to [0 1] range.

close all
clear all

% This code is needed to read xml files
addpath(genpath('./xml_io_tools/'));

% Get image directory
imDir = dir('../rgb/*.png');

% Cycle through all images in the directory
for i=1:numel(imDir)
    
    % Read data
    name = imDir(i).name(1:end-4);                                         % Image name
    im = imread(['../rgb/', name, '.png']);                                 % Read RGB image
    im = im2double(im);                                                    % Convert to double
    depth = opencv_read(['../depth/', name, '.xml']);                       % Read xml depth data
    
    % Display
    tmp = [im, repmat(mat2gray(depth), [1 1 3])];
    tmp = imresize(tmp, 1000/size(tmp,2));
    imshow(tmp);
    drawnow;
end