LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
LSSTDataManagementBasePackage
MaskedImage.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008, 2009, 2010 LSST Corporation.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 
30 #ifndef LSST_IMAGE_MASKEDIMAGE_H
31 #define LSST_IMAGE_MASKEDIMAGE_H
32 
33 #include <list>
34 #include <map>
35 #include <memory>
36 #include <ostream>
37 #include <string>
38 
39 #include "boost/mpl/at.hpp"
40 #include "boost/iterator/zip_iterator.hpp"
41 #include "boost/tuple/tuple.hpp" // cannot convert to std::tuple (yet) because of use with boost::gil
42 
43 #include "lsst/daf/base/Citizen.h"
46 #include "lsst/afw/image/Image.h"
47 #include "lsst/afw/image/Mask.h"
48 
49 namespace lsst {
50 namespace afw {
51 namespace image {
52  namespace detail {
54  struct MaskedImage_tag : public basic_tag { };
57 
58  std::string const fitsFile_RE = "\\.fits(\\.[fg]z)?$";
59  std::string const compressedFileNoMEF_RE = "(\\.gz)$";
61  }
62 }}}
63 
64 #include "lsst/afw/image/Pixel.h"
66 
67 namespace lsst {
68 namespace afw {
69  namespace formatters {
70  template<typename ImagePixelT, typename MaskPixelT, typename VariancePixelT> class MaskedImageFormatter;
71  }
72 
73 namespace image {
74 
76 template<typename ImagePixelT, typename MaskPixelT=lsst::afw::image::MaskPixel,
77  typename VariancePixelT=lsst::afw::image::VariancePixel>
80 public:
84  typedef typename Mask<MaskPixelT>::Ptr MaskPtr;
88  typedef std::shared_ptr<MaskedImage> Ptr;
89  typedef std::shared_ptr<const MaskedImage> ConstPtr;
92 
93  typedef lsst::afw::image::Image<VariancePixelT> Variance; // These need to be here, and in this order, as
94  typedef lsst::afw::image::Image<ImagePixelT> Image; // "typedef Image::Ptr ImagePtr;" confuses swig (it can't
95  typedef lsst::afw::image::Mask<MaskPixelT> Mask; // find ImagePtr) and we can't use Image<> after these typedefs
96 
98 
99 #if !defined(SWIG)
100  template<typename ImagePT=ImagePixelT, typename MaskPT=MaskPixelT, typename VarPT=VariancePixelT>
105  };
106 #endif
107 
108  /************************************************************************************************************/
110  template<typename, typename, typename> class MaskedImageIterator;
112  template<typename, typename, typename> class const_MaskedImageIterator;
114  template<typename, typename, typename> class MaskedImageLocator;
116  template<typename, typename, typename> class const_MaskedImageLocator;
117 
118  /************************************************************************************************************/
119 
120 #if !defined(SWIG)
125 
126  /************************************************************************************************************/
128  template<typename ImageIterator, typename MaskIterator, typename VarianceIterator,
129  template<typename> class Ref=Reference>
131  typedef boost::tuple<ImageIterator, MaskIterator, VarianceIterator> IMV_iterator_tuple;
132 
133  public:
136  typedef typename boost::zip_iterator<IMV_iterator_tuple>::reference IMV_tuple;
139  template<typename, typename, typename> friend class const_MaskedImageIterator;
141  typedef Pixel type;
142 
144  MaskedImageIteratorBase(ImageIterator const& img, MaskIterator const& msk, VarianceIterator const &var) :
145  _iter(boost::make_zip_iterator(boost::make_tuple(img, msk, var))) {
146  }
148  typename Ref<ImagePixelT>::type image() {
149  return _iter->template get<0>()[0];
150  }
151 
153  typename Ref<MaskPixelT>::type mask() {
154  return _iter->template get<1>()[0];
155  }
156 
158  typename Ref<VariancePixelT>::type variance() {
159  return _iter->template get<2>()[0];
160  }
161 
165  return _iter.get_iterator_tuple();
166  }
167 
169  void operator+=(std::ptrdiff_t delta
170  ) {
171  _iter += delta;
172  }
174  void operator-=(std::ptrdiff_t delta
175  ) {
176  _iter -= delta;
177  }
179  void operator++() { // prefix
180  ++_iter;
181  }
183  void operator++(int) { // postfix
184  _iter++;
185  }
187  std::ptrdiff_t operator-(MaskedImageIteratorBase const& rhs) {
188  return &this->_iter->template get<0>() - &rhs._iter->template get<0>();
189  }
192  return &this->_iter->template get<0>() == &rhs._iter->template get<0>();
193  }
196  return &this->_iter->template get<0>() != &rhs._iter->template get<0>();
197  }
200  return &this->_iter->template get<0>() < &rhs._iter->template get<0>();
201  }
203  operator Pixel() const {
204  return Pixel(_iter->template get<0>()[0],
205  _iter->template get<1>()[0],
206  _iter->template get<2>()[0]);
207  }
208 
211  return Pixel(image(), mask(), variance());
212  }
214  const Pixel operator*() const {
215  return Pixel(image(), mask(), variance());
216  }
217 
218  protected:
219  typename boost::zip_iterator<IMV_iterator_tuple> _iter;
220  };
221 
223  template<typename ImageIterator, typename MaskIterator, typename VarianceIterator>
224  class MaskedImageIterator :
225  public MaskedImageIteratorBase<ImageIterator, MaskIterator, VarianceIterator> {
227  public:
228  MaskedImageIterator(ImageIterator& img, MaskIterator& msk, VarianceIterator &var) :
229  MaskedImageIteratorBase_t(img, msk, var) {
230  }
232  MaskedImageIterator operator+(std::ptrdiff_t delta) {
233  MaskedImageIterator lhs = *this;
234  lhs += delta;
235 
236  return lhs;
237  }
238  };
239 
241  template<typename ImageIterator, typename MaskIterator, typename VarianceIterator>
242  class const_MaskedImageIterator :
243  public MaskedImageIteratorBase<typename detail::const_iterator_type<ImageIterator>::type,
244  typename detail::const_iterator_type<MaskIterator>::type,
245  typename detail::const_iterator_type<VarianceIterator>::type,
246  ConstReference> {
247 
248  typedef typename detail::const_iterator_type<ImageIterator>::type const_ImageIterator;
249  typedef typename detail::const_iterator_type<MaskIterator>::type const_MaskIterator;
250  typedef typename detail::const_iterator_type<VarianceIterator>::type const_VarianceIterator;
251 
254  public:
257  const_MaskIterator(iter.get_iterator_tuple().template get<1>()),
258  const_VarianceIterator(iter.get_iterator_tuple().template get<2>())
259  ) {
260  ;
261  }
263  const_MaskedImageIterator& operator+(std::ptrdiff_t delta) {
264  const_MaskedImageIterator lhs = *this;
265  lhs += delta;
266 
267  return lhs;
268  }
269  };
270 
271  /************************************************************************************************************/
273  template<typename ImageLocator, typename MaskLocator, typename VarianceLocator,
274  template<typename> class Ref=Reference>
276  typedef typename boost::tuple<ImageLocator, MaskLocator, VarianceLocator> IMVLocator;
277  //
278  // A class to provide _[xy]_iterator for MaskedImageLocator. We can't just use
279  // a zip_iterator as moving this iterator must be the same as moving the locator
280  // itself, for consistency with {Image,Mask}::xy_locator
281  //
282  template<template<typename> class X_OR_Y >
284  public:
286 
287  void operator+=(const int di) {
288  // Equivalent to "_mil->_loc.template get<0>().x() += di;"
289  X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())() += di;
290  X_OR_Y<MaskLocator>(_mil->_loc.template get<1>())() += di;
291  X_OR_Y<VarianceLocator>(_mil->_loc.template get<2>())() += di;
292  }
293 
294  void operator++() { // prefix
295  // Equivalent to "++_mil->_loc.template get<0>().x();"
296  ++X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())();
297  ++X_OR_Y<MaskLocator>(_mil->_loc.template get<1>())();
298  ++X_OR_Y<VarianceLocator>(_mil->_loc.template get<2>())();
299  }
300 
301  bool operator==(_x_or_y_iterator const& rhs) {
302  return
303  X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())() ==
304  X_OR_Y<ImageLocator>(rhs._mil->_loc.template get<0>())();
305 
306  }
307  bool operator!=(_x_or_y_iterator const& rhs) {
308  return
309  X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())() !=
310  X_OR_Y<ImageLocator>(rhs._mil->_loc.template get<0>())();
311 
312  }
313  bool operator<(_x_or_y_iterator const& rhs) {
314  return
315  X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())() <
316  X_OR_Y<ImageLocator>(rhs._mil->_loc.template get<0>())();
317 
318  }
319 
321  return Pixel((*(X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())()))[0],
322  (*(X_OR_Y<MaskLocator>(_mil->_loc.template get<1>())()))[0],
323  (*(X_OR_Y<VarianceLocator>(_mil->_loc.template get<2>())()))[0]);
324  }
325 
326  typename Ref<ImagePixelT>::type image() {
327  // Equivalent to "return (*_mil->_loc.template get<0>().x())[0];"
328 
329  return (*(X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())()))[0];
330  }
331  typename Ref<MaskPixelT>::type mask() {
332  return (*(X_OR_Y<MaskLocator>(_mil->_loc.template get<1>())()))[0];
333  }
334  typename Ref<VariancePixelT>::type variance() {
335  return (*(X_OR_Y<VarianceLocator>(_mil->_loc.template get<2>())()))[0];
336  }
337  protected:
339  };
340 
341  // Two classes to provide .x() and .y() in _x_or_y_iterator
342  template<typename LocT>
343  class apply_x {
344  typedef typename LocT::x_iterator IterT;
345  public:
346  apply_x(LocT &loc) : _loc(loc) { }
347  IterT& operator()() { return _loc.x(); }
348  private:
349  LocT& _loc;
350  };
351 
352  template<typename LocT>
353  class apply_y {
354  typedef typename LocT::y_iterator IterT;
355  public:
356  apply_y(LocT &loc) : _loc(loc) { }
357  IterT& operator()() { return _loc.y(); }
358  private:
359  LocT& _loc;
360  };
361 
362  public:
363  typedef typename boost::tuple<typename ImageLocator::cached_location_t,
364  typename MaskLocator::cached_location_t,
365  typename VarianceLocator::cached_location_t> IMVCachedLocation;
367  typedef _x_or_y_iterator<apply_x> x_iterator;
369  typedef _x_or_y_iterator<apply_y> y_iterator;
372  public:
373  //template<typename, typename, typename, template<typename> class> friend class MaskedImageLocatorBase;
374  template<typename, typename, typename> friend class const_MaskedImageLocator;
375 
377  cached_location_t(IMVLocator const& loc, int x, int y) :
378  _imv(loc.template get<0>().cache_location(x, y),
379  loc.template get<1>().cache_location(x, y),
380  loc.template get<2>().cache_location(x, y)) {
381  ;
382  }
383  //protected:
385  };
387  MaskedImageLocatorBase(ImageLocator const& img, MaskLocator const& msk, VarianceLocator const& var) :
388  _loc(img, msk, var) {
389  ;
390  }
391 
394  return Pixel(_loc.template get<0>().x()[0][0],
395  _loc.template get<1>().x()[0][0],
396  _loc.template get<2>().x()[0][0]);
397  }
398 
400  Pixel operator()(int x, int y) {
401  return Pixel(_loc.template get<0>()(x, y)[0],
402  _loc.template get<1>()(x, y)[0],
403  _loc.template get<2>()(x, y)[0]);
404  }
405 
407  Pixel operator[](cached_location_t const& cached_loc) {
408  return Pixel(_loc.template get<0>()[cached_loc._imv.template get<0>()][0],
409  _loc.template get<1>()[cached_loc._imv.template get<1>()][0],
410  _loc.template get<2>()[cached_loc._imv.template get<2>()][0]);
411  }
416  return x_iterator(this);
417  }
418 
423  return y_iterator(this);
424  }
425 
427  cached_location_t cache_location(int x, int y) const {
428  return cached_location_t(_loc, x, y);
429  }
430  //
431  // We don't want to duplicate code for image/mask/variance -- but the boost::mpl stuff isn't pretty
432  // as we can't say int_<N> within a template<int N>. So define a set of functions apply_IMV
433  // to do the dirty work
434  //
435  typedef typename boost::mpl::vector<ImagePixelT, MaskPixelT, VariancePixelT> PixelTVec;
436 
437  template<typename N>
438  typename Ref<typename boost::mpl::at<PixelTVec, N>::type>::type apply_IMV(cached_location_t const& cached_loc) {
439  return _loc.template get<N::value>()[cached_loc._imv.template get<N::value>()][0];
440  }
441 
442  template<typename N>
443  typename Ref<typename boost::mpl::at<PixelTVec, N>::type>::type apply_IMV() {
444  return _loc.template get<N::value>()[0][0];
445  }
446 
447  template<typename N>
448  typename Ref<typename boost::mpl::at<PixelTVec, N>::type>::type apply_IMV(int x, int y) {
449  return _loc.template get<N::value>()(x, y)[0];
450  }
451  //
452  // Use those templated classes to implement image/mask/variance
453  //
455  typename Ref<ImagePixelT>::type image(cached_location_t const& cached_loc) {
456  return apply_IMV<boost::mpl::int_<0> >(cached_loc);
457  }
459  typename Ref<ImagePixelT>::type image() {
460  return apply_IMV<boost::mpl::int_<0> >();
461  }
463  typename Ref<ImagePixelT>::type image(int x, int y) {
464  return apply_IMV<boost::mpl::int_<0> >(x, y);
465  }
466 
468  typename Ref<MaskPixelT>::type mask(cached_location_t const& cached_loc) {
469  return apply_IMV<boost::mpl::int_<1> >(cached_loc);
470  }
472  typename Ref<MaskPixelT>::type mask() {
473  return apply_IMV<boost::mpl::int_<1> >();
474  }
476  typename Ref<MaskPixelT>::type mask(int x, int y) {
477  return apply_IMV<boost::mpl::int_<1> >(x, y);
478  }
479 
481  typename Ref<VariancePixelT>::type variance(cached_location_t const& cached_loc) {
482  return apply_IMV<boost::mpl::int_<2> >(cached_loc);
483  }
485  typename Ref<VariancePixelT>::type variance() {
486  return apply_IMV<boost::mpl::int_<2> >();
487  }
489  typename Ref<VariancePixelT>::type variance(int x, int y) {
490  return apply_IMV<boost::mpl::int_<2> >(x, y);
491  }
492 
495  return _loc.template get<0>() == rhs._loc.template get<0>();
496  }
499  return !(*this == rhs);
500  }
503  return _loc.template get<0>() < rhs._loc.template get<0>();
504  }
505 
507  MaskedImageLocatorBase& operator+=(pair2I const& p) {
508  return operator+=(detail::difference_type(p.first, p.second));
509  }
510 
512  MaskedImageLocatorBase& operator+=(detail::difference_type p) {
513  _loc.template get<0>() += p;
514  _loc.template get<1>() += p;
515  _loc.template get<2>() += p;
516 
517  return *this;
518  }
519 
520  // Workaround for DM-5590: clang-3.8 cannot access _loc from
521  // friend class const_MaskedImageLocator.
522  IMVLocator const & getLoc() const { return _loc; }
523 
524  protected:
526  };
527 
529  template<typename ImageLocator, typename MaskLocator, typename VarianceLocator>
530  class MaskedImageLocator :
531  public MaskedImageLocatorBase<ImageLocator, MaskLocator, VarianceLocator> {
533  public:
534  MaskedImageLocator(ImageLocator& img, MaskLocator& msk, VarianceLocator &var) :
535  MaskedImageLocatorBase_t(img, msk, var) {
536  }
537  };
538 
540  template<typename ImageLocator, typename MaskLocator, typename VarianceLocator>
541  class const_MaskedImageLocator :
542  public MaskedImageLocatorBase<typename detail::const_locator_type<ImageLocator>::type,
543  typename detail::const_locator_type<MaskLocator>::type,
544  typename detail::const_locator_type<VarianceLocator>::type,
545  ConstReference> {
546 
547  typedef typename detail::const_locator_type<ImageLocator>::type const_ImageLocator;
548  typedef typename detail::const_locator_type<MaskLocator>::type const_MaskLocator;
549  typedef typename detail::const_locator_type<VarianceLocator>::type const_VarianceLocator;
550 
553  public:
555  MaskedImageLocatorBase_t(const_ImageLocator(iter.getLoc().template get<0>()),
556  const_MaskLocator(iter.getLoc().template get<1>()),
557  const_VarianceLocator(iter.getLoc().template get<2>())
558  ) {
559  ;
560  }
561  };
562 
563 #endif // !defined(SWIG)
564 
565 /************************************************************************************************************/
566  // An iterator to a MaskedImage
567  typedef MaskedImageIterator<typename Image::iterator,
569  // A const_iterator to a MaskedImage
570  typedef const_MaskedImageIterator<typename Image::iterator,
572  // A reverse_iterator to a MaskedImage
573  typedef MaskedImageIterator<typename Image::reverse_iterator,
575 #if 0 // doesn't compile. I should fix this, but it's low priority. RHL
576  typedef const_MaskedImageIterator<typename Image::reverse_iterator,
578  typename Mask::reverse_iterator, typename Variance::reverse_iterator> const_reverse_iterator;
579 #endif
580  typedef MaskedImageIterator<typename Image::x_iterator,
584  typedef const_MaskedImageIterator<typename Image::x_iterator,
590  typedef MaskedImageIterator<typename Image::y_iterator,
593  typedef const_MaskedImageIterator<typename Image::y_iterator,
595 
597  typedef MaskedImageLocator<typename Image::xy_locator,
600  typedef const_MaskedImageLocator<typename Image::xy_locator,
602 
604  typedef typename MaskedImageLocator<typename Image::xy_locator,
607  typedef typename MaskedImageLocator<typename Image::xy_locator,
609 
610  /************************************************************************************************************/
611 
612  // Constructors
613  explicit MaskedImage(
614  unsigned int width, unsigned int height,
615  MaskPlaneDict const& planeDict=MaskPlaneDict()
616  );
617  explicit MaskedImage(
619  MaskPlaneDict const& planeDict=MaskPlaneDict()
620  );
621  explicit MaskedImage(
622  ImagePtr image,
623  MaskPtr mask = MaskPtr(),
624  VariancePtr variance = VariancePtr()
625  );
626  explicit MaskedImage(
627  geom::Box2I const & bbox,
628  MaskPlaneDict const& planeDict=MaskPlaneDict()
629  );
630 
646  explicit MaskedImage(
647  std::string const & fileName,
649  geom::Box2I const & bbox=geom::Box2I(), ImageOrigin origin=PARENT,
650  bool conformMasks=false, bool needAllHdus=false,
654  );
655 
671  explicit MaskedImage(
672  fits::MemFileManager & manager,
674  geom::Box2I const & bbox=geom::Box2I(), ImageOrigin origin=PARENT,
675  bool conformMasks=false, bool needAllHdus=false,
679  );
680 
696  explicit MaskedImage(
697  fits::Fits & fitsfile,
699  geom::Box2I const & bbox=geom::Box2I(), ImageOrigin origin=PARENT,
700  bool conformMasks=false, bool needAllHdus=false,
704  );
705 
706  MaskedImage(
707  MaskedImage const& rhs,
708  bool const deep=false
709  );
710  MaskedImage(
711  MaskedImage const & rhs,
712  geom::Box2I const & bbox,
713  ImageOrigin const origin=PARENT,
714  bool const deep=false
715  );
720  template<typename OtherPixelT>
723 
724  const bool deep
725  ) :
726  lsst::daf::base::Citizen(typeid(this)), _image(), _mask(), _variance() {
727  if (!deep) {
728  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
729  "Only deep copies are permitted for MaskedImages with different pixel types");
730  }
731 
732  _image = typename Image::Ptr(new Image(*rhs.getImage(), deep));
733  _mask = typename Mask::Ptr(new Mask(*rhs.getMask(), deep));
734  _variance = typename Variance::Ptr(new Variance(*rhs.getVariance(), deep));
735  }
736 
737 #if defined(DOXYGEN)
738  MaskedImage& operator=(MaskedImage const& rhs);
739 #endif
740 
741  virtual ~MaskedImage() {}
742 
743  void swap(MaskedImage &rhs);
744 
745  // Operators
746  MaskedImage& operator=(Pixel const& rhs);
747  MaskedImage& operator=(SinglePixel const& rhs);
748 
749  void operator<<=(MaskedImage const& rhs);
750 
751  void assign(MaskedImage const &rsh, geom::Box2I const &bbox = geom::Box2I(), ImageOrigin origin=PARENT);
752 
753  void operator+=(ImagePixelT const rhs);
754  void operator+=(MaskedImage const& rhs);
756  *_image += rhs;
757  }
759  *_image += function;
760  }
761  void scaledPlus(double const c, MaskedImage const& rhs);
762 
763  void operator-=(ImagePixelT const rhs);
764  void operator-=(MaskedImage const& rhs);
766  *_image -= rhs;
767  }
769  *_image -= function;
770  }
771  void scaledMinus(double const c, MaskedImage const& rhs);
772 
773  void operator*=(ImagePixelT const rhs);
774  void operator*=(MaskedImage const& rhs);
776  *_image *= rhs;
777  *_variance *= rhs; // yes, multiply twice
778  *_variance *= rhs;
779  }
780  void scaledMultiplies(double const c, MaskedImage const& rhs);
781 
782  void operator/=(ImagePixelT const rhs);
783  void operator/=(MaskedImage const& rhs);
785  *_image /= rhs;
786  *_variance /= rhs; // yes, divide twice
787  *_variance /= rhs;
788  }
789  void scaledDivides(double const c, MaskedImage const& rhs);
790 
805  void writeFits(
806  std::string const & fileName,
811  ) const;
812 
826  void writeFits(
827  fits::MemFileManager & manager,
832  ) const;
833 
847  void writeFits(
848  fits::Fits & fitsfile,
853  ) const;
854 
860  static MaskedImage readFits(std::string const & filename) {
862  }
863 
871  }
872 
873  // Getters
875  ImagePtr getImage(bool const noThrow=false) const {
876  if (!_image && !noThrow) {
877  throw LSST_EXCEPT(
878  lsst::pex::exceptions::RuntimeError,
879  "MaskedImage's Image is NULL"
880  );
881  }
882  return _image;
883  }
885  MaskPtr getMask(bool const noThrow=false) const {
886  if (!_mask && !noThrow) {
887  throw LSST_EXCEPT(
888  lsst::pex::exceptions::RuntimeError,
889  "MaskedImage's Mask is NULL"
890  );
891  }
892 
893  return _mask;
894  }
896  VariancePtr getVariance(bool const noThrow=false) const {
897  if (!_variance && !noThrow) {
898  throw LSST_EXCEPT(
899  lsst::pex::exceptions::RuntimeError,
900  "MaskedImage's Variance is NULL"
901  );
902  }
903 
904  return _variance;
905  }
907  int getWidth() const { return _image->getWidth(); }
909  int getHeight() const { return _image->getHeight(); }
910  geom::Extent2I getDimensions() const {return _image->getDimensions();}
911  geom::Box2I getBBox(ImageOrigin const origin=PARENT) const {return _image->getBBox(origin);}
919  int getX0() const { return _image->getX0(); }
927  int getY0() const { return _image->getY0(); }
935  geom::Point2I getXY0() const { return _image->getXY0(); }
936 
945  void setXY0(int const x0, int const y0) {
946  setXY0(geom::Point2I(x0,y0));
947  }
948 
957  void setXY0(geom::Point2I const origin) {
958  if (_image) {
959  _image->setXY0(origin);
960  }
961 
962  if (_mask) {
963  _mask->setXY0(origin);
964  }
965 
966  if (_variance) {
967  _variance->setXY0(origin);
968  }
969  }
970 
971 
977  inline double indexToPosition(
978  double ind,
979  lsst::afw::image::xOrY const xy
980  ) const {
981  return getImage()->indexToPosition(ind, xy);
982  }
983 
989  std::pair<int, double> positionToIndex(
990  double const pos,
991  lsst::afw::image::xOrY const xy
992  ) const {
993  return getImage()->positionToIndex(pos, xy);
994  }
995 
996  //
997  // Iterators and Locators
998  //
999  iterator begin() const;
1000  iterator end() const;
1001  iterator at(int const x, int const y) const;
1002  reverse_iterator rbegin() const;
1003  reverse_iterator rend() const;
1004 
1005  fast_iterator begin(bool) const;
1006  fast_iterator end(bool) const;
1007 
1008  x_iterator row_begin(int y) const;
1009  x_iterator row_end(int y) const;
1010 
1012  x_iterator x_at(int x, int y) const {
1013 #if 0
1014  typename Image::x_iterator imageEnd = getImage()->x_at(x, y);
1015  typename Mask::x_iterator maskEnd = getMask()->x_at(x, y);
1016  typename Variance::x_iterator varianceEnd = getVariance()->x_at(x, y);
1017 #else // bypass checks for non-NULL pointers
1018  typename Image::x_iterator imageEnd = _image->x_at(x, y);
1019  typename Mask::x_iterator maskEnd = _mask->x_at(x, y);
1020  typename Variance::x_iterator varianceEnd = _variance->x_at(x, y);
1021 #endif
1022 
1023  return x_iterator(imageEnd, maskEnd, varianceEnd);
1024  }
1025 
1026  y_iterator col_begin(int x) const;
1027  y_iterator col_end(int x) const;
1028 
1030  y_iterator y_at(int x, int y) const {
1031 #if 0
1032  typename Image::y_iterator imageEnd = getImage()->y_at(x, y);
1033  typename Mask::y_iterator maskEnd = getMask()->y_at(x, y);
1034  typename Variance::y_iterator varianceEnd = getVariance()->y_at(x, y);
1035 #else // bypass checks for non-NULL pointers
1036  typename Image::y_iterator imageEnd = _image->y_at(x, y);
1037  typename Mask::y_iterator maskEnd = _mask->y_at(x, y);
1038  typename Variance::y_iterator varianceEnd = _variance->y_at(x, y);
1039 #endif
1040  return y_iterator(imageEnd, maskEnd, varianceEnd);
1041  }
1042 
1043 
1045  xy_locator xy_at(int x, int y) const {
1046 #if 0
1047  typename Image::xy_locator imageEnd = getImage()->xy_at(x, y);
1048  typename Mask::xy_locator maskEnd = getMask()->xy_at(x, y);
1049  typename Variance::xy_locator varianceEnd = getVariance()->xy_at(x, y);
1050 #else // bypass checks for non-NULL pointers
1051  typename Image::xy_locator imageEnd = _image->xy_at(x, y);
1052  typename Mask::xy_locator maskEnd = _mask->xy_at(x, y);
1053  typename Variance::xy_locator varianceEnd = _variance->xy_at(x, y);
1054 #endif
1055 
1056  return xy_locator(imageEnd, maskEnd, varianceEnd);
1057  }
1058 
1059 private:
1060 
1062  void conformSizes();
1063 
1067 };
1068 
1072 template<typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
1073 MaskedImage<ImagePixelT, MaskPixelT, VariancePixelT>* makeMaskedImage(
1074  typename Image<ImagePixelT>::Ptr image,
1075  typename Mask<MaskPixelT>::Ptr mask = typename Mask<MaskPixelT>::Ptr(),
1076  typename Image<VariancePixelT>::Ptr variance = typename Image<VariancePixelT>::Ptr()
1077  ) {
1078  return new MaskedImage<ImagePixelT, MaskPixelT, VariancePixelT>(image, mask, variance);
1079 }
1080 
1081 /*
1082  * Some metafunctions to extract an Image::Ptr from a MaskedImage::Ptr (or return the original Image::Ptr)
1083  *
1084  * GetImage is the public interface (it forwards the tag --- just for the sake of the UI); the real work
1085  * is in GetImage_ which defines a typedef for the Image and a static function, getImage
1086  *
1087  * E.g.
1088  * In the function
1089  *
1090  * template<typename ImageT>
1091  * void func(typename ImageT::Ptr image) {
1092  * typename GetImage<ImageT>::type::Ptr im = GetImage<ImageT>::getImage(image);
1093  * }
1094  *
1095  * "im" is an Image::Ptr irrespective of whether ImageT is Masked or not.
1096  */
1097 namespace {
1098 template<typename ImageT, typename TagT>
1099 struct GetImage_ {
1100  typedef ImageT type;
1101  static typename type::Ptr getImage(typename ImageT::Ptr image) {
1102  return image;
1103  }
1104 };
1105 
1106 template<typename ImageT>
1107 struct GetImage_<ImageT, typename image::detail::MaskedImage_tag> {
1108  typedef typename ImageT::Image type;
1109  static typename type::Ptr getImage(typename ImageT::Ptr image) {
1110  return image->getImage();
1111  }
1112 };
1113 } // anonymous namespace
1114 
1115 template<typename ImageT>
1116 struct GetImage : public GetImage_<ImageT, typename ImageT::image_category> {
1117 };
1118 
1119 }}} // lsst::afw::image
1120 
1121 #endif // LSST_IMAGE_MASKEDIMAGE_H
int y
int iter
x_iterator row_begin(int y) const
Return an x_iterator to the start of the image.
Definition: MaskedImage.cc:757
MaskedImageLocatorBase & operator+=(detail::difference_type p)
Increment the locator&#39;s x and y positions by p.
Definition: MaskedImage.h:512
std::uint16_t MaskPixel
Ref< ImagePixelT >::type image(int x, int y)
Return a reference to the image offset by (x, y) from the current position of the locator...
Definition: MaskedImage.h:463
Image< VariancePixelT >::Ptr VariancePtr
shared pointer to the variance Image
Definition: MaskedImage.h:86
Ref< ImagePixelT >::type image(cached_location_t const &cached_loc)
Return a reference to the image at the offset set when we created the cached_location_t.
Definition: MaskedImage.h:455
void scaledDivides(double const c, MaskedImage const &rhs)
Definition: MaskedImage.cc:556
Ref< MaskPixelT >::type mask()
Return (a reference to) the mask part of the Pixel pointed at by the iterator.
Definition: MaskedImage.h:153
MaskedImageIterator(ImageIterator &img, MaskIterator &msk, VarianceIterator &var)
Definition: MaskedImage.h:228
Ref< MaskPixelT >::type mask()
Return a reference to the mask at the current position of the locator.
Definition: MaskedImage.h:472
const_MaskedImageLocator< typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator > const_xy_locator
A const_locator for a MaskedImage.
Definition: MaskedImage.h:601
detail::const_iterator_type< ImageIterator >::type const_ImageIterator
Definition: MaskedImage.h:248
y_iterator y()
Return an iterator that can be used to move (or dereference) a locator.
Definition: MaskedImage.h:422
#define LSST_PERSIST_FORMATTER(formatter...)
Macro used to connect the persistable class with the Formatter and boost::serialization.
Definition: Persistable.h:98
MaskedImageIteratorBase(ImageIterator const &img, MaskIterator const &msk, VarianceIterator const &var)
Construct a MaskedImageIteratorBase from the image/mask/variance iterators.
Definition: MaskedImage.h:144
The base class for MaskedImageLocators (const and non-const)
Definition: MaskedImage.h:275
void operator-=(lsst::afw::math::Function2< double > const &function)
Definition: MaskedImage.h:768
MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > * makeMaskedImage(typename Image< ImagePixelT >::Ptr image, typename Mask< MaskPixelT >::Ptr mask=typename Mask< MaskPixelT >::Ptr(), typename Image< VariancePixelT >::Ptr variance=typename Image< VariancePixelT >::Ptr())
A function to return a MaskedImage of the correct type (cf.
Definition: MaskedImage.h:1073
boost::tuple< ImageLocator, MaskLocator, VarianceLocator > IMVLocator
Definition: MaskedImage.h:276
Citizen(const std::type_info &)
Definition: Citizen.cc:174
Ref< typename boost::mpl::at< PixelTVec, N >::type >::type apply_IMV(int x, int y)
Definition: MaskedImage.h:448
boost::mpl::vector< ImagePixelT, MaskPixelT, VariancePixelT > PixelTVec
Definition: MaskedImage.h:435
_view_t::reverse_iterator reverse_iterator
An STL compliant reverse iterator.
Definition: Image.h:146
const_MaskedImageIterator< typename Image::iterator, typename Mask::iterator, typename Variance::iterator > const_iterator
Definition: MaskedImage.h:571
boost::zip_iterator< IMV_iterator_tuple > _iter
Definition: MaskedImage.h:219
Pixel type
Type pointed to by the iterator.
Definition: MaskedImage.h:141
A templated class to return this classes&#39; type (present in Image/Mask/MaskedImage) ...
Definition: MaskedImage.h:102
Pixel operator()(int x, int y)
Dereference a locator, returning a Pixel offset by (x, y) from the locator.
Definition: MaskedImage.h:400
iterator begin() const
Return an iterator to the start of the image.
Definition: MaskedImage.cc:703
lsst::afw::image::pixel::Pixel< ImagePixelT, MaskPixelT, VariancePixelT > Pixel
A Pixel in the MaskedImage.
Definition: MaskedImage.h:116
x_iterator fast_iterator
A fast STL compliant iterator for contiguous images N.b.
Definition: MaskedImage.h:588
void operator<<=(MaskedImage const &rhs)
Copy the pixels from the rhs to the lhs.
Definition: MaskedImage.cc:375
detail::const_locator_type< MaskLocator >::type const_MaskLocator
Definition: MaskedImage.h:548
void operator/=(ImagePixelT const rhs)
Definition: MaskedImage.cc:571
boost::tuple< typename ImageLocator::cached_location_t, typename MaskLocator::cached_location_t, typename VarianceLocator::cached_location_t > IMVCachedLocation
Definition: MaskedImage.h:365
int getHeight() const
Return the number of rows in the image.
Definition: MaskedImage.h:909
int getX0() const
Return the image&#39;s column-origin.
Definition: MaskedImage.h:919
void scaledPlus(double const c, MaskedImage const &rhs)
Add a scaled MaskedImage c*rhs to a MaskedImage.
Definition: MaskedImage.cc:420
Pixel operator*()
Dereference a locator, returning a Pixel.
Definition: MaskedImage.h:393
void writeFits(std::string const &fileName, boost::shared_ptr< daf::base::PropertySet const > metadata=boost::shared_ptr< daf::base::PropertySet const >(), boost::shared_ptr< daf::base::PropertySet const > imageMetadata=boost::shared_ptr< daf::base::PropertySet const >(), boost::shared_ptr< daf::base::PropertySet const > maskMetadata=boost::shared_ptr< daf::base::PropertySet const >(), boost::shared_ptr< daf::base::PropertySet const > varianceMetadata=boost::shared_ptr< daf::base::PropertySet const >()) const
Write a MaskedImage to a regular FITS file.
Definition: MaskedImage.cc:577
iterator at(int const x, int const y) const
Return an iterator at the point (x, y)
Definition: MaskedImage.cc:727
detail::const_iterator_type< VarianceIterator >::type const_VarianceIterator
Definition: MaskedImage.h:250
Ref< VariancePixelT >::type variance(int x, int y)
Return a reference to the variance offset by (x, y) from the current position of the locator...
Definition: MaskedImage.h:489
bool operator==(MaskedImageIteratorBase const &rhs)
Return true if the lhs equals the rhs.
Definition: MaskedImage.h:191
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
Definition: Image.h:150
Pixel operator[](cached_location_t const &cached_loc)
Dereference a locator, returning a Pixel offset by the amount set when we created the cached_location...
Definition: MaskedImage.h:407
x_iterator row_end(int y) const
Return an x_iterator to the end of the image.
Definition: MaskedImage.cc:767
MaskedImageLocatorBase< ImageLocator, MaskLocator, VarianceLocator > MaskedImageLocatorBase_t
Definition: MaskedImage.h:532
Ref< typename boost::mpl::at< PixelTVec, N >::type >::type apply_IMV(cached_location_t const &cached_loc)
Definition: MaskedImage.h:438
The base class for MaskedImageIterators (const and non-const)
Definition: MaskedImage.h:130
detail::const_iterator_type< MaskIterator >::type const_MaskIterator
Definition: MaskedImage.h:249
geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: MaskedImage.h:911
detail::MaskPlaneDict MaskPlaneDict
Definition: Mask.h:96
void operator+=(lsst::afw::math::Function2< double > const &function)
Definition: MaskedImage.h:758
MaskedImageIterator< typename Image::x_iterator, typename Mask::x_iterator, typename Variance::x_iterator > x_iterator
An iterator to a row of a MaskedImage.
Definition: MaskedImage.h:582
Ref< MaskPixelT >::type mask(cached_location_t const &cached_loc)
Return a reference to the mask at the offset set when we created the cached_location_t.
Definition: MaskedImage.h:468
detail::const_locator_type< ImageLocator >::type const_ImageLocator
Definition: MaskedImage.h:547
Classes to provide utility functions for a &quot;Pixel&quot; to get at image/mask/variance operators.
lsst::afw::image::pixel::SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > SinglePixel
A single Pixel of the same type as those in the MaskedImage.
Definition: MaskedImage.h:124
ImagePtr getImage(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage&#39;s image.
Definition: MaskedImage.h:875
A single pixel of the same type as a MaskedImage.
Definition: Pixel.h:64
void setXY0(geom::Point2I const origin)
Set the MaskedImage&#39;s origin.
Definition: MaskedImage.h:957
void operator+=(std::ptrdiff_t delta)
Increment the iterator by delta.
Definition: MaskedImage.h:169
void operator++(int)
Increment the iterator (postfix)
Definition: MaskedImage.h:183
cached_location_t(IMVLocator const &loc, int x, int y)
Create a cached_location_t that can be used to access pixels (x, y) away from loc.
Definition: MaskedImage.h:377
void swap(MaskedImage &rhs)
Definition: MaskedImage.cc:329
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:202
lsst::afw::image::Mask< MaskPixelT > Mask
Definition: MaskedImage.h:95
A Function taking two arguments.
Definition: Function.h:300
void operator+=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:755
Interface for MaskedImageFormatter class.
geom::Extent2I getDimensions() const
Definition: MaskedImage.h:910
MaskedImage(unsigned int width, unsigned int height, MaskPlaneDict const &planeDict=MaskPlaneDict())
Constructors.
Definition: MaskedImage.cc:52
boost::tuple< ImageIterator, MaskIterator, VarianceIterator > IMV_iterator_tuple
Definition: MaskedImage.h:131
int const x0
Definition: saturated.cc:45
void operator-=(ImagePixelT const rhs)
Subtract a scalar rhs from a MaskedImage.
Definition: MaskedImage.cc:460
void operator+=(ImagePixelT const rhs)
Add a scalar rhs to a MaskedImage.
Definition: MaskedImage.cc:429
MaskedImageIterator< typename Image::iterator, typename Mask::iterator, typename Variance::iterator > iterator
Definition: MaskedImage.h:568
An integer coordinate rectangle.
Definition: Box.h:53
Ref< VariancePixelT >::type variance()
Return (a reference to) the variance part of the Pixel pointed at by the iterator.
Definition: MaskedImage.h:158
bool operator==(MaskedImageLocatorBase const &rhs)
Return true iff two locators are equal.
Definition: MaskedImage.h:494
Mask< MaskPixelT >::MaskPlaneDict MaskPlaneDict
The Mask&#39;s MaskPlaneDict.
Definition: MaskedImage.h:91
xy_locator xy_at(int x, int y) const
Return an xy_locator at the point (x, y)
Definition: MaskedImage.h:1045
VariancePtr getVariance(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage&#39;s variance.
Definition: MaskedImage.h:896
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
bool operator!=(MaskedImageIteratorBase const &rhs)
Return true if the lhs doesn&#39;t equal the rhs.
Definition: MaskedImage.h:195
_view_t::iterator iterator
An STL compliant iterator.
Definition: Image.h:142
const_MaskedImageIterator & operator+(std::ptrdiff_t delta)
Return a const_MaskedImageIterator that&#39;s delta beyond this.
Definition: MaskedImage.h:263
_x_or_y_iterator< apply_x > x_iterator
An x_iterator that provides a view of the xy_locator (i.e. advancing one advances the other) ...
Definition: MaskedImage.h:367
double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const
Convert image index to image position (see Image::indexToPosition)
Definition: MaskedImage.h:977
x_iterator x_at(int x, int y) const
Return an x_iterator at the point (x, y)
Definition: MaskedImage.h:1012
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:42
MaskedImageIteratorBase< ImageIterator, MaskIterator, VarianceIterator > MaskedImageIteratorBase_t
Definition: MaskedImage.h:226
MaskedImageLocator(ImageLocator &img, MaskLocator &msk, VarianceLocator &var)
Definition: MaskedImage.h:534
reverse_iterator rbegin() const
Return a reverse_iterator to the start of the image.
Definition: MaskedImage.cc:737
MaskedImage(MaskedImage< OtherPixelT, MaskPixelT, VariancePixelT > const &rhs, const bool deep)
generalised copy constructor; defined here in the header so that the compiler can instantiate N(N-1)/...
Definition: MaskedImage.h:721
void ImageT ImageT int float saturatedPixelValue int const width
Definition: saturated.cc:44
static MaskedImage readFits(fits::MemFileManager &manager)
Read a MaskedImage from a FITS RAM file.
Definition: MaskedImage.h:869
Interface for Persistable base class.
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:92
MaskedImageIterator< typename Image::y_iterator, typename Mask::y_iterator, typename Variance::y_iterator > y_iterator
An iterator to a column of a MaskedImage.
Definition: MaskedImage.h:591
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:106
iterator end() const
Return an iterator to the end of the image.
Definition: MaskedImage.cc:717
const_MaskedImageIterator< typename Image::y_iterator, typename Mask::y_iterator, typename Variance::y_iterator > const_y_iterator
A const_iterator to a column of a MaskedImage.
Definition: MaskedImage.h:594
A traits class for MaskedImage.
Definition: MaskedImage.h:54
_x_or_y_iterator< apply_y > y_iterator
A y_iterator that provides a view of the xy_locator (i.e. advancing one advances the other) ...
Definition: MaskedImage.h:369
void operator-=(std::ptrdiff_t delta)
Decrement the iterator by delta.
Definition: MaskedImage.h:174
MaskPtr getMask(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage&#39;s mask.
Definition: MaskedImage.h:885
void operator*=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:775
void operator/=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:784
const_MaskedImageIterator(MaskedImageIterator< ImageIterator, MaskIterator, VarianceIterator > const &iter)
Definition: MaskedImage.h:255
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:78
_view_t::y_iterator y_iterator
An iterator for traversing the pixels in a column.
Definition: Image.h:159
MaskedImageIterator< typename Image::reverse_iterator, typename Mask::reverse_iterator, typename Variance::reverse_iterator > reverse_iterator
Definition: MaskedImage.h:574
Support for 2-D images.
detail::MaskedImage_tag image_category
Definition: MaskedImage.h:97
MaskedImageLocatorBase< const_ImageLocator, const_MaskLocator, const_VarianceLocator, ConstReference > MaskedImageLocatorBase_t
Definition: MaskedImage.h:552
std::shared_ptr< Image< ImagePixelT > > Ptr
Definition: Image.h:419
void operator++()
Increment the iterator (prefix)
Definition: MaskedImage.h:179
boost::zip_iterator< IMV_iterator_tuple >::reference IMV_tuple
The underlying iterator tuple.
Definition: MaskedImage.h:136
double x
reverse_iterator rend() const
Return a reverse_iterator to the end of the image.
Definition: MaskedImage.cc:747
Ref< ImagePixelT >::type image()
Return (a reference to) the image part of the Pixel pointed at by the iterator.
Definition: MaskedImage.h:148
A saved relative position, providing efficient access to neighbouring pixels.
Definition: MaskedImage.h:371
detail::const_locator_type< VarianceLocator >::type const_VarianceLocator
Definition: MaskedImage.h:549
y_iterator col_end(int x) const
Return an y_iterator to the end of the image.
Definition: MaskedImage.cc:789
Pixel operator*()
Dereference the iterator, returning a Pixel.
Definition: MaskedImage.h:210
void scaledMultiplies(double const c, MaskedImage const &rhs)
Definition: MaskedImage.cc:499
void ImageT ImageT int float saturatedPixelValue int const height
Definition: saturated.cc:44
const Pixel operator*() const
Dereference the iterator, returning a const Pixel.
Definition: MaskedImage.h:214
LSST bitmasks.
Image< ImagePixelT >::Ptr ImagePtr
shared pointer to the Image
Definition: MaskedImage.h:82
bool operator!=(MaskedImageLocatorBase const &rhs)
Return true iff two locators are not equal.
Definition: MaskedImage.h:498
lsst::afw::image::Image< VariancePixelT > Variance
Definition: MaskedImage.h:93
std::shared_ptr< const MaskedImage > ConstPtr
Definition: MaskedImage.h:89
std::string const compressedFileNoMEF_RE
regexp to identify when MaskedImages should
Definition: MaskedImage.h:60
MaskedImageIterator operator+(std::ptrdiff_t delta)
Return a MaskedImageIterator that&#39;s delta beyond this.
Definition: MaskedImage.h:232
std::shared_ptr< MaskedImage > Ptr
shared pointer to a MaskedImage
Definition: MaskedImage.h:88
std::shared_ptr< Mask > Ptr
Definition: Mask.h:94
std::ptrdiff_t operator-(MaskedImageIteratorBase const &rhs)
Return the distance between two iterators.
Definition: MaskedImage.h:187
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
Ref< ImagePixelT >::type image()
Return a reference to the image at the current position of the locator.
Definition: MaskedImage.h:459
x_iterator x()
Return an iterator that can be used to move (or dereference) a locator.
Definition: MaskedImage.h:415
A pixel of a MaskedImage.
Definition: Pixel.h:138
Mask< MaskPixelT >::Ptr MaskPtr
shared pointer to the Mask
Definition: MaskedImage.h:84
An const iterator to the MaskedImage.
Definition: MaskedImage.h:112
std::string const fitsFile_RE
Definition: MaskedImage.h:58
cached_location_t cache_location(int x, int y) const
Create a cached_location_t offset by (x, y) from locator.
Definition: MaskedImage.h:427
void assign(MaskedImage const &rsh, geom::Box2I const &bbox=geom::Box2I(), ImageOrigin origin=PARENT)
Copy pixels from another masked image to a specified subregion of this masked image.
Definition: MaskedImage.cc:391
#define PTR(...)
Definition: base.h:41
Class implementing persistence and retrieval for MaskedImages.
void setXY0(int const x0, int const y0)
Set the MaskedImage&#39;s origin.
Definition: MaskedImage.h:945
geom::Point2I getXY0() const
Return the image&#39;s origin.
Definition: MaskedImage.h:935
bool operator<(MaskedImageLocatorBase const &rhs)
Return true iff lhs is less than rhs.
Definition: MaskedImage.h:502
Class for storing generic metadata.
Definition: PropertySet.h:82
Ref< MaskPixelT >::type mask(int x, int y)
Return a reference to the mask offset by (x, y) from the current position of the locator.
Definition: MaskedImage.h:476
Ref< VariancePixelT >::type variance()
Return a reference to the variance at the current position of the locator.
Definition: MaskedImage.h:485
int getWidth() const
Return the number of columns in the image.
Definition: MaskedImage.h:907
int getY0() const
Return the image&#39;s row-origin.
Definition: MaskedImage.h:927
const IMV_iterator_tuple get_iterator_tuple() const
Return the underlying iterator tuple.
Definition: MaskedImage.h:164
void operator*=(ImagePixelT const rhs)
Definition: MaskedImage.cc:514
MaskedImageLocator< typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator >::x_iterator xy_x_iterator
an x_iterator associated with an xy_locator
Definition: MaskedImage.h:605
static MaskedImage readFits(std::string const &filename)
Read a MaskedImage from a regular FITS file.
Definition: MaskedImage.h:860
MaskedImage< ImagePT, MaskPT, VarPT > type
Return the desired type.
Definition: MaskedImage.h:104
y_iterator col_begin(int x) const
Return an y_iterator to the start of the image.
Definition: MaskedImage.cc:779
Base class for all persistable classes.
Definition: Persistable.h:74
MaskedImageIteratorBase< const_ImageIterator, const_MaskIterator, const_VarianceIterator, ConstReference > MaskedImageIteratorBase_t
Definition: MaskedImage.h:253
lsst::afw::image::Image< ImagePixelT > Image
Definition: MaskedImage.h:94
MaskedImageLocator< typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator > xy_locator
A locator for a MaskedImage.
Definition: MaskedImage.h:598
MaskedImageLocator< typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator >::y_iterator xy_y_iterator
an y_iterator associated with an xy_locator
Definition: MaskedImage.h:608
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Definition: Citizen.h:53
#define CONST_PTR(...)
A shared pointer to a const object.
Definition: base.h:47
void operator-=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:765
bool operator<(MaskedImageIteratorBase const &rhs)
Return true if the lhs is less than the rhs.
Definition: MaskedImage.h:199
Ref< VariancePixelT >::type variance(cached_location_t const &cached_loc)
Return a reference to the variance at the offset set when we created the cached_location_t.
Definition: MaskedImage.h:481
int const y0
Definition: saturated.cc:45
float VariancePixel
! default type for Masks and MaskedImage Masks
A class used to identify classes that represent MaskedImage pixels.
Definition: MaskedImage.h:56
MaskedImageLocatorBase(ImageLocator const &img, MaskLocator const &msk, VarianceLocator const &var)
Construct a MaskedImageLocator from image/mask/variance locators.
Definition: MaskedImage.h:387
_view_t::xy_locator xy_locator
An xy_locator.
Definition: Image.h:138
y_iterator y_at(int x, int y) const
Return an y_iterator at the point (x, y)
Definition: MaskedImage.h:1030
MaskedImage & operator=(MaskedImage const &rhs)
Make the lhs use the rhs&#39;s pixels.
Definition: MaskedImage.cc:324
Definition of default types for Masks and Variance Images.
MaskedImageLocatorBase & operator+=(pair2I const &p)
Increment the locator&#39;s x and y positions by p.
Definition: MaskedImage.h:507
const_MaskedImageLocator(MaskedImageLocator< ImageLocator, MaskLocator, VarianceLocator > const &iter)
Definition: MaskedImage.h:554
void scaledMinus(double const c, MaskedImage const &rhs)
Subtract a scaled MaskedImage c*rhs from a MaskedImage.
Definition: MaskedImage.cc:451
const_MaskedImageIterator< typename Image::x_iterator, typename Mask::x_iterator, typename Variance::x_iterator > const_x_iterator
A const_iterator to a row of a MaskedImage.
Definition: MaskedImage.h:585
std::pair< int, double > positionToIndex(double const pos, lsst::afw::image::xOrY const xy) const
Convert image position to index (see Image::positionToIndex)
Definition: MaskedImage.h:989
A const locator for the MaskedImage.
Definition: MaskedImage.h:116
metafunction to extract reference type from PixelT
Definition: Image.h:97
Ref< typename boost::mpl::at< PixelTVec, N >::type >::type apply_IMV()
Definition: MaskedImage.h:443
metafunction to extract const reference type from PixelT
Definition: Image.h:102