Merge pull request #20102 from yo1990:master

Add missing sqrt to magSpectrum().

* https://github.com/opencv/opencv/issues/20100

* slight optimization + fix for double-precision case

Co-authored-by: Yuma Oyama <yuma.oyama@acuity-inc.co.jp>
Co-authored-by: Vadim Pisarevsky <vadim.pisarevsky@me.com>
pull/20180/head^2
yo1990 4 years ago committed by GitHub
parent 8ecfbdb4ff
commit d3be58b6d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      modules/imgproc/src/phasecorr.cpp

@ -78,9 +78,9 @@ static void magSpectrums( InputArray _src, OutputArray _dst)
{
if( k == 1 )
dataSrc += cols - 1, dataDst += cols - 1;
dataDst[0] = dataSrc[0]*dataSrc[0];
dataDst[0] = (float)std::abs(dataSrc[0]);
if( rows % 2 == 0 )
dataDst[(rows-1)*stepDst] = dataSrc[(rows-1)*stepSrc]*dataSrc[(rows-1)*stepSrc];
dataDst[(rows-1)*stepDst] = (float)std::abs(dataSrc[(rows-1)*stepSrc]);
for( j = 1; j <= rows - 2; j += 2 )
{
@ -97,9 +97,9 @@ static void magSpectrums( InputArray _src, OutputArray _dst)
{
if( is_1d && cn == 1 )
{
dataDst[0] = dataSrc[0]*dataSrc[0];
dataDst[0] = (float)std::abs(dataSrc[0]);
if( cols % 2 == 0 )
dataDst[j1] = dataSrc[j1]*dataSrc[j1];
dataDst[j1] = (float)std::abs(dataSrc[j1]);
}
for( j = j0; j < j1; j += 2 )
@ -122,9 +122,9 @@ static void magSpectrums( InputArray _src, OutputArray _dst)
{
if( k == 1 )
dataSrc += cols - 1, dataDst += cols - 1;
dataDst[0] = dataSrc[0]*dataSrc[0];
dataDst[0] = std::abs(dataSrc[0]);
if( rows % 2 == 0 )
dataDst[(rows-1)*stepDst] = dataSrc[(rows-1)*stepSrc]*dataSrc[(rows-1)*stepSrc];
dataDst[(rows-1)*stepDst] = std::abs(dataSrc[(rows-1)*stepSrc]);
for( j = 1; j <= rows - 2; j += 2 )
{
@ -141,9 +141,9 @@ static void magSpectrums( InputArray _src, OutputArray _dst)
{
if( is_1d && cn == 1 )
{
dataDst[0] = dataSrc[0]*dataSrc[0];
dataDst[0] = std::abs(dataSrc[0]);
if( cols % 2 == 0 )
dataDst[j1] = dataSrc[j1]*dataSrc[j1];
dataDst[j1] = std::abs(dataSrc[j1]);
}
for( j = j0; j < j1; j += 2 )

Loading…
Cancel
Save