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 | Private Attributes | List of all members
lsst::ip::diffim::ImageStatistics< PixelT > Class Template Reference

Class to calculate difference image statistics. More...

#include <ImageStatistics.h>

Public Types

typedef boost::shared_ptr
< ImageStatistics
Ptr
 
typedef
lsst::afw::image::MaskedImage
< PixelT >::x_iterator 
x_iterator
 

Public Member Functions

 ImageStatistics (lsst::pex::policy::Policy const &policy)
 
virtual ~ImageStatistics ()
 
void reset ()
 
void apply (lsst::afw::image::MaskedImage< PixelT > const &image)
 
void apply (lsst::afw::image::MaskedImage< PixelT > const &image, int core)
 
void setBpMask (lsst::afw::image::MaskPixel bpMask)
 
lsst::afw::image::MaskPixel getBpMask ()
 
double getMean () const
 
double getVariance () const
 
double getRms () const
 
int getNpix () const
 
bool evaluateQuality (lsst::pex::policy::Policy const &policy)
 

Private Attributes

double _xsum
 
double _x2sum
 
int _npix
 
lsst::afw::image::MaskPixel _bpMask
 

Detailed Description

template<typename PixelT>
class lsst::ip::diffim::ImageStatistics< PixelT >

Class to calculate difference image statistics.

Note
Find mean and unbiased variance of pixel residuals in units of sqrt(variance)

Definition at line 58 of file ImageStatistics.h.

Member Typedef Documentation

template<typename PixelT>
typedef boost::shared_ptr<ImageStatistics> lsst::ip::diffim::ImageStatistics< PixelT >::Ptr

Definition at line 60 of file ImageStatistics.h.

Definition at line 61 of file ImageStatistics.h.

Constructor & Destructor Documentation

template<typename PixelT>
lsst::ip::diffim::ImageStatistics< PixelT >::ImageStatistics ( lsst::pex::policy::Policy const &  policy)
inline

Definition at line 63 of file ImageStatistics.h.

63  :
64  _xsum(0.), _x2sum(0.), _npix(0), _bpMask(0) {
65 
66  std::vector<std::string> detBadMaskPlanes = policy.getStringArray("badMaskPlanes");
67  for (std::vector<std::string>::iterator mi = detBadMaskPlanes.begin();
68  mi != detBadMaskPlanes.end(); ++mi){
69 
70  try {
72  } catch (pexExcept::Exception& e) {
73  lsst::pex::logging::TTrace<6>("lsst.ip.diffim.ImageStatistics",
74  "Cannot update bad bit mask with %s", (*mi).c_str());
75  lsst::pex::logging::TTrace<7>("lsst.ip.diffim.ImageStatistics",
76  e.what());
77  }
78  }
79  } ;
lsst::afw::image::MaskPixel _bpMask
static MaskPixelT getPlaneBitMask(const std::vector< std::string > &names)
Return the bitmask corresponding to a vector of plane names OR&#39;d together.
Definition: Mask.cc:860
virtual char const * what(void) const
Definition: Exception.cc:112
template<typename PixelT>
virtual lsst::ip::diffim::ImageStatistics< PixelT >::~ImageStatistics ( )
inlinevirtual

Definition at line 80 of file ImageStatistics.h.

80 {} ;

Member Function Documentation

template<typename PixelT>
void lsst::ip::diffim::ImageStatistics< PixelT >::apply ( lsst::afw::image::MaskedImage< PixelT > const &  image)
inline

Definition at line 86 of file ImageStatistics.h.

86  {
87  apply(image, -1);
88  }
void apply(lsst::afw::image::MaskedImage< PixelT > const &image)
template<typename PixelT>
void lsst::ip::diffim::ImageStatistics< PixelT >::apply ( lsst::afw::image::MaskedImage< PixelT > const &  image,
int  core 
)
inline

Definition at line 90 of file ImageStatistics.h.

90  {
91  reset();
92  int y0, y1, x0, x1;
93  if (core == -1) {
94  y0 = 0;
95  y1 = image.getHeight();
96  x0 = 0;
97  x1 = image.getWidth();
98  }
99  else {
100  y0 = std::max(0, image.getHeight()/2 - core);
101  y1 = std::min(image.getHeight(), image.getHeight()/2 + core + 1);
102  x0 = std::max(0, image.getWidth()/2 - core);
103  x1 = std::min(image.getWidth(), image.getWidth()/2 + core + 1);
104  }
105 
106  for (int y = y0; y != y1; ++y) {
107  for (x_iterator ptr = image.x_at(x0, y), end = image.x_at(x1, y);
108  ptr != end; ++ptr) {
109  if (!((*ptr).mask() & _bpMask)) {
110  double const ivar = 1. / (*ptr).variance();
111  if (lsst::utils::lsst_isfinite(ivar)) {
112  _xsum += (*ptr).image() * sqrt(ivar);
113  _x2sum += (*ptr).image() * (*ptr).image() * ivar;
114  _npix += 1;
115  }
116  }
117  }
118  }
119  if ((!lsst::utils::lsst_isfinite(_xsum)) || (!lsst::utils::lsst_isfinite(_x2sum))) {
121  "Nan/Inf in ImageStatistics.apply");
122  }
123  }
int y
int getWidth() const
Return the number of columns in the image.
Definition: MaskedImage.h:901
lsst::afw::image::MaskPixel _bpMask
int const x0
Definition: saturated.cc:45
lsst::afw::image::MaskedImage< PixelT >::x_iterator x_iterator
x_iterator x_at(int x, int y) const
Return an x_iterator at the point (x, y)
Definition: MaskedImage.h:1006
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int const y0
Definition: saturated.cc:45
int getHeight() const
Return the number of rows in the image.
Definition: MaskedImage.h:903
template<typename PixelT>
bool lsst::ip::diffim::ImageStatistics< PixelT >::evaluateQuality ( lsst::pex::policy::Policy const &  policy)
inline

Definition at line 145 of file ImageStatistics.h.

145  {
146  if ( fabs(getMean()) > policy.getDouble("maximumFootprintResidualMean") ) return false;
147  if ( getRms() > policy.getDouble("maximumFootprintResidualStd") ) return false;
148  return true;
149  }
template<typename PixelT>
lsst::afw::image::MaskPixel lsst::ip::diffim::ImageStatistics< PixelT >::getBpMask ( )
inline

Definition at line 126 of file ImageStatistics.h.

126 {return _bpMask;}
lsst::afw::image::MaskPixel _bpMask
template<typename PixelT>
double lsst::ip::diffim::ImageStatistics< PixelT >::getMean ( ) const
inline

Definition at line 129 of file ImageStatistics.h.

129  {
130  return (_npix > 0) ? _xsum/_npix : std::numeric_limits<double>::quiet_NaN();
131  }
template<typename PixelT>
int lsst::ip::diffim::ImageStatistics< PixelT >::getNpix ( ) const
inline

Definition at line 142 of file ImageStatistics.h.

template<typename PixelT>
double lsst::ip::diffim::ImageStatistics< PixelT >::getRms ( ) const
inline

Definition at line 138 of file ImageStatistics.h.

138  {
139  return sqrt(getVariance());
140  }
template<typename PixelT>
double lsst::ip::diffim::ImageStatistics< PixelT >::getVariance ( ) const
inline

Definition at line 133 of file ImageStatistics.h.

133  {
134  return (_npix > 1) ? (_x2sum/_npix - _xsum/_npix * _xsum/_npix) * _npix/(_npix-1.) :
135  std::numeric_limits<double>::quiet_NaN();
136  }
template<typename PixelT>
void lsst::ip::diffim::ImageStatistics< PixelT >::reset ( )
inline
template<typename PixelT>
void lsst::ip::diffim::ImageStatistics< PixelT >::setBpMask ( lsst::afw::image::MaskPixel  bpMask)
inline

Definition at line 125 of file ImageStatistics.h.

125 {_bpMask = bpMask;}
lsst::afw::image::MaskPixel _bpMask

Member Data Documentation

template<typename PixelT>
lsst::afw::image::MaskPixel lsst::ip::diffim::ImageStatistics< PixelT >::_bpMask
private

Definition at line 155 of file ImageStatistics.h.

template<typename PixelT>
int lsst::ip::diffim::ImageStatistics< PixelT >::_npix
private

Definition at line 154 of file ImageStatistics.h.

template<typename PixelT>
double lsst::ip::diffim::ImageStatistics< PixelT >::_x2sum
private

Definition at line 153 of file ImageStatistics.h.

template<typename PixelT>
double lsst::ip::diffim::ImageStatistics< PixelT >::_xsum
private

Definition at line 152 of file ImageStatistics.h.


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