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: regImg.m
    path of file: ./repos/lrslibrary/algorithms/rpca/DECOLOR/internal
    
    the code of the file until where you have to start completion: function [I2warp,tau,residue,OmegaOut] = regImg(I1,I2,tau,weight,maxIts)

% This function registers I2 to I1 based on different different transformation
% tau --- the transformation parameter,
% which must be initialized, since its length specifies the type of transf.
% length(tau) = 3: rigid

    
function [I2warp,tau,residue,OmegaOut] = regImg(I1,I2,tau,weight,maxIts)

% This function registers I2 to I1 based on different different transformation
% tau --- the transformation parameter,
% which must be initialized, since its length specifies the type of transf.
% length(tau) = 3: rigid
% length(tau) = 4: similarity
% length(tau) = 6: affine
% length(tau) = 8: projective

% initialize variables
I1 = double(I1);
I2 = double(I2);
sizeI = size(I1);
sizeD = sizeI(1)*sizeI(2);

if nargin < 3 || isempty(tau)
    tau = zeros(6,1); % the default is affine transf.
end