LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
lsst.afw.detection::Threshold Class Reference

A Threshold is used to pass a threshold value to detection algorithms. More...

#include <Threshold.h>

Public Types

enum  ThresholdType {
  VALUE, BITMASK, STDEV, VARIANCE,
  PIXEL_STDEV
}
 Types of threshold: More...
 

Public Member Functions

 Threshold (double const value, ThresholdType const type=VALUE, bool const polarity=true, double const includeMultiplier=1.0)
 
ThresholdType getType () const
 return type of threshold More...
 
double getValue (const double param=-1) const
 
template<typename ImageT >
double getValue (ImageT const &image) const
 
bool getPolarity () const
 return Threshold's polarity More...
 
void setPolarity (bool const polarity)
 set Threshold's polarity More...
 
double getIncludeMultiplier () const
 return includeMultiplier More...
 
void setIncludeMultiplier (double const includeMultiplier)
 set includeMultiplier More...
 

Static Public Member Functions

static ThresholdType parseTypeString (std::string const &typeStr)
 
static std::string getTypeString (ThresholdType const &type)
 

Private Attributes

double _value
 value of threshold, to be interpreted via _type More...
 
ThresholdType _type
 type of threshold More...
 
bool _polarity
 true for positive polarity, false for negative More...
 
double _includeMultiplier
 multiplier for threshold needed for inclusion in FootprintSet More...
 

Detailed Description

A Threshold is used to pass a threshold value to detection algorithms.

The threshold may be a simple value (type == VALUE), or in units of the image standard deviation. Alternatively you may specify that you'll provide the standard deviation (type == STDEV) or variance (type == VARIANCE)

Note that the constructor is not declared explicit, so you may pass a bare threshold, and it'll be interpreted as a VALUE.

Examples:
spatialCellExample.cc.

Definition at line 44 of file Threshold.h.

Member Enumeration Documentation

Types of threshold:

Enumerator
VALUE 

Use pixel value.

BITMASK 

Use (pixels & (given mask))

STDEV 

Use number of sigma given s.d.

VARIANCE 

Use number of sigma given variance.

PIXEL_STDEV 

Use number of sigma given per-pixel s.d.

Definition at line 47 of file Threshold.h.

47  {
48  VALUE,
49  BITMASK,
50  STDEV,
51  VARIANCE,
53  };
Use number of sigma given per-pixel s.d.
Definition: Threshold.h:52
Use (pixels &amp; (given mask))
Definition: Threshold.h:49
Use number of sigma given variance.
Definition: Threshold.h:51
Use number of sigma given s.d.
Definition: Threshold.h:50

Constructor & Destructor Documentation

lsst.afw.detection::Threshold::Threshold ( double const  value,
ThresholdType const  type = VALUE,
bool const  polarity = true,
double const  includeMultiplier = 1.0 
)
inline

Threshold constructor

Parameters
valuedesired threshold value
typeinterpretation of type
polaritysearch pixel above threshold? (useful for -ve thresholds)
includeMultiplierthreshold multiplier for inclusion in FootprintSet

Definition at line 58 of file Threshold.h.

63  : _value(value), _type(type), _polarity(polarity),
64  _includeMultiplier(includeMultiplier) {}
double _value
value of threshold, to be interpreted via _type
Definition: Threshold.h:100
ThresholdType _type
type of threshold
Definition: Threshold.h:101
bool _polarity
true for positive polarity, false for negative
Definition: Threshold.h:102
double _includeMultiplier
multiplier for threshold needed for inclusion in FootprintSet
Definition: Threshold.h:103

Member Function Documentation

double lsst.afw.detection::Threshold::getIncludeMultiplier ( ) const
inline

return includeMultiplier

Definition at line 94 of file Threshold.h.

94 { return _includeMultiplier; }
double _includeMultiplier
multiplier for threshold needed for inclusion in FootprintSet
Definition: Threshold.h:103
bool lsst.afw.detection::Threshold::getPolarity ( ) const
inline

return Threshold's polarity

Definition at line 88 of file Threshold.h.

88 { return _polarity; }
bool _polarity
true for positive polarity, false for negative
Definition: Threshold.h:102
ThresholdType lsst.afw.detection::Threshold::getType ( void  ) const
inline

return type of threshold

Definition at line 67 of file Threshold.h.

67 { return _type; }
ThresholdType _type
type of threshold
Definition: Threshold.h:101
std::string lsst.afw.detection::Threshold::getTypeString ( ThresholdType const &  type)
static

Definition at line 59 of file Threshold.cc.

59  {
60  if (type == VALUE) {
61  return "value";
62  } else if (type == STDEV) {
63  return "stdev";
64  } else if (type == VARIANCE) {
65  return "variance";
66  } else {
67  throw LSST_EXCEPT(
68  lsst::pex::exceptions::InvalidParameterError,
69  (boost::format("Unsopported Threshold type: %d") % type).str()
70  );
71  }
72 }
Use number of sigma given variance.
Definition: Threshold.h:51
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
Use number of sigma given s.d.
Definition: Threshold.h:50
double lsst.afw.detection::Threshold::getValue ( const double  param = -1) const

return value of threshold, to be interpreted via type

Parameters
paramvalue of variance/stdev if needed
Returns
value of threshold

Definition at line 79 of file Threshold.cc.

79  {
80  switch (_type) {
81  case STDEV:
82  if (param <= 0) {
83  throw LSST_EXCEPT(
84  lsst::pex::exceptions::InvalidParameterError,
85  (boost::format("St. dev. must be > 0: %g") % param).str()
86  );
87  }
88  return _value*param;
89  case VALUE:
90  case BITMASK:
91  case PIXEL_STDEV:
92  return _value;
93  case VARIANCE:
94  if (param <= 0) {
95  throw LSST_EXCEPT(
96  lsst::pex::exceptions::InvalidParameterError,
97  (boost::format("Variance must be > 0: %g") % param).str()
98  );
99  }
100  return _value*std::sqrt(param);
101  default:
102  throw LSST_EXCEPT(
103  lsst::pex::exceptions::InvalidParameterError,
104  (boost::format("Unsupported type: %d") % _type).str()
105  );
106  }
107 }
Use number of sigma given per-pixel s.d.
Definition: Threshold.h:52
double _value
value of threshold, to be interpreted via _type
Definition: Threshold.h:100
ThresholdType _type
type of threshold
Definition: Threshold.h:101
Vector param
Use (pixels &amp; (given mask))
Definition: Threshold.h:49
Use number of sigma given variance.
Definition: Threshold.h:51
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
Use number of sigma given s.d.
Definition: Threshold.h:50
template<typename ImageT >
double lsst.afw.detection::Threshold::getValue ( ImageT const &  image) const

return value of threshold by interrogating the image, if required

Parameters
imageImage to interrogate, if threshold type demands
Returns
value of threshold

Definition at line 110 of file Threshold.cc.

110  {
111  double param = -1; // Parameter for getValue()
112  if (_type == STDEV ||
113  _type == VARIANCE) {
115  double const sd = stats.getValue(math::STDEVCLIP);
116 
117  pexLogging::TTrace<3>("afw.detection", "St. Dev = %g", sd);
118 
119  if (_type == VARIANCE) {
120  param = sd*sd;
121  } else {
122  param = sd;
123  }
124  }
125  return getValue(param);
126 }
double getValue(Property const prop=NOTHING) const
Return the value of the desired property (if specified in the constructor)
Definition: Statistics.cc:1009
ThresholdType _type
type of threshold
Definition: Threshold.h:101
estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)
Definition: Statistics.h:73
Vector param
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
Use number of sigma given variance.
Definition: Threshold.h:51
double getValue(const double param=-1) const
Definition: Threshold.cc:79
Use number of sigma given s.d.
Definition: Threshold.h:50
Statistics makeStatistics(afwImage::Mask< afwImage::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl)
Specialization to handle Masks.
Definition: Statistics.cc:1082
Threshold::ThresholdType lsst.afw.detection::Threshold::parseTypeString ( std::string const &  typeStr)
static

Definition at line 40 of file Threshold.cc.

40  {
41  if (typeStr.compare("bitmask") == 0) {
42  return Threshold::BITMASK;
43  } else if (typeStr.compare("value") == 0) {
44  return Threshold::VALUE;
45  } else if (typeStr.compare("stdev") == 0) {
46  return Threshold::STDEV;
47  } else if (typeStr.compare("variance") == 0) {
48  return Threshold::VARIANCE;
49  } else if (typeStr.compare("pixel_stdev") == 0) {
51  } else {
52  throw LSST_EXCEPT(
53  lsst::pex::exceptions::InvalidParameterError,
54  (boost::format("Unsupported Threshold type: %s") % typeStr).str()
55  );
56  }
57 }
Use number of sigma given per-pixel s.d.
Definition: Threshold.h:52
Use (pixels &amp; (given mask))
Definition: Threshold.h:49
Use number of sigma given variance.
Definition: Threshold.h:51
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
Use number of sigma given s.d.
Definition: Threshold.h:50
void lsst.afw.detection::Threshold::setIncludeMultiplier ( double const  includeMultiplier)
inline

set includeMultiplier

Parameters
includeMultiplierdesired multiplier

Definition at line 96 of file Threshold.h.

97  { _includeMultiplier = includeMultiplier; }
double _includeMultiplier
multiplier for threshold needed for inclusion in FootprintSet
Definition: Threshold.h:103
void lsst.afw.detection::Threshold::setPolarity ( bool const  polarity)
inline

set Threshold's polarity

Parameters
polaritydesired polarity

Definition at line 90 of file Threshold.h.

91  { _polarity = polarity; }
bool _polarity
true for positive polarity, false for negative
Definition: Threshold.h:102

Member Data Documentation

double lsst.afw.detection::Threshold::_includeMultiplier
private

multiplier for threshold needed for inclusion in FootprintSet

Definition at line 103 of file Threshold.h.

bool lsst.afw.detection::Threshold::_polarity
private

true for positive polarity, false for negative

Definition at line 102 of file Threshold.h.

ThresholdType lsst.afw.detection::Threshold::_type
private

type of threshold

Definition at line 101 of file Threshold.h.

double lsst.afw.detection::Threshold::_value
private

value of threshold, to be interpreted via _type

Definition at line 100 of file Threshold.h.


The documentation for this class was generated from the following files: