I was pondering over how to implement it. It's obvious that initially it is necessary to compute mean of the template:
template = rgb2gray(imread('....'));
% for the template image given in the task it's around 110
template_mean = mean2(template);
% get the zero-mean template
template_zero_mean =template-template_mean;
The question is what to do next? Should the mean for the image also be computed and subtracted from the image?