Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing sqrt to magSpectrum(). #20102

Merged
merged 2 commits into from
May 29, 2021
Merged

Add missing sqrt to magSpectrum(). #20102

merged 2 commits into from
May 29, 2021

Conversation

yo1990
Copy link
Contributor

@yo1990 yo1990 commented May 17, 2021

resolves #20100

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Add some std::sqrt() to magSpectrum().
#20100

force_builders=ARMv7,Custom
build_image:Custom=centos:7
buildworker:Custom=linux-1,linux-4,linux-6

@llschloesser
Copy link

For phase correlation, the | | in DFT' (F G* / |F G*|) means absolute value and not magnitude, right? Is magSpectrums() the wrong operation to use for phase correlation?

@llschloesser
Copy link

For phase correlation, the | | in DFT' (F G* / |F G*|) means absolute value and not magnitude, right? Is magSpectrums() the wrong operation to use for phase correlation?

In my code I replaced:
magnitude_of_spectrums(cross_power_, cross_power_magnitude_);
with
cv::absdiff(cross_power_, cv::Scalar::all(0), cross_power_magnitude_);
and observed no loss of accuracy/quality. Same good results as before. What am I not understanding?

@llschloesser
Copy link

For phase correlation, the | | in DFT' (F G* / |F G*|) means absolute value and not magnitude, right? Is magSpectrums() the wrong operation to use for phase correlation?

In my code I replaced:
magnitude_of_spectrums(cross_power_, cross_power_magnitude_);
with
cv::absdiff(cross_power_, cv::Scalar::all(0), cross_power_magnitude_);
and observed no loss of accuracy/quality. Same good results as before. What am I not understanding?

In the book Image Processing, Analysis, and Machine Vision, the magnitude function | F(u,v) | is defined as sqrt(R(u,v)^2 + I(u,v)^2). So it seems that the magnitude function on a spectrum is indeed the right operation and is denoted with single bars rather than double?

@vpisarev vpisarev self-requested a review May 29, 2021 03:16
@vpisarev
Copy link
Contributor

👍

@yo1990
Copy link
Contributor Author

yo1990 commented May 29, 2021

Thank you.
I agree with your corrections; absolute value is more appropriate, not magnitude.

@alalek alalek merged commit d3be58b into opencv:3.4 May 29, 2021
This was referenced May 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DC component sqrt is missing in magSpectrums() called in phaseCorrelate().
5 participants