LSST Applications g00d0e8bbd7+edbf708997,g03191d30f7+9ce8016dbd,g1955dfad08+0bd186d245,g199a45376c+5137f08352,g1fd858c14a+a888a50aa2,g262e1987ae+45f9aba685,g29ae962dfc+1c7d47a24f,g2cef7863aa+73c82f25e4,g35bb328faa+edbf708997,g3fd5ace14f+eed17d2c67,g47891489e3+6dc8069a4c,g53246c7159+edbf708997,g64539dfbff+c4107e45b5,g67b6fd64d1+6dc8069a4c,g74acd417e5+f452e9c21a,g786e29fd12+af89c03590,g7ae74a0b1c+a25e60b391,g7aefaa3e3d+2025e9ce17,g7cc15d900a+2d158402f9,g87389fa792+a4172ec7da,g89139ef638+6dc8069a4c,g8d4809ba88+c4107e45b5,g8d7436a09f+e96c132b44,g8ea07a8fe4+db21c37724,g98df359435+aae6d409c1,ga2180abaac+edbf708997,gac66b60396+966efe6077,gb632fb1845+88945a90f8,gbaa8f7a6c5+38b34f4976,gbf99507273+edbf708997,gca7fc764a6+6dc8069a4c,gd7ef33dd92+6dc8069a4c,gda68eeecaf+7d1e613a8d,gdab6d2f7ff+f452e9c21a,gdbb4c4dda9+c4107e45b5,ge410e46f29+6dc8069a4c,ge41e95a9f2+c4107e45b5,geaed405ab2+e194be0d2b,w.2025.47
LSST Data Management Base Package
Loading...
Searching...
No Matches
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

template<typename PixelT>
typedef lsst::afw::image::MaskedImage<PixelT>::x_iterator lsst::ip::diffim::ImageStatistics< PixelT >::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");
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 } ;
#define LOGL_DEBUG(logger, message...)
Log a debug-level message using a varargs/printf style interface.
Definition Log.h:515
Class to calculate difference image statistics.

◆ ~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 }
void apply(lsst::afw::image::MaskedImage< PixelT > const &image)

◆ 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 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition Exception.h:48
lsst::afw::image::MaskedImage< PixelT >::x_iterator x_iterator
T max(T... args)
T min(T... args)

◆ 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 }
T quiet_NaN(T... args)

◆ 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: