How do I determine the displacement between two matrices using a two-dimensional cross-correlation function (xcorr2)

7 views (last 30 days)
For a project I need to finish a script that uses two matrices the "kernel" and "searchArea" to determine the displacement of the interventricular septum of the heart using the blockchaining method with multiple frames of the cardiac cycle. The "kernel" is a fraction of the orginal frame image and the "searchArea" is an area thats surrounds the kernel in the next frame. I have to use cross correlation to do this and already tried the following (this process will be repeated for all the frames):
crossCor = xcorr2(searchArea,kernel);
[max_cc,imax] = max(abs(crossCor(:)));
[ypeak, xpeak] = ind2sub(size(crossCor),imax(1));
dispLat = ypeak-size(kernel,1)
dispAx = xpeak-size(kernel,2)
This code was writen based on the xcorr2 documentation: https://nl.mathworks.com/help/signal/ref/xcorr2.html
The code does work but the results do not meet my expectations, the script that I got provided with uses the lateral displacement (x displacement) and axial displacement (y displacement) to create tracking frames:
The results should show the displacement of the septum just like in frame 1, but you can see that in frame 2 and 3 the displacement is way off.
I do not know if i'm on the right track here of giving the provided script the right displacements, but any advice or nudges in the right direction are welcome!

Answers (0)

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!