user3030102
user3030102

Reputation: 21

finding all peaks in phase correlation matrix in opencv

I am writing a program in C++ with OpenCv which needs to find the phase correlation matrix between two images and find all the peaks present above a response threshold. I did find a function called phaseCorrRes() but it returns only the highest peak using minMaxLoc(). How do I modify this function to retrive all the peaks?

Upvotes: 1

Views: 2198

Answers (2)

user3030102
user3030102

Reputation: 21

It is best to follow the sequence as mentioned in the phaseCorrRes(). we can just add two more steps after carrying FFTShift() which are normalization and threshold. Now if we just change the pixels near and at each peak extracted using minMaxLoc() to 0 (i.e. black) we can iteratively find all the peaks using minMaxLoc(). However, just change the function by creating a copy of the function in the program and not in the original source code.

Upvotes: 1

vz_
vz_

Reputation: 482

I think you shold use other way to solve your problem, if that function do not useful for you. I recommend you the following steps:

  1. Transform you images to the frequency domain with DFT (Discrete Fourier Transform).
  2. From the result complex matrix get the phases.
  3. Calculate the correlation.
  4. Apply some threshold value.

For this steps you need:

  1. dft()
  2. phase()
  3. matchTemplate() with method = CV_TM_CCORR_NORMED
  4. threshold() with type = THRESH_TOZERO

Hope this helps you.

Upvotes: 3

Related Questions