LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Member Functions | Private Types | Private Attributes | List of all members
lsst::meas::algorithms::PsfImagePca< ImageT > Class Template Reference

#include <ImagePca.h>

Inheritance diagram for lsst::meas::algorithms::PsfImagePca< ImageT >:
lsst::afw::image::ImagePca< ImageT >

Public Member Functions

 PsfImagePca (bool constantWeight=true, int border=3)
 Ctor. More...
 
virtual void analyze ()
 
- Public Member Functions inherited from lsst::afw::image::ImagePca< ImageT >
 ImagePca (bool constantWeight=true)
 ctor More...
 
virtual ~ImagePca ()
 
void addImage (typename ImageT::Ptr img, double flux=0.0)
 
ImageList getImageList () const
 Return the list of images being analyzed. More...
 
geom::Extent2I const getDimensions () const
 Return the dimension of the images being analyzed. More...
 
ImageT::Ptr getMean () const
 
virtual double updateBadPixels (unsigned long mask, int const ncomp)
 
std::vector< double > const & getEigenValues () const
 Return Eigen values. More...
 
ImageList const & getEigenImages () const
 Return Eigen images. More...
 

Private Types

typedef afw::image::ImagePca
< ImageT > 
Super
 Base class. More...
 

Private Attributes

int const _border
 Border width for background subtraction. More...
 

Additional Inherited Members

- Public Types inherited from lsst::afw::image::ImagePca< ImageT >
typedef boost::shared_ptr< ImageT > Ptr
 
typedef boost::shared_ptr
< const ImageT > 
ConstPtr
 
typedef std::vector< typename
ImageT::Ptr > 
ImageList
 

Detailed Description

template<typename ImageT>
class lsst::meas::algorithms::PsfImagePca< ImageT >

Definition at line 46 of file ImagePca.h.

Member Typedef Documentation

template<typename ImageT>
typedef afw::image::ImagePca<ImageT> lsst::meas::algorithms::PsfImagePca< ImageT >::Super
private

Base class.

Definition at line 47 of file ImagePca.h.

Constructor & Destructor Documentation

template<typename ImageT>
lsst::meas::algorithms::PsfImagePca< ImageT >::PsfImagePca ( bool  constantWeight = true,
int  border = 3 
)
inlineexplicit

Ctor.

Definition at line 50 of file ImagePca.h.

50 : Super(constantWeight), _border(border) {}
afw::image::ImagePca< ImageT > Super
Base class.
Definition: ImagePca.h:47
int const _border
Border width for background subtraction.
Definition: ImagePca.h:58

Member Function Documentation

template<typename ImageT >
void lsst::meas::algorithms::PsfImagePca< ImageT >::analyze ( )
virtual

Generate eigenimages that are normalised and background-subtracted

The background subtraction ensures PSF variation doesn't couple with small background errors.

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

Definition at line 41 of file ImagePca.cc.

42 {
44 
45  typename Super::ImageList const &eImageList = this->getEigenImages();
46  typename Super::ImageList::const_iterator iter = eImageList.begin(), end = eImageList.end();
47  for (size_t i = 0; iter != end; ++i, ++iter) {
48  PTR(ImageT) eImage = *iter;
49 
50  /*
51  * Normalise eigenImages to have a maximum of 1.0. For n > 0 they
52  * (should) have mean == 0, so we can't use that to normalize
53  */
54  afw::math::Statistics stats = afw::math::makeStatistics(*eImage, (afw::math::MIN | afw::math::MAX));
55  double const min = stats.getValue(afw::math::MIN);
56  double const max = stats.getValue(afw::math::MAX);
57 
58  double const extreme = (fabs(min) > max) ? min :max;
59  if (extreme != 0.0) {
60  *eImage /= extreme;
61  }
62 
63  /*
64  * Estimate and subtract the mean background level from the i > 0
65  * eigen images; if we don't do that then PSF variation can get mixed
66  * with subtle variations in the background and potentially amplify
67  * them disasterously.
68  *
69  * It is not at all clear that doing this is a good idea; it'd be
70  * better to get the sky level right in the first place.
71  */
72  if (i > 0 && _border > 0) { /* not the zeroth KL component */
73  int const height = eImage->getHeight();
74  int const width = eImage->getWidth();
75  double background;
76  if (2*_border >= std::min(height, width)) {
77  // _Border consumes the entire image
78  background = afw::math::makeStatistics(*afw::image::GetImage<ImageT>::getImage(eImage),
80  } else {
81  // Use the median of the edge pixels
82 
83  // If ImageT is a MaskedImage, unpack the Image
84  typename afw::image::GetImage<ImageT>::type::Ptr eImageIm =
85  afw::image::GetImage<ImageT>::getImage(eImage);
86 
87  int const nEdge = width*height - (width - 2*_border)*(height - 2*_border);
88  std::vector<double> edgePixels(nEdge);
89 
90  std::vector<double>::iterator bi = edgePixels.begin();
91 
92  typedef typename afw::image::GetImage<ImageT>::type::x_iterator imIter;
93  int y = 0;
94  for (; y != _border; ++y) { // Bottom border of eImage
95  for (imIter ptr = eImageIm->row_begin(y),
96  end = eImageIm->row_end(y); ptr != end; ++ptr, ++bi) {
97  *bi = *ptr;
98  }
99  }
100  for (; y != height - _border; ++y) { // Left and right borders of eImage
101  for (imIter ptr = eImageIm->row_begin(y),
102  end = eImageIm->x_at(_border, y); ptr != end; ++ptr, ++bi) {
103  *bi = *ptr;
104  }
105  for (imIter ptr = eImageIm->x_at(width - _border, y),
106  end = eImageIm->row_end(y); ptr != end; ++ptr, ++bi) {
107  *bi = *ptr;
108  }
109  }
110  for (; y != height; ++y) { // Top border of eImage
111  for (imIter ptr = eImageIm->row_begin(y),
112  end = eImageIm->row_end(y); ptr != end; ++ptr, ++bi) {
113  *bi = *ptr;
114  }
115  }
116  assert(std::distance(edgePixels.begin(), bi) == nEdge);
117 
118  background = afw::math::makeStatistics(edgePixels, afw::math::MEDIAN).getValue();
119  }
120  *eImage -= background;
121  }
122  }
123 }
int y
int iter
estimate sample minimum
Definition: Statistics.h:76
#define PTR(...)
Definition: base.h:41
estimate sample maximum
Definition: Statistics.h:77
double getValue(Property const prop=NOTHING) const
Return the value of the desired property (if specified in the constructor)
Definition: Statistics.cc:1009
ImageList const & getEigenImages() const
Return Eigen images.
Definition: ImagePca.h:70
estimate sample median
Definition: Statistics.h:70
void ImageT ImageT int float saturatedPixelValue int const width
Definition: saturated.cc:44
if(width!=gim.getWidth()||height!=gim.getHeight()||x0!=gim.getX0()||y0!=gim.getY0())
Definition: saturated.cc:47
std::vector< typename ImageT::Ptr > ImageList
Definition: ImagePca.h:52
void ImageT ImageT int float saturatedPixelValue int const height
Definition: saturated.cc:44
virtual void analyze()
Definition: ImagePca.cc:135
Statistics makeStatistics(afwImage::Mask< afwImage::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl)
Specialization to handle Masks.
Definition: Statistics.cc:1082
int const _border
Border width for background subtraction.
Definition: ImagePca.h:58

Member Data Documentation

template<typename ImageT>
int const lsst::meas::algorithms::PsfImagePca< ImageT >::_border
private

Border width for background subtraction.

Definition at line 58 of file ImagePca.h.


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