From f108795e2cf0059813009ccff96ae2605a5c75a2 Mon Sep 17 00:00:00 2001 From: Suleyman TURKMEN Date: Thu, 5 Jan 2017 19:47:34 +0200 Subject: [PATCH] Update sift.cpp --- modules/nonfree/src/sift.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/nonfree/src/sift.cpp b/modules/nonfree/src/sift.cpp index 9ce6b988ac..8ecdd877b0 100644 --- a/modules/nonfree/src/sift.cpp +++ b/modules/nonfree/src/sift.cpp @@ -170,10 +170,12 @@ static Mat createInitialImage( const Mat& img, bool doubleImageSize, float sigma { Mat gray, gray_fpt; if( img.channels() == 3 || img.channels() == 4 ) + { cvtColor(img, gray, COLOR_BGR2GRAY); + gray.convertTo(gray_fpt, DataType::type, SIFT_FIXPT_SCALE, 0); + } else - img.copyTo(gray); - gray.convertTo(gray_fpt, DataType::type, SIFT_FIXPT_SCALE, 0); + img.convertTo(gray_fpt, DataType::type, SIFT_FIXPT_SCALE, 0); float sig_diff; @@ -181,7 +183,7 @@ static Mat createInitialImage( const Mat& img, bool doubleImageSize, float sigma { sig_diff = sqrtf( std::max(sigma * sigma - SIFT_INIT_SIGMA * SIFT_INIT_SIGMA * 4, 0.01f) ); Mat dbl; - resize(gray_fpt, dbl, Size(gray.cols*2, gray.rows*2), 0, 0, INTER_LINEAR); + resize(gray_fpt, dbl, Size(gray_fpt.cols*2, gray_fpt.rows*2), 0, 0, INTER_LINEAR); GaussianBlur(dbl, dbl, Size(), sig_diff, sig_diff); return dbl; }