function xyinput = dic_basecorr3(CORRSIZE, PRECISION, OPTIMIZE, hwid, base_points_x, base_points_y, base)

base_points_for(:,1)=reshape(base_points_x,[],1);
base_points_for(:,2)=reshape(base_points_y,[],1);

ncp = size(base_points_for, 1);
rects_base = dic_calc_rects(base_points_for,2*CORRSIZE,base);

n = 2*CORRSIZE + 1;
mn = n*n;

for icp = 1:ncp
    if isequal(rects_base(icp,3:4),[0 0])
	continue
    end

    sub_base = imcrop(base,rects_base(icp,:));
    
    if sum(sub_base(:)) == sub_base(1)*numel(sub_base)
	eid = sprintf('Images:%s:sameElementsInTemplate',mfilename);
	msg = 'The values of TEMPLATE cannot all be the same.';
	error(eid,'%s',msg);
    end
    

    double_sub_base = double(sub_base);
    local_sum_A = dic_local_sum(double_sub_base,n,n);
    local_sum_A2 = dic_local_sum(double_sub_base.*double_sub_base,n,n);
    denom_A = sqrt( max(( local_sum_A2 - (local_sum_A.^2)/mn ) / (mn-1), 0) );
    i_nonzero = find(denom_A~=0);
    normxcorr_hw(hwid, 2, icp, sub_base, single(local_sum_A), single(denom_A), uint16(i_nonzero));
end
