function preprocess_depth( config, file_info )

parfor file_i = 1:file_info.num_files
    % File paths
    [parent_dirs, name_root] = get_file_info_entry(file_info, file_i);
    clean_depth_normals_and_curvature(config, parent_dirs, name_root);
end

end % end preprocess_depth

function clean_depth_normals_and_curvature(config, parent_dirs, name_root)
file_dot_mat = [name_root '.mat'];

paths.depth     = fullfile(config.paths.depth, file_dot_mat);
paths.normals   = fullfile(config.paths.normals, file_dot_mat);
paths.curvature = fullfile(config.paths.curvature, file_dot_mat);
paths.depth = fullfile(parent_dirs{:}, ...
                       sprintf(config.data_info.depth_format, name_root));

% Check whether files exist
file_exists.depth     = exist(paths.depth, 'file');
file_exists.normals   = exist(paths.normals, 'file');
file_exists.curvature = exist(paths.curvature, 'file');

% Get depth cleaned
if file_exists.depth
    load(paths.depth, 'depth');
else
    % Load raw depth
    depth = double(imread(paths.depth));

    % Depth Crop, Scaling, Smoothing and Hole filling
    depth = depth_img_preprocess(depth, config.load_params);
    save(paths.depth, 'depth');
end

if ~file_exists.normals || ~file_exists.curvature
    % Convert to 3D point cloud
    pcd = depth_img_to_xyz(depth, config.load_params);

    % Normals
    if file_exists.normals
        load(paths.normals, 'normals');
    else
        [normals, ~] = depth_img_to_normals_cross(pcd, config.normal_params);
        save(paths.normals, 'normals');
    end

    % Curvature
    if ~file_exists.curvature
        curvature = pcd_normals_to_curvature(pcd, normals, config.curv_params);
        save(paths.curvature, 'curvature');
    end
end

end
