LSSTApplications  19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
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>
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>
227  class const_MaskedImageIterator
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,
238  MaskedImageIteratorBase_t;
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>
514  class const_MaskedImageLocator
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,
525  MaskedImageLocatorBase_t;
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());
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
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::apply_IMV
Ref< typename boost::mpl::at< PixelTVec, N >::type >::type apply_IMV(cached_location_t const &cached_loc)
Definition: MaskedImage.h:423
y
int y
Definition: SpanSet.cc:49
lsst::afw::image::MaskedImage::MaskedImageIteratorBase::IMV_tuple
boost::zip_iterator< IMV_iterator_tuple >::reference IMV_tuple
The underlying iterator tuple.
Definition: MaskedImage.h:125
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::variance
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
lsst::afw::image::MaskedImage::MaskedImage
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
lsst::afw::image::MaskedImage::MaskedImageIteratorBase::operator<
bool operator<(MaskedImageIteratorBase const &rhs)
Return true if the lhs is less than the rhs.
Definition: MaskedImage.h:188
lsst::afw::image
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Definition: imageAlgorithm.dox:1
lsst::afw::image::MaskedImage::MaskedImageIteratorBase::_iter
boost::zip_iterator< IMV_iterator_tuple > _iter
Definition: MaskedImage.h:203
lsst::afw::image::MaskedImage::swap
void swap(MaskedImage &rhs)
Definition: MaskedImage.cc:198
lsst::afw::image::MaskedImage::image_category
detail::MaskedImage_tag image_category
Definition: MaskedImage.h:88
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::variance
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
lsst::afw::image::MaskedImage::MaskedImageIteratorBase
The base class for MaskedImageIterators (const and non-const)
Definition: MaskedImage.h:118
lsst::afw::image::MaskedImage::scaledMultiplies
void scaledMultiplies(double const c, MaskedImage const &rhs)
Definition: MaskedImage.cc:322
lsst::afw::image::ImageBase::assign
void assign(ImageBase const &rhs, lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT)
Copy pixels from another image to a specified subregion of this image.
Definition: Image.cc:160
lsst::afw::image::MaskedImage::row_begin
x_iterator row_begin(int y) const
Return an x_iterator to the start of the image.
Definition: MaskedImage.cc:605
lsst::afw::image::MaskedImage::MaskedImageIteratorBase::operator*
const Pixel operator*() const
Dereference the iterator, returning a const Pixel.
Definition: MaskedImage.h:200
lsst::afw::image::MaskedImage::operator-=
MaskedImage & operator-=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:850
lsst::afw::image::MaskedImage::xy_at
xy_locator xy_at(int x, int y) const
Return an xy_locator at the point (x, y)
Definition: MaskedImage.h:1242
std::string
STL class.
std::shared_ptr
STL class.
lsst::afw::image::MaskedImage::begin
iterator begin() const
Return an iterator to the start of the image.
Definition: MaskedImage.cc:551
lsst::afw::image::MaskedImage::MaskedImageIterator
An iterator to the MaskedImage.
Definition: MaskedImage.h:99
lsst::afw::image::Mask
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:77
lsst::afw::image::pixel::Pixel
A pixel of a MaskedImage.
Definition: Pixel.h:148
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::apply_IMV
Ref< typename boost::mpl::at< PixelTVec, N >::type >::type apply_IMV(int x, int y)
Definition: MaskedImage.h:434
lsst::afw::image::MaskedImage::ImagePtr
std::shared_ptr< image::Image< ImagePixelT > > ImagePtr
shared pointer to the Image
Definition: MaskedImage.h:76
lsst::afw::image::MaskedImage::const_MaskedImageLocator
A const locator for the MaskedImage.
Definition: MaskedImage.h:108
lsst::afw::image::MaskedImage::row_end
x_iterator row_end(int y) const
Return an x_iterator to the end of the image.
Definition: MaskedImage.cc:615
lsst::afw::image::pixel::SinglePixel
A single pixel of the same type as a MaskedImage.
Definition: Pixel.h:73
lsst::afw::image::MaskedImage::MaskedImageIteratorBase::operator*
Pixel operator*()
Dereference the iterator, returning a Pixel.
Definition: MaskedImage.h:198
lsst::afw::image::MaskedImage::MaskedImageIterator::MaskedImageIterator
MaskedImageIterator(ImageIterator &img, MaskIterator &msk, VarianceIterator &var)
Definition: MaskedImage.h:214
std::pair
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::operator*
Pixel operator*()
Dereference a locator, returning a Pixel.
Definition: MaskedImage.h:383
lsst::afw::image::MaskedImage::readFits
static MaskedImage readFits(std::string const &filename)
Read a MaskedImage from a regular FITS file.
Definition: MaskedImage.h:1030
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::operator<
bool operator<(MaskedImageLocatorBase const &rhs)
Return true iff lhs is less than rhs.
Definition: MaskedImage.h:476
lsst::afw::fits::Fits
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:297
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::variance
Ref< VariancePixelT >::type variance()
Return a reference to the variance at the current position of the locator.
Definition: MaskedImage.h:463
lsst::afw::image::MaskedImage::operator+=
MaskedImage & operator+=(lsst::afw::math::Function2< double > const &function)
Definition: MaskedImage.h:827
lsst::afw::image::MaskedImage::operator+=
MaskedImage & operator+=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:823
lsst::afw::image::MaskedImage::indexToPosition
double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const
Convert image index to image position (see Image::indexToPosition)
Definition: MaskedImage.h:1149
lsst::afw::image::ImageBase::y_at
y_iterator y_at(int x, int y) const
Return an y_iterator to the point (x, y) in the image.
Definition: ImageBase.h:417
lsst::afw::image::MaskedImage::MaskedImageIteratorBase::operator++
MaskedImageIteratorBase operator++(int)
Increment the iterator (postfix)
Definition: MaskedImage.h:170
lsst::afw::image::MaskedImage::operator=
MaskedImage & operator=(MaskedImage const &rhs)
Make the lhs use the rhs's pixels.
lsst::afw::image::MaskedImage::operator/=
MaskedImage & operator/=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:878
lsst::afw::image::MaskedImage::MaskedImageIteratorBase::image
Ref< ImagePixelT >::type image()
Return (a reference to) the image part of the Pixel pointed at by the iterator.
Definition: MaskedImage.h:139
lsst::afw::image::MaskedImage::SinglePixel
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
lsst::afw::image::detail::compressedFileNoMEF_RE
std::string const compressedFileNoMEF_RE
regexp to identify compressed files that we can't write MEFs to
Definition: MaskedImage.h:57
lsst::afw
Definition: imageAlgorithm.dox:1
lsst::afw::image::MaskedImage::ImageTypeFactory
A templated class to return this classes' type (present in Image/Mask/MaskedImage)
Definition: MaskedImage.h:92
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::y
y_iterator y()
Return an iterator that can be used to move (or dereference) a locator.
Definition: MaskedImage.h:411
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::x
x_iterator x()
Return an iterator that can be used to move (or dereference) a locator.
Definition: MaskedImage.h:405
lsst::afw::image::MaskedImage::operator-=
MaskedImage & operator-=(lsst::afw::math::Function2< double > const &function)
Definition: MaskedImage.h:854
lsst::afw::image::ImageBase< ImagePixelT >::reverse_iterator
_view_t::reverse_iterator reverse_iterator
An STL compliant reverse iterator.
Definition: ImageBase.h:129
lsst::afw::image::ImageBase::indexToPosition
double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const
Convert image index to image position.
Definition: ImageBase.h:347
lsst::afw::image::ImageBase< ImagePixelT >::y_iterator
_view_t::y_iterator y_iterator
An iterator for traversing the pixels in a column.
Definition: ImageBase.h:143
lsst::afw::image::MaskedImage::x_at
x_iterator x_at(int x, int y) const
Return an x_iterator at the point (x, y)
Definition: MaskedImage.h:1208
lsst::afw::image::MaskedImage::getBBox
lsst::geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: MaskedImage.h:1086
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::mask
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
boost
Definition: Polygon.cc:25
lsst::afw::image::ImageBase< ImagePixelT >::xy_locator
_view_t::xy_locator xy_locator
An xy_locator.
Definition: ImageBase.h:121
lsst::afw::image::MaskedImage::operator=
MaskedImage & operator=(MaskedImage &&rhs)
lsst::afw::image::MaskedImage::MaskedImage
MaskedImage(unsigned int width, unsigned int height, MaskPlaneDict const &planeDict=MaskPlaneDict())
Construct from a supplied dimensions.
Definition: MaskedImage.cc:48
lsst::afw::image::MaskedImage::ImageTypeFactory::type
MaskedImage< ImagePT, MaskPT, VarPT > type
Return the desired type.
Definition: MaskedImage.h:94
lsst::afw::image::MaskedImage::MaskedImageIteratorBase::operator!=
bool operator!=(MaskedImageIteratorBase const &rhs)
Return true if the lhs doesn't equal the rhs.
Definition: MaskedImage.h:184
lsst::afw::image::ImageBase::positionToIndex
std::pair< int, double > positionToIndex(double const pos, lsst::afw::image::xOrY const xy) const
Convert image position to index (nearest integer and fractional parts)
Definition: ImageBase.h:328
lsst::afw::image::MaskedImage::MaskedImageIteratorBase::mask
Ref< MaskPixelT >::type mask()
Return (a reference to) the mask part of the Pixel pointed at by the iterator.
Definition: MaskedImage.h:142
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::operator!=
bool operator!=(MaskedImageLocatorBase const &rhs)
Return true iff two locators are not equal.
Definition: MaskedImage.h:474
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::_loc
IMVLocator _loc
Definition: MaskedImage.h:499
lsst::afw::image::MaskedImage::getWidth
int getWidth() const
Return the number of columns in the image.
Definition: MaskedImage.h:1082
lsst::afw::fits::MemFileManager
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:121
mask
afw::table::Key< afw::table::Array< MaskPixelT > > mask
Definition: HeavyFootprint.cc:217
lsst::afw::image::ImageBase::getHeight
int getHeight() const
Return the number of rows in the image.
Definition: ImageBase.h:296
Image.h
lsst::afw::image::MaskedImage::getHeight
int getHeight() const
Return the number of rows in the image.
Definition: MaskedImage.h:1084
lsst::afw::image::MaskedImage::positionToIndex
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::afw::image::MaskedImage::const_MaskedImageIterator::operator+
const_MaskedImageIterator & operator+(std::ptrdiff_t delta)
Return a const_MaskedImageIterator that's delta beyond this.
Definition: MaskedImage.h:250
lsst::afw::fits::ImageWriteOptions
Options for writing an image to FITS.
Definition: fits.h:219
lsst::afw::image::MaskedImage::operator*=
MaskedImage & operator*=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:868
lsst::afw::image::MaskedImage::setMask
void setMask(Mask const &other)
Set the mask plane's pixel values to those of another Mask.
Definition: MaskedImage.h:1067
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::getLoc
IMVLocator const & getLoc() const
Definition: MaskedImage.h:496
lsst::afw::image::MaskedImage::col_end
y_iterator col_end(int x) const
Return an y_iterator to the end of the image.
Definition: MaskedImage.cc:635
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::PixelTVec
boost::mpl::vector< ImagePixelT, MaskPixelT, VariancePixelT > PixelTVec
Definition: MaskedImage.h:420
lsst::afw::image::MaskedImage::Variance
lsst::afw::image::Image< VariancePixelT > Variance
Definition: MaskedImage.h:84
lsst::afw::image::ImageBase::x_at
x_iterator x_at(int x, int y) const
Return an x_iterator to the point (x, y) in the image.
Definition: ImageBase.h:405
lsst::afw::image::MaskedImage::MaskedImageIteratorBase::operator++
MaskedImageIteratorBase & operator++()
Increment the iterator (prefix)
Definition: MaskedImage.h:165
lsst::afw::image::ConstReference
metafunction to extract const reference type from PixelT
Definition: ImageBase.h:90
lsst::afw::image::Reference
metafunction to extract reference type from PixelT
Definition: ImageBase.h:85
lsst::afw::image::MaskedImage::getY0
int getY0() const
Return the image's row-origin.
Definition: MaskedImage.h:1102
lsst::afw::image::MaskedImage::getXY0
lsst::geom::Point2I getXY0() const
Return the image's origin.
Definition: MaskedImage.h:1110
lsst::afw::image::MaskedImage::const_MaskedImageLocator::const_MaskedImageLocator
const_MaskedImageLocator(MaskedImageLocator< ImageLocator, MaskLocator, VarianceLocator > const &iter)
Definition: MaskedImage.h:528
lsst::afw::image::MaskedImage::const_x_iterator
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::MaskedImage
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:73
lsst::afw::image::detail::fitsFile_RE
std::string const fitsFile_RE
regexp to identify when MaskedImages should be written as MEFs
Definition: MaskedImage.h:55
image
afw::table::Key< afw::table::Array< ImagePixelT > > image
Definition: HeavyFootprint.cc:216
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::operator+=
MaskedImageLocatorBase & operator+=(pair2I const &p)
Increment the locator's x and y positions by p
Definition: MaskedImage.h:481
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::cached_location_t::cached_location_t
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
lsst::afw::image::detail::MaskedImage_tag
A traits class for MaskedImage.
Definition: MaskedImage.h:50
lsst::afw::image::MaskedImage::rbegin
reverse_iterator rbegin() const
Return a reverse_iterator to the start of the image.
Definition: MaskedImage.cc:585
lsst::afw::image::MaskedImage::setXY0
void setXY0(lsst::geom::Point2I const origin)
Set the MaskedImage's origin.
Definition: MaskedImage.h:1130
lsst::afw::image::ImageBase::xy_at
xy_locator xy_at(int x, int y) const
Return an xy_locator at the point (x, y) in the image.
Definition: ImageBase.h:423
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::mask
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
lsst::afw::image::MaskedImage::setImage
void setImage(Image const &other)
Set the image plane's pixel values to those of another Image.
Definition: MaskedImage.h:1055
x
double x
Definition: ChebyshevBoundedField.cc:277
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::IMVCachedLocation
boost::tuple< typename ImageLocator::cached_location_t, typename MaskLocator::cached_location_t, typename VarianceLocator::cached_location_t > IMVCachedLocation
Definition: MaskedImage.h:353
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::image
Ref< ImagePixelT >::type image()
Return a reference to the image at the current position of the locator.
Definition: MaskedImage.h:445
other
ItemVariant const * other
Definition: Schema.cc:56
lsst::afw::image::MaskedImage::xy_locator
MaskedImageLocator< typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator > xy_locator
A locator for a MaskedImage.
Definition: MaskedImage.h:577
lsst::afw::image::MaskedImage::operator[]
MaskedImage operator[](lsst::geom::Box2I const &bbox) const
Return a subimage corresponding to the given box (interpreted as PARENT coordinates).
Definition: MaskedImage.h:795
lsst::afw::image::VariancePixel
float VariancePixel
default type for MaskedImage variance images
Definition: LsstImageTypes.h:35
lsst::afw::image::detail::MaskedImagePixel_tag
A class used to identify classes that represent MaskedImage pixels.
Definition: MaskedImage.h:52
lsst::afw::image::MaskedImage::getX0
int getX0() const
Return the image's column-origin.
Definition: MaskedImage.h:1094
lsst::afw::image::MaskedImage::MaskedImageIteratorBase::operator==
bool operator==(MaskedImageIteratorBase const &rhs)
Return true if the lhs equals the rhs.
Definition: MaskedImage.h:180
lsst::afw::image::MaskedImage::operator/=
MaskedImage & operator/=(ImagePixelT const rhs)
Definition: MaskedImage.cc:399
lsst::afw::image::MaskedImage::at
iterator at(int const x, int const y) const
Return an iterator at the point (x, y)
Definition: MaskedImage.cc:575
lsst::afw::image::MaskedImage::MaskPlaneDict
Mask< MaskPixelT >::MaskPlaneDict MaskPlaneDict
The Mask's MaskPlaneDict.
Definition: MaskedImage.h:82
lsst::afw::image::MaskedImage::VariancePtr
std::shared_ptr< image::Image< VariancePixelT > > VariancePtr
shared pointer to the variance Image
Definition: MaskedImage.h:80
lsst::afw::image::MaskedImage::scaledPlus
void scaledPlus(double const c, MaskedImage const &rhs)
Add a scaled MaskedImage c*rhs to a MaskedImage.
Definition: MaskedImage.cc:246
dimensions
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:49
lsst::afw::image::MaskedImage::Mask
lsst::afw::image::Mask< MaskPixelT > Mask
Definition: MaskedImage.h:86
lsst::afw::image::MaskPixel
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks
Definition: LsstImageTypes.h:34
lsst::afw::image::MaskedImage::operator+=
MaskedImage & operator+=(ImagePixelT const rhs)
Add a scalar rhs to a MaskedImage.
Definition: MaskedImage.cc:255
std::map< std::string, int >
lsst::afw::image::MaskedImage::readFits
static MaskedImage readFits(fits::MemFileManager &manager)
Read a MaskedImage from a FITS RAM file.
Definition: MaskedImage.h:1039
lsst::afw::image::MaskedImage::MaskedImageIteratorBase::MaskedImageIteratorBase
MaskedImageIteratorBase(ImageIterator const &img, MaskIterator const &msk, VarianceIterator const &var)
Construct a MaskedImageIteratorBase from the image/mask/variance iterators.
Definition: MaskedImage.h:135
lsst::afw::image::MaskedImage::scaledMinus
void scaledMinus(double const c, MaskedImage const &rhs)
Subtract a scaled MaskedImage c*rhs from a MaskedImage.
Definition: MaskedImage.cc:270
lsst::afw::image::MaskedImage::~MaskedImage
virtual ~MaskedImage()=default
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::cache_location
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
lsst::afw::image::ImageBase< ImagePixelT >::x_iterator
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
Definition: ImageBase.h:133
lsst::afw::image::MaskedImage::end
iterator end() const
Return an iterator to the end of the image.
Definition: MaskedImage.cc:565
lsst::afw::image::MaskedImage::reverse_iterator
MaskedImageIterator< typename Image::reverse_iterator, typename Mask::reverse_iterator, typename Variance::reverse_iterator > reverse_iterator
Definition: MaskedImage.h:547
lsst::afw::image::MaskedImage::Pixel
lsst::afw::image::pixel::Pixel< ImagePixelT, MaskPixelT, VariancePixelT > Pixel
A Pixel in the MaskedImage.
Definition: MaskedImage.h:108
lsst::afw::image::MaskedImage::MaskedImageIteratorBase::operator-=
MaskedImageIteratorBase & operator-=(std::ptrdiff_t delta)
Decrement the iterator by delta
Definition: MaskedImage.h:159
lsst::afw::image::MaskedImage::const_iterator
const_MaskedImageIterator< typename Image::iterator, typename Mask::iterator, typename Variance::iterator > const_iterator
Definition: MaskedImage.h:543
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
lsst::afw::image::MaskedImage::getVariance
VariancePtr getVariance() const
Return a (shared_ptr to) the MaskedImage's variance.
Definition: MaskedImage.h:1079
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
lsst::afw::image::MaskedImage::MaskedImageIteratorBase::operator+=
MaskedImageIteratorBase & operator+=(std::ptrdiff_t delta)
Increment the iterator by delta
Definition: MaskedImage.h:153
lsst::afw::image::MaskedImage::scaledDivides
void scaledDivides(double const c, MaskedImage const &rhs)
Definition: MaskedImage.cc:383
lsst::afw::image::MaskedImage::MaskPtr
std::shared_ptr< image::Mask< MaskPixelT > > MaskPtr
shared pointer to the Mask
Definition: MaskedImage.h:78
lsst::afw::math::Function2< double >
lsst::afw::image::MaskedImage::const_xy_locator
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
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::cached_location_t
A saved relative position, providing efficient access to neighbouring pixels.
Definition: MaskedImage.h:359
LsstImageTypes.h
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::image
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
lsst::afw::image::ImageBase::getX0
int getX0() const
Return the image's column-origin.
Definition: ImageBase.h:304
lsst::afw::image::ImageBase::getDimensions
lsst::geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
Definition: ImageBase.h:354
Mask.h
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::operator+=
MaskedImageLocatorBase & operator+=(detail::difference_type p)
Increment the locator's x and y positions by p
Definition: MaskedImage.h:486
variance
afw::table::Key< afw::table::Array< VariancePixelT > > variance
Definition: HeavyFootprint.cc:218
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::mask
Ref< MaskPixelT >::type mask()
Return a reference to the mask at the current position of the locator.
Definition: MaskedImage.h:454
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::MaskedImageLocatorBase
MaskedImageLocatorBase(ImageLocator const &img, MaskLocator const &msk, VarianceLocator const &var)
Construct a MaskedImageLocator from image/mask/variance locators.
Definition: MaskedImage.h:377
lsst.pex::exceptions::InvalidParameterError
Reports invalid arguments.
Definition: Runtime.h:66
lsst::afw::image::MaskedImage::MaskedImageIteratorBase::operator-
std::ptrdiff_t operator-(MaskedImageIteratorBase const &rhs)
Return the distance between two iterators.
Definition: MaskedImage.h:176
lsst::afw::image::MaskedImage::fast_iterator
x_iterator fast_iterator
A fast STL compliant iterator for contiguous images N.b.
Definition: MaskedImage.h:564
Pixel.h
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::y_iterator
_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
lsst::afw::image::MaskedImage::y_iterator
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
type
table::Key< int > type
Definition: Detector.cc:163
lsst::afw::image::MaskedImage::MaskedImageLocator
A locator for the MaskedImage.
Definition: MaskedImage.h:105
lsst::afw::image::MaskedImage::MaskedImageIteratorBase::variance
Ref< VariancePixelT >::type variance()
Return (a reference to) the variance part of the Pixel pointed at by the iterator.
Definition: MaskedImage.h:145
lsst::afw::image::MaskedImage::MaskedImageIterator::operator+
MaskedImageIterator operator+(std::ptrdiff_t delta)
Return a MaskedImageIterator that's delta beyond this.
Definition: MaskedImage.h:217
lsst::geom::Point< int, 2 >
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::operator[]
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
lsst::afw::image::ImageBase< ImagePixelT >::iterator
_view_t::iterator iterator
An STL compliant iterator.
Definition: ImageBase.h:125
lsst::afw::image::MaskedImage::MaskedImageIteratorBase::type
Pixel type
Type pointed to by the iterator.
Definition: MaskedImage.h:132
lsst::afw::image::MaskedImage::xy_y_iterator
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
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::image
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
lsst::afw::image::MaskedImage::const_MaskedImageIterator
An const iterator to the MaskedImage.
Definition: MaskedImage.h:102
std::ptrdiff_t
lsst::geom::Box2I
An integer coordinate rectangle.
Definition: Box.h:55
lsst::afw::image::MaskedImage::MaskedImageLocator::MaskedImageLocator
MaskedImageLocator(ImageLocator &img, MaskLocator &msk, VarianceLocator &var)
Definition: MaskedImage.h:508
lsst::afw::image::PARENT
@ PARENT
Definition: ImageBase.h:94
lsst::afw::image::ImageBase::getXY0
lsst::geom::Point2I getXY0() const
Return the image's origin.
Definition: ImageBase.h:321
lsst::afw::image::MaskedImage::getImage
ImagePtr getImage() const
Return a (shared_ptr to) the MaskedImage's image.
Definition: MaskedImage.h:1046
lsst::afw::image::ImageBase::setXY0
void setXY0(lsst::geom::Point2I const origin)
Set the ImageBase's origin.
Definition: ImageBase.h:432
lsst::afw::image::makeMaskedImage
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
lsst::afw::image::ImageBase::getY0
int getY0() const
Return the image's row-origin.
Definition: ImageBase.h:312
lsst::afw::image::GetImage
Definition: MaskedImage.h:1315
lsst::afw::image::MaskedImage::iterator
MaskedImageIterator< typename Image::iterator, typename Mask::iterator, typename Variance::iterator > iterator
Definition: MaskedImage.h:539
lsst::afw::image::ImageOrigin
ImageOrigin
Definition: ImageBase.h:94
lsst::afw::image::imagesOverlap
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:700
lsst::afw::image::MaskedImage::MaskedImageIteratorBase::get_iterator_tuple
const IMV_iterator_tuple get_iterator_tuple() const
Return the underlying iterator tuple.
Definition: MaskedImage.h:150
lsst::afw::image::MaskedImage::setXY0
void setXY0(int const x0, int const y0)
Set the MaskedImage's origin.
Definition: MaskedImage.h:1120
lsst::afw::image::xOrY
xOrY
Definition: ImageUtils.h:36
lsst::afw::image::ImageBase::getBBox
lsst::geom::Box2I getBBox(ImageOrigin origin=PARENT) const
Definition: ImageBase.h:443
lsst::afw::image::MaskedImage::writeFits
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:406
lsst::afw::image::Image
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:58
lsst::afw::image::MaskedImage::assign
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:228
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::apply_IMV
Ref< typename boost::mpl::at< PixelTVec, N >::type >::type apply_IMV()
Definition: MaskedImage.h:429
lsst::afw::image::detail::basic_tag
Base image tag.
Definition: ImageBase.h:61
lsst::afw::image::MaskedImage::col_begin
y_iterator col_begin(int x) const
Return an y_iterator to the start of the image.
Definition: MaskedImage.cc:625
lsst::afw::image::MaskedImage::getMask
MaskPtr getMask() const
Return a (shared_ptr to) the MaskedImage's mask.
Definition: MaskedImage.h:1058
lsst::afw::image::MaskedImage::setVariance
void setVariance(Variance const &other)
Set the variance plane's pixel values to those of another Image.
Definition: MaskedImage.h:1076
lsst::afw::image::MaskedImage::operator*=
MaskedImage & operator*=(ImagePixelT const rhs)
Definition: MaskedImage.cc:338
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::operator()
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::MaskedImage::const_MaskedImageIterator::const_MaskedImageIterator
const_MaskedImageIterator(MaskedImageIterator< ImageIterator, MaskIterator, VarianceIterator > const &iter)
Definition: MaskedImage.h:241
lsst::geom::Extent< int, 2 >
lsst::afw::image::MaskedImage::xy_x_iterator
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
astshim.fitsChanContinued.iter
def iter(self)
Definition: fitsChanContinued.py:88
lsst::afw::image::MaskedImage::y_at
y_iterator y_at(int x, int y) const
Return an y_iterator at the point (x, y)
Definition: MaskedImage.h:1228
lsst::afw::image::MaskedImage::operator-=
MaskedImage & operator-=(ImagePixelT const rhs)
Subtract a scalar rhs from a MaskedImage.
Definition: MaskedImage.cc:279
lsst::afw::image::MaskedImage::Image
lsst::afw::image::Image< ImagePixelT > Image
Definition: MaskedImage.h:85
lsst::afw::image::MaskedImage::getDimensions
lsst::geom::Extent2I getDimensions() const
Definition: MaskedImage.h:1085
lsst::afw::image::MaskedImage::MaskedImageLocatorBase
The base class for MaskedImageLocators (const and non-const)
Definition: MaskedImage.h:261
lsst::afw::image::MaskedImage::x_iterator
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
lsst::afw::image::ImageBase::getWidth
int getWidth() const
Return the number of columns in the image.
Definition: ImageBase.h:294
bbox
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::cached_location_t::_imv
IMVCachedLocation _imv
Definition: MaskedImage.h:374
lsst::afw::image::MaskedImage::subset
MaskedImage subset(lsst::geom::Box2I const &bbox, ImageOrigin origin=PARENT) const
Return a subimage corresponding to the given box.
Definition: MaskedImage.h:790
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::x_iterator
_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
lsst::afw::image::MaskedImage::MaskedImageLocatorBase::operator==
bool operator==(MaskedImageLocatorBase const &rhs)
Return true iff two locators are equal.
Definition: MaskedImage.h:470
lsst::afw::image::MaskedImage::rend
reverse_iterator rend() const
Return a reverse_iterator to the end of the image.
Definition: MaskedImage.cc:595
lsst::afw::image::MaskedImage::const_y_iterator
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