38 namespace algorithms {
40 template <
typename ImageT>
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;
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);
58 double const extreme = (fabs(min) > max) ? min :max;
72 if (i > 0 && _border > 0) {
73 int const height = eImage->getHeight();
74 int const width = eImage->getWidth();
76 if (2*_border >= std::min(height, width)) {
78 background = afw::math::makeStatistics(*afw::image::GetImage<ImageT>::getImage(eImage),
79 afw::math::MEDIAN).getValue();
84 std::shared_ptr<typename afw::image::GetImage<ImageT>::type> eImageIm =
85 afw::image::GetImage<ImageT>::getImage(eImage);
87 int const nEdge = width*height - (width - 2*_border)*(height - 2*_border);
88 std::vector<double> edgePixels(nEdge);
90 std::vector<double>::iterator bi = edgePixels.begin();
92 typedef typename afw::image::GetImage<ImageT>::type::x_iterator imIter;
94 for (; y != _border; ++y) {
95 for (imIter ptr = eImageIm->row_begin(y),
96 end = eImageIm->row_end(y); ptr != end; ++ptr, ++bi) {
100 for (; y != height - _border; ++y) {
101 for (imIter ptr = eImageIm->row_begin(y),
102 end = eImageIm->x_at(_border, y); ptr != end; ++ptr, ++bi) {
105 for (imIter ptr = eImageIm->x_at(width - _border, y),
106 end = eImageIm->row_end(y); ptr != end; ++ptr, ++bi) {
110 for (; y != height; ++y) {
111 for (imIter ptr = eImageIm->row_begin(y),
112 end = eImageIm->row_end(y); ptr != end; ++ptr, ++bi) {
116 assert(std::distance(edgePixels.begin(), bi) == nEdge);
118 background = afw::math::makeStatistics(edgePixels, afw::math::MEDIAN).getValue();
120 *eImage -= background;
125 #define INSTANTIATE_IMAGE(IMAGE) \
126 template class PsfImagePca<IMAGE >;
128 #define INSTANTIATE(TYPE) \
129 INSTANTIATE_IMAGE(afw::image::Image<TYPE>); \
130 INSTANTIATE_IMAGE(afw::image::MaskedImage<TYPE>);
#define INSTANTIATE(TYPE)
virtual void analyze()
Generate eigenimages that are normalised and background-subtracted.
Class for doing PCA on PSF stars.