0

I found an algorithm where a cross correlation (normxcorr2) is applied between two images with the same size in order to measure the displacement of the particle inside the image between the two instants.

For example, for this case ( fixed image left and moving image right), the algorithm shows as displacement the vector (-0.0076, 0.5383)

I didn't get why this calculation is meaningful especially that in this case the parameters for normxcorr2 have the same size !

Could someone clarify to me why it's relevant to do cross correlation in this case?

ransa
  • 71
  • 10
  • what do you mean by "sense"? What is the question? – Ander Biguri Jun 20 '17 at 12:59
  • @AnderBiguri I edited the question ! – ransa Jun 20 '17 at 13:05
  • 1
    The size of the images is irrelevant. Cross correlation will give you how much you need to displace one of the images so the "content" of the image is aligned with the other one. In your case, the result is that you need to move it very very little in `x` direction (-0.007 pixels!) and half a pixel in the other direction. – Ander Biguri Jun 20 '17 at 13:13
  • 1
    ProTip: It is very helpful for better understanding if you know what the code is meant to do before you start reading line by line – Ander Biguri Jun 20 '17 at 13:14
  • @AnderBiguri Thank you for your answer, ss there any method less costly to perform this calculation ? – ransa Jun 20 '17 at 13:39
  • 2
    Also note that depending on your image size, `normxcorr2` performs the required calculations either using spatial-domain convolution, or in the frequency domain via the FFT. This is why you have subpixel accuracy and its quite efficient. You can't get any better unfortunately. To gain a better understanding of how `normxcorr2` works, a similar algorithm is provided for you in the duplicate link above in your question. – rayryeng Jun 20 '17 at 13:41
  • @rayryeng Thank you for sharing the post – ransa Jun 20 '17 at 13:53

1 Answers1

1

To measure displacements, you need to overlap the two images with different offsets and retain the best correlation. This can be done with subpixel accuracy, by interpolation (can be interpolation in images space or in correlation coefficient space).

Usually, you locate a smaller image in a large one, which leaves some play for movement. If the two images are the same size, you have to sacrifice some boundary pixels to make one of them smaller. (You can also displace one of the images and reconstruct the missing pixels by extrapolation, but this is more articificial.)

  • Than you for the answer. What's the advantage of removing the boundary pixels for one of the images before doing cross correlation? – ransa Jun 20 '17 at 13:43
  • Mh, I guess you didn't capture my answer. It is not an advantage, it is a must-do. –  Jun 20 '17 at 13:47