Skip to content

Add missing sqrt to magSpectrum().#20102

Merged
alalek merged 2 commits intoopencv:3.4from
yo1990:master
May 29, 2021
Merged

Add missing sqrt to magSpectrum().#20102
alalek merged 2 commits intoopencv:3.4from
yo1990:master

Conversation

@yo1990
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown
Contributor

👍

@yo1990
Copy link
Copy Markdown
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