function [img] = load_raw_image(img_path, params)
% Load raw image
img = im2double(imread(img_path));

% Crop and resize image.
if isfield(params, 'crop')
    img = img(params.crop(1):params.crop(2), ...
              params.crop(3):params.crop(4), :);
end
if isfield(params, 'scale')
    img = imresize(img, params.scale);
end

if isfield(params, 'color_space')
    switch params.color_space
      case 'rgb'
        % Nothing to do
      case 'lab'
        % Compute Lab image
        img = applycform(img, params.clab);
      case 'hsv'
        img = rgb2hsv(img);
      otherwise
        error('Unknown color space');
    end
end

end
