LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Types | Public Member Functions | List of all members
lsst::ip::diffim::detail::KernelPca< ImageT > Class Template Reference

Overrides the analyze method of base class afwImage::ImagePca. More...

#include <KernelPca.h>

Inheritance diagram for lsst::ip::diffim::detail::KernelPca< ImageT >:
lsst::afw::image::ImagePca< ImageT >

Public Types

typedef std::shared_ptr< KernelPca< ImageT > > Ptr
 
using ImageList = std::vector< std::shared_ptr< ImageT > >
 

Public Member Functions

 KernelPca (bool constantWeight=true)
 Ctor. More...
 
virtual void analyze ()
 Generate eigenimages that are normalised. More...
 
void addImage (std::shared_ptr< ImageT > img, double flux=0.0)
 Add an image to the set to be analyzed. More...
 
ImageList getImageList () const
 Return the list of images being analyzed. More...
 
lsst::geom::Extent2I const getDimensions () const
 Return the dimension of the images being analyzed. More...
 
std::shared_ptr< ImageT > getMean () const
 Return the mean of the images in ImagePca's list. More...
 
virtual double updateBadPixels (unsigned long mask, int const ncomp)
 Update the bad pixels (i.e. More...
 
std::vector< double > const & getEigenValues () const
 Return Eigen values. More...
 
ImageList const & getEigenImages () const
 Return Eigen images. More...
 

Detailed Description

template<typename ImageT>
class lsst::ip::diffim::detail::KernelPca< ImageT >

Overrides the analyze method of base class afwImage::ImagePca.

Note
Templated on the Image types it is running on (typically [exclusively?] afwMath::Kernel::Pixel, which is double)
This override normalizes the resulting eigenImages to have peak value of 1.0.

Definition at line 24 of file KernelPca.h.

Member Typedef Documentation

◆ ImageList

template<typename ImageT >
using lsst::afw::image::ImagePca< ImageT >::ImageList = std::vector<std::shared_ptr<ImageT> >
inherited

Definition at line 47 of file ImagePca.h.

◆ Ptr

template<typename ImageT >
typedef std::shared_ptr<KernelPca<ImageT> > lsst::ip::diffim::detail::KernelPca< ImageT >::Ptr

Definition at line 27 of file KernelPca.h.

Constructor & Destructor Documentation

◆ KernelPca()

template<typename ImageT >
lsst::ip::diffim::detail::KernelPca< ImageT >::KernelPca ( bool  constantWeight = true)
inlineexplicit

Ctor.

Definition at line 33 of file KernelPca.h.

33 : Super(constantWeight) {}

Member Function Documentation

◆ addImage()

template<typename ImageT >
void lsst::afw::image::ImagePca< ImageT >::addImage ( std::shared_ptr< ImageT >  img,
double  flux = 0.0 
)
inherited

Add an image to the set to be analyzed.

Parameters
imgImage to add to set
fluxImage's flux
Exceptions
lsst::pex::exceptions::LengthErrorif all the images aren't the same size

Definition at line 64 of file ImagePca.cc.

64  {
65  if (_imageList.empty()) {
66  _dimensions = img->getDimensions();
67  } else {
68  if (getDimensions() != img->getDimensions()) {
70  (boost::format("Dimension mismatch: saw %dx%d; expected %dx%d") %
71  img->getWidth() % img->getHeight() % _dimensions.getX() % _dimensions.getY())
72  .str());
73  }
74  }
75 
76  if (flux == 0.0) {
77  throw LSST_EXCEPT(lsst::pex::exceptions::OutOfRangeError, "Flux may not be zero");
78  }
79 
80  _imageList.push_back(img);
81  _fluxList.push_back(flux);
82 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
lsst::geom::Extent2I const getDimensions() const
Return the dimension of the images being analyzed.
Definition: ImagePca.h:75
Reports attempts to exceed implementation-defined length limits for some classes.
Definition: Runtime.h:76
Reports attempts to access elements outside a valid range of indices.
Definition: Runtime.h:89
T empty(T... args)
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174
T push_back(T... args)

◆ analyze()

template<typename ImageT >
void lsst::ip::diffim::detail::KernelPca< ImageT >::analyze
virtual

Generate eigenimages that are normalised.

Reimplemented from lsst::afw::image::ImagePca< ImageT >.

Definition at line 163 of file KernelPca.cc.

164  {
165  Super::analyze();
166 
167  typename Super::ImageList const &eImageList = this->getEigenImages();
168  typename Super::ImageList::const_iterator iter = eImageList.begin(), end = eImageList.end();
169  for (size_t i = 0; iter != end; ++i, ++iter) {
170  std::shared_ptr<ImageT> eImage = *iter;
171 
172  /*
173  * Normalise eigenImages to have a maximum of 1.0. For n > 0 they
174  * (should) have mean == 0, so we can't use that to normalize
175  */
177  double const min = stats.getValue(afwMath::MIN);
178  double const max = stats.getValue(afwMath::MAX);
179 
180  double const extreme = (fabs(min) > max) ? min :max;
181  if (extreme != 0.0) {
182  *eImage /= extreme;
183  }
184  }
185  }
int min
int end
int max
ImageList const & getEigenImages() const
Return Eigen images.
Definition: ImagePca.h:100
std::vector< std::shared_ptr< ImageT > > ImageList
Definition: ImagePca.h:47
virtual void analyze()
Definition: ImagePca.cc:123
A class to evaluate image statistics.
Definition: Statistics.h:220
double getValue(Property const prop=NOTHING) const
Return the value of the desired property (if specified in the constructor)
Definition: Statistics.cc:1047
T fabs(T... args)
Statistics makeStatistics(lsst::afw::image::Image< Pixel > const &img, lsst::afw::image::Mask< image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Handle a watered-down front-end to the constructor (no variance)
Definition: Statistics.h:359
@ MIN
estimate sample minimum
Definition: Statistics.h:75
@ MAX
estimate sample maximum
Definition: Statistics.h:76

◆ getDimensions()

template<typename ImageT >
lsst::geom::Extent2I const lsst::afw::image::ImagePca< ImageT >::getDimensions ( ) const
inlineinherited

Return the dimension of the images being analyzed.

Definition at line 75 of file ImagePca.h.

75 { return _dimensions; }

◆ getEigenImages()

template<typename ImageT >
ImageList const& lsst::afw::image::ImagePca< ImageT >::getEigenImages ( ) const
inlineinherited

Return Eigen images.

Definition at line 100 of file ImagePca.h.

100 { return _eigenImages; }

◆ getEigenValues()

template<typename ImageT >
std::vector<double> const& lsst::afw::image::ImagePca< ImageT >::getEigenValues ( ) const
inlineinherited

Return Eigen values.

Definition at line 98 of file ImagePca.h.

98 { return _eigenValues; }

◆ getImageList()

template<typename ImageT >
ImagePca< ImageT >::ImageList lsst::afw::image::ImagePca< ImageT >::getImageList
inherited

Return the list of images being analyzed.

Definition at line 85 of file ImagePca.cc.

85  {
86  return _imageList;
87 }

◆ getMean()

template<typename ImageT >
std::shared_ptr< ImageT > lsst::afw::image::ImagePca< ImageT >::getMean
inherited

Return the mean of the images in ImagePca's list.

Definition at line 90 of file ImagePca.cc.

90  {
91  if (_imageList.empty()) {
92  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError, "You haven't provided any images");
93  }
94 
95  std::shared_ptr<ImageT> mean(new ImageT(getDimensions()));
96  *mean = static_cast<typename ImageT::Pixel>(0);
97 
98  for (typename ImageList::const_iterator ptr = _imageList.begin(), end = _imageList.end(); ptr != end;
99  ++ptr) {
100  *mean += **ptr;
101  }
102  *mean /= _imageList.size();
103 
104  return mean;
105 }
uint64_t * ptr
Definition: RangeSet.cc:88
T begin(T... args)
T end(T... args)
float Pixel
Typedefs to be used for pixel values.
Definition: common.h:37
T size(T... args)

◆ updateBadPixels()

template<typename ImageT >
double lsst::afw::image::ImagePca< ImageT >::updateBadPixels ( unsigned long  mask,
int const  ncomp 
)
virtualinherited

Update the bad pixels (i.e.

those for which (value & mask) != 0) based on the current PCA decomposition; if none is available, use the mean of the good pixels

Parameters
maskMask defining bad pixels
ncompNumber of components to use in estimate
Returns
the maximum change made to any pixel

N.b. the work is actually done in do_updateBadPixels as the code only makes sense and compiles when we are doing a PCA on a set of MaskedImages

Definition at line 386 of file ImagePca.cc.

386  {
387  return do_updateBadPixels<ImageT>(typename ImageT::image_category(), _imageList, _fluxList, _eigenImages,
388  mask, ncomp);
389 }
afw::table::Key< afw::table::Array< MaskPixelT > > mask

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