LSSTApplications  19.0.0-10-g920eed2,19.0.0-11-g48a0200+2,19.0.0-18-gfc4e62b+13,19.0.0-2-g3b2f90d+2,19.0.0-2-gd671419+5,19.0.0-20-g5a5a17ab+11,19.0.0-21-g2644856+13,19.0.0-23-g84eeccb+1,19.0.0-24-g878c510+1,19.0.0-25-g6c8df7140,19.0.0-25-gb330496+1,19.0.0-3-g2b32d65+5,19.0.0-3-g8227491+12,19.0.0-3-g9c54d0d+12,19.0.0-3-gca68e65+8,19.0.0-3-gcfc5f51+5,19.0.0-3-ge110943+11,19.0.0-3-ge74d124,19.0.0-3-gfe04aa6+13,19.0.0-30-g9c3fd16+1,19.0.0-4-g06f5963+5,19.0.0-4-g3d16501+13,19.0.0-4-g4a9c019+5,19.0.0-4-g5a8b323,19.0.0-4-g66397f0+1,19.0.0-4-g8278b9b+1,19.0.0-4-g8557e14,19.0.0-4-g8964aba+13,19.0.0-4-ge404a01+12,19.0.0-5-g40f3a5a,19.0.0-5-g4db63b3,19.0.0-5-gfb03ce7+13,19.0.0-6-gbaebbfb+12,19.0.0-61-gec4c6e08+1,19.0.0-7-g039c0b5+11,19.0.0-7-gbea9075+4,19.0.0-7-gc567de5+13,19.0.0-71-g41c0270,19.0.0-9-g2f02add+1,19.0.0-9-g463f923+12,w.2020.22
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 
804  [[deprecated("Use `assign` instead. To be removed after 20.0.0.")]] // DM-22814
805  MaskedImage&
806  operator<<=(MaskedImage const& rhs);
807 
819  void assign(MaskedImage const& rhs, lsst::geom::Box2I const& bbox = lsst::geom::Box2I(),
820  ImageOrigin origin = PARENT);
821 
823  MaskedImage& operator+=(ImagePixelT const rhs);
833  MaskedImage& operator+=(MaskedImage const& rhs);
835  *_image += rhs;
836  return *this;
837  }
839  *_image += function;
840  return *this;
841  }
850  void scaledPlus(double const c, MaskedImage const& rhs);
851 
853  MaskedImage& operator-=(ImagePixelT const rhs);
860  MaskedImage& operator-=(MaskedImage const& rhs);
862  *_image -= rhs;
863  return *this;
864  }
866  *_image -= function;
867  return *this;
868  }
875  void scaledMinus(double const c, MaskedImage const& rhs);
876 
877  MaskedImage& operator*=(ImagePixelT const rhs);
878  MaskedImage& operator*=(MaskedImage const& rhs);
880  *_image *= rhs;
881  *_variance *= rhs; // yes, multiply twice
882  *_variance *= rhs;
883  return *this;
884  }
885  void scaledMultiplies(double const c, MaskedImage const& rhs);
886 
887  MaskedImage& operator/=(ImagePixelT const rhs);
888  MaskedImage& operator/=(MaskedImage const& rhs);
890  *_image /= rhs;
891  *_variance /= rhs; // yes, divide twice
892  *_variance /= rhs;
893  return *this;
894  }
895  void scaledDivides(double const c, MaskedImage const& rhs);
896 
911  void writeFits(std::string const& fileName,
920 
934  void writeFits(fits::MemFileManager& manager,
943 
957  void writeFits(fits::Fits& fitsfile,
966 
983  void writeFits(std::string const& fileName, fits::ImageWriteOptions const& imageOptions,
984  fits::ImageWriteOptions const& maskOptions, fits::ImageWriteOptions const& varianceOptions,
986  std::shared_ptr<daf::base::PropertySet const> imageMetadata = nullptr,
987  std::shared_ptr<daf::base::PropertySet const> maskMetadata = nullptr,
988  std::shared_ptr<daf::base::PropertySet const> varianceMetadata = nullptr) const;
989 
1006  void writeFits(fits::MemFileManager& manager, fits::ImageWriteOptions const& imageOptions,
1007  fits::ImageWriteOptions const& maskOptions, fits::ImageWriteOptions const& varianceOptions,
1009  std::shared_ptr<daf::base::PropertySet const> imageMetadata = nullptr,
1010  std::shared_ptr<daf::base::PropertySet const> maskMetadata = nullptr,
1011  std::shared_ptr<daf::base::PropertySet const> varianceMetadata = nullptr) const;
1012 
1029  void writeFits(fits::Fits& fitsfile, fits::ImageWriteOptions const& imageOptions,
1030  fits::ImageWriteOptions const& maskOptions, fits::ImageWriteOptions const& varianceOptions,
1032  std::shared_ptr<daf::base::PropertySet const> imageMetadata = nullptr,
1033  std::shared_ptr<daf::base::PropertySet const> maskMetadata = nullptr,
1034  std::shared_ptr<daf::base::PropertySet const> varianceMetadata = nullptr) const;
1035 
1041  static MaskedImage readFits(std::string const& filename) {
1043  }
1044 
1052  }
1053 
1054  // Getters
1055 
1057  ImagePtr getImage() const { return _image; }
1058 
1066  void setImage(Image const& other) { _image->assign(other); }
1067 
1069  MaskPtr getMask() const { return _mask; }
1070 
1078  void setMask(Mask const& other) { _mask->assign(other); }
1079 
1087  void setVariance(Variance const& other) { _variance->assign(other); }
1088 
1090  VariancePtr getVariance() const { return _variance; }
1091 
1093  int getWidth() const { return _image->getWidth(); }
1095  int getHeight() const { return _image->getHeight(); }
1096  lsst::geom::Extent2I getDimensions() const { return _image->getDimensions(); }
1097  lsst::geom::Box2I getBBox(ImageOrigin const origin = PARENT) const { return _image->getBBox(origin); }
1105  int getX0() const { return _image->getX0(); }
1113  int getY0() const { return _image->getY0(); }
1121  lsst::geom::Point2I getXY0() const { return _image->getXY0(); }
1122 
1131  void setXY0(int const x0, int const y0) { setXY0(lsst::geom::Point2I(x0, y0)); }
1132 
1141  void setXY0(lsst::geom::Point2I const origin) {
1142  if (_image) {
1143  _image->setXY0(origin);
1144  }
1145 
1146  if (_mask) {
1147  _mask->setXY0(origin);
1148  }
1149 
1150  if (_variance) {
1151  _variance->setXY0(origin);
1152  }
1153  }
1154 
1160  inline double indexToPosition(double ind,
1161  lsst::afw::image::xOrY const xy
1162  ) const {
1163  return getImage()->indexToPosition(ind, xy);
1164  }
1165 
1172  double const pos,
1173  lsst::afw::image::xOrY const xy
1174  ) const {
1175  return getImage()->positionToIndex(pos, xy);
1176  }
1177 
1178  //
1179  // Iterators and Locators
1180  //
1182  iterator begin() const;
1184  iterator end() const;
1186  iterator at(int const x, int const y) const;
1188  reverse_iterator rbegin() const;
1190  reverse_iterator rend() const;
1191 
1202  fast_iterator begin(bool contiguous) const;
1211  fast_iterator end(bool contiguous) const;
1212 
1214  x_iterator row_begin(int y) const;
1216  x_iterator row_end(int y) const;
1217 
1219  x_iterator x_at(int x, int y) const {
1220 #if 0
1221  typename Image::x_iterator imageEnd = getImage()->x_at(x, y);
1222  typename Mask::x_iterator maskEnd = getMask()->x_at(x, y);
1223  typename Variance::x_iterator varianceEnd = getVariance()->x_at(x, y);
1224 #else // bypass checks for non-NULL pointers
1225  typename Image::x_iterator imageEnd = _image->x_at(x, y);
1226  typename Mask::x_iterator maskEnd = _mask->x_at(x, y);
1227  typename Variance::x_iterator varianceEnd = _variance->x_at(x, y);
1228 #endif
1229 
1230  return x_iterator(imageEnd, maskEnd, varianceEnd);
1231  }
1232 
1234  y_iterator col_begin(int x) const;
1236  y_iterator col_end(int x) const;
1237 
1239  y_iterator y_at(int x, int y) const {
1240 #if 0
1241  typename Image::y_iterator imageEnd = getImage()->y_at(x, y);
1242  typename Mask::y_iterator maskEnd = getMask()->y_at(x, y);
1243  typename Variance::y_iterator varianceEnd = getVariance()->y_at(x, y);
1244 #else // bypass checks for non-NULL pointers
1245  typename Image::y_iterator imageEnd = _image->y_at(x, y);
1246  typename Mask::y_iterator maskEnd = _mask->y_at(x, y);
1247  typename Variance::y_iterator varianceEnd = _variance->y_at(x, y);
1248 #endif
1249  return y_iterator(imageEnd, maskEnd, varianceEnd);
1250  }
1251 
1253  xy_locator xy_at(int x, int y) const {
1254 #if 0
1255  typename Image::xy_locator imageEnd = getImage()->xy_at(x, y);
1256  typename Mask::xy_locator maskEnd = getMask()->xy_at(x, y);
1257  typename Variance::xy_locator varianceEnd = getVariance()->xy_at(x, y);
1258 #else // bypass checks for non-NULL pointers
1259  typename Image::xy_locator imageEnd = _image->xy_at(x, y);
1260  typename Mask::xy_locator maskEnd = _mask->xy_at(x, y);
1261  typename Variance::xy_locator varianceEnd = _variance->xy_at(x, y);
1262 #endif
1263 
1264  return xy_locator(imageEnd, maskEnd, varianceEnd);
1265  }
1266 
1267 private:
1268  void conformSizes();
1269 
1270  ImagePtr _image;
1271  MaskPtr _mask;
1272  VariancePtr _variance;
1273 };
1274 
1278 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
1283 ) {
1285 }
1286 
1290 template <typename ImagePixelT1, typename ImagePixelT2>
1291 bool imagesOverlap(MaskedImage<ImagePixelT1, MaskPixel, VariancePixel> const& image1,
1292  MaskedImage<ImagePixelT2, MaskPixel, VariancePixel> const& image2);
1293 
1294 /*
1295  * Some metafunctions to extract an Image pointer from a MaskedImage pointer (or return the original Image
1296  * pointer)
1297  *
1298  * GetImage is the public interface (it forwards the tag --- just for the sake of the UI); the real work
1299  * is in GetImage_ which defines a typedef for the Image and a static function, getImage
1300  *
1301  * E.g.
1302  * In the function
1303  *
1304  * template<typename ImageT>
1305  * void func(shared_ptr<ImageT> image) {
1306  * typename shared_ptr<GetImage<ImageT>::type> im = GetImage<ImageT>::getImage(image);
1307  * }
1308  *
1309  * "im" is a shared_ptr<Image> irrespective of whether ImageT is Masked or not.
1310  */
1311 namespace {
1312 template <typename ImageT, typename TagT>
1313 struct GetImage_ {
1314  typedef ImageT type;
1315  static std::shared_ptr<type> getImage(std::shared_ptr<ImageT> image) { return image; }
1316 };
1317 
1318 template <typename ImageT>
1319 struct GetImage_<ImageT, typename image::detail::MaskedImage_tag> {
1320  typedef typename ImageT::Image type;
1321  static std::shared_ptr<type> getImage(std::shared_ptr<ImageT> image) { return image->getImage(); }
1322 };
1323 } // anonymous namespace
1324 
1325 template <typename ImageT>
1326 struct GetImage : public GetImage_<ImageT, typename ImageT::image_category> {};
1327 } // namespace image
1328 } // namespace afw
1329 } // namespace lsst
1330 
1331 #endif // LSST_IMAGE_MASKEDIMAGE_H
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:329
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:166
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:612
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:861
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:1253
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:558
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:622
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:1041
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:838
lsst::afw::image::MaskedImage::operator+=
MaskedImage & operator+=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:834
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:1160
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:456
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:889
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:865
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:386
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:1219
lsst::afw::image::MaskedImage::getBBox
lsst::geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: MaskedImage.h:1097
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:367
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:1093
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:335
Image.h
lsst::afw::image::MaskedImage::getHeight
int getHeight() const
Return the number of rows in the image.
Definition: MaskedImage.h:1095
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:1171
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:879
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:1078
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:642
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:444
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:1113
lsst::afw::image::MaskedImage::getXY0
lsst::geom::Point2I getXY0() const
Return the image's origin.
Definition: MaskedImage.h:1121
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:592
lsst::afw::image::MaskedImage::setXY0
void setXY0(lsst::geom::Point2I const origin)
Set the MaskedImage's origin.
Definition: MaskedImage.h:1141
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:462
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:1066
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
lsst::afw::image::MaskedImage::operator<<=
MaskedImage & operator<<=(MaskedImage const &rhs)
Copy the pixels from the rhs to the lhs.
Definition: MaskedImage.cc:229
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:1105
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:406
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:582
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:253
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:262
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:1050
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:277
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:572
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:1090
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:390
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:343
lsst::afw::image::ImageBase::getDimensions
lsst::geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
Definition: ImageBase.h:393
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:360
lsst::afw::image::MaskedImage::getImage
ImagePtr getImage() const
Return a (shared_ptr to) the MaskedImage's image.
Definition: MaskedImage.h:1057
lsst::afw::image::ImageBase::setXY0
void setXY0(lsst::geom::Point2I const origin)
Set the ImageBase's origin.
Definition: ImageBase.h:471
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:1279
lsst::afw::image::ImageBase::getY0
int getY0() const
Return the image's row-origin.
Definition: ImageBase.h:351
lsst::afw::image::GetImage
Definition: MaskedImage.h:1326
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:706
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:1131
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:482
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:413
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:235
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:632
lsst::afw::image::MaskedImage::getMask
MaskPtr getMask() const
Return a (shared_ptr to) the MaskedImage's mask.
Definition: MaskedImage.h:1069
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:1087
lsst::afw::image::MaskedImage::operator*=
MaskedImage & operator*=(ImagePixelT const rhs)
Definition: MaskedImage.cc:345
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:1239
lsst::afw::image::MaskedImage::operator-=
MaskedImage & operator-=(ImagePixelT const rhs)
Subtract a scalar rhs from a MaskedImage.
Definition: MaskedImage.cc:286
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:1096
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:333
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:602
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