Skip to content

Commit 3e66654

Browse files
committed
Merge pull request opencv#7973 from sturkmen72:patch-2
2 parents 6ed571b + f108795 commit 3e66654

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

modules/nonfree/src/sift.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,18 +170,20 @@ static Mat createInitialImage( const Mat& img, bool doubleImageSize, float sigma
170170
{
171171
Mat gray, gray_fpt;
172172
if( img.channels() == 3 || img.channels() == 4 )
173+
{
173174
cvtColor(img, gray, COLOR_BGR2GRAY);
175+
gray.convertTo(gray_fpt, DataType<sift_wt>::type, SIFT_FIXPT_SCALE, 0);
176+
}
174177
else
175-
img.copyTo(gray);
176-
gray.convertTo(gray_fpt, DataType<sift_wt>::type, SIFT_FIXPT_SCALE, 0);
178+
img.convertTo(gray_fpt, DataType<sift_wt>::type, SIFT_FIXPT_SCALE, 0);
177179

178180
float sig_diff;
179181

180182
if( doubleImageSize )
181183
{
182184
sig_diff = sqrtf( std::max(sigma * sigma - SIFT_INIT_SIGMA * SIFT_INIT_SIGMA * 4, 0.01f) );
183185
Mat dbl;
184-
resize(gray_fpt, dbl, Size(gray.cols*2, gray.rows*2), 0, 0, INTER_LINEAR);
186+
resize(gray_fpt, dbl, Size(gray_fpt.cols*2, gray_fpt.rows*2), 0, 0, INTER_LINEAR);
185187
GaussianBlur(dbl, dbl, Size(), sig_diff, sig_diff);
186188
return dbl;
187189
}

0 commit comments

Comments
 (0)