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: read_normal_map.m
    path of file: ./repos/PBACalib/matlab/colmap
    
    the code of the file until where you have to start completion: % Copyright (c) 2022, ETH Zurich and UNC Chapel Hill.
% All rights reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are met:
%
%     * Redistributions of source code must retain the above copyright
%       notice, this list of conditions and the following disclaimer.
%
%     * Redist
    
function [normal_map, normal_map_rgb] = read_normal_map(path, varargin)

normal_map = read_array(path);

normal_map_rgb = -[normal_map(:,:,1) normal_map(:,:,2) ...
                   2 * normal_map(:,:,3) + 1];
normal_map_rgb = reshape(normal_map_rgb, ...
                         size(normal_map,1), size(normal_map,2), 3);
normal_map_rgb = uint8(((normal_map_rgb + 1) ./ 2) .* 255);

if length(varargin) == 1
    depth_map = varargin{1};
    normal_map_rgb(repmat(isnan(depth_map), [1, 1, 3])) = 0;
end