Commit 604d5e54064bfdbe6c0b64ac8d7360c38063de31
1 parent
2253be05
removed initSigma
Showing
1 changed file
with
6 additions
and
8 deletions
openbr/plugins/imgproc/custom_sift.cpp
| @@ -132,7 +132,7 @@ static inline void unpackOctave(const KeyPoint &kpt, int &octave, int &layer, fl | @@ -132,7 +132,7 @@ static inline void unpackOctave(const KeyPoint &kpt, int &octave, int &layer, fl | ||
| 132 | scale = octave >= 0 ? 1.f/(1 << octave) : (float)(1 << -octave); | 132 | scale = octave >= 0 ? 1.f/(1 << octave) : (float)(1 << -octave); |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | -static Mat createInitialImage( const Mat& img, bool doubleImageSize, float sigma, float initSigma ) | 135 | +static Mat createInitialImage( const Mat& img, bool doubleImageSize, float sigma) |
| 136 | { | 136 | { |
| 137 | Mat gray, gray_fpt; | 137 | Mat gray, gray_fpt; |
| 138 | if( img.channels() == 3 || img.channels() == 4 ) | 138 | if( img.channels() == 3 || img.channels() == 4 ) |
| @@ -145,7 +145,7 @@ static Mat createInitialImage( const Mat& img, bool doubleImageSize, float sigma | @@ -145,7 +145,7 @@ static Mat createInitialImage( const Mat& img, bool doubleImageSize, float sigma | ||
| 145 | 145 | ||
| 146 | if( doubleImageSize ) | 146 | if( doubleImageSize ) |
| 147 | { | 147 | { |
| 148 | - sig_diff = sqrtf( std::max(sigma * sigma - initSigma * initSigma * 4, 0.01f) ); | 148 | + sig_diff = sqrtf( std::max(sigma * sigma, 0.01f) ); |
| 149 | Mat dbl; | 149 | Mat dbl; |
| 150 | resize(gray_fpt, dbl, Size(gray.cols*2, gray.rows*2), 0, 0, INTER_LINEAR); | 150 | resize(gray_fpt, dbl, Size(gray.cols*2, gray.rows*2), 0, 0, INTER_LINEAR); |
| 151 | GaussianBlur(dbl, dbl, Size(), sig_diff, sig_diff); | 151 | GaussianBlur(dbl, dbl, Size(), sig_diff, sig_diff); |
| @@ -153,7 +153,7 @@ static Mat createInitialImage( const Mat& img, bool doubleImageSize, float sigma | @@ -153,7 +153,7 @@ static Mat createInitialImage( const Mat& img, bool doubleImageSize, float sigma | ||
| 153 | } | 153 | } |
| 154 | else | 154 | else |
| 155 | { | 155 | { |
| 156 | - sig_diff = sqrtf( std::max(sigma * sigma - initSigma * initSigma, 0.01f) ); | 156 | + sig_diff = sqrtf( std::max(sigma * sigma, 0.01f) ); |
| 157 | GaussianBlur(gray_fpt, gray_fpt, Size(), sig_diff, sig_diff); | 157 | GaussianBlur(gray_fpt, gray_fpt, Size(), sig_diff, sig_diff); |
| 158 | return gray_fpt; | 158 | return gray_fpt; |
| 159 | } | 159 | } |
| @@ -385,7 +385,7 @@ static int descriptorSize(int bins, int width) | @@ -385,7 +385,7 @@ static int descriptorSize(int bins, int width) | ||
| 385 | return width*width*bins; | 385 | return width*width*bins; |
| 386 | } | 386 | } |
| 387 | 387 | ||
| 388 | -static void extractSIFT(const Mat &image, vector<KeyPoint> &keypoints, Mat &descriptors, int nOctaveLayers, double sigma, int bins, int width, float initSigma) | 388 | +static void extractSIFT(const Mat &image, vector<KeyPoint> &keypoints, Mat &descriptors, int nOctaveLayers, double sigma, int bins, int width) |
| 389 | { | 389 | { |
| 390 | if( image.empty() || image.depth() != CV_8U ) | 390 | if( image.empty() || image.depth() != CV_8U ) |
| 391 | CV_Error( CV_StsBadArg, "image is empty or has incorrect depth (!=CV_8U)" ); | 391 | CV_Error( CV_StsBadArg, "image is empty or has incorrect depth (!=CV_8U)" ); |
| @@ -404,7 +404,7 @@ static void extractSIFT(const Mat &image, vector<KeyPoint> &keypoints, Mat &desc | @@ -404,7 +404,7 @@ static void extractSIFT(const Mat &image, vector<KeyPoint> &keypoints, Mat &desc | ||
| 404 | CV_Assert( firstOctave >= -1 && actualNLayers <= nOctaveLayers ); | 404 | CV_Assert( firstOctave >= -1 && actualNLayers <= nOctaveLayers ); |
| 405 | actualNOctaves = maxOctave - firstOctave + 1; | 405 | actualNOctaves = maxOctave - firstOctave + 1; |
| 406 | 406 | ||
| 407 | - const Mat base = createInitialImage(image, firstOctave < 0, (float)sigma, initSigma); | 407 | + const Mat base = createInitialImage(image, firstOctave < 0, (float)sigma); |
| 408 | const int nOctaves = actualNOctaves > 0 ? actualNOctaves : cvRound(log( (double)std::min( base.cols, base.rows ) ) / log(2.) - 2) - firstOctave; | 408 | const int nOctaves = actualNOctaves > 0 ? actualNOctaves : cvRound(log( (double)std::min( base.cols, base.rows ) ) / log(2.) - 2) - firstOctave; |
| 409 | 409 | ||
| 410 | vector<Mat> gpyr, dogpyr; | 410 | vector<Mat> gpyr, dogpyr; |
| @@ -432,12 +432,10 @@ class CustomSIFTTransform : public UntrainableTransform | @@ -432,12 +432,10 @@ class CustomSIFTTransform : public UntrainableTransform | ||
| 432 | Q_PROPERTY(QList<int> sizes READ get_sizes WRITE set_sizes RESET reset_sizes STORED false) | 432 | Q_PROPERTY(QList<int> sizes READ get_sizes WRITE set_sizes RESET reset_sizes STORED false) |
| 433 | Q_PROPERTY(int bins READ get_bins WRITE set_bins RESET reset_bins STORED false) | 433 | Q_PROPERTY(int bins READ get_bins WRITE set_bins RESET reset_bins STORED false) |
| 434 | Q_PROPERTY(int width READ get_width WRITE set_width RESET reset_width STORED false) | 434 | Q_PROPERTY(int width READ get_width WRITE set_width RESET reset_width STORED false) |
| 435 | - Q_PROPERTY(float initSigma READ get_initSigma WRITE set_initSigma RESET reset_initSigma STORED false) | ||
| 436 | BR_PROPERTY(int, size, 1) | 435 | BR_PROPERTY(int, size, 1) |
| 437 | BR_PROPERTY(QList<int>, sizes, QList<int>()) | 436 | BR_PROPERTY(QList<int>, sizes, QList<int>()) |
| 438 | BR_PROPERTY(int, bins, 8) | 437 | BR_PROPERTY(int, bins, 8) |
| 439 | BR_PROPERTY(int, width, 4) | 438 | BR_PROPERTY(int, width, 4) |
| 440 | - BR_PROPERTY(float, initSigma, 0.5f) | ||
| 441 | 439 | ||
| 442 | void init() | 440 | void init() |
| 443 | { | 441 | { |
| @@ -453,7 +451,7 @@ class CustomSIFTTransform : public UntrainableTransform | @@ -453,7 +451,7 @@ class CustomSIFTTransform : public UntrainableTransform | ||
| 453 | keyPoints.push_back(KeyPoint(val.x(), val.y(), sz)); | 451 | keyPoints.push_back(KeyPoint(val.x(), val.y(), sz)); |
| 454 | 452 | ||
| 455 | Mat m; | 453 | Mat m; |
| 456 | - extractSIFT(src, keyPoints, m, 3, 1.6f, bins, width, initSigma); | 454 | + extractSIFT(src, keyPoints, m, 3, 1.6f, bins, width); |
| 457 | m.setTo(0, m<0); // SIFT returns large negative values when it goes off the edge of the image. | 455 | m.setTo(0, m<0); // SIFT returns large negative values when it goes off the edge of the image. |
| 458 | dst += m; | 456 | dst += m; |
| 459 | } | 457 | } |