lsst.afw  13.0-109-g62eb66483
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 
25 /*
26  * Implementation of the Class MaskedImage
27  */
28 
29 #ifndef LSST_IMAGE_MASKEDIMAGE_H
30 #define LSST_IMAGE_MASKEDIMAGE_H
31 
32 #include <list>
33 #include <map>
34 #include <memory>
35 #include <ostream>
36 #include <string>
37 
38 #include "boost/mpl/at.hpp"
39 #include "boost/iterator/zip_iterator.hpp"
40 #include "boost/tuple/tuple.hpp" // cannot convert to std::tuple (yet) because of use with boost::gil
41 
42 #include "lsst/daf/base/Citizen.h"
43 #include "lsst/daf/base/Persistable.h"
45 #include "lsst/afw/image/Image.h"
46 #include "lsst/afw/image/Mask.h"
47 
48 namespace lsst {
49 namespace afw {
50 namespace image {
51 namespace detail {
53 struct MaskedImage_tag : public basic_tag {};
56 
58 std::string const fitsFile_RE = "\\.fits(\\.[fg]z)?$";
60 std::string const compressedFileNoMEF_RE = "(\\.gz)$";
61 }
62 }
63 }
64 }
65 
66 #include "lsst/afw/image/Pixel.h"
68 
69 namespace lsst {
70 namespace afw {
71 namespace formatters {
72 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
73 class MaskedImageFormatter;
74 }
75 
76 namespace image {
77 
79 template <typename ImagePixelT, typename MaskPixelT = lsst::afw::image::MaskPixel,
80  typename VariancePixelT = lsst::afw::image::VariancePixel>
81 class MaskedImage : public lsst::daf::base::Persistable, public lsst::daf::base::Citizen {
82 public:
84  typedef std::shared_ptr<image::Image<ImagePixelT>> ImagePtr;
86  typedef std::shared_ptr<image::Mask<MaskPixelT>> MaskPtr;
88  typedef std::shared_ptr<image::Image<VariancePixelT>> VariancePtr;
91 
95 
97 
99  template <typename ImagePT = ImagePixelT, typename MaskPT = MaskPixelT, typename VarPT = VariancePixelT>
103  };
104 
106  template <typename, typename, typename>
109  template <typename, typename, typename>
112  template <typename, typename, typename>
115  template <typename, typename, typename>
116  class const_MaskedImageLocator;
117 
122 
124  template <typename ImageIterator, typename MaskIterator, typename VarianceIterator,
125  template <typename> class Ref = Reference>
127  typedef boost::tuple<ImageIterator, MaskIterator, VarianceIterator> IMV_iterator_tuple;
128 
129  public:
133  typedef typename boost::zip_iterator<IMV_iterator_tuple>::reference IMV_tuple;
137  template <typename, typename, typename>
140  typedef Pixel type;
141 
143  MaskedImageIteratorBase(ImageIterator const& img, MaskIterator const& msk,
144  VarianceIterator const& var)
145  : _iter(boost::make_zip_iterator(boost::make_tuple(img, msk, var))) {}
147  typename Ref<ImagePixelT>::type image() { return _iter->template get<0>()[0]; }
148 
150  typename Ref<MaskPixelT>::type mask() { return _iter->template get<1>()[0]; }
151 
153  typename Ref<VariancePixelT>::type variance() { return _iter->template get<2>()[0]; }
154 
158  const IMV_iterator_tuple get_iterator_tuple() const { return _iter.get_iterator_tuple(); }
159 
161  MaskedImageIteratorBase& operator+=(std::ptrdiff_t delta
162  ) {
163  _iter += delta;
164  return *this;
165  }
167  MaskedImageIteratorBase& operator-=(std::ptrdiff_t delta
168  ) {
169  _iter -= delta;
170  return *this;
171  }
174  ++_iter;
175  return *this;
176  }
179  MaskedImageIteratorBase tmp(*this);
180  _iter++;
181  return tmp;
182  }
184  std::ptrdiff_t operator-(MaskedImageIteratorBase const& rhs) {
185  return &this->_iter->template get<0>() - &rhs._iter->template get<0>();
186  }
189  return &this->_iter->template get<0>() == &rhs._iter->template get<0>();
190  }
193  return &this->_iter->template get<0>() != &rhs._iter->template get<0>();
194  }
197  return &this->_iter->template get<0>() < &rhs._iter->template get<0>();
198  }
200  operator Pixel() const {
201  return Pixel(_iter->template get<0>()[0], _iter->template get<1>()[0],
202  _iter->template get<2>()[0]);
203  }
204 
206  Pixel operator*() { return Pixel(image(), mask(), variance()); }
208  const Pixel operator*() const { return Pixel(image(), mask(), variance()); }
209 
210  protected:
211  typename boost::zip_iterator<IMV_iterator_tuple> _iter;
212  };
213 
215  template <typename ImageIterator, typename MaskIterator, typename VarianceIterator>
216  class MaskedImageIterator
217  : public MaskedImageIteratorBase<ImageIterator, MaskIterator, VarianceIterator> {
219  MaskedImageIteratorBase_t;
220 
221  public:
222  MaskedImageIterator(ImageIterator& img, MaskIterator& msk, VarianceIterator& var)
223  : MaskedImageIteratorBase_t(img, msk, var) {}
225  MaskedImageIterator operator+(std::ptrdiff_t delta) {
226  MaskedImageIterator lhs = *this;
227  lhs += delta;
228 
229  return lhs;
230  }
231  };
232 
234  template <typename ImageIterator, typename MaskIterator, typename VarianceIterator>
236  : public MaskedImageIteratorBase<typename detail::const_iterator_type<ImageIterator>::type,
237  typename detail::const_iterator_type<MaskIterator>::type,
238  typename detail::const_iterator_type<VarianceIterator>::type,
239  ConstReference> {
240  typedef typename detail::const_iterator_type<ImageIterator>::type const_ImageIterator;
241  typedef typename detail::const_iterator_type<MaskIterator>::type const_MaskIterator;
242  typedef typename detail::const_iterator_type<VarianceIterator>::type const_VarianceIterator;
243 
244  typedef MaskedImageIteratorBase<const_ImageIterator, const_MaskIterator, const_VarianceIterator,
247 
248  public:
251  : MaskedImageIteratorBase_t(
252  const_ImageIterator(iter.get_iterator_tuple().template get<0>()),
253  const_MaskIterator(iter.get_iterator_tuple().template get<1>()),
254  const_VarianceIterator(iter.get_iterator_tuple().template get<2>())) {
255  ;
256  }
258  const_MaskedImageIterator& operator+(std::ptrdiff_t delta) {
259  const_MaskedImageIterator lhs = *this;
260  lhs += delta;
261 
262  return lhs;
263  }
264  };
265 
267  template <typename ImageLocator, typename MaskLocator, typename VarianceLocator,
268  template <typename> class Ref = Reference>
270  typedef typename boost::tuple<ImageLocator, MaskLocator, VarianceLocator> IMVLocator;
271  //
272  // A class to provide _[xy]_iterator for MaskedImageLocator. We can't just use
273  // a zip_iterator as moving this iterator must be the same as moving the locator
274  // itself, for consistency with {Image,Mask}::xy_locator
275  //
276  template <template <typename> class X_OR_Y>
277  class _x_or_y_iterator {
278  public:
279  _x_or_y_iterator(MaskedImageLocatorBase* mil) : _mil(mil) {}
280 
281  _x_or_y_iterator& operator+=(const int di) {
282  // Equivalent to "_mil->_loc.template get<0>().x() += di;"
283  X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())() += di;
284  X_OR_Y<MaskLocator>(_mil->_loc.template get<1>())() += di;
285  X_OR_Y<VarianceLocator>(_mil->_loc.template get<2>())() += di;
286  return *this;
287  }
288 
289  _x_or_y_iterator& operator++() { // prefix
290  // Equivalent to "++_mil->_loc.template get<0>().x();"
291  ++X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())();
292  ++X_OR_Y<MaskLocator>(_mil->_loc.template get<1>())();
293  ++X_OR_Y<VarianceLocator>(_mil->_loc.template get<2>())();
294  return *this;
295  }
296 
297  bool operator==(_x_or_y_iterator const& rhs) {
298  return X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())() ==
299  X_OR_Y<ImageLocator>(rhs._mil->_loc.template get<0>())();
300  }
301  bool operator!=(_x_or_y_iterator const& rhs) {
302  return X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())() !=
303  X_OR_Y<ImageLocator>(rhs._mil->_loc.template get<0>())();
304  }
305  bool operator<(_x_or_y_iterator const& rhs) {
306  return X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())() <
307  X_OR_Y<ImageLocator>(rhs._mil->_loc.template get<0>())();
308  }
309 
310  Pixel operator*() {
311  return Pixel((*(X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())()))[0],
312  (*(X_OR_Y<MaskLocator>(_mil->_loc.template get<1>())()))[0],
313  (*(X_OR_Y<VarianceLocator>(_mil->_loc.template get<2>())()))[0]);
314  }
315 
316  typename Ref<ImagePixelT>::type image() {
317  // Equivalent to "return (*_mil->_loc.template get<0>().x())[0];"
318 
319  return (*(X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())()))[0];
320  }
321  typename Ref<MaskPixelT>::type mask() {
322  return (*(X_OR_Y<MaskLocator>(_mil->_loc.template get<1>())()))[0];
323  }
324  typename Ref<VariancePixelT>::type variance() {
325  return (*(X_OR_Y<VarianceLocator>(_mil->_loc.template get<2>())()))[0];
326  }
327 
328  protected:
330  };
331 
332  // Two classes to provide .x() and .y() in _x_or_y_iterator
333  template <typename LocT>
334  class apply_x {
335  typedef typename LocT::x_iterator IterT;
336 
337  public:
338  apply_x(LocT& loc) : _loc(loc) {}
339  IterT& operator()() { return _loc.x(); }
340 
341  private:
342  LocT& _loc;
343  };
344 
345  template <typename LocT>
346  class apply_y {
347  typedef typename LocT::y_iterator IterT;
348 
349  public:
350  apply_y(LocT& loc) : _loc(loc) {}
351  IterT& operator()() { return _loc.y(); }
352 
353  private:
354  LocT& _loc;
355  };
356 
357  public:
358  typedef typename boost::tuple<typename ImageLocator::cached_location_t,
359  typename MaskLocator::cached_location_t,
360  typename VarianceLocator::cached_location_t>
363  typedef _x_or_y_iterator<apply_x> x_iterator;
365  typedef _x_or_y_iterator<apply_y> y_iterator;
368  public:
369  // template<typename, typename, typename, template<typename> class> friend class
370  // MaskedImageLocatorBase;
371  template <typename, typename, typename>
373 
375  cached_location_t(IMVLocator const& loc, int x, int y)
376  : _imv(loc.template get<0>().cache_location(x, y),
377  loc.template get<1>().cache_location(x, y),
378  loc.template get<2>().cache_location(x, y)) {
379  ;
380  }
381  // protected:
383  };
385  MaskedImageLocatorBase(ImageLocator const& img, MaskLocator const& msk, VarianceLocator const& var)
386  : _loc(img, msk, var) {
387  ;
388  }
389 
391  Pixel operator*() {
392  return Pixel(_loc.template get<0>().x()[0][0], _loc.template get<1>().x()[0][0],
393  _loc.template get<2>().x()[0][0]);
394  }
395 
397  Pixel operator()(int x, int y) {
398  return Pixel(_loc.template get<0>()(x, y)[0], _loc.template get<1>()(x, y)[0],
399  _loc.template get<2>()(x, y)[0]);
400  }
401 
404  Pixel operator[](cached_location_t const& cached_loc) {
405  return Pixel(_loc.template get<0>()[cached_loc._imv.template get<0>()][0],
406  _loc.template get<1>()[cached_loc._imv.template get<1>()][0],
407  _loc.template get<2>()[cached_loc._imv.template get<2>()][0]);
408  }
413  x_iterator x() { return x_iterator(this); }
414 
419  y_iterator y() { return y_iterator(this); }
420 
422  cached_location_t cache_location(int x, int y) const { return cached_location_t(_loc, x, y); }
423  //
424  // We don't want to duplicate code for image/mask/variance -- but the boost::mpl stuff isn't pretty
425  // as we can't say int_<N> within a template<int N>. So define a set of functions apply_IMV
426  // to do the dirty work
427  //
428  typedef typename boost::mpl::vector<ImagePixelT, MaskPixelT, VariancePixelT> PixelTVec;
429 
430  template <typename N>
431  typename Ref<typename boost::mpl::at<PixelTVec, N>::type>::type apply_IMV(
432  cached_location_t const& cached_loc) {
433  return _loc.template get<N::value>()[cached_loc._imv.template get<N::value>()][0];
434  }
435 
436  template <typename N>
437  typename Ref<typename boost::mpl::at<PixelTVec, N>::type>::type apply_IMV() {
438  return _loc.template get<N::value>()[0][0];
439  }
440 
441  template <typename N>
442  typename Ref<typename boost::mpl::at<PixelTVec, N>::type>::type apply_IMV(int x, int y) {
443  return _loc.template get<N::value>()(x, y)[0];
444  }
445  //
446  // Use those templated classes to implement image/mask/variance
447  //
449  typename Ref<ImagePixelT>::type image(cached_location_t const& cached_loc) {
450  return apply_IMV<boost::mpl::int_<0>>(cached_loc);
451  }
453  typename Ref<ImagePixelT>::type image() { return apply_IMV<boost::mpl::int_<0>>(); }
455  typename Ref<ImagePixelT>::type image(int x, int y) { return apply_IMV<boost::mpl::int_<0>>(x, y); }
456 
458  typename Ref<MaskPixelT>::type mask(cached_location_t const& cached_loc) {
459  return apply_IMV<boost::mpl::int_<1>>(cached_loc);
460  }
462  typename Ref<MaskPixelT>::type mask() { return apply_IMV<boost::mpl::int_<1>>(); }
464  typename Ref<MaskPixelT>::type mask(int x, int y) { return apply_IMV<boost::mpl::int_<1>>(x, y); }
465 
467  typename Ref<VariancePixelT>::type variance(cached_location_t const& cached_loc) {
468  return apply_IMV<boost::mpl::int_<2>>(cached_loc);
469  }
471  typename Ref<VariancePixelT>::type variance() { return apply_IMV<boost::mpl::int_<2>>(); }
473  typename Ref<VariancePixelT>::type variance(int x, int y) {
474  return apply_IMV<boost::mpl::int_<2>>(x, y);
475  }
476 
479  return _loc.template get<0>() == rhs._loc.template get<0>();
480  }
482  bool operator!=(MaskedImageLocatorBase const& rhs) { return !(*this == rhs); }
485  return _loc.template get<0>() < rhs._loc.template get<0>();
486  }
487 
489  MaskedImageLocatorBase& operator+=(pair2I const& p) {
490  return operator+=(detail::difference_type(p.first, p.second));
491  }
492 
494  MaskedImageLocatorBase& operator+=(detail::difference_type p) {
495  _loc.template get<0>() += p;
496  _loc.template get<1>() += p;
497  _loc.template get<2>() += p;
498 
499  return *this;
500  }
501 
502  // Workaround for DM-5590: clang-3.8 cannot access _loc from
503  // friend class const_MaskedImageLocator.
504  IMVLocator const& getLoc() const { return _loc; }
505 
506  protected:
507  IMVLocator _loc;
508  };
509 
511  template <typename ImageLocator, typename MaskLocator, typename VarianceLocator>
512  class MaskedImageLocator : public MaskedImageLocatorBase<ImageLocator, MaskLocator, VarianceLocator> {
514 
515  public:
516  MaskedImageLocator(ImageLocator& img, MaskLocator& msk, VarianceLocator& var)
517  : MaskedImageLocatorBase_t(img, msk, var) {}
518  };
519 
521  template <typename ImageLocator, typename MaskLocator, typename VarianceLocator>
523  : public MaskedImageLocatorBase<typename detail::const_locator_type<ImageLocator>::type,
524  typename detail::const_locator_type<MaskLocator>::type,
525  typename detail::const_locator_type<VarianceLocator>::type,
526  ConstReference> {
527  typedef typename detail::const_locator_type<ImageLocator>::type const_ImageLocator;
528  typedef typename detail::const_locator_type<MaskLocator>::type const_MaskLocator;
529  typedef typename detail::const_locator_type<VarianceLocator>::type const_VarianceLocator;
530 
531  typedef MaskedImageLocatorBase<const_ImageLocator, const_MaskLocator, const_VarianceLocator,
534 
535  public:
537  : MaskedImageLocatorBase_t(const_ImageLocator(iter.getLoc().template get<0>()),
538  const_MaskLocator(iter.getLoc().template get<1>()),
539  const_VarianceLocator(iter.getLoc().template get<2>())) {
540  ;
541  }
542  };
543 
544  // An iterator to a MaskedImage
545  typedef MaskedImageIterator<typename Image::iterator, typename Mask::iterator,
546  typename Variance::iterator>
548  // A const_iterator to a MaskedImage
549  typedef const_MaskedImageIterator<typename Image::iterator, typename Mask::iterator,
550  typename Variance::iterator>
552  // A reverse_iterator to a MaskedImage
553  typedef MaskedImageIterator<typename Image::reverse_iterator, typename Mask::reverse_iterator,
556 #if 0 // doesn't compile. I should fix this, but it's low priority. RHL
557  typedef const_MaskedImageIterator<typename Image::reverse_iterator,
559  typename Mask::reverse_iterator, typename Variance::reverse_iterator> const_reverse_iterator;
560 #endif
561  typedef MaskedImageIterator<typename Image::x_iterator, typename Mask::x_iterator,
563  typename Variance::x_iterator>
566  typedef const_MaskedImageIterator<typename Image::x_iterator, typename Mask::x_iterator,
567  typename Variance::x_iterator>
574  typedef MaskedImageIterator<typename Image::y_iterator, typename Mask::y_iterator,
575  typename Variance::y_iterator>
578  typedef const_MaskedImageIterator<typename Image::y_iterator, typename Mask::y_iterator,
579  typename Variance::y_iterator>
581 
583  typedef MaskedImageLocator<typename Image::xy_locator, typename Mask::xy_locator,
584  typename Variance::xy_locator>
587  typedef const_MaskedImageLocator<typename Image::xy_locator, typename Mask::xy_locator,
588  typename Variance::xy_locator>
590 
592  typedef typename MaskedImageLocator<typename Image::xy_locator, typename Mask::xy_locator,
595  typedef typename MaskedImageLocator<typename Image::xy_locator, typename Mask::xy_locator,
597 
598  // Constructors
606  explicit MaskedImage(unsigned int width, unsigned int height,
607  MaskPlaneDict const& planeDict = MaskPlaneDict());
615  MaskPlaneDict const& planeDict = MaskPlaneDict());
624  explicit MaskedImage(ImagePtr image, MaskPtr mask = MaskPtr(), VariancePtr variance = VariancePtr());
636  explicit MaskedImage(geom::Box2I const& bbox, MaskPlaneDict const& planeDict = MaskPlaneDict());
637 
653  explicit MaskedImage(
654  std::string const& fileName,
655  std::shared_ptr<daf::base::PropertySet> metadata = std::shared_ptr<daf::base::PropertySet>(),
656  geom::Box2I const& bbox = geom::Box2I(), ImageOrigin origin = PARENT, bool conformMasks = false,
657  bool needAllHdus = false,
658  std::shared_ptr<daf::base::PropertySet> imageMetadata = std::shared_ptr<daf::base::PropertySet>(),
659  std::shared_ptr<daf::base::PropertySet> maskMetadata = std::shared_ptr<daf::base::PropertySet>(),
660  std::shared_ptr<daf::base::PropertySet> varianceMetadata =
661  std::shared_ptr<daf::base::PropertySet>());
662 
678  explicit MaskedImage(
679  fits::MemFileManager& manager,
680  std::shared_ptr<daf::base::PropertySet> metadata = std::shared_ptr<daf::base::PropertySet>(),
681  geom::Box2I const& bbox = geom::Box2I(), ImageOrigin origin = PARENT, bool conformMasks = false,
682  bool needAllHdus = false,
683  std::shared_ptr<daf::base::PropertySet> imageMetadata = std::shared_ptr<daf::base::PropertySet>(),
684  std::shared_ptr<daf::base::PropertySet> maskMetadata = std::shared_ptr<daf::base::PropertySet>(),
685  std::shared_ptr<daf::base::PropertySet> varianceMetadata =
686  std::shared_ptr<daf::base::PropertySet>());
687 
703  explicit MaskedImage(
704  fits::Fits& fitsfile,
705  std::shared_ptr<daf::base::PropertySet> metadata = std::shared_ptr<daf::base::PropertySet>(),
706  geom::Box2I const& bbox = geom::Box2I(), ImageOrigin origin = PARENT, bool conformMasks = false,
707  bool needAllHdus = false,
708  std::shared_ptr<daf::base::PropertySet> imageMetadata = std::shared_ptr<daf::base::PropertySet>(),
709  std::shared_ptr<daf::base::PropertySet> maskMetadata = std::shared_ptr<daf::base::PropertySet>(),
710  std::shared_ptr<daf::base::PropertySet> varianceMetadata =
711  std::shared_ptr<daf::base::PropertySet>());
712 
719  MaskedImage(MaskedImage const& rhs, bool const deep = false);
729  MaskedImage(MaskedImage const& rhs, geom::Box2I const& bbox, ImageOrigin const origin = PARENT,
730  bool const deep = false);
736  template <typename OtherPixelT>
738 
739  const bool deep
740  )
741  : lsst::daf::base::Citizen(typeid(this)), _image(), _mask(), _variance() {
742  if (!deep) {
743  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
744  "Only deep copies are permitted for MaskedImages with different pixel types");
745  }
746 
747  _image = ImagePtr(new Image(*rhs.getImage(), deep));
748  _mask = MaskPtr(new Mask(*rhs.getMask(), deep));
749  _variance = VariancePtr(new Variance(*rhs.getVariance(), deep));
750  }
751 
752 #if defined(DOXYGEN)
753 
762  MaskedImage& operator=(MaskedImage const& rhs);
763 #endif
764 
765  virtual ~MaskedImage() {}
766 
767  void swap(MaskedImage& rhs);
768 
769  // Operators
771  MaskedImage& operator=(Pixel const& rhs);
773  MaskedImage& operator=(SinglePixel const& rhs);
774 
782  MaskedImage& operator<<=(MaskedImage const& rhs);
783 
795  void assign(MaskedImage const& rhs, geom::Box2I const& bbox = geom::Box2I(), ImageOrigin origin = PARENT);
796 
798  MaskedImage& operator+=(ImagePixelT const rhs);
808  MaskedImage& operator+=(MaskedImage const& rhs);
810  *_image += rhs;
811  return *this;
812  }
814  *_image += function;
815  return *this;
816  }
825  void scaledPlus(double const c, MaskedImage const& rhs);
826 
828  MaskedImage& operator-=(ImagePixelT const rhs);
835  MaskedImage& operator-=(MaskedImage const& rhs);
837  *_image -= rhs;
838  return *this;
839  }
841  *_image -= function;
842  return *this;
843  }
850  void scaledMinus(double const c, MaskedImage const& rhs);
851 
852  MaskedImage& operator*=(ImagePixelT const rhs);
853  MaskedImage& operator*=(MaskedImage const& rhs);
855  *_image *= rhs;
856  *_variance *= rhs; // yes, multiply twice
857  *_variance *= rhs;
858  return *this;
859  }
860  void scaledMultiplies(double const c, MaskedImage const& rhs);
861 
862  MaskedImage& operator/=(ImagePixelT const rhs);
863  MaskedImage& operator/=(MaskedImage const& rhs);
865  *_image /= rhs;
866  *_variance /= rhs; // yes, divide twice
867  *_variance /= rhs;
868  return *this;
869  }
870  void scaledDivides(double const c, MaskedImage const& rhs);
871 
886  void writeFits(std::string const& fileName, std::shared_ptr<daf::base::PropertySet const> metadata =
887  std::shared_ptr<daf::base::PropertySet const>(),
888  std::shared_ptr<daf::base::PropertySet const> imageMetadata =
889  std::shared_ptr<daf::base::PropertySet const>(),
890  std::shared_ptr<daf::base::PropertySet const> maskMetadata =
891  std::shared_ptr<daf::base::PropertySet const>(),
892  std::shared_ptr<daf::base::PropertySet const> varianceMetadata =
893  std::shared_ptr<daf::base::PropertySet const>()) const;
894 
908  void writeFits(fits::MemFileManager& manager, std::shared_ptr<daf::base::PropertySet const> metadata =
909  std::shared_ptr<daf::base::PropertySet const>(),
910  std::shared_ptr<daf::base::PropertySet const> imageMetadata =
911  std::shared_ptr<daf::base::PropertySet const>(),
912  std::shared_ptr<daf::base::PropertySet const> maskMetadata =
913  std::shared_ptr<daf::base::PropertySet const>(),
914  std::shared_ptr<daf::base::PropertySet const> varianceMetadata =
915  std::shared_ptr<daf::base::PropertySet const>()) const;
916 
930  void writeFits(fits::Fits& fitsfile, std::shared_ptr<daf::base::PropertySet const> metadata =
931  std::shared_ptr<daf::base::PropertySet const>(),
932  std::shared_ptr<daf::base::PropertySet const> imageMetadata =
933  std::shared_ptr<daf::base::PropertySet const>(),
934  std::shared_ptr<daf::base::PropertySet const> maskMetadata =
935  std::shared_ptr<daf::base::PropertySet const>(),
936  std::shared_ptr<daf::base::PropertySet const> varianceMetadata =
937  std::shared_ptr<daf::base::PropertySet const>()) const;
938 
955  void writeFits(
956  std::string const& fileName,
957  fits::ImageWriteOptions const& imageOptions,
958  fits::ImageWriteOptions const& maskOptions,
959  fits::ImageWriteOptions const& varianceOptions,
960  std::shared_ptr<daf::base::PropertySet const> metadata = nullptr,
961  std::shared_ptr<daf::base::PropertySet const> imageMetadata = nullptr,
962  std::shared_ptr<daf::base::PropertySet const> maskMetadata = nullptr,
963  std::shared_ptr<daf::base::PropertySet const> varianceMetadata = nullptr
964  ) const;
965 
982  void writeFits(
983  fits::MemFileManager& manager,
984  fits::ImageWriteOptions const& imageOptions,
985  fits::ImageWriteOptions const& maskOptions,
986  fits::ImageWriteOptions const& varianceOptions,
987  std::shared_ptr<daf::base::PropertySet const> metadata = nullptr,
988  std::shared_ptr<daf::base::PropertySet const> imageMetadata = nullptr,
989  std::shared_ptr<daf::base::PropertySet const> maskMetadata = nullptr,
990  std::shared_ptr<daf::base::PropertySet const> varianceMetadata = nullptr
991  ) const;
992 
1009  void writeFits(
1010  fits::Fits& fitsfile,
1011  fits::ImageWriteOptions const& imageOptions,
1012  fits::ImageWriteOptions const& maskOptions,
1013  fits::ImageWriteOptions const& varianceOptions,
1014  std::shared_ptr<daf::base::PropertySet const> metadata = nullptr,
1015  std::shared_ptr<daf::base::PropertySet const> imageMetadata = nullptr,
1016  std::shared_ptr<daf::base::PropertySet const> maskMetadata = nullptr,
1017  std::shared_ptr<daf::base::PropertySet const> varianceMetadata = nullptr
1018  ) const;
1019 
1025  static MaskedImage readFits(std::string const& filename) {
1027  }
1028 
1036  }
1037 
1038  // Getters
1039 
1041  ImagePtr getImage() const { return _image; }
1042 
1050  void setImage(Image const & other) { _image->assign(other); }
1051 
1053  MaskPtr getMask() const { return _mask; }
1054 
1062  void setMask(Mask const & other) { _mask->assign(other); }
1063 
1071  void setVariance(Variance const & other) { _variance->assign(other); }
1072 
1074  VariancePtr getVariance() const { return _variance; }
1075 
1077  int getWidth() const { return _image->getWidth(); }
1079  int getHeight() const { return _image->getHeight(); }
1080  geom::Extent2I getDimensions() const { return _image->getDimensions(); }
1081  geom::Box2I getBBox(ImageOrigin const origin = PARENT) const { return _image->getBBox(origin); }
1089  int getX0() const { return _image->getX0(); }
1097  int getY0() const { return _image->getY0(); }
1105  geom::Point2I getXY0() const { return _image->getXY0(); }
1106 
1115  void setXY0(int const x0, int const y0) { setXY0(geom::Point2I(x0, y0)); }
1116 
1125  void setXY0(geom::Point2I const origin) {
1126  if (_image) {
1127  _image->setXY0(origin);
1128  }
1129 
1130  if (_mask) {
1131  _mask->setXY0(origin);
1132  }
1133 
1134  if (_variance) {
1135  _variance->setXY0(origin);
1136  }
1137  }
1138 
1144  inline double indexToPosition(double ind,
1145  lsst::afw::image::xOrY const xy
1146  ) const {
1147  return getImage()->indexToPosition(ind, xy);
1148  }
1149 
1155  std::pair<int, double> positionToIndex(
1156  double const pos,
1157  lsst::afw::image::xOrY const xy
1158  ) const {
1159  return getImage()->positionToIndex(pos, xy);
1160  }
1161 
1162  //
1163  // Iterators and Locators
1164  //
1166  iterator begin() const;
1168  iterator end() const;
1170  iterator at(int const x, int const y) const;
1172  reverse_iterator rbegin() const;
1174  reverse_iterator rend() const;
1175 
1186  fast_iterator begin(bool contiguous) const;
1195  fast_iterator end(bool contiguous) const;
1196 
1198  x_iterator row_begin(int y) const;
1200  x_iterator row_end(int y) const;
1201 
1203  x_iterator x_at(int x, int y) const {
1204 #if 0
1205  typename Image::x_iterator imageEnd = getImage()->x_at(x, y);
1206  typename Mask::x_iterator maskEnd = getMask()->x_at(x, y);
1207  typename Variance::x_iterator varianceEnd = getVariance()->x_at(x, y);
1208 #else // bypass checks for non-NULL pointers
1209  typename Image::x_iterator imageEnd = _image->x_at(x, y);
1210  typename Mask::x_iterator maskEnd = _mask->x_at(x, y);
1211  typename Variance::x_iterator varianceEnd = _variance->x_at(x, y);
1212 #endif
1213 
1214  return x_iterator(imageEnd, maskEnd, varianceEnd);
1215  }
1216 
1218  y_iterator col_begin(int x) const;
1220  y_iterator col_end(int x) const;
1221 
1223  y_iterator y_at(int x, int y) const {
1224 #if 0
1225  typename Image::y_iterator imageEnd = getImage()->y_at(x, y);
1226  typename Mask::y_iterator maskEnd = getMask()->y_at(x, y);
1227  typename Variance::y_iterator varianceEnd = getVariance()->y_at(x, y);
1228 #else // bypass checks for non-NULL pointers
1229  typename Image::y_iterator imageEnd = _image->y_at(x, y);
1230  typename Mask::y_iterator maskEnd = _mask->y_at(x, y);
1231  typename Variance::y_iterator varianceEnd = _variance->y_at(x, y);
1232 #endif
1233  return y_iterator(imageEnd, maskEnd, varianceEnd);
1234  }
1235 
1237  xy_locator xy_at(int x, int y) const {
1238 #if 0
1239  typename Image::xy_locator imageEnd = getImage()->xy_at(x, y);
1240  typename Mask::xy_locator maskEnd = getMask()->xy_at(x, y);
1241  typename Variance::xy_locator varianceEnd = getVariance()->xy_at(x, y);
1242 #else // bypass checks for non-NULL pointers
1243  typename Image::xy_locator imageEnd = _image->xy_at(x, y);
1244  typename Mask::xy_locator maskEnd = _mask->xy_at(x, y);
1245  typename Variance::xy_locator varianceEnd = _variance->xy_at(x, y);
1246 #endif
1247 
1248  return xy_locator(imageEnd, maskEnd, varianceEnd);
1249  }
1250 
1251 private:
1252 #ifndef DOXYGEN
1253  LSST_PERSIST_FORMATTER(
1255 #endif
1256  void conformSizes();
1257 
1258  ImagePtr _image;
1259  MaskPtr _mask;
1260  VariancePtr _variance;
1261 };
1262 
1266 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
1268  typename std::shared_ptr<Image<ImagePixelT>> image,
1269  typename std::shared_ptr<Mask<MaskPixelT>> mask = Mask<MaskPixelT>(),
1270  typename std::shared_ptr<Image<VariancePixelT>> variance = Image<VariancePixelT>()
1271  ) {
1273 }
1274 
1275 /*
1276  * Some metafunctions to extract an Image pointer from a MaskedImage pointer (or return the original Image
1277  * pointer)
1278  *
1279  * GetImage is the public interface (it forwards the tag --- just for the sake of the UI); the real work
1280  * is in GetImage_ which defines a typedef for the Image and a static function, getImage
1281  *
1282  * E.g.
1283  * In the function
1284  *
1285  * template<typename ImageT>
1286  * void func(shared_ptr<ImageT> image) {
1287  * typename shared_ptr<GetImage<ImageT>::type> im = GetImage<ImageT>::getImage(image);
1288  * }
1289  *
1290  * "im" is a shared_ptr<Image> irrespective of whether ImageT is Masked or not.
1291  */
1292 namespace {
1293 template <typename ImageT, typename TagT>
1294 struct GetImage_ {
1295  typedef ImageT type;
1296  static std::shared_ptr<type> getImage(std::shared_ptr<ImageT> image) { return image; }
1297 };
1298 
1299 template <typename ImageT>
1300 struct GetImage_<ImageT, typename image::detail::MaskedImage_tag> {
1301  typedef typename ImageT::Image type;
1302  static std::shared_ptr<type> getImage(std::shared_ptr<ImageT> image) { return image->getImage(); }
1303 };
1304 } // anonymous namespace
1305 
1306 template <typename ImageT>
1307 struct GetImage : public GetImage_<ImageT, typename ImageT::image_category> {};
1308 }
1309 }
1310 } // lsst::afw::image
1311 
1312 #endif // LSST_IMAGE_MASKEDIMAGE_H
VariancePtr getVariance() const
Return a (shared_ptr to) the MaskedImage&#39;s variance.
Definition: MaskedImage.h:1074
MaskedImageLocatorBase & operator+=(detail::difference_type p)
Increment the locator&#39;s x and y positions by p
Definition: MaskedImage.h:494
cached_location_t cache_location(int x, int y) const
Create a cached_location_t offset by (x, y) from locator.
Definition: MaskedImage.h:422
MaskedImageIterator operator+(std::ptrdiff_t delta)
Return a MaskedImageIterator that&#39;s delta beyond this.
Definition: MaskedImage.h:225
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:1155
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:455
void scaledPlus(OutImageT &outImage, double c1, InImageT const &inImage1, double c2, InImageT const &inImage2)
Compute the scaled sum of two images.
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:449
Ref< MaskPixelT >::type mask()
Return (a reference to) the mask part of the Pixel pointed at by the iterator.
Definition: MaskedImage.h:150
Ref< MaskPixelT >::type mask()
Return a reference to the mask at the current position of the locator.
Definition: MaskedImage.h:462
afw::table::Key< afw::table::Array< VariancePixelT > > variance
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:589
y_iterator y()
Return an iterator that can be used to move (or dereference) a locator.
Definition: MaskedImage.h:419
MaskedImageIteratorBase(ImageIterator const &img, MaskIterator const &msk, VarianceIterator const &var)
Construct a MaskedImageIteratorBase from the image/mask/variance iterators.
Definition: MaskedImage.h:143
afw::table::Key< afw::table::Array< ImagePixelT > > image
The base class for MaskedImageLocators (const and non-const)
Definition: MaskedImage.h:269
MaskedImageLocator(ImageLocator &img, MaskLocator &msk, VarianceLocator &var)
Definition: MaskedImage.h:516
Definition: Span.h:37
MaskedImage & operator-=(lsst::afw::math::Function2< double > const &function)
Definition: MaskedImage.h:840
Ref< typename boost::mpl::at< PixelTVec, N >::type >::type apply_IMV(int x, int y)
Definition: MaskedImage.h:442
boost::mpl::vector< ImagePixelT, MaskPixelT, VariancePixelT > PixelTVec
Definition: MaskedImage.h:428
_view_t::reverse_iterator reverse_iterator
An STL compliant reverse iterator.
Definition: ImageBase.h:133
std::shared_ptr< image::Mask< MaskPixelT > > MaskPtr
shared pointer to the Mask
Definition: MaskedImage.h:86
const_MaskedImageIterator< typename Image::iterator, typename Mask::iterator, typename Variance::iterator > const_iterator
Definition: MaskedImage.h:551
boost::zip_iterator< IMV_iterator_tuple > _iter
Definition: MaskedImage.h:211
Image< LhsPixelT > & operator+=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Add lhs to Image rhs (i.e. pixel-by-pixel addition) where types are different.
Definition: Image.cc:649
bool operator!=(Coord const &lhs, Coord const &rhs)
Inequality; the complement of equality.
Definition: Coord.h:818
afw::table::Key< afw::table::Array< MaskPixelT > > mask
Pixel type
Type pointed to by the iterator.
Definition: MaskedImage.h:140
A templated class to return this classes&#39; type (present in Image/Mask/MaskedImage) ...
Definition: MaskedImage.h:100
Pixel operator()(int x, int y)
Dereference a locator, returning a Pixel offset by (x, y) from the locator.
Definition: MaskedImage.h:397
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:572
const_MaskedImageLocator(MaskedImageLocator< ImageLocator, MaskLocator, VarianceLocator > const &iter)
Definition: MaskedImage.h:536
boost::tuple< typename ImageLocator::cached_location_t, typename MaskLocator::cached_location_t, typename VarianceLocator::cached_location_t > IMVCachedLocation
Definition: MaskedImage.h:361
y_iterator y_at(int x, int y) const
Return an y_iterator at the point (x, y)
Definition: MaskedImage.h:1223
std::map< std::string, int > MaskPlaneDict
Definition: Mask.h:64
std::shared_ptr< Image< PixelT > > operator*(Image< PixelT > const &img, ImageSlice< PixelT > const &slc)
Overload operator*()
Definition: ImageSlice.cc:104
Pixel operator*()
Dereference a locator, returning a Pixel.
Definition: MaskedImage.h:391
Options for writing an image to FITS.
Definition: fits.h:201
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:473
bool operator==(MaskedImageIteratorBase const &rhs)
Return true if the lhs equals the rhs.
Definition: MaskedImage.h:188
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
Definition: ImageBase.h:137
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:404
Ref< typename boost::mpl::at< PixelTVec, N >::type >::type apply_IMV(cached_location_t const &cached_loc)
Definition: MaskedImage.h:431
The base class for MaskedImageIterators (const and non-const)
Definition: MaskedImage.h:126
detail::MaskPlaneDict MaskPlaneDict
Definition: Mask.h:85
bool operator==(CoordKey const &lhs, CoordKey const &rhs)
Compare CoordKeys for equality using the constituent Keys.
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:564
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:458
lsst::afw::image::pixel::SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > SinglePixel
A single Pixel of the same type as those in the MaskedImage.
Definition: MaskedImage.h:121
A single pixel of the same type as a MaskedImage.
Definition: Pixel.h:71
std::shared_ptr< image::Image< VariancePixelT > > VariancePtr
shared pointer to the variance Image
Definition: MaskedImage.h:88
void setXY0(geom::Point2I const origin)
Set the MaskedImage&#39;s origin.
Definition: MaskedImage.h:1125
MaskedImageIteratorBase operator++(int)
Increment the iterator (postfix)
Definition: MaskedImage.h:178
MaskedImage & operator-=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:836
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:375
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:279
lsst::afw::image::Mask< MaskPixelT > Mask
Definition: MaskedImage.h:94
MaskedImageIteratorBase & operator+=(std::ptrdiff_t delta)
Increment the iterator by delta
Definition: MaskedImage.h:161
A Function taking two arguments.
Definition: Function.h:266
geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: MaskedImage.h:1081
MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > * makeMaskedImage(typename std::shared_ptr< Image< ImagePixelT >> image, typename std::shared_ptr< Mask< MaskPixelT >> mask=Mask< MaskPixelT >(), typename std::shared_ptr< Image< VariancePixelT >> variance=Image< VariancePixelT >())
A function to return a MaskedImage of the correct type (cf.
Definition: MaskedImage.h:1267
x_iterator x_at(int x, int y) const
Return an x_iterator at the point (x, y)
Definition: MaskedImage.h:1203
const_MaskedImageIterator & operator+(std::ptrdiff_t delta)
Return a const_MaskedImageIterator that&#39;s delta beyond this.
Definition: MaskedImage.h:258
MaskedImageIterator< typename Image::iterator, typename Mask::iterator, typename Variance::iterator > iterator
Definition: MaskedImage.h:547
An integer coordinate rectangle.
Definition: Box.h:55
Ref< VariancePixelT >::type variance()
Return (a reference to) the variance part of the Pixel pointed at by the iterator.
Definition: MaskedImage.h:153
bool operator==(MaskedImageLocatorBase const &rhs)
Return true iff two locators are equal.
Definition: MaskedImage.h:478
Mask< MaskPixelT >::MaskPlaneDict MaskPlaneDict
The Mask&#39;s MaskPlaneDict.
Definition: MaskedImage.h:90
ImagePtr getImage() const
Return a (shared_ptr to) the MaskedImage&#39;s image.
Definition: MaskedImage.h:1041
MaskedImage & operator/=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:864
bool operator!=(MaskedImageIteratorBase const &rhs)
Return true if the lhs doesn&#39;t equal the rhs.
Definition: MaskedImage.h:192
MaskedImage & operator+=(lsst::afw::math::Function2< double > const &function)
Definition: MaskedImage.h:813
_view_t::iterator iterator
An STL compliant iterator.
Definition: ImageBase.h:129
double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const
Convert image index to image position (see Image::indexToPosition)
Definition: MaskedImage.h:1144
_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:363
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:44
geom::Extent2I getDimensions() const
Definition: MaskedImage.h:1080
int getHeight() const
Return the number of rows in the image.
Definition: MaskedImage.h:1079
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:737
A base class for image defects.
Definition: cameraGeom.dox:3
int end
int getX0() const
Return the image&#39;s column-origin.
Definition: MaskedImage.h:1089
static MaskedImage readFits(fits::MemFileManager &manager)
Read a MaskedImage from a FITS RAM file.
Definition: MaskedImage.h:1034
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:83
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:576
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:101
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:580
A traits class for MaskedImage.
Definition: MaskedImage.h:53
_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:365
const IMV_iterator_tuple get_iterator_tuple() const
Return the underlying iterator tuple.
Definition: MaskedImage.h:158
const Pixel operator*() const
Dereference the iterator, returning a const Pixel.
Definition: MaskedImage.h:208
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:81
_view_t::y_iterator y_iterator
An iterator for traversing the pixels in a column.
Definition: ImageBase.h:147
MaskedImageIterator< typename Image::reverse_iterator, typename Mask::reverse_iterator, typename Variance::reverse_iterator > reverse_iterator
Definition: MaskedImage.h:555
std::shared_ptr< image::Image< ImagePixelT > > ImagePtr
shared pointer to the Image
Definition: MaskedImage.h:84
detail::MaskedImage_tag image_category
Definition: MaskedImage.h:96
boost::zip_iterator< IMV_iterator_tuple >::reference IMV_tuple
The underlying iterator tuple.
Definition: MaskedImage.h:133
double x
Ref< ImagePixelT >::type image()
Return (a reference to) the image part of the Pixel pointed at by the iterator.
Definition: MaskedImage.h:147
A saved relative position, providing efficient access to neighbouring pixels.
Definition: MaskedImage.h:367
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks
Pixel operator*()
Dereference the iterator, returning a Pixel.
Definition: MaskedImage.h:206
void setMask(Mask const &other)
Set the mask plane&#39;s pixel values to those of another Mask.
Definition: MaskedImage.h:1062
bool operator!=(MaskedImageLocatorBase const &rhs)
Return true iff two locators are not equal.
Definition: MaskedImage.h:482
lsst::afw::image::Image< VariancePixelT > Variance
Definition: MaskedImage.h:92
MaskPtr getMask() const
Return a (shared_ptr to) the MaskedImage&#39;s mask.
Definition: MaskedImage.h:1053
std::string const compressedFileNoMEF_RE
regexp to identify compressed files that we can&#39;t write MEFs to
Definition: MaskedImage.h:60
void swap(Image< PixelT > &a, Image< PixelT > &b)
Definition: Image.cc:442
int getY0() const
Return the image&#39;s row-origin.
Definition: MaskedImage.h:1097
std::ptrdiff_t operator-(MaskedImageIteratorBase const &rhs)
Return the distance between two iterators.
Definition: MaskedImage.h:184
Ref< ImagePixelT >::type image()
Return a reference to the image at the current position of the locator.
Definition: MaskedImage.h:453
x_iterator x()
Return an iterator that can be used to move (or dereference) a locator.
Definition: MaskedImage.h:413
A pixel of a MaskedImage.
Definition: Pixel.h:146
MaskedImageIteratorBase & operator++()
Increment the iterator (prefix)
Definition: MaskedImage.h:173
An const iterator to the MaskedImage.
Definition: MaskedImage.h:110
MaskedImage & operator+=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:809
Image< LhsPixelT > & operator*=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Multiply lhs by Image rhs (i.e. pixel-by-pixel multiplication) where types are different.
Definition: Image.cc:661
std::string const fitsFile_RE
regexp to identify when MaskedImages should be written as MEFs
Definition: MaskedImage.h:58
MaskedImageIterator(ImageIterator &img, MaskIterator &msk, VarianceIterator &var)
Definition: MaskedImage.h:222
MaskedImageIteratorBase & operator-=(std::ptrdiff_t delta)
Decrement the iterator by delta
Definition: MaskedImage.h:167
Class implementing persistence and retrieval for MaskedImages.
const_MaskedImageIterator(MaskedImageIterator< ImageIterator, MaskIterator, VarianceIterator > const &iter)
Definition: MaskedImage.h:249
void setXY0(int const x0, int const y0)
Set the MaskedImage&#39;s origin.
Definition: MaskedImage.h:1115
Image< LhsPixelT > & operator-=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Subtract lhs from Image rhs (i.e. pixel-by-pixel subtraction) where types are different.
Definition: Image.cc:655
bool operator<(MaskedImageLocatorBase const &rhs)
Return true iff lhs is less than rhs.
Definition: MaskedImage.h:484
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:464
void setImage(Image const &other)
Set the image plane&#39;s pixel values to those of another Image.
Definition: MaskedImage.h:1050
Ref< VariancePixelT >::type variance()
Return a reference to the variance at the current position of the locator.
Definition: MaskedImage.h:471
void setVariance(Variance const &other)
Set the variance plane&#39;s pixel values to those of another Image.
Definition: MaskedImage.h:1071
int getWidth() const
Return the number of columns in the image.
Definition: MaskedImage.h:1077
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:593
static MaskedImage readFits(std::string const &filename)
Read a MaskedImage from a regular FITS file.
Definition: MaskedImage.h:1025
MaskedImage & operator*=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:854
MaskedImage< ImagePT, MaskPT, VarPT > type
Return the desired type.
Definition: MaskedImage.h:102
Image< LhsPixelT > & operator/=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Divide lhs by Image rhs (i.e. pixel-by-pixel division) where types are different. ...
Definition: Image.cc:667
lsst::afw::image::Image< ImagePixelT > Image
Definition: MaskedImage.h:93
MaskedImageLocator< typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator > xy_locator
A locator for a MaskedImage.
Definition: MaskedImage.h:585
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:596
bool operator<(MaskedImageIteratorBase const &rhs)
Return true if the lhs is less than the rhs.
Definition: MaskedImage.h:196
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:467
float VariancePixel
default type for MaskedImage variance images
A class used to identify classes that represent MaskedImage pixels.
Definition: MaskedImage.h:55
MaskedImageLocatorBase(ImageLocator const &img, MaskLocator const &msk, VarianceLocator const &var)
Construct a MaskedImageLocator from image/mask/variance locators.
Definition: MaskedImage.h:385
_view_t::xy_locator xy_locator
An xy_locator.
Definition: ImageBase.h:125
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:68
MaskedImageLocatorBase & operator+=(pair2I const &p)
Increment the locator&#39;s x and y positions by p
Definition: MaskedImage.h:489
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:568
xy_locator xy_at(int x, int y) const
Return an xy_locator at the point (x, y)
Definition: MaskedImage.h:1237
geom::Point2I getXY0() const
Return the image&#39;s origin.
Definition: MaskedImage.h:1105
A const locator for the MaskedImage.
Definition: MaskedImage.h:116
metafunction to extract reference type from PixelT
Definition: ImageBase.h:89
Ref< typename boost::mpl::at< PixelTVec, N >::type >::type apply_IMV()
Definition: MaskedImage.h:437
metafunction to extract const reference type from PixelT
Definition: ImageBase.h:94