function H_map = calcHMap(H_list, H_list2, length) 
% This function creates a mapping from all images to the 
% reference image (center) by taking advantage of composition

% Use ref as the reference image (middle)
ref = (length)/2;
ref = int8(ref);

temp = ref-1;

% Initially set all values to the identity matrix
for i = 1: length
    H_map(i) = {eye(3)}; 
end

% Multiply through left half (accululation, in a way)
while temp > 0
    for j = 1: temp
        H_map{j}
        H_list2{temp}
        H_map{j} = H_map{j} * H_list2{temp};
    end
    temp = temp -1;
end

% Switch to the right half
temp = ref +1;

% Multiply through the right half
while temp <= length
    for j = temp:length
        H_map{j} = H_map{j} * (H_list{temp - 1});
    end
    temp = temp + 1;
end
end