LSST Applications g02d81e74bb+86cf3d8bc9,g180d380827+7a4e862ed4,g2079a07aa2+86d27d4dc4,g2305ad1205+e1ca1c66fa,g29320951ab+012e1474a1,g295015adf3+341ea1ce94,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g33d1c0ed96+0e5473021a,g3a166c0a6a+0e5473021a,g3ddfee87b4+c429d67c83,g48712c4677+f88676dd22,g487adcacf7+27e1e21933,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+b41db86c35,g5a732f18d5+53520f316c,g64a986408d+86cf3d8bc9,g858d7b2824+86cf3d8bc9,g8a8a8dda67+585e252eca,g99cad8db69+84912a7fdc,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+a2b54eae19,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+6681f309db,gc120e1dc64+f0fcc2f6d8,gc28159a63d+0e5473021a,gcf0d15dbbd+c429d67c83,gdaeeff99f8+f9a426f77a,ge6526c86ff+0433e6603d,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gff1a9f87cc+86cf3d8bc9,w.2024.17
LSST Data Management Base Package
Loading...
Searching...
No Matches
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.
 
virtual void analyze ()
 Generate eigenimages that are normalised.
 
void addImage (std::shared_ptr< ImageT > img, double flux=0.0)
 Add an image to the set to be analyzed.
 
ImageList getImageList () const
 Return the list of images being analyzed.
 
lsst::geom::Extent2I const getDimensions () const
 Return the dimension of the images being analyzed.
 
std::shared_ptr< ImageT > getMean () const
 Return the mean of the images in ImagePca's list.
 
virtual double updateBadPixels (unsigned long mask, int const ncomp)
 Update the bad pixels (i.e.
 
std::vector< double > const & getEigenValues () const
 Return Eigen values.
 
ImageList const & getEigenImages () const
 Return Eigen images.
 

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)
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 {
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) {
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
A class to evaluate image statistics.
Definition Statistics.h:222
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:361
@ MIN
estimate sample minimum
Definition Statistics.h:66
@ MAX
estimate sample maximum
Definition Statistics.h:67

◆ 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 ( ) const
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 ( ) const
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:95
T begin(T... args)
T end(T... args)
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 385 of file ImagePca.cc.

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

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