Skip to content

Commit bb901d7

Browse files
author
Carsten Griwodz
committed
[popsift] configuration to ignore edge and peak thresholds
1 parent f815fbb commit bb901d7

4 files changed

Lines changed: 63 additions & 21 deletions

File tree

src/application/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ static void parseargs(int argc, char** argv, popsift::Config& config, string& in
7474
"Initial sigma value")
7575
("threshold",
7676
value<float>()->notifier([&](float f) { config.setThreshold(f); })->default_value(config.getThreshold()),
77-
"Contrast threshold")
77+
popsift::Config::getPeakThreshUsage().c_str() )
7878
("edge-threshold",
7979
value<float>()->notifier([&](float f) { config.setEdgeLimit(f); })->default_value(config.getEdgeLimit()),
80-
"On-edge threshold")
80+
popsift::Config::getEdgeThreshUsage().c_str() )
8181
("edge-limit",
8282
value<float>()->notifier([&](float f) { config.setEdgeLimit(f); }),
83-
"On-edge threshold")
83+
"synonym to --edge-threshold" )
8484
("downsampling",
8585
value<float>()->notifier([&](float f) { config.setDownsampling(f); })->default_value(config.getDownsampling()),
8686
"Downscale width and height of input by 2^N")

src/popsift/s_extrema.cu

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -482,14 +482,21 @@ __device__ inline bool find_extrema_in_dog_sub(cudaTextureObject_t dog,
482482

483483
/* accept-reject extremum */
484484
// if( fabsf(contr) < (d_consts.threshold*2.0f) )
485-
if( fabsf(contr) < scalbnf( d_consts.threshold, 1 ) )
485+
if( d_consts.threshold > 0.0f )
486486
{
487-
return false;
487+
if( fabsf(contr) < scalbnf( d_consts.threshold, 1 ) )
488+
{
489+
return false;
490+
}
488491
}
489492

490-
/* reject condition: tr(H)^2/det(H) < (r+1)^2/r */
491-
if( edgeval >= (d_consts.edge_limit+1.0f)*(d_consts.edge_limit+1.0f)/d_consts.edge_limit ) {
492-
return false;
493+
if( d_consts.edge_limit > 0.0f )
494+
{
495+
/* reject condition: tr(H)^2/det(H) < (r+1)^2/r */
496+
if( edgeval >= (d_consts.edge_limit+1.0f)*(d_consts.edge_limit+1.0f)/d_consts.edge_limit )
497+
{
498+
return false;
499+
}
493500
}
494501

495502
ec.xpos = xn;

src/popsift/sift_conf.cu

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "sift_conf.h"
1010

1111
#include <iostream>
12+
#include <sstream>
1213
#include <algorithm>
1314

1415
using namespace std;
@@ -28,8 +29,8 @@ Config::Config( )
2829
, octaves( -1 )
2930
, levels( 3 )
3031
, sigma( 1.6f )
31-
, _edge_limit( 10.0f )
32-
, _threshold( 0.04 ) // ( 10.0f / 256.0f )
32+
, _edge_limit( getEdgeThreshDefault( ) )
33+
, _threshold( getPeakThreshDefault() )
3334
, _gauss_mode( getGaussModeDefault() )
3435
, _sift_mode( Config::PopSift )
3536
, _log_mode( Config::None )
@@ -285,9 +286,38 @@ float Config::getSigma( ) const { return sigma; }
285286

286287
void Config::setEdgeLimit( float v ) { _edge_limit = v; }
287288
float Config::getEdgeLimit( ) const { return _edge_limit; }
289+
float Config::getEdgeThreshDefault( )
290+
{
291+
return 10.0f;
292+
}
293+
std::string Config::getEdgeThreshUsage( )
294+
{
295+
std::ostringstream ostr;
296+
ostr << "Edge Threshold: eliminates peaks of the DoG scale space whose curvature is too small." << endl
297+
<< "Default: " << getEdgeThreshDefault() << endl
298+
<< "Set to a value <= 0 to disable." << endl;
299+
return ostr.str();
300+
}
288301

289302
void Config::setThreshold( float v ) { _threshold = v; }
290303
float Config::getThreshold( ) const { return _threshold; }
304+
float Config::getPeakThreshold() const
305+
{
306+
return ( _threshold * 0.5f * 255.0f / levels );
307+
}
308+
float Config::getPeakThreshDefault( )
309+
{
310+
return 0.04f; // ( 10.0f / 256.0f )
311+
}
312+
std::string Config::getPeakThreshUsage( )
313+
{
314+
std::ostringstream ostr;
315+
ostr << "Peak Threshold: eliminates peaks of the DoG scale space that are too small" <<endl
316+
<< "(contrast too small in absolute value)." << endl
317+
<< "Default: " << getPeakThreshDefault() << endl
318+
<< "Set to a value <= 0 to disable." << endl;
319+
return ostr.str();
320+
}
291321

292322
void Config::setPrintGaussTables() { _print_gauss_tables = true; }
293323
void Config::setFilterMaxExtrema( int ext ) { _filter_max_extrema = ext; }
@@ -323,11 +353,6 @@ Config::SiftMode Config::getSiftMode() const
323353
return _sift_mode;
324354
}
325355

326-
float Config::getPeakThreshold() const
327-
{
328-
return ( _threshold * 0.5f * 255.0f / levels );
329-
}
330-
331356
bool Config::ifPrintGaussTables() const
332357
{
333358
return _print_gauss_tables;

src/popsift/sift_conf.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,25 @@ struct Config
215215
void setSigma( float v );
216216
float getSigma( ) const;
217217

218-
void setEdgeLimit( float v );
219-
float getEdgeLimit( ) const;
218+
/** Set the Edge threshold, which requires a minimum curviness in the
219+
* the extremum. Set to a value <= 0 to ignore.
220+
*/
221+
void setEdgeLimit( float v );
222+
float getEdgeLimit( ) const;
223+
static std::string getEdgeThreshUsage( );
224+
static float getEdgeThreshDefault( );
220225

226+
/** Set the Peak threshold, which requires a minimum difference between
227+
* a peak and its surrounding pixels. Set to a value <= 0 to ignore.
228+
*/
221229
void setThreshold( float v );
222230
float getThreshold( ) const;
231+
/** computes the actual peak threshold depending on the threshold
232+
* parameter and the non-augmented number of levels
233+
*/
234+
float getPeakThreshold() const;
235+
static std::string getPeakThreshUsage( );
236+
static float getPeakThreshDefault( );
223237

224238
void setInitialBlur( float blur );
225239
bool hasInitialBlur( ) const;
@@ -233,10 +247,6 @@ struct Config
233247
void setFilterSorting( const std::string& direction );
234248
void setFilterSorting( GridFilterMode m );
235249

236-
/// computes the actual peak threshold depending on the threshold
237-
/// parameter and the non-augmented number of levels
238-
float getPeakThreshold() const;
239-
240250
/// print Gauss spans and tables?
241251
bool ifPrintGaussTables() const;
242252

0 commit comments

Comments
 (0)