Does absolute intensity in an image matter when computing the normalized cross correlation with NORMXCORR2?

3 views (last 30 days)
I have two different images of the same object which differ in overall intensity. I would like to know if this will affect the normalized cross correlation computation with NORMXCORR2.

Accepted Answer

Anish on 18 Jan 2011
The normalized cross correlation computed in normxcorr2 is robust to differences in illumination between the template and input image. In the example below, two different outputs are obtained. The first is with the template and input image with the same intensities (0 or 1). In the second case, the correlation relationship between the input image and the template are left the same, but vary the intensity of the template and input. In both cases, the same output is obtained within double precision accuracy.
BW = rand(10,10) > 0.5;
template = BW(4:6,4:6);
output = normxcorr2(template,BW);
[maxCoefficient,ind] = max(abs(output(:)));
[rmax,cmax] = ind2sub(size(output),ind) % Change intensity of template and input image, but keep correlation the same
template = double(template);
template = 0.6*template
A = double(BW);
A = 0.2*A;
outputWithScaledInput = normxcorr2(template,A); [maxCoefficient,ind] = max(abs(outputWithScaledInput(:))); [rmax,cmax] = ind2sub(size(output),ind)
%Look at difference in correlation coefficients with inputs scaled to different intensity

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!