LSSTApplications  18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
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 
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/afw/image/Image.h"
43 #include "lsst/afw/image/Mask.h"
44 
45 namespace lsst {
46 namespace afw {
47 namespace image {
48 namespace detail {
50 struct MaskedImage_tag : public basic_tag {};
53 
55 std::string const fitsFile_RE = "\\.fits(\\.[fg]z)?$";
58 } // namespace detail
59 } // namespace image
60 } // namespace afw
61 } // namespace lsst
62 
63 #include "lsst/afw/image/Pixel.h"
65 
66 namespace lsst {
67 namespace afw {
68 namespace image {
69 
71 template <typename ImagePixelT, typename MaskPixelT = lsst::afw::image::MaskPixel,
72  typename VariancePixelT = lsst::afw::image::VariancePixel>
73 class MaskedImage {
74 public:
83 
87 
89 
91  template <typename ImagePT = ImagePixelT, typename MaskPT = MaskPixelT, typename VarPT = VariancePixelT>
95  };
96 
98  template <typename, typename, typename>
101  template <typename, typename, typename>
104  template <typename, typename, typename>
107  template <typename, typename, typename>
108  class const_MaskedImageLocator;
109 
114 
116  template <typename ImageIterator, typename MaskIterator, typename VarianceIterator,
117  template <typename> class Ref = Reference>
119  typedef boost::tuple<ImageIterator, MaskIterator, VarianceIterator> IMV_iterator_tuple;
120 
121  public:
125  typedef typename boost::zip_iterator<IMV_iterator_tuple>::reference IMV_tuple;
129  template <typename, typename, typename>
132  typedef Pixel type;
133 
135  MaskedImageIteratorBase(ImageIterator const& img, MaskIterator const& msk,
136  VarianceIterator const& var)
137  : _iter(boost::make_zip_iterator(boost::make_tuple(img, msk, var))) {}
139  typename Ref<ImagePixelT>::type image() { return _iter->template get<0>()[0]; }
140 
142  typename Ref<MaskPixelT>::type mask() { return _iter->template get<1>()[0]; }
143 
145  typename Ref<VariancePixelT>::type variance() { return _iter->template get<2>()[0]; }
146 
150  const IMV_iterator_tuple get_iterator_tuple() const { return _iter.get_iterator_tuple(); }
151 
154  ) {
155  _iter += delta;
156  return *this;
157  }
160  ) {
161  _iter -= delta;
162  return *this;
163  }
166  ++_iter;
167  return *this;
168  }
171  MaskedImageIteratorBase tmp(*this);
172  _iter++;
173  return tmp;
174  }
177  return &this->_iter->template get<0>() - &rhs._iter->template get<0>();
178  }
181  return &this->_iter->template get<0>() == &rhs._iter->template get<0>();
182  }
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  }
192  operator Pixel() const {
193  return Pixel(_iter->template get<0>()[0], _iter->template get<1>()[0],
194  _iter->template get<2>()[0]);
195  }
196 
198  Pixel operator*() { return Pixel(image(), mask(), variance()); }
200  const Pixel operator*() const { return Pixel(image(), mask(), variance()); }
201 
202  protected:
203  typename boost::zip_iterator<IMV_iterator_tuple> _iter;
204  };
205 
207  template <typename ImageIterator, typename MaskIterator, typename VarianceIterator>
208  class MaskedImageIterator
209  : public MaskedImageIteratorBase<ImageIterator, MaskIterator, VarianceIterator> {
211  MaskedImageIteratorBase_t;
212 
213  public:
214  MaskedImageIterator(ImageIterator& img, MaskIterator& msk, VarianceIterator& var)
215  : MaskedImageIteratorBase_t(img, msk, var) {}
218  MaskedImageIterator lhs = *this;
219  lhs += delta;
220 
221  return lhs;
222  }
223  };
224 
226  template <typename ImageIterator, typename MaskIterator, typename VarianceIterator>
228  : public MaskedImageIteratorBase<typename detail::const_iterator_type<ImageIterator>::type,
229  typename detail::const_iterator_type<MaskIterator>::type,
230  typename detail::const_iterator_type<VarianceIterator>::type,
231  ConstReference> {
232  typedef typename detail::const_iterator_type<ImageIterator>::type const_ImageIterator;
233  typedef typename detail::const_iterator_type<MaskIterator>::type const_MaskIterator;
234  typedef typename detail::const_iterator_type<VarianceIterator>::type const_VarianceIterator;
235 
236  typedef MaskedImageIteratorBase<const_ImageIterator, const_MaskIterator, const_VarianceIterator,
239 
240  public:
243  : MaskedImageIteratorBase_t(
244  const_ImageIterator(iter.get_iterator_tuple().template get<0>()),
245  const_MaskIterator(iter.get_iterator_tuple().template get<1>()),
246  const_VarianceIterator(iter.get_iterator_tuple().template get<2>())) {
247  ;
248  }
251  const_MaskedImageIterator lhs = *this;
252  lhs += delta;
253 
254  return lhs;
255  }
256  };
257 
259  template <typename ImageLocator, typename MaskLocator, typename VarianceLocator,
260  template <typename> class Ref = Reference>
262  typedef typename boost::tuple<ImageLocator, MaskLocator, VarianceLocator> IMVLocator;
263  //
264  // A class to provide _[xy]_iterator for MaskedImageLocator. We can't just use
265  // a zip_iterator as moving this iterator must be the same as moving the locator
266  // itself, for consistency with {Image,Mask}::xy_locator
267  //
268  template <template <typename> class X_OR_Y>
269  class _x_or_y_iterator {
270  public:
271  _x_or_y_iterator(MaskedImageLocatorBase* mil) : _mil(mil) {}
272 
273  _x_or_y_iterator& operator+=(const int di) {
274  // Equivalent to "_mil->_loc.template get<0>().x() += di;"
275  X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())() += di;
276  X_OR_Y<MaskLocator>(_mil->_loc.template get<1>())() += di;
277  X_OR_Y<VarianceLocator>(_mil->_loc.template get<2>())() += di;
278  return *this;
279  }
280 
281  _x_or_y_iterator& operator++() { // prefix
282  // Equivalent to "++_mil->_loc.template get<0>().x();"
283  ++X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())();
284  ++X_OR_Y<MaskLocator>(_mil->_loc.template get<1>())();
285  ++X_OR_Y<VarianceLocator>(_mil->_loc.template get<2>())();
286  return *this;
287  }
288 
289  bool operator==(_x_or_y_iterator const& rhs) {
290  return X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())() ==
291  X_OR_Y<ImageLocator>(rhs._mil->_loc.template get<0>())();
292  }
293  bool operator!=(_x_or_y_iterator const& rhs) {
294  return X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())() !=
295  X_OR_Y<ImageLocator>(rhs._mil->_loc.template get<0>())();
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 
302  Pixel operator*() {
303  return Pixel((*(X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())()))[0],
304  (*(X_OR_Y<MaskLocator>(_mil->_loc.template get<1>())()))[0],
305  (*(X_OR_Y<VarianceLocator>(_mil->_loc.template get<2>())()))[0]);
306  }
307 
308  typename Ref<ImagePixelT>::type image() {
309  // Equivalent to "return (*_mil->_loc.template get<0>().x())[0];"
310 
311  return (*(X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())()))[0];
312  }
313  typename Ref<MaskPixelT>::type mask() {
314  return (*(X_OR_Y<MaskLocator>(_mil->_loc.template get<1>())()))[0];
315  }
317  return (*(X_OR_Y<VarianceLocator>(_mil->_loc.template get<2>())()))[0];
318  }
319 
320  protected:
322  };
323 
324  // Two classes to provide .x() and .y() in _x_or_y_iterator
325  template <typename LocT>
326  class apply_x {
327  typedef typename LocT::x_iterator IterT;
328 
329  public:
330  apply_x(LocT& loc) : _loc(loc) {}
331  IterT& operator()() { return _loc.x(); }
332 
333  private:
334  LocT& _loc;
335  };
336 
337  template <typename LocT>
338  class apply_y {
339  typedef typename LocT::y_iterator IterT;
340 
341  public:
342  apply_y(LocT& loc) : _loc(loc) {}
343  IterT& operator()() { return _loc.y(); }
344 
345  private:
346  LocT& _loc;
347  };
348 
349  public:
350  typedef typename boost::tuple<typename ImageLocator::cached_location_t,
351  typename MaskLocator::cached_location_t,
352  typename VarianceLocator::cached_location_t>
355  typedef _x_or_y_iterator<apply_x> x_iterator;
357  typedef _x_or_y_iterator<apply_y> y_iterator;
360  public:
361  // template<typename, typename, typename, template<typename> class> friend class
362  // MaskedImageLocatorBase;
363  template <typename, typename, typename>
365 
367  cached_location_t(IMVLocator const& loc, int x, int y)
368  : _imv(loc.template get<0>().cache_location(x, y),
369  loc.template get<1>().cache_location(x, y),
370  loc.template get<2>().cache_location(x, y)) {
371  ;
372  }
373  // protected:
375  };
377  MaskedImageLocatorBase(ImageLocator const& img, MaskLocator const& msk, VarianceLocator const& var)
378  : _loc(img, msk, var) {
379  ;
380  }
381 
383  Pixel operator*() {
384  return Pixel(_loc.template get<0>().x()[0][0], _loc.template get<1>().x()[0][0],
385  _loc.template get<2>().x()[0][0]);
386  }
387 
389  Pixel operator()(int x, int y) {
390  return Pixel(_loc.template get<0>()(x, y)[0], _loc.template get<1>()(x, y)[0],
391  _loc.template get<2>()(x, y)[0]);
392  }
393 
396  Pixel operator[](cached_location_t const& cached_loc) {
397  return Pixel(_loc.template get<0>()[cached_loc._imv.template get<0>()][0],
398  _loc.template get<1>()[cached_loc._imv.template get<1>()][0],
399  _loc.template get<2>()[cached_loc._imv.template get<2>()][0]);
400  }
405  x_iterator x() { return x_iterator(this); }
406 
411  y_iterator y() { return y_iterator(this); }
412 
414  cached_location_t cache_location(int x, int y) const { return cached_location_t(_loc, x, y); }
415  //
416  // We don't want to duplicate code for image/mask/variance -- but the boost::mpl stuff isn't pretty
417  // as we can't say int_<N> within a template<int N>. So define a set of functions apply_IMV
418  // to do the dirty work
419  //
420  typedef typename boost::mpl::vector<ImagePixelT, MaskPixelT, VariancePixelT> PixelTVec;
421 
422  template <typename N>
424  cached_location_t const& cached_loc) {
425  return _loc.template get<N::value>()[cached_loc._imv.template get<N::value>()][0];
426  }
427 
428  template <typename N>
430  return _loc.template get<N::value>()[0][0];
431  }
432 
433  template <typename N>
435  return _loc.template get<N::value>()(x, y)[0];
436  }
437  //
438  // Use those templated classes to implement image/mask/variance
439  //
441  typename Ref<ImagePixelT>::type image(cached_location_t const& cached_loc) {
442  return apply_IMV<boost::mpl::int_<0>>(cached_loc);
443  }
445  typename Ref<ImagePixelT>::type image() { return apply_IMV<boost::mpl::int_<0>>(); }
447  typename Ref<ImagePixelT>::type image(int x, int y) { return apply_IMV<boost::mpl::int_<0>>(x, y); }
448 
450  typename Ref<MaskPixelT>::type mask(cached_location_t const& cached_loc) {
451  return apply_IMV<boost::mpl::int_<1>>(cached_loc);
452  }
454  typename Ref<MaskPixelT>::type mask() { return apply_IMV<boost::mpl::int_<1>>(); }
456  typename Ref<MaskPixelT>::type mask(int x, int y) { return apply_IMV<boost::mpl::int_<1>>(x, y); }
457 
459  typename Ref<VariancePixelT>::type variance(cached_location_t const& cached_loc) {
460  return apply_IMV<boost::mpl::int_<2>>(cached_loc);
461  }
463  typename Ref<VariancePixelT>::type variance() { return apply_IMV<boost::mpl::int_<2>>(); }
465  typename Ref<VariancePixelT>::type variance(int x, int y) {
466  return apply_IMV<boost::mpl::int_<2>>(x, y);
467  }
468 
471  return _loc.template get<0>() == rhs._loc.template get<0>();
472  }
474  bool operator!=(MaskedImageLocatorBase const& rhs) { return !(*this == rhs); }
477  return _loc.template get<0>() < rhs._loc.template get<0>();
478  }
479 
481  MaskedImageLocatorBase& operator+=(pair2I const& p) {
482  return operator+=(detail::difference_type(p.first, p.second));
483  }
484 
486  MaskedImageLocatorBase& operator+=(detail::difference_type p) {
487  _loc.template get<0>() += p;
488  _loc.template get<1>() += p;
489  _loc.template get<2>() += p;
490 
491  return *this;
492  }
493 
494  // Workaround for DM-5590: clang-3.8 cannot access _loc from
495  // friend class const_MaskedImageLocator.
496  IMVLocator const& getLoc() const { return _loc; }
497 
498  protected:
499  IMVLocator _loc;
500  };
501 
503  template <typename ImageLocator, typename MaskLocator, typename VarianceLocator>
504  class MaskedImageLocator : public MaskedImageLocatorBase<ImageLocator, MaskLocator, VarianceLocator> {
506 
507  public:
508  MaskedImageLocator(ImageLocator& img, MaskLocator& msk, VarianceLocator& var)
509  : MaskedImageLocatorBase_t(img, msk, var) {}
510  };
511 
513  template <typename ImageLocator, typename MaskLocator, typename VarianceLocator>
515  : public MaskedImageLocatorBase<typename detail::const_locator_type<ImageLocator>::type,
516  typename detail::const_locator_type<MaskLocator>::type,
517  typename detail::const_locator_type<VarianceLocator>::type,
518  ConstReference> {
519  typedef typename detail::const_locator_type<ImageLocator>::type const_ImageLocator;
520  typedef typename detail::const_locator_type<MaskLocator>::type const_MaskLocator;
521  typedef typename detail::const_locator_type<VarianceLocator>::type const_VarianceLocator;
522 
523  typedef MaskedImageLocatorBase<const_ImageLocator, const_MaskLocator, const_VarianceLocator,
526 
527  public:
529  : MaskedImageLocatorBase_t(const_ImageLocator(iter.getLoc().template get<0>()),
530  const_MaskLocator(iter.getLoc().template get<1>()),
531  const_VarianceLocator(iter.getLoc().template get<2>())) {
532  ;
533  }
534  };
535 
536  // An iterator to a MaskedImage
537  typedef MaskedImageIterator<typename Image::iterator, typename Mask::iterator,
538  typename Variance::iterator>
540  // A const_iterator to a MaskedImage
541  typedef const_MaskedImageIterator<typename Image::iterator, typename Mask::iterator,
542  typename Variance::iterator>
544  // A reverse_iterator to a MaskedImage
545  typedef MaskedImageIterator<typename Image::reverse_iterator, typename Mask::reverse_iterator,
548 #if 0 // doesn't compile. I should fix this, but it's low priority. RHL
549  typedef const_MaskedImageIterator<typename Image::reverse_iterator,
551  typename Mask::reverse_iterator, typename Variance::reverse_iterator> const_reverse_iterator;
552 #endif
553  typedef MaskedImageIterator<typename Image::x_iterator, typename Mask::x_iterator,
555  typename Variance::x_iterator>
558  typedef const_MaskedImageIterator<typename Image::x_iterator, typename Mask::x_iterator,
559  typename Variance::x_iterator>
566  typedef MaskedImageIterator<typename Image::y_iterator, typename Mask::y_iterator,
567  typename Variance::y_iterator>
570  typedef const_MaskedImageIterator<typename Image::y_iterator, typename Mask::y_iterator,
571  typename Variance::y_iterator>
573 
575  typedef MaskedImageLocator<typename Image::xy_locator, typename Mask::xy_locator,
576  typename Variance::xy_locator>
579  typedef const_MaskedImageLocator<typename Image::xy_locator, typename Mask::xy_locator,
580  typename Variance::xy_locator>
582 
584  typedef typename MaskedImageLocator<typename Image::xy_locator, typename Mask::xy_locator,
587  typedef typename MaskedImageLocator<typename Image::xy_locator, typename Mask::xy_locator,
589 
590  // Constructors
598  explicit MaskedImage(unsigned int width, unsigned int height,
599  MaskPlaneDict const& planeDict = MaskPlaneDict());
607  MaskPlaneDict const& planeDict = MaskPlaneDict());
616  explicit MaskedImage(ImagePtr image, MaskPtr mask = MaskPtr(), VariancePtr variance = VariancePtr());
628  explicit MaskedImage(lsst::geom::Box2I const& bbox, MaskPlaneDict const& planeDict = MaskPlaneDict());
629 
647  explicit MaskedImage(
648  std::string const& fileName,
650  lsst::geom::Box2I const& bbox = lsst::geom::Box2I(), ImageOrigin origin = PARENT,
651  bool conformMasks = false, bool needAllHdus = false,
654  std::shared_ptr<daf::base::PropertySet> varianceMetadata =
656  bool allowUnsafe = false);
657 
675  explicit MaskedImage(
676  fits::MemFileManager& manager,
678  lsst::geom::Box2I const& bbox = lsst::geom::Box2I(), ImageOrigin origin = PARENT,
679  bool conformMasks = false, bool needAllHdus = false,
682  std::shared_ptr<daf::base::PropertySet> varianceMetadata =
684  bool allowUnsafe = false);
685 
703  explicit MaskedImage(
704  fits::Fits& fitsfile,
706  lsst::geom::Box2I const& bbox = lsst::geom::Box2I(), ImageOrigin origin = PARENT,
707  bool conformMasks = false, bool needAllHdus = false,
710  std::shared_ptr<daf::base::PropertySet> varianceMetadata =
712  bool allowUnsafe = false);
713 
720  MaskedImage(MaskedImage const& rhs, bool const deep = false);
721  MaskedImage(MaskedImage&& rhs);
722 
732  MaskedImage(MaskedImage const& rhs, lsst::geom::Box2I const& bbox, ImageOrigin const origin = PARENT,
733  bool const deep = false);
739  template <typename OtherPixelT>
741 
742  const bool deep
743  )
744  : _image(), _mask(), _variance() {
745  if (!deep) {
747  "Only deep copies are permitted for MaskedImages with different pixel types");
748  }
749 
750  _image = ImagePtr(new Image(*rhs.getImage(), deep));
751  _mask = MaskPtr(new Mask(*rhs.getMask(), deep));
752  _variance = VariancePtr(new Variance(*rhs.getVariance(), deep));
753  }
754 
764  MaskedImage& operator=(MaskedImage const& rhs);
765  MaskedImage& operator=(MaskedImage&& rhs);
766 
767  virtual ~MaskedImage() = default;
768 
769  void swap(MaskedImage& rhs);
770 
771  // Operators
773  MaskedImage& operator=(Pixel const& rhs);
775  MaskedImage& operator=(SinglePixel const& rhs);
776 
790  MaskedImage subset(lsst::geom::Box2I const& bbox, ImageOrigin origin = PARENT) const {
791  return MaskedImage(*this, bbox, origin, false);
792  }
793 
795  MaskedImage operator[](lsst::geom::Box2I const& bbox) const { return subset(bbox); }
796 
804  [[deprecated("Use `assign` instead. To be removed after 20.0.0.")]] // DM-22276
805  MaskedImage&
806  operator<<=(MaskedImage const& rhs);
807 
819  void assign(MaskedImage const& rhs, lsst::geom::Box2I const& bbox = lsst::geom::Box2I(),
820  ImageOrigin origin = PARENT);
821 
823  MaskedImage& operator+=(ImagePixelT const rhs);
833  MaskedImage& operator+=(MaskedImage const& rhs);
835  *_image += rhs;
836  return *this;
837  }
839  *_image += function;
840  return *this;
841  }
850  void scaledPlus(double const c, MaskedImage const& rhs);
851 
853  MaskedImage& operator-=(ImagePixelT const rhs);
860  MaskedImage& operator-=(MaskedImage const& rhs);
862  *_image -= rhs;
863  return *this;
864  }
866  *_image -= function;
867  return *this;
868  }
875  void scaledMinus(double const c, MaskedImage const& rhs);
876 
877  MaskedImage& operator*=(ImagePixelT const rhs);
878  MaskedImage& operator*=(MaskedImage const& rhs);
880  *_image *= rhs;
881  *_variance *= rhs; // yes, multiply twice
882  *_variance *= rhs;
883  return *this;
884  }
885  void scaledMultiplies(double const c, MaskedImage const& rhs);
886 
887  MaskedImage& operator/=(ImagePixelT const rhs);
888  MaskedImage& operator/=(MaskedImage const& rhs);
890  *_image /= rhs;
891  *_variance /= rhs; // yes, divide twice
892  *_variance /= rhs;
893  return *this;
894  }
895  void scaledDivides(double const c, MaskedImage const& rhs);
896 
911  void writeFits(std::string const& fileName,
920 
934  void writeFits(fits::MemFileManager& manager,
943 
957  void writeFits(fits::Fits& fitsfile,
966 
983  void writeFits(std::string const& fileName, fits::ImageWriteOptions const& imageOptions,
984  fits::ImageWriteOptions const& maskOptions, fits::ImageWriteOptions const& varianceOptions,
986  std::shared_ptr<daf::base::PropertySet const> imageMetadata = nullptr,
987  std::shared_ptr<daf::base::PropertySet const> maskMetadata = nullptr,
988  std::shared_ptr<daf::base::PropertySet const> varianceMetadata = nullptr) const;
989 
1006  void writeFits(fits::MemFileManager& manager, fits::ImageWriteOptions const& imageOptions,
1007  fits::ImageWriteOptions const& maskOptions, fits::ImageWriteOptions const& varianceOptions,
1009  std::shared_ptr<daf::base::PropertySet const> imageMetadata = nullptr,
1010  std::shared_ptr<daf::base::PropertySet const> maskMetadata = nullptr,
1011  std::shared_ptr<daf::base::PropertySet const> varianceMetadata = nullptr) const;
1012 
1029  void writeFits(fits::Fits& fitsfile, fits::ImageWriteOptions const& imageOptions,
1030  fits::ImageWriteOptions const& maskOptions, fits::ImageWriteOptions const& varianceOptions,
1032  std::shared_ptr<daf::base::PropertySet const> imageMetadata = nullptr,
1033  std::shared_ptr<daf::base::PropertySet const> maskMetadata = nullptr,
1034  std::shared_ptr<daf::base::PropertySet const> varianceMetadata = nullptr) const;
1035 
1041  static MaskedImage readFits(std::string const& filename) {
1043  }
1044 
1052  }
1053 
1054  // Getters
1055 
1057  ImagePtr getImage() const { return _image; }
1058 
1066  void setImage(Image const& other) { _image->assign(other); }
1067 
1069  MaskPtr getMask() const { return _mask; }
1070 
1078  void setMask(Mask const& other) { _mask->assign(other); }
1079 
1087  void setVariance(Variance const& other) { _variance->assign(other); }
1088 
1090  VariancePtr getVariance() const { return _variance; }
1091 
1093  int getWidth() const { return _image->getWidth(); }
1095  int getHeight() const { return _image->getHeight(); }
1096  lsst::geom::Extent2I getDimensions() const { return _image->getDimensions(); }
1097  lsst::geom::Box2I getBBox(ImageOrigin const origin = PARENT) const { return _image->getBBox(origin); }
1105  int getX0() const { return _image->getX0(); }
1113  int getY0() const { return _image->getY0(); }
1121  lsst::geom::Point2I getXY0() const { return _image->getXY0(); }
1122 
1131  void setXY0(int const x0, int const y0) { setXY0(lsst::geom::Point2I(x0, y0)); }
1132 
1141  void setXY0(lsst::geom::Point2I const origin) {
1142  if (_image) {
1143  _image->setXY0(origin);
1144  }
1145 
1146  if (_mask) {
1147  _mask->setXY0(origin);
1148  }
1149 
1150  if (_variance) {
1151  _variance->setXY0(origin);
1152  }
1153  }
1154 
1160  inline double indexToPosition(double ind,
1161  lsst::afw::image::xOrY const xy
1162  ) const {
1163  return getImage()->indexToPosition(ind, xy);
1164  }
1165 
1172  double const pos,
1173  lsst::afw::image::xOrY const xy
1174  ) const {
1175  return getImage()->positionToIndex(pos, xy);
1176  }
1177 
1178  //
1179  // Iterators and Locators
1180  //
1182  iterator begin() const;
1184  iterator end() const;
1186  iterator at(int const x, int const y) const;
1188  reverse_iterator rbegin() const;
1190  reverse_iterator rend() const;
1191 
1202  fast_iterator begin(bool contiguous) const;
1211  fast_iterator end(bool contiguous) const;
1212 
1214  x_iterator row_begin(int y) const;
1216  x_iterator row_end(int y) const;
1217 
1219  x_iterator x_at(int x, int y) const {
1220 #if 0
1221  typename Image::x_iterator imageEnd = getImage()->x_at(x, y);
1222  typename Mask::x_iterator maskEnd = getMask()->x_at(x, y);
1223  typename Variance::x_iterator varianceEnd = getVariance()->x_at(x, y);
1224 #else // bypass checks for non-NULL pointers
1225  typename Image::x_iterator imageEnd = _image->x_at(x, y);
1226  typename Mask::x_iterator maskEnd = _mask->x_at(x, y);
1227  typename Variance::x_iterator varianceEnd = _variance->x_at(x, y);
1228 #endif
1229 
1230  return x_iterator(imageEnd, maskEnd, varianceEnd);
1231  }
1232 
1234  y_iterator col_begin(int x) const;
1236  y_iterator col_end(int x) const;
1237 
1239  y_iterator y_at(int x, int y) const {
1240 #if 0
1241  typename Image::y_iterator imageEnd = getImage()->y_at(x, y);
1242  typename Mask::y_iterator maskEnd = getMask()->y_at(x, y);
1243  typename Variance::y_iterator varianceEnd = getVariance()->y_at(x, y);
1244 #else // bypass checks for non-NULL pointers
1245  typename Image::y_iterator imageEnd = _image->y_at(x, y);
1246  typename Mask::y_iterator maskEnd = _mask->y_at(x, y);
1247  typename Variance::y_iterator varianceEnd = _variance->y_at(x, y);
1248 #endif
1249  return y_iterator(imageEnd, maskEnd, varianceEnd);
1250  }
1251 
1253  xy_locator xy_at(int x, int y) const {
1254 #if 0
1255  typename Image::xy_locator imageEnd = getImage()->xy_at(x, y);
1256  typename Mask::xy_locator maskEnd = getMask()->xy_at(x, y);
1257  typename Variance::xy_locator varianceEnd = getVariance()->xy_at(x, y);
1258 #else // bypass checks for non-NULL pointers
1259  typename Image::xy_locator imageEnd = _image->xy_at(x, y);
1260  typename Mask::xy_locator maskEnd = _mask->xy_at(x, y);
1261  typename Variance::xy_locator varianceEnd = _variance->xy_at(x, y);
1262 #endif
1263 
1264  return xy_locator(imageEnd, maskEnd, varianceEnd);
1265  }
1266 
1267 private:
1268  void conformSizes();
1269 
1270  ImagePtr _image;
1271  MaskPtr _mask;
1272  VariancePtr _variance;
1273 };
1274 
1278 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
1280  typename std::shared_ptr<Image<ImagePixelT>> image,
1283 ) {
1285 }
1286 
1290 template <typename ImagePixelT1, typename ImagePixelT2>
1293 
1294 /*
1295  * Some metafunctions to extract an Image pointer from a MaskedImage pointer (or return the original Image
1296  * pointer)
1297  *
1298  * GetImage is the public interface (it forwards the tag --- just for the sake of the UI); the real work
1299  * is in GetImage_ which defines a typedef for the Image and a static function, getImage
1300  *
1301  * E.g.
1302  * In the function
1303  *
1304  * template<typename ImageT>
1305  * void func(shared_ptr<ImageT> image) {
1306  * typename shared_ptr<GetImage<ImageT>::type> im = GetImage<ImageT>::getImage(image);
1307  * }
1308  *
1309  * "im" is a shared_ptr<Image> irrespective of whether ImageT is Masked or not.
1310  */
1311 namespace {
1312 template <typename ImageT, typename TagT>
1313 struct GetImage_ {
1314  typedef ImageT type;
1315  static std::shared_ptr<type> getImage(std::shared_ptr<ImageT> image) { return image; }
1316 };
1317 
1318 template <typename ImageT>
1319 struct GetImage_<ImageT, typename image::detail::MaskedImage_tag> {
1320  typedef typename ImageT::Image type;
1321  static std::shared_ptr<type> getImage(std::shared_ptr<ImageT> image) { return image->getImage(); }
1322 };
1323 } // anonymous namespace
1324 
1325 template <typename ImageT>
1326 struct GetImage : public GetImage_<ImageT, typename ImageT::image_category> {};
1327 } // namespace image
1328 } // namespace afw
1329 } // namespace lsst
1330 
1331 #endif // LSST_IMAGE_MASKEDIMAGE_H
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
VariancePtr getVariance() const
Return a (shared_ptr to) the MaskedImage&#39;s variance.
Definition: MaskedImage.h:1090
MaskedImageLocatorBase & operator+=(detail::difference_type p)
Increment the locator&#39;s x and y positions by p
Definition: MaskedImage.h:486
cached_location_t cache_location(int x, int y) const
Create a cached_location_t offset by (x, y) from locator.
Definition: MaskedImage.h:414
MaskedImageIterator operator+(std::ptrdiff_t delta)
Return a MaskedImageIterator that&#39;s delta beyond this.
Definition: MaskedImage.h:217
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:1171
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:447
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:441
Ref< MaskPixelT >::type mask()
Return (a reference to) the mask part of the Pixel pointed at by the iterator.
Definition: MaskedImage.h:142
Ref< MaskPixelT >::type mask()
Return a reference to the mask at the current position of the locator.
Definition: MaskedImage.h:454
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:581
y_iterator y()
Return an iterator that can be used to move (or dereference) a locator.
Definition: MaskedImage.h:411
MaskedImageIteratorBase(ImageIterator const &img, MaskIterator const &msk, VarianceIterator const &var)
Construct a MaskedImageIteratorBase from the image/mask/variance iterators.
Definition: MaskedImage.h:135
afw::table::Key< afw::table::Array< ImagePixelT > > image
The base class for MaskedImageLocators (const and non-const)
Definition: MaskedImage.h:261
MaskedImageLocator(ImageLocator &img, MaskLocator &msk, VarianceLocator &var)
Definition: MaskedImage.h:508
Definition: Polygon.cc:25
MaskedImage & operator-=(lsst::afw::math::Function2< double > const &function)
Definition: MaskedImage.h:865
Ref< typename boost::mpl::at< PixelTVec, N >::type >::type apply_IMV(int x, int y)
Definition: MaskedImage.h:434
boost::mpl::vector< ImagePixelT, MaskPixelT, VariancePixelT > PixelTVec
Definition: MaskedImage.h:420
_view_t::reverse_iterator reverse_iterator
An STL compliant reverse iterator.
Definition: ImageBase.h:129
std::shared_ptr< image::Mask< MaskPixelT > > MaskPtr
shared pointer to the Mask
Definition: MaskedImage.h:78
const_MaskedImageIterator< typename Image::iterator, typename Mask::iterator, typename Variance::iterator > const_iterator
Definition: MaskedImage.h:543
boost::zip_iterator< IMV_iterator_tuple > _iter
Definition: MaskedImage.h:203
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:671
afw::table::Key< afw::table::Array< MaskPixelT > > mask
float Pixel
Typedefs to be used for pixel values.
Definition: common.h:37
Pixel type
Type pointed to by the iterator.
Definition: MaskedImage.h:132
A templated class to return this classes&#39; type (present in Image/Mask/MaskedImage) ...
Definition: MaskedImage.h:92
Pixel operator()(int x, int y)
Dereference a locator, returning a Pixel offset by (x, y) from the locator.
Definition: MaskedImage.h:389
lsst::afw::image::pixel::Pixel< ImagePixelT, MaskPixelT, VariancePixelT > Pixel
A Pixel in the MaskedImage.
Definition: MaskedImage.h:108
x_iterator fast_iterator
A fast STL compliant iterator for contiguous images N.b.
Definition: MaskedImage.h:564
const_MaskedImageLocator(MaskedImageLocator< ImageLocator, MaskLocator, VarianceLocator > const &iter)
Definition: MaskedImage.h:528
boost::tuple< typename ImageLocator::cached_location_t, typename MaskLocator::cached_location_t, typename VarianceLocator::cached_location_t > IMVCachedLocation
Definition: MaskedImage.h:353
y_iterator y_at(int x, int y) const
Return an y_iterator at the point (x, y)
Definition: MaskedImage.h:1239
std::map< std::string, int > MaskPlaneDict
Definition: Mask.h:58
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:383
Options for writing an image to FITS.
Definition: fits.h:219
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:465
bool operator==(MaskedImageIteratorBase const &rhs)
Return true if the lhs equals the rhs.
Definition: MaskedImage.h:180
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
Definition: ImageBase.h:133
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:396
Ref< typename boost::mpl::at< PixelTVec, N >::type >::type apply_IMV(cached_location_t const &cached_loc)
Definition: MaskedImage.h:423
int y
Definition: SpanSet.cc:49
The base class for MaskedImageIterators (const and non-const)
Definition: MaskedImage.h:118
MaskedImage operator[](lsst::geom::Box2I const &bbox) const
Return a subimage corresponding to the given box (interpreted as PARENT coordinates).
Definition: MaskedImage.h:795
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:556
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:450
void setXY0(lsst::geom::Point2I const origin)
Set the MaskedImage&#39;s origin.
Definition: MaskedImage.h:1141
lsst::afw::image::pixel::SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > SinglePixel
A single Pixel of the same type as those in the MaskedImage.
Definition: MaskedImage.h:113
A single pixel of the same type as a MaskedImage.
Definition: Pixel.h:73
std::shared_ptr< image::Image< VariancePixelT > > VariancePtr
shared pointer to the variance Image
Definition: MaskedImage.h:80
MaskedImageIteratorBase operator++(int)
Increment the iterator (postfix)
Definition: MaskedImage.h:170
ItemVariant const * other
Definition: Schema.cc:56
MaskedImage & operator-=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:861
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:367
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:297
lsst::geom::Point2I getXY0() const
Return the image&#39;s origin.
Definition: MaskedImage.h:1121
lsst::afw::image::Mask< MaskPixelT > Mask
Definition: MaskedImage.h:86
MaskedImageIteratorBase & operator+=(std::ptrdiff_t delta)
Increment the iterator by delta
Definition: MaskedImage.h:153
A Function taking two arguments.
Definition: Function.h:259
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:1279
x_iterator x_at(int x, int y) const
Return an x_iterator at the point (x, y)
Definition: MaskedImage.h:1219
const_MaskedImageIterator & operator+(std::ptrdiff_t delta)
Return a const_MaskedImageIterator that&#39;s delta beyond this.
Definition: MaskedImage.h:250
MaskedImageIterator< typename Image::iterator, typename Mask::iterator, typename Variance::iterator > iterator
Definition: MaskedImage.h:539
Ref< VariancePixelT >::type variance()
Return (a reference to) the variance part of the Pixel pointed at by the iterator.
Definition: MaskedImage.h:145
bool operator==(MaskedImageLocatorBase const &rhs)
Return true iff two locators are equal.
Definition: MaskedImage.h:470
Mask< MaskPixelT >::MaskPlaneDict MaskPlaneDict
The Mask&#39;s MaskPlaneDict.
Definition: MaskedImage.h:82
lsst::geom::Extent2I getDimensions() const
Definition: MaskedImage.h:1096
ImagePtr getImage() const
Return a (shared_ptr to) the MaskedImage&#39;s image.
Definition: MaskedImage.h:1057
STL class.
An iterator to the MaskedImage.
Definition: MaskedImage.h:99
MaskedImage & operator/=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:889
bool operator!=(MaskedImageIteratorBase const &rhs)
Return true if the lhs doesn&#39;t equal the rhs.
Definition: MaskedImage.h:184
MaskedImage & operator+=(lsst::afw::math::Function2< double > const &function)
Definition: MaskedImage.h:838
_view_t::iterator iterator
An STL compliant iterator.
Definition: ImageBase.h:125
double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const
Convert image index to image position (see Image::indexToPosition)
Definition: MaskedImage.h:1160
_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:355
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:49
int getHeight() const
Return the number of rows in the image.
Definition: MaskedImage.h:1095
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:740
A base class for image defects.
table::Key< int > type
Definition: Detector.cc:163
int getX0() const
Return the image&#39;s column-origin.
Definition: MaskedImage.h:1105
static MaskedImage readFits(fits::MemFileManager &manager)
Read a MaskedImage from a FITS RAM file.
Definition: MaskedImage.h:1050
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:77
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:568
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:121
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:572
A traits class for MaskedImage.
Definition: MaskedImage.h:50
_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:357
const IMV_iterator_tuple get_iterator_tuple() const
Return the underlying iterator tuple.
Definition: MaskedImage.h:150
const Pixel operator*() const
Dereference the iterator, returning a const Pixel.
Definition: MaskedImage.h:200
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:73
_view_t::y_iterator y_iterator
An iterator for traversing the pixels in a column.
Definition: ImageBase.h:143
MaskedImageIterator< typename Image::reverse_iterator, typename Mask::reverse_iterator, typename Variance::reverse_iterator > reverse_iterator
Definition: MaskedImage.h:547
std::shared_ptr< image::Image< ImagePixelT > > ImagePtr
shared pointer to the Image
Definition: MaskedImage.h:76
bool imagesOverlap(ImageBase< T1 > const &image1, ImageBase< T2 > const &image2)
Return true if the pixels for two images or masks overlap in memory.
Definition: Image.cc:706
detail::MaskedImage_tag image_category
Definition: MaskedImage.h:88
boost::zip_iterator< IMV_iterator_tuple >::reference IMV_tuple
The underlying iterator tuple.
Definition: MaskedImage.h:125
Ref< ImagePixelT >::type image()
Return (a reference to) the image part of the Pixel pointed at by the iterator.
Definition: MaskedImage.h:139
A saved relative position, providing efficient access to neighbouring pixels.
Definition: MaskedImage.h:359
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks
Pixel operator*()
Dereference the iterator, returning a Pixel.
Definition: MaskedImage.h:198
double x
void setMask(Mask const &other)
Set the mask plane&#39;s pixel values to those of another Mask.
Definition: MaskedImage.h:1078
bool operator!=(MaskedImageLocatorBase const &rhs)
Return true iff two locators are not equal.
Definition: MaskedImage.h:474
lsst::afw::image::Image< VariancePixelT > Variance
Definition: MaskedImage.h:84
MaskPtr getMask() const
Return a (shared_ptr to) the MaskedImage&#39;s mask.
Definition: MaskedImage.h:1069
std::string const compressedFileNoMEF_RE
regexp to identify compressed files that we can&#39;t write MEFs to
Definition: MaskedImage.h:57
void swap(Image< PixelT > &a, Image< PixelT > &b)
Definition: Image.cc:456
int getY0() const
Return the image&#39;s row-origin.
Definition: MaskedImage.h:1113
std::ptrdiff_t operator-(MaskedImageIteratorBase const &rhs)
Return the distance between two iterators.
Definition: MaskedImage.h:176
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
Ref< ImagePixelT >::type image()
Return a reference to the image at the current position of the locator.
Definition: MaskedImage.h:445
x_iterator x()
Return an iterator that can be used to move (or dereference) a locator.
Definition: MaskedImage.h:405
A pixel of a MaskedImage.
Definition: Pixel.h:148
MaskedImageIteratorBase & operator++()
Increment the iterator (prefix)
Definition: MaskedImage.h:165
An const iterator to the MaskedImage.
Definition: MaskedImage.h:102
MaskedImage & operator+=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:834
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:683
std::string const fitsFile_RE
regexp to identify when MaskedImages should be written as MEFs
Definition: MaskedImage.h:55
MaskedImageIterator(ImageIterator &img, MaskIterator &msk, VarianceIterator &var)
Definition: MaskedImage.h:214
MaskedImageIteratorBase & operator-=(std::ptrdiff_t delta)
Decrement the iterator by delta
Definition: MaskedImage.h:159
const_MaskedImageIterator(MaskedImageIterator< ImageIterator, MaskIterator, VarianceIterator > const &iter)
Definition: MaskedImage.h:241
void setXY0(int const x0, int const y0)
Set the MaskedImage&#39;s origin.
Definition: MaskedImage.h:1131
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:677
bool operator<(MaskedImageLocatorBase const &rhs)
Return true iff lhs is less than rhs.
Definition: MaskedImage.h:476
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:456
void setImage(Image const &other)
Set the image plane&#39;s pixel values to those of another Image.
Definition: MaskedImage.h:1066
Ref< VariancePixelT >::type variance()
Return a reference to the variance at the current position of the locator.
Definition: MaskedImage.h:463
MaskedImage subset(lsst::geom::Box2I const &bbox, ImageOrigin origin=PARENT) const
Return a subimage corresponding to the given box.
Definition: MaskedImage.h:790
Reports invalid arguments.
Definition: Runtime.h:66
void setVariance(Variance const &other)
Set the variance plane&#39;s pixel values to those of another Image.
Definition: MaskedImage.h:1087
int getWidth() const
Return the number of columns in the image.
Definition: MaskedImage.h:1093
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:585
static MaskedImage readFits(std::string const &filename)
Read a MaskedImage from a regular FITS file.
Definition: MaskedImage.h:1041
MaskedImage & operator*=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:879
MaskedImage< ImagePT, MaskPT, VarPT > type
Return the desired type.
Definition: MaskedImage.h:94
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:689
lsst::afw::image::Image< ImagePixelT > Image
Definition: MaskedImage.h:85
MaskedImageLocator< typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator > xy_locator
A locator for a MaskedImage.
Definition: MaskedImage.h:577
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:588
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...
bool operator<(MaskedImageIteratorBase const &rhs)
Return true if the lhs is less than the rhs.
Definition: MaskedImage.h:188
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:459
float VariancePixel
default type for MaskedImage variance images
lsst::geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: MaskedImage.h:1097
A class used to identify classes that represent MaskedImage pixels.
Definition: MaskedImage.h:52
MaskedImageLocatorBase(ImageLocator const &img, MaskLocator const &msk, VarianceLocator const &var)
Construct a MaskedImageLocator from image/mask/variance locators.
Definition: MaskedImage.h:377
_view_t::xy_locator xy_locator
An xy_locator.
Definition: ImageBase.h:121
An integer coordinate rectangle.
Definition: Box.h:55
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:58
MaskedImageLocatorBase & operator+=(pair2I const &p)
Increment the locator&#39;s x and y positions by p
Definition: MaskedImage.h:481
int end
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:560
xy_locator xy_at(int x, int y) const
Return an xy_locator at the point (x, y)
Definition: MaskedImage.h:1253
A const locator for the MaskedImage.
Definition: MaskedImage.h:108
metafunction to extract reference type from PixelT
Definition: ImageBase.h:85
Ref< typename boost::mpl::at< PixelTVec, N >::type >::type apply_IMV()
Definition: MaskedImage.h:429
metafunction to extract const reference type from PixelT
Definition: ImageBase.h:90