You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: doNNMatchingToHtml.m
    path of file: ./repos/Image-Harmonization-Dataset-iHarmony4/Lalonde and Efros/colorStatistics/mycode/globalMatching
    
    the code of the file until where you have to start completion: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function doNNMatchingToHtml
%   Writes the result of nearest-neighbor matching to an html file for easy visualization.
% 
% Input parameters:
%
%   - varargin: Possible values:
%     - 'Recompute':
%       - 0: (default) will not compute the histogram when results are
%         already available. 
%       - 1: will re-compute histogram no matter what
%
% Output parameters:
%
%
%

    
function
parallelized = 0;
randomized = 1;
processResultsDatabaseFast(dbPath, 'image_1', outputBasePath, dbFn, parallelized, randomized, ...
    'ColorSpace', colorSpace, 'DbPath', dbPath, 'ImagesPath', imagesPath, 'ObjectDb', objectDb, ...
    'Type', type, 'CompType', compType, 'HtmlInfo', htmlInfo, 'SubsampledImagesPath', subsampledImagesPath);

%%
function r=dbFnNNMatchingToHtml(outputBasePath, annotation, varargin)
global count;
r=0;

%% Initialize
% read arguments
defaultArgs = struct('ColorSpace', [], 'Type', [], 'CompType', [], 'DbPath', [], 'ImagesPath', [], ...
    'ObjectDb', [], 'HtmlInfo', [], 'SubsampledImagesPath', []);
args = parseargs(defaultArgs, varargin{:});

% read the image
img = imread(fullfile(args.ImagesPath, annotation.image.folder, annotation.image.filename));
% load the masks
load(fullfile(args.DbPath, annotation.file.folder, annotation.object.masks.filename)); %bgMask, objMask
% draw the object outline
objOutline = bwperim(objMask);
iB = repmat(zeros(size(img,1), size(img,2)), [1 1 2]);
iB(:,:,3) = objOutline;
img(repmat(objOutline, [1 1 2])) = 0;
img(find(iB)) = 255;

%% Find the corresponding object and background image in the database
fprintf('Finding indices in the database...');
objImgInd = getDatabaseIndexFromFilename(args.ObjectDb, 'document', annotation.objImgSrc.folder, annotation.objImgSrc.filename);
bgImgInd = getDatabaseIndexFromFilename(args.ObjectDb, 'document', annotation.bgImgSrc.folder, annotation.bgImgSrc.filename);
fprintf('done.');

%% Compute nearest neighbor for each type and each color space
fprintf('Computing nearest-neighbors...');
% Loop over all color spaces
if strcmp(args.ColorSpace, 'lab')
    colorType = 1;
elseif strcmp(args.ColorSpace, 'lalphabeta')
    colorType = 4;
else
    error('Unsupported color type!');
end