LSSTApplications  19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
LSSTDataManagementBasePackage
Public Types | Public Member Functions | 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 std::shared_ptr< ImageStatisticsPtr
 
typedef lsst::afw::image::MaskedImage< PixelT >::x_iterator x_iterator
 

Public Member Functions

 ImageStatistics (lsst::daf::base::PropertySet const &ps)
 
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::daf::base::PropertySet const &ps)
 

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 59 of file ImageStatistics.h.

Member Typedef Documentation

◆ Ptr

Definition at line 61 of file ImageStatistics.h.

◆ x_iterator

Definition at line 62 of file ImageStatistics.h.

Constructor & Destructor Documentation

◆ ImageStatistics()

template<typename PixelT >
lsst::ip::diffim::ImageStatistics< PixelT >::ImageStatistics ( lsst::daf::base::PropertySet const &  ps)
inline

Definition at line 64 of file ImageStatistics.h.

64  :
65  _xsum(0.), _x2sum(0.), _npix(0), _bpMask(0) {
66 
67  std::vector<std::string> detBadMaskPlanes = ps.getArray<std::string>("badMaskPlanes");
68  for (std::vector<std::string>::iterator mi = detBadMaskPlanes.begin();
69  mi != detBadMaskPlanes.end(); ++mi){
70 
71  try {
73  } catch (pexExcept::Exception& e) {
74  LOGL_DEBUG("TRACE4.ip.diffim.ImageStatistics",
75  "Cannot update bad bit mask with %s", (*mi).c_str());
76  LOGL_DEBUG("TRACE5.ip.diffim.ImageStatistics",
77  e.what());
78  }
79  }
80  } ;

◆ ~ImageStatistics()

template<typename PixelT >
virtual lsst::ip::diffim::ImageStatistics< PixelT >::~ImageStatistics ( )
inlinevirtual

Definition at line 81 of file ImageStatistics.h.

81 {} ;

Member Function Documentation

◆ apply() [1/2]

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

Definition at line 87 of file ImageStatistics.h.

87  {
88  apply(image, -1);
89  }

◆ apply() [2/2]

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

Definition at line 91 of file ImageStatistics.h.

91  {
92  reset();
93  int y0, y1, x0, x1;
94  if (core == -1) {
95  y0 = 0;
96  y1 = image.getHeight();
97  x0 = 0;
98  x1 = image.getWidth();
99  }
100  else {
101  y0 = std::max(0, image.getHeight()/2 - core);
102  y1 = std::min(image.getHeight(), image.getHeight()/2 + core + 1);
103  x0 = std::max(0, image.getWidth()/2 - core);
104  x1 = std::min(image.getWidth(), image.getWidth()/2 + core + 1);
105  }
106 
107  for (int y = y0; y != y1; ++y) {
108  for (x_iterator ptr = image.x_at(x0, y), end = image.x_at(x1, y);
109  ptr != end; ++ptr) {
110  if (!((*ptr).mask() & _bpMask)) {
111  double const ivar = 1. / (*ptr).variance();
112  if (std::isfinite(ivar)) {
113  _xsum += (*ptr).image() * sqrt(ivar);
114  _x2sum += (*ptr).image() * (*ptr).image() * ivar;
115  _npix += 1;
116  }
117  }
118  }
119  }
120  if ((!std::isfinite(_xsum)) || (!std::isfinite(_x2sum))) {
122  "Nan/Inf in ImageStatistics.apply");
123  }
124  }

◆ evaluateQuality()

template<typename PixelT >
bool lsst::ip::diffim::ImageStatistics< PixelT >::evaluateQuality ( lsst::daf::base::PropertySet const &  ps)
inline

Definition at line 146 of file ImageStatistics.h.

146  {
147  if ( fabs(getMean()) > ps.getAsDouble("maximumFootprintResidualMean") ) return false;
148  if ( getRms() > ps.getAsDouble("maximumFootprintResidualStd") ) return false;
149  return true;
150  }

◆ getBpMask()

template<typename PixelT >
lsst::afw::image::MaskPixel lsst::ip::diffim::ImageStatistics< PixelT >::getBpMask ( )
inline

Definition at line 127 of file ImageStatistics.h.

127 {return _bpMask;}

◆ getMean()

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

Definition at line 130 of file ImageStatistics.h.

130  {
131  return (_npix > 0) ? _xsum/_npix : std::numeric_limits<double>::quiet_NaN();
132  }

◆ getNpix()

template<typename PixelT >
int lsst::ip::diffim::ImageStatistics< PixelT >::getNpix ( ) const
inline

Definition at line 143 of file ImageStatistics.h.

143 { return _npix; }

◆ getRms()

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

Definition at line 139 of file ImageStatistics.h.

139  {
140  return sqrt(getVariance());
141  }

◆ getVariance()

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

Definition at line 134 of file ImageStatistics.h.

134  {
135  return (_npix > 1) ? (_x2sum/_npix - _xsum/_npix * _xsum/_npix) * _npix/(_npix-1.) :
137  }

◆ reset()

template<typename PixelT >
void lsst::ip::diffim::ImageStatistics< PixelT >::reset ( )
inline

Definition at line 84 of file ImageStatistics.h.

84 { _xsum = _x2sum = 0.; _npix = 0;}

◆ setBpMask()

template<typename PixelT >
void lsst::ip::diffim::ImageStatistics< PixelT >::setBpMask ( lsst::afw::image::MaskPixel  bpMask)
inline

Definition at line 126 of file ImageStatistics.h.

126 {_bpMask = bpMask;}

The documentation for this class was generated from the following file:
y
int y
Definition: SpanSet.cc:49
lsst::afw::image
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Definition: imageAlgorithm.dox:1
lsst::ip::diffim::ImageStatistics::getMean
double getMean() const
Definition: ImageStatistics.h:130
std::string
STL class.
lsst::ip::diffim::ImageStatistics::x_iterator
lsst::afw::image::MaskedImage< PixelT >::x_iterator x_iterator
Definition: ImageStatistics.h:62
std::fabs
T fabs(T... args)
std::numeric_limits::quiet_NaN
T quiet_NaN(T... args)
std::vector< std::string >
lsst::ip::diffim::ImageStatistics::reset
void reset()
Definition: ImageStatistics.h:84
lsst::ip::diffim::ImageStatistics::getVariance
double getVariance() const
Definition: ImageStatistics.h:134
std::sqrt
T sqrt(T... args)
end
int end
Definition: BoundedField.cc:105
lsst::afw::image::Mask::getPlaneBitMask
static MaskPixelT getPlaneBitMask(const std::vector< std::string > &names)
Return the bitmask corresponding to a vector of plane names OR'd together.
Definition: Mask.cc:379
std::isfinite
T isfinite(T... args)
ptr
uint64_t * ptr
Definition: RangeSet.cc:88
lsst::ip::diffim::ImageStatistics::apply
void apply(lsst::afw::image::MaskedImage< PixelT > const &image)
Definition: ImageStatistics.h:87
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
std::min
T min(T... args)
LOGL_DEBUG
#define LOGL_DEBUG(logger, message...)
Definition: Log.h:504
std::vector::begin
T begin(T... args)
lsst.pex::exceptions::Exception
Provides consistent interface for LSST exceptions.
Definition: Exception.h:107
lsst::ip::diffim::ImageStatistics::getRms
double getRms() const
Definition: ImageStatistics.h:139
std::vector::end
T end(T... args)
std::max
T max(T... args)
lsst.pex::exceptions::Exception::what
virtual char const * what(void) const noexcept
Return a character string summarizing this exception.
Definition: Exception.cc:99