Reputation: 11
Suppose I want to perform correlation between two images. I know there is a function normxcorr2 which can be used to find the correlation between two images (img1, img2) like this
C = normxcorr2(img1, img2)
But can I find the correlation using imfilter? Does this command perform correlation?
corr = imfilter(img1, img2, 'corr','replicate');
When I run the imfilter command and use the imshow() command to output the resulting image, I can see that it is different from what I get when I output the resulting image using normxcorr2 command.The image generated through normxcorr2 looks more like what i would expect from the correlation of the two images. What's the difference between these two methods?
Upvotes: 0
Views: 360
Reputation: 1058
There are differences between named functions in MATLAB. To be more specific, imfilter
function performs a single convolution, and the normxcorr2
performs correlation between two signals (images). To read more about the difference between convolution and correlation this link may help.
There are also other functions in MATLAB namely xcorr2
to calculate cross-correlation and filter2
for FIR filtering of img1 by img2.
Upvotes: 0