From e309c51430d3f98458412a2dff236266cac21d6a Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Fri, 18 May 2012 08:33:19 +0000 Subject: [PATCH] Fixed phaseCorrelate result for not power of 2 size images #1812 (thanks to Jeff Mast) --- modules/imgproc/src/phasecorr.cpp | 2 +- modules/imgproc/test/test_pc.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/imgproc/src/phasecorr.cpp b/modules/imgproc/src/phasecorr.cpp index 26b7c5c375..f78af82fd2 100644 --- a/modules/imgproc/src/phasecorr.cpp +++ b/modules/imgproc/src/phasecorr.cpp @@ -556,7 +556,7 @@ cv::Point2d cv::phaseCorrelate(InputArray _src1, InputArray _src2, InputArray _w t = weightedCentroid(C, peakLoc, Size(5, 5)); // adjust shift relative to image center... - Point2d center((double)src1.cols / 2.0, (double)src1.rows / 2.0); + Point2d center((double)padded1.cols / 2.0, (double)padded1.rows / 2.0); return (center - t); } diff --git a/modules/imgproc/test/test_pc.cpp b/modules/imgproc/test/test_pc.cpp index 6d6f6c07f9..f1c86d5757 100644 --- a/modules/imgproc/test/test_pc.cpp +++ b/modules/imgproc/test/test_pc.cpp @@ -63,8 +63,8 @@ void CV_PhaseCorrelatorTest::run( int ) { ts->set_failed_test_info(cvtest::TS::OK); - Mat r1 = Mat::ones(Size(128, 128), CV_64F); - Mat r2 = Mat::ones(Size(128, 128), CV_64F); + Mat r1 = Mat::ones(Size(129, 128), CV_64F); + Mat r2 = Mat::ones(Size(129, 128), CV_64F); double expectedShiftX = -10.0; double expectedShiftY = -20.0;