diff --git a/modules/imgproc/src/templmatch.cpp b/modules/imgproc/src/templmatch.cpp index a82f34863..64cb1c408 100644 --- a/modules/imgproc/src/templmatch.cpp +++ b/modules/imgproc/src/templmatch.cpp @@ -166,6 +166,7 @@ void crossCorr( const Mat& img, const Mat& templ, Mat& corr, for( k = 0; k < cn; k++ ) { Mat src = src0; + dftImg = Scalar::all(0); if( cn > 1 ) { @@ -181,12 +182,6 @@ void crossCorr( const Mat& img, const Mat& templ, Mat& corr, copyMakeBorder(dst1, dst, y1-y0, dst.rows-dst1.rows-(y1-y0), x1-x0, dst.cols-dst1.cols-(x1-x0), borderType); - if( dftsize.width > dsz.width ) - { - Mat part(dftImg, Range(0, dsz.height), Range(dsz.width, dftsize.width)); - part = Scalar::all(0); - } - dft( dftImg, dftImg, 0, dsz.height ); Mat dftTempl1(dftTempl, Rect(0, tcn > 1 ? k*dftsize.height : 0, dftsize.width, dftsize.height));