function S2Map = C1Im_caS2Centroid_2_S2Map_SumNormXCorr(c1im, caS2centroid,bReweightLayers);
%function S2Map = C1Im_caS2Centroid_2_S2Map_SumNormXCorr(c1im, caS2centroid,bReweightLayers);
%
%calculate the S2 layer given a c1 image and a cell array of s2 centroids.
S2Map = zeros(size(c1im,1), size(c1im,2), length(caS2centroid));
tic
for i = 1:length(caS2centroid);
    fprintf('%d of %d.  %d seconds elapsed\r',i,length(caS2centroid),round(toc));
    if(length(unique(caS2centroid{i}(:))) == 1)
       S2Map(:,:,i) = zeros(size(c1im));
    else
       S2Map(:,:,i) = NormXCorr_SumLayerByLayer(caS2centroid{i}, c1im,bReweightLayers);
    end
end
 
