function [depth] = load_raw_depth(depth_path, params)
% Load raw image
depth = double(imread(depth_path));

% Crop and resize image
if isfield(params, 'crop')
    depth = depth(params.crop(1):params.crop(2), ...
                  params.crop(3):params.crop(4), :);
end
if isfield(params, 'scale')
    % Use nearest neighbor since 0 values are invalid, 
    % and we dont want to average them with valid values. 
    depth = imresize(depth, params.scale, 'nearest');
end

% If the maximum depth is greater than 10,
% then we probably need to convert mm to meters.
if max(depth(:)) > 10
    depth = depth/1000; % Convert mm to m
end

% Max depth cutoff
if isfield(params, 'max_depth')
    depth = min(depth, params.max_depth);
end
end
