LSST Applications  21.0.0+04719a4bac,21.0.0-1-ga51b5d4+f5e6047307,21.0.0-11-g2b59f77+a9c1acf22d,21.0.0-11-ga42c5b2+86977b0b17,21.0.0-12-gf4ce030+76814010d2,21.0.0-13-g1721dae+760e7a6536,21.0.0-13-g3a573fe+768d78a30a,21.0.0-15-g5a7caf0+f21cbc5713,21.0.0-16-g0fb55c1+b60e2d390c,21.0.0-19-g4cded4ca+71a93a33c0,21.0.0-2-g103fe59+bb20972958,21.0.0-2-g45278ab+04719a4bac,21.0.0-2-g5242d73+3ad5d60fb1,21.0.0-2-g7f82c8f+8babb168e8,21.0.0-2-g8f08a60+06509c8b61,21.0.0-2-g8faa9b5+616205b9df,21.0.0-2-ga326454+8babb168e8,21.0.0-2-gde069b7+5e4aea9c2f,21.0.0-2-gecfae73+1d3a86e577,21.0.0-2-gfc62afb+3ad5d60fb1,21.0.0-25-g1d57be3cd+e73869a214,21.0.0-3-g357aad2+ed88757d29,21.0.0-3-g4a4ce7f+3ad5d60fb1,21.0.0-3-g4be5c26+3ad5d60fb1,21.0.0-3-g65f322c+e0b24896a3,21.0.0-3-g7d9da8d+616205b9df,21.0.0-3-ge02ed75+a9c1acf22d,21.0.0-4-g591bb35+a9c1acf22d,21.0.0-4-g65b4814+b60e2d390c,21.0.0-4-gccdca77+0de219a2bc,21.0.0-4-ge8a399c+6c55c39e83,21.0.0-5-gd00fb1e+05fce91b99,21.0.0-6-gc675373+3ad5d60fb1,21.0.0-64-g1122c245+4fb2b8f86e,21.0.0-7-g04766d7+cd19d05db2,21.0.0-7-gdf92d54+04719a4bac,21.0.0-8-g5674e7b+d1bd76f71f,master-gac4afde19b+a9c1acf22d,w.2021.13
LSST Data Management Base Package
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>
99  class MaskedImageIterator;
101  template <typename, typename, typename>
104  template <typename, typename, typename>
105  class MaskedImageLocator;
107  template <typename, typename, typename>
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>
209  : public MaskedImageIteratorBase<ImageIterator, MaskIterator, VarianceIterator> {
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:
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 
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 
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
548 #if 0 // doesn't compile. I should fix this, but it's low priority. RHL
550  typedef const_MaskedImageIterator<typename Image::reverse_iterator,
551  typename Mask::reverse_iterator, typename Variance::reverse_iterator> const_reverse_iterator;
552 #endif
554  typedef MaskedImageIterator<typename Image::x_iterator, typename Mask::x_iterator,
555  typename Variance::x_iterator>
559  typename Variance::x_iterator>
566  typedef MaskedImageIterator<typename Image::y_iterator, typename Mask::y_iterator,
567  typename Variance::y_iterator>
571  typename Variance::y_iterator>
573 
575  typedef MaskedImageLocator<typename Image::xy_locator, typename Mask::xy_locator,
576  typename Variance::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());
628  explicit MaskedImage(lsst::geom::Box2I const& bbox, MaskPlaneDict const& planeDict = MaskPlaneDict());
629 
647  explicit MaskedImage(
648  std::string const& fileName,
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,
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,
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 
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 
791  return MaskedImage(*this, bbox, origin, false);
792  }
793 
796 
808  void assign(MaskedImage const& rhs, lsst::geom::Box2I const& bbox = lsst::geom::Box2I(),
809  ImageOrigin origin = PARENT);
810 
812  MaskedImage& operator+=(ImagePixelT const rhs);
822  MaskedImage& operator+=(MaskedImage const& rhs);
824  *_image += rhs;
825  return *this;
826  }
828  *_image += function;
829  return *this;
830  }
839  void scaledPlus(double const c, MaskedImage const& rhs);
840 
842  MaskedImage& operator-=(ImagePixelT const rhs);
849  MaskedImage& operator-=(MaskedImage const& rhs);
851  *_image -= rhs;
852  return *this;
853  }
855  *_image -= function;
856  return *this;
857  }
864  void scaledMinus(double const c, MaskedImage const& rhs);
865 
866  MaskedImage& operator*=(ImagePixelT const rhs);
867  MaskedImage& operator*=(MaskedImage const& rhs);
869  *_image *= rhs;
870  *_variance *= rhs; // yes, multiply twice
871  *_variance *= rhs;
872  return *this;
873  }
874  void scaledMultiplies(double const c, MaskedImage const& rhs);
875 
876  MaskedImage& operator/=(ImagePixelT const rhs);
877  MaskedImage& operator/=(MaskedImage const& rhs);
879  *_image /= rhs;
880  *_variance /= rhs; // yes, divide twice
881  *_variance /= rhs;
882  return *this;
883  }
884  void scaledDivides(double const c, MaskedImage const& rhs);
885 
900  void writeFits(std::string const& fileName,
909 
923  void writeFits(fits::MemFileManager& manager,
932 
946  void writeFits(fits::Fits& fitsfile,
955 
972  void writeFits(std::string const& fileName, fits::ImageWriteOptions const& imageOptions,
973  fits::ImageWriteOptions const& maskOptions, fits::ImageWriteOptions const& varianceOptions,
975  std::shared_ptr<daf::base::PropertySet const> imageMetadata = nullptr,
976  std::shared_ptr<daf::base::PropertySet const> maskMetadata = nullptr,
977  std::shared_ptr<daf::base::PropertySet const> varianceMetadata = nullptr) const;
978 
995  void writeFits(fits::MemFileManager& manager, fits::ImageWriteOptions const& imageOptions,
996  fits::ImageWriteOptions const& maskOptions, fits::ImageWriteOptions const& varianceOptions,
998  std::shared_ptr<daf::base::PropertySet const> imageMetadata = nullptr,
999  std::shared_ptr<daf::base::PropertySet const> maskMetadata = nullptr,
1000  std::shared_ptr<daf::base::PropertySet const> varianceMetadata = nullptr) const;
1001 
1018  void writeFits(fits::Fits& fitsfile, fits::ImageWriteOptions const& imageOptions,
1019  fits::ImageWriteOptions const& maskOptions, fits::ImageWriteOptions const& varianceOptions,
1021  std::shared_ptr<daf::base::PropertySet const> imageMetadata = nullptr,
1022  std::shared_ptr<daf::base::PropertySet const> maskMetadata = nullptr,
1023  std::shared_ptr<daf::base::PropertySet const> varianceMetadata = nullptr) const;
1024 
1030  static MaskedImage readFits(std::string const& filename) {
1032  }
1033 
1041  }
1042 
1043  // Getters
1044 
1046  ImagePtr getImage() const { return _image; }
1047 
1055  void setImage(Image const& other) { _image->assign(other); }
1056 
1058  MaskPtr getMask() const { return _mask; }
1059 
1067  void setMask(Mask const& other) { _mask->assign(other); }
1068 
1076  void setVariance(Variance const& other) { _variance->assign(other); }
1077 
1079  VariancePtr getVariance() const { return _variance; }
1080 
1082  int getWidth() const { return _image->getWidth(); }
1084  int getHeight() const { return _image->getHeight(); }
1085  lsst::geom::Extent2I getDimensions() const { return _image->getDimensions(); }
1086  lsst::geom::Box2I getBBox(ImageOrigin const origin = PARENT) const { return _image->getBBox(origin); }
1094  int getX0() const { return _image->getX0(); }
1102  int getY0() const { return _image->getY0(); }
1110  lsst::geom::Point2I getXY0() const { return _image->getXY0(); }
1111 
1120  void setXY0(int const x0, int const y0) { setXY0(lsst::geom::Point2I(x0, y0)); }
1121 
1130  void setXY0(lsst::geom::Point2I const origin) {
1131  if (_image) {
1132  _image->setXY0(origin);
1133  }
1134 
1135  if (_mask) {
1136  _mask->setXY0(origin);
1137  }
1138 
1139  if (_variance) {
1140  _variance->setXY0(origin);
1141  }
1142  }
1143 
1149  inline double indexToPosition(double ind,
1150  lsst::afw::image::xOrY const xy
1151  ) const {
1152  return getImage()->indexToPosition(ind, xy);
1153  }
1154 
1161  double const pos,
1162  lsst::afw::image::xOrY const xy
1163  ) const {
1164  return getImage()->positionToIndex(pos, xy);
1165  }
1166 
1167  //
1168  // Iterators and Locators
1169  //
1171  iterator begin() const;
1173  iterator end() const;
1175  iterator at(int const x, int const y) const;
1177  reverse_iterator rbegin() const;
1179  reverse_iterator rend() const;
1180 
1191  fast_iterator begin(bool contiguous) const;
1200  fast_iterator end(bool contiguous) const;
1201 
1203  x_iterator row_begin(int y) const;
1205  x_iterator row_end(int y) const;
1206 
1208  x_iterator x_at(int x, int y) const {
1209 #if 0
1210  typename Image::x_iterator imageEnd = getImage()->x_at(x, y);
1211  typename Mask::x_iterator maskEnd = getMask()->x_at(x, y);
1212  typename Variance::x_iterator varianceEnd = getVariance()->x_at(x, y);
1213 #else // bypass checks for non-NULL pointers
1214  typename Image::x_iterator imageEnd = _image->x_at(x, y);
1215  typename Mask::x_iterator maskEnd = _mask->x_at(x, y);
1216  typename Variance::x_iterator varianceEnd = _variance->x_at(x, y);
1217 #endif
1218 
1219  return x_iterator(imageEnd, maskEnd, varianceEnd);
1220  }
1221 
1223  y_iterator col_begin(int x) const;
1225  y_iterator col_end(int x) const;
1226 
1228  y_iterator y_at(int x, int y) const {
1229 #if 0
1230  typename Image::y_iterator imageEnd = getImage()->y_at(x, y);
1231  typename Mask::y_iterator maskEnd = getMask()->y_at(x, y);
1232  typename Variance::y_iterator varianceEnd = getVariance()->y_at(x, y);
1233 #else // bypass checks for non-NULL pointers
1234  typename Image::y_iterator imageEnd = _image->y_at(x, y);
1235  typename Mask::y_iterator maskEnd = _mask->y_at(x, y);
1236  typename Variance::y_iterator varianceEnd = _variance->y_at(x, y);
1237 #endif
1238  return y_iterator(imageEnd, maskEnd, varianceEnd);
1239  }
1240 
1242  xy_locator xy_at(int x, int y) const {
1243 #if 0
1244  typename Image::xy_locator imageEnd = getImage()->xy_at(x, y);
1245  typename Mask::xy_locator maskEnd = getMask()->xy_at(x, y);
1246  typename Variance::xy_locator varianceEnd = getVariance()->xy_at(x, y);
1247 #else // bypass checks for non-NULL pointers
1248  typename Image::xy_locator imageEnd = _image->xy_at(x, y);
1249  typename Mask::xy_locator maskEnd = _mask->xy_at(x, y);
1250  typename Variance::xy_locator varianceEnd = _variance->xy_at(x, y);
1251 #endif
1252 
1253  return xy_locator(imageEnd, maskEnd, varianceEnd);
1254  }
1255 
1256 private:
1257  void conformSizes();
1258 
1259  ImagePtr _image;
1260  MaskPtr _mask;
1261  VariancePtr _variance;
1262 };
1263 
1267 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
1272 ) {
1274 }
1275 
1279 template <typename ImagePixelT1, typename ImagePixelT2>
1280 bool imagesOverlap(MaskedImage<ImagePixelT1, MaskPixel, VariancePixel> const& image1,
1281  MaskedImage<ImagePixelT2, MaskPixel, VariancePixel> const& image2);
1282 
1283 /*
1284  * Some metafunctions to extract an Image pointer from a MaskedImage pointer (or return the original Image
1285  * pointer)
1286  *
1287  * GetImage is the public interface (it forwards the tag --- just for the sake of the UI); the real work
1288  * is in GetImage_ which defines a typedef for the Image and a static function, getImage
1289  *
1290  * E.g.
1291  * In the function
1292  *
1293  * template<typename ImageT>
1294  * void func(shared_ptr<ImageT> image) {
1295  * typename shared_ptr<GetImage<ImageT>::type> im = GetImage<ImageT>::getImage(image);
1296  * }
1297  *
1298  * "im" is a shared_ptr<Image> irrespective of whether ImageT is Masked or not.
1299  */
1300 namespace {
1301 template <typename ImageT, typename TagT>
1302 struct GetImage_ {
1303  typedef ImageT type;
1304  static std::shared_ptr<type> getImage(std::shared_ptr<ImageT> image) { return image; }
1305 };
1306 
1307 template <typename ImageT>
1308 struct GetImage_<ImageT, typename image::detail::MaskedImage_tag> {
1309  typedef typename ImageT::Image type;
1310  static std::shared_ptr<type> getImage(std::shared_ptr<ImageT> image) { return image->getImage(); }
1311 };
1312 } // anonymous namespace
1313 
1314 template <typename ImageT>
1315 struct GetImage : public GetImage_<ImageT, typename ImageT::image_category> {};
1316 } // namespace image
1317 } // namespace afw
1318 } // namespace lsst
1319 
1320 #endif // LSST_IMAGE_MASKEDIMAGE_H
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
double x
table::Key< int > type
Definition: Detector.cc:163
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:49
afw::table::Key< afw::table::Array< ImagePixelT > > image
afw::table::Key< afw::table::Array< MaskPixelT > > mask
afw::table::Key< afw::table::Array< VariancePixelT > > variance
ItemVariant const * other
Definition: Schema.cc:56
int y
Definition: SpanSet.cc:49
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:297
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:121
_view_t::xy_locator xy_locator
An xy_locator.
Definition: ImageBase.h:121
_view_t::reverse_iterator reverse_iterator
An STL compliant reverse iterator.
Definition: ImageBase.h:129
_view_t::iterator iterator
An STL compliant iterator.
Definition: ImageBase.h:125
_view_t::y_iterator y_iterator
An iterator for traversing the pixels in a column.
Definition: ImageBase.h:143
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
Definition: ImageBase.h:133
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:58
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:77
The base class for MaskedImageIterators (const and non-const)
Definition: MaskedImage.h:118
bool operator==(MaskedImageIteratorBase const &rhs)
Return true if the lhs equals the rhs.
Definition: MaskedImage.h:180
MaskedImageIteratorBase operator++(int)
Increment the iterator (postfix)
Definition: MaskedImage.h:170
const Pixel operator*() const
Dereference the iterator, returning a const Pixel.
Definition: MaskedImage.h:200
std::ptrdiff_t operator-(MaskedImageIteratorBase const &rhs)
Return the distance between two iterators.
Definition: MaskedImage.h:176
bool operator!=(MaskedImageIteratorBase const &rhs)
Return true if the lhs doesn't equal the rhs.
Definition: MaskedImage.h:184
boost::zip_iterator< IMV_iterator_tuple > _iter
Definition: MaskedImage.h:203
MaskedImageIteratorBase & operator++()
Increment the iterator (prefix)
Definition: MaskedImage.h:165
Pixel operator*()
Dereference the iterator, returning a Pixel.
Definition: MaskedImage.h:198
Ref< MaskPixelT >::type mask()
Return (a reference to) the mask part of the Pixel pointed at by the iterator.
Definition: MaskedImage.h:142
Ref< ImagePixelT >::type image()
Return (a reference to) the image part of the Pixel pointed at by the iterator.
Definition: MaskedImage.h:139
MaskedImageIteratorBase & operator+=(std::ptrdiff_t delta)
Increment the iterator by delta
Definition: MaskedImage.h:153
MaskedImageIteratorBase & operator-=(std::ptrdiff_t delta)
Decrement the iterator by delta
Definition: MaskedImage.h:159
Pixel type
Type pointed to by the iterator.
Definition: MaskedImage.h:132
MaskedImageIteratorBase(ImageIterator const &img, MaskIterator const &msk, VarianceIterator const &var)
Construct a MaskedImageIteratorBase from the image/mask/variance iterators.
Definition: MaskedImage.h:135
boost::zip_iterator< IMV_iterator_tuple >::reference IMV_tuple
The underlying iterator tuple.
Definition: MaskedImage.h:125
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<(MaskedImageIteratorBase const &rhs)
Return true if the lhs is less than the rhs.
Definition: MaskedImage.h:188
const IMV_iterator_tuple get_iterator_tuple() const
Return the underlying iterator tuple.
Definition: MaskedImage.h:150
MaskedImageIterator(ImageIterator &img, MaskIterator &msk, VarianceIterator &var)
Definition: MaskedImage.h:214
MaskedImageIterator operator+(std::ptrdiff_t delta)
Return a MaskedImageIterator that's delta beyond this.
Definition: MaskedImage.h:217
A saved relative position, providing efficient access to neighbouring pixels.
Definition: MaskedImage.h:359
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
The base class for MaskedImageLocators (const and non-const)
Definition: MaskedImage.h:261
Ref< typename boost::mpl::at< PixelTVec, N >::type >::type apply_IMV(int x, int y)
Definition: MaskedImage.h:434
MaskedImageLocatorBase & operator+=(pair2I const &p)
Increment the locator's x and y positions by p
Definition: MaskedImage.h:481
_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
Pixel operator*()
Dereference a locator, returning a Pixel.
Definition: MaskedImage.h:383
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
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
MaskedImageLocatorBase & operator+=(detail::difference_type p)
Increment the locator's x and y positions by p
Definition: MaskedImage.h:486
_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
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
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
Ref< ImagePixelT >::type image()
Return a reference to the image at the current position of the locator.
Definition: MaskedImage.h:445
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
boost::tuple< typename ImageLocator::cached_location_t, typename MaskLocator::cached_location_t, typename VarianceLocator::cached_location_t > IMVCachedLocation
Definition: MaskedImage.h:353
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
Pixel operator()(int x, int y)
Dereference a locator, returning a Pixel offset by (x, y) from the locator.
Definition: MaskedImage.h:389
y_iterator y()
Return an iterator that can be used to move (or dereference) a locator.
Definition: MaskedImage.h:411
bool operator==(MaskedImageLocatorBase const &rhs)
Return true iff two locators are equal.
Definition: MaskedImage.h:470
Ref< MaskPixelT >::type mask()
Return a reference to the mask at the current position of the locator.
Definition: MaskedImage.h:454
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
Ref< VariancePixelT >::type variance()
Return a reference to the variance at the current position of the locator.
Definition: MaskedImage.h:463
Ref< typename boost::mpl::at< PixelTVec, N >::type >::type apply_IMV()
Definition: MaskedImage.h:429
bool operator!=(MaskedImageLocatorBase const &rhs)
Return true iff two locators are not equal.
Definition: MaskedImage.h:474
boost::mpl::vector< ImagePixelT, MaskPixelT, VariancePixelT > PixelTVec
Definition: MaskedImage.h:420
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
bool operator<(MaskedImageLocatorBase const &rhs)
Return true iff lhs is less than rhs.
Definition: MaskedImage.h:476
MaskedImageLocatorBase(ImageLocator const &img, MaskLocator const &msk, VarianceLocator const &var)
Construct a MaskedImageLocator from image/mask/variance locators.
Definition: MaskedImage.h:377
x_iterator x()
Return an iterator that can be used to move (or dereference) a locator.
Definition: MaskedImage.h:405
MaskedImageLocator(ImageLocator &img, MaskLocator &msk, VarianceLocator &var)
Definition: MaskedImage.h:508
An const iterator to the MaskedImage.
Definition: MaskedImage.h:231
const_MaskedImageIterator & operator+(std::ptrdiff_t delta)
Return a const_MaskedImageIterator that's delta beyond this.
Definition: MaskedImage.h:250
const_MaskedImageIterator(MaskedImageIterator< ImageIterator, MaskIterator, VarianceIterator > const &iter)
Definition: MaskedImage.h:241
A const locator for the MaskedImage.
Definition: MaskedImage.h:518
const_MaskedImageLocator(MaskedImageLocator< ImageLocator, MaskLocator, VarianceLocator > const &iter)
Definition: MaskedImage.h:528
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:73
void scaledPlus(double const c, MaskedImage const &rhs)
Add a scaled MaskedImage c*rhs to a MaskedImage.
Definition: MaskedImage.cc:247
MaskedImage operator[](lsst::geom::Box2I const &bbox) const
Return a subimage corresponding to the given box (interpreted as PARENT coordinates).
Definition: MaskedImage.h:795
void writeFits(std::string const &fileName, std::shared_ptr< daf::base::PropertySet const > metadata=std::shared_ptr< daf::base::PropertySet const >(), std::shared_ptr< daf::base::PropertySet const > imageMetadata=std::shared_ptr< daf::base::PropertySet const >(), std::shared_ptr< daf::base::PropertySet const > maskMetadata=std::shared_ptr< daf::base::PropertySet const >(), std::shared_ptr< daf::base::PropertySet const > varianceMetadata=std::shared_ptr< daf::base::PropertySet const >()) const
Write a MaskedImage to a regular FITS file.
Definition: MaskedImage.cc:427
int getX0() const
Return the image's column-origin.
Definition: MaskedImage.h:1094
MaskedImage(unsigned int width, unsigned int height, MaskPlaneDict const &planeDict=MaskPlaneDict())
Construct from a supplied dimensions.
Definition: MaskedImage.cc:49
void setXY0(lsst::geom::Point2I const origin)
Set the MaskedImage's origin.
Definition: MaskedImage.h:1130
lsst::geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: MaskedImage.h:1086
MaskedImage & operator*=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:868
void setVariance(Variance const &other)
Set the variance plane's pixel values to those of another Image.
Definition: MaskedImage.h:1076
void setXY0(int const x0, int const y0)
Set the MaskedImage's origin.
Definition: MaskedImage.h:1120
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
MaskedImage & operator/=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:878
static MaskedImage readFits(fits::MemFileManager &manager)
Read a MaskedImage from a FITS RAM file.
Definition: MaskedImage.h:1039
const_MaskedImageIterator< typename Image::iterator, typename Mask::iterator, typename Variance::iterator > const_iterator
Definition: MaskedImage.h:543
lsst::afw::image::Image< VariancePixelT > Variance
Definition: MaskedImage.h:84
void scaledDivides(double const c, MaskedImage const &rhs)
Definition: MaskedImage.cc:399
Mask< MaskPixelT >::MaskPlaneDict MaskPlaneDict
The Mask's MaskPlaneDict.
Definition: MaskedImage.h:82
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
std::shared_ptr< image::Mask< MaskPixelT > > MaskPtr
shared pointer to the Mask
Definition: MaskedImage.h:78
int getHeight() const
Return the number of rows in the image.
Definition: MaskedImage.h:1084
MaskedImage & operator-=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:850
int getY0() const
Return the image's row-origin.
Definition: MaskedImage.h:1102
virtual ~MaskedImage()=default
MaskedImageIterator< typename Image::reverse_iterator, typename Mask::reverse_iterator, typename Variance::reverse_iterator > reverse_iterator
Definition: MaskedImage.h:547
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
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
MaskedImage & operator=(MaskedImage &&rhs)
std::shared_ptr< image::Image< VariancePixelT > > VariancePtr
shared pointer to the variance Image
Definition: MaskedImage.h:80
x_iterator fast_iterator
A fast STL compliant iterator for contiguous images N.b.
Definition: MaskedImage.h:564
iterator begin() const
Return an iterator to the start of the image.
Definition: MaskedImage.cc:572
MaskedImage & operator+=(lsst::afw::math::Function2< double > const &function)
Definition: MaskedImage.h:827
reverse_iterator rbegin() const
Return a reverse_iterator to the start of the image.
Definition: MaskedImage.cc:606
void setMask(Mask const &other)
Set the mask plane's pixel values to those of another Mask.
Definition: MaskedImage.h:1067
y_iterator col_end(int x) const
Return an y_iterator to the end of the image.
Definition: MaskedImage.cc:656
void scaledMinus(double const c, MaskedImage const &rhs)
Subtract a scaled MaskedImage c*rhs from a MaskedImage.
Definition: MaskedImage.cc:271
lsst::afw::image::Image< ImagePixelT > Image
Definition: MaskedImage.h:85
lsst::geom::Extent2I getDimensions() const
Definition: MaskedImage.h:1085
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:1160
lsst::geom::Point2I getXY0() const
Return the image's origin.
Definition: MaskedImage.h:1110
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
lsst::afw::image::pixel::Pixel< ImagePixelT, MaskPixelT, VariancePixelT > Pixel
A Pixel in the MaskedImage.
Definition: MaskedImage.h:108
std::shared_ptr< image::Image< ImagePixelT > > ImagePtr
shared pointer to the Image
Definition: MaskedImage.h:76
xy_locator xy_at(int x, int y) const
Return an xy_locator at the point (x, y)
Definition: MaskedImage.h:1242
MaskedImage & operator-=(ImagePixelT const rhs)
Subtract a scalar rhs from a MaskedImage.
Definition: MaskedImage.cc:280
int getWidth() const
Return the number of columns in the image.
Definition: MaskedImage.h:1082
x_iterator row_end(int y) const
Return an x_iterator to the end of the image.
Definition: MaskedImage.cc:636
MaskedImage subset(lsst::geom::Box2I const &bbox, ImageOrigin origin=PARENT) const
Return a subimage corresponding to the given box.
Definition: MaskedImage.h:790
void scaledMultiplies(double const c, MaskedImage const &rhs)
Definition: MaskedImage.cc:328
iterator end() const
Return an iterator to the end of the image.
Definition: MaskedImage.cc:586
void assign(MaskedImage const &rhs, lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT)
Copy pixels from another masked image to a specified subregion of this masked image.
Definition: MaskedImage.cc:229
VariancePtr getVariance() const
Return a (shared_ptr to) the MaskedImage's variance.
Definition: MaskedImage.h:1079
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
MaskedImage & operator=(MaskedImage const &rhs)
Make the lhs use the rhs's pixels.
x_iterator row_begin(int y) const
Return an x_iterator to the start of the image.
Definition: MaskedImage.cc:626
void swap(MaskedImage &rhs)
Definition: MaskedImage.cc:199
double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const
Convert image index to image position (see Image::indexToPosition)
Definition: MaskedImage.h:1149
MaskedImage & operator+=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:823
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
void setImage(Image const &other)
Set the image plane's pixel values to those of another Image.
Definition: MaskedImage.h:1055
y_iterator col_begin(int x) const
Return an y_iterator to the start of the image.
Definition: MaskedImage.cc:646
lsst::afw::image::Mask< MaskPixelT > Mask
Definition: MaskedImage.h:86
reverse_iterator rend() const
Return a reverse_iterator to the end of the image.
Definition: MaskedImage.cc:616
MaskedImageIterator< typename Image::iterator, typename Mask::iterator, typename Variance::iterator > iterator
Definition: MaskedImage.h:539
static MaskedImage readFits(std::string const &filename)
Read a MaskedImage from a regular FITS file.
Definition: MaskedImage.h:1030
MaskedImage & operator+=(ImagePixelT const rhs)
Add a scalar rhs to a MaskedImage.
Definition: MaskedImage.cc:256
x_iterator x_at(int x, int y) const
Return an x_iterator at the point (x, y)
Definition: MaskedImage.h:1208
MaskedImage & operator*=(ImagePixelT const rhs)
Definition: MaskedImage.cc:349
MaskedImage & operator-=(lsst::afw::math::Function2< double > const &function)
Definition: MaskedImage.h:854
iterator at(int const x, int const y) const
Return an iterator at the point (x, y)
Definition: MaskedImage.cc:596
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
MaskedImage & operator/=(ImagePixelT const rhs)
Definition: MaskedImage.cc:420
y_iterator y_at(int x, int y) const
Return an y_iterator at the point (x, y)
Definition: MaskedImage.h:1228
detail::MaskedImage_tag image_category
Definition: MaskedImage.h:88
MaskPtr getMask() const
Return a (shared_ptr to) the MaskedImage's mask.
Definition: MaskedImage.h:1058
MaskedImageLocator< typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator > xy_locator
A locator for a MaskedImage.
Definition: MaskedImage.h:577
ImagePtr getImage() const
Return a (shared_ptr to) the MaskedImage's image.
Definition: MaskedImage.h:1046
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
A pixel of a MaskedImage.
Definition: Pixel.h:148
A single pixel of the same type as a MaskedImage.
Definition: Pixel.h:73
A Function taking two arguments.
Definition: Function.h:259
An integer coordinate rectangle.
Definition: Box.h:55
Reports invalid arguments.
Definition: Runtime.h:66
Definition: Polygon.cc:25
std::string const fitsFile_RE
regexp to identify when MaskedImages should be written as MEFs
Definition: MaskedImage.h:55
std::string const compressedFileNoMEF_RE
regexp to identify compressed files that we can't write MEFs to
Definition: MaskedImage.h:57
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks
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:1268
float VariancePixel
default type for MaskedImage variance images
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
A base class for image defects.
Options for writing an image to FITS.
Definition: fits.h:219
metafunction to extract const reference type from PixelT
Definition: ImageBase.h:90
A templated class to return this classes' type (present in Image/Mask/MaskedImage)
Definition: MaskedImage.h:92
MaskedImage< ImagePT, MaskPT, VarPT > type
Return the desired type.
Definition: MaskedImage.h:94
metafunction to extract reference type from PixelT
Definition: ImageBase.h:85
A traits class for MaskedImage.
Definition: MaskedImage.h:50
A class used to identify classes that represent MaskedImage pixels.
Definition: MaskedImage.h:52