Applying xcorr2 to match two subsequent images. Do I need normxcorr2, do I need to substract mean values?
7 次查看(过去 30 天)
显示 更早的评论
Sorry for the title gore, but basically I am tracking the downward vertical flow of some bubbles. I have two images, the first at t=0, and then the bubbles have moved vertically to t=t. So basically I have the same image in both, but one is shifted by the vertical velocity of the bubbles.
I am applying a normxcorr2 to get my result, and it is working very well.
My code right now looks like this:
%first image
img1;
% second image
img2;
%cross correlation
ccr = ccr = normxcorr2(img1,img2);
%find the maximum
[ypeak,xpeak]=find(ccr==max(ccr(:)));
%convert to y coordinates
yoffset = ypeak-size(img2,1);
xoffset = xpeak-size(img2,2);
So visually inspecting my result, the match works very well.
My question is that from understanding what I am doing, if I was to apply just xcorr2, I would need to subtract the mean from each image (so that I have equal negative and positive values for the xcorr). Why don't I need to do this the normxcorr2.
I have tried applying just xcorr2 on img1 and img2, and also have tried applying xcorr2 on
img1 = img1 - mean(mean(img1))
I receive a similar, but different answer. Any ideas why?
Any sort of explanation here would be greatly appreciated.
0 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!