LSSTApplications  17.0+124,17.0+14,17.0+73,18.0.0+37,18.0.0+80,18.0.0-4-g68ffd23+4,18.1.0-1-g0001055+12,18.1.0-1-g03d53ef+5,18.1.0-1-g1349e88+55,18.1.0-1-g2505f39+44,18.1.0-1-g5315e5e+4,18.1.0-1-g5e4b7ea+14,18.1.0-1-g7e8fceb+4,18.1.0-1-g85f8cd4+48,18.1.0-1-g8ff0b9f+4,18.1.0-1-ga2c679d+1,18.1.0-1-gd55f500+35,18.1.0-10-gb58edde+2,18.1.0-11-g0997b02+4,18.1.0-13-gfe4edf0b+12,18.1.0-14-g259bd21+21,18.1.0-19-gdb69f3f+2,18.1.0-2-g5f9922c+24,18.1.0-2-gd3b74e5+11,18.1.0-2-gfbf3545+32,18.1.0-26-g728bddb4+5,18.1.0-27-g6ff7ca9+2,18.1.0-3-g52aa583+25,18.1.0-3-g8ea57af+9,18.1.0-3-gb69f684+42,18.1.0-3-gfcaddf3+6,18.1.0-32-gd8786685a,18.1.0-4-gf3f9b77+6,18.1.0-5-g1dd662b+2,18.1.0-5-g6dbcb01+41,18.1.0-6-gae77429+3,18.1.0-7-g9d75d83+9,18.1.0-7-gae09a6d+30,18.1.0-9-gc381ef5+4,w.2019.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>
108  class const_MaskedImageLocator;
109 
114 
116  template <typename ImageIterator, typename MaskIterator, typename VarianceIterator,
117  template <typename> class Ref = Reference>
119  typedef boost::tuple<ImageIterator, MaskIterator, VarianceIterator> IMV_iterator_tuple;
120 
121  public:
125  typedef typename boost::zip_iterator<IMV_iterator_tuple>::reference IMV_tuple;
129  template <typename, typename, typename>
132  typedef Pixel type;
133 
135  MaskedImageIteratorBase(ImageIterator const& img, MaskIterator const& msk,
136  VarianceIterator const& var)
137  : _iter(boost::make_zip_iterator(boost::make_tuple(img, msk, var))) {}
139  typename Ref<ImagePixelT>::type image() { return _iter->template get<0>()[0]; }
140 
142  typename Ref<MaskPixelT>::type mask() { return _iter->template get<1>()[0]; }
143 
145  typename Ref<VariancePixelT>::type variance() { return _iter->template get<2>()[0]; }
146 
150  const IMV_iterator_tuple get_iterator_tuple() const { return _iter.get_iterator_tuple(); }
151 
154  ) {
155  _iter += delta;
156  return *this;
157  }
160  ) {
161  _iter -= delta;
162  return *this;
163  }
166  ++_iter;
167  return *this;
168  }
171  MaskedImageIteratorBase tmp(*this);
172  _iter++;
173  return tmp;
174  }
177  return &this->_iter->template get<0>() - &rhs._iter->template get<0>();
178  }
181  return &this->_iter->template get<0>() == &rhs._iter->template get<0>();
182  }
185  return &this->_iter->template get<0>() != &rhs._iter->template get<0>();
186  }
189  return &this->_iter->template get<0>() < &rhs._iter->template get<0>();
190  }
192  operator Pixel() const {
193  return Pixel(_iter->template get<0>()[0], _iter->template get<1>()[0],
194  _iter->template get<2>()[0]);
195  }
196 
198  Pixel operator*() { return Pixel(image(), mask(), variance()); }
200  const Pixel operator*() const { return Pixel(image(), mask(), variance()); }
201 
202  protected:
203  typename boost::zip_iterator<IMV_iterator_tuple> _iter;
204  };
205 
207  template <typename ImageIterator, typename MaskIterator, typename VarianceIterator>
208  class MaskedImageIterator
209  : public MaskedImageIteratorBase<ImageIterator, MaskIterator, VarianceIterator> {
211  MaskedImageIteratorBase_t;
212 
213  public:
214  MaskedImageIterator(ImageIterator& img, MaskIterator& msk, VarianceIterator& var)
215  : MaskedImageIteratorBase_t(img, msk, var) {}
218  MaskedImageIterator lhs = *this;
219  lhs += delta;
220 
221  return lhs;
222  }
223  };
224 
226  template <typename ImageIterator, typename MaskIterator, typename VarianceIterator>
228  : public MaskedImageIteratorBase<typename detail::const_iterator_type<ImageIterator>::type,
229  typename detail::const_iterator_type<MaskIterator>::type,
230  typename detail::const_iterator_type<VarianceIterator>::type,
231  ConstReference> {
232  typedef typename detail::const_iterator_type<ImageIterator>::type const_ImageIterator;
233  typedef typename detail::const_iterator_type<MaskIterator>::type const_MaskIterator;
234  typedef typename detail::const_iterator_type<VarianceIterator>::type const_VarianceIterator;
235 
236  typedef MaskedImageIteratorBase<const_ImageIterator, const_MaskIterator, const_VarianceIterator,
239 
240  public:
243  : MaskedImageIteratorBase_t(
244  const_ImageIterator(iter.get_iterator_tuple().template get<0>()),
245  const_MaskIterator(iter.get_iterator_tuple().template get<1>()),
246  const_VarianceIterator(iter.get_iterator_tuple().template get<2>())) {
247  ;
248  }
251  const_MaskedImageIterator lhs = *this;
252  lhs += delta;
253 
254  return lhs;
255  }
256  };
257 
259  template <typename ImageLocator, typename MaskLocator, typename VarianceLocator,
260  template <typename> class Ref = Reference>
262  typedef typename boost::tuple<ImageLocator, MaskLocator, VarianceLocator> IMVLocator;
263  //
264  // A class to provide _[xy]_iterator for MaskedImageLocator. We can't just use
265  // a zip_iterator as moving this iterator must be the same as moving the locator
266  // itself, for consistency with {Image,Mask}::xy_locator
267  //
268  template <template <typename> class X_OR_Y>
269  class _x_or_y_iterator {
270  public:
271  _x_or_y_iterator(MaskedImageLocatorBase* mil) : _mil(mil) {}
272 
273  _x_or_y_iterator& operator+=(const int di) {
274  // Equivalent to "_mil->_loc.template get<0>().x() += di;"
275  X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())() += di;
276  X_OR_Y<MaskLocator>(_mil->_loc.template get<1>())() += di;
277  X_OR_Y<VarianceLocator>(_mil->_loc.template get<2>())() += di;
278  return *this;
279  }
280 
281  _x_or_y_iterator& operator++() { // prefix
282  // Equivalent to "++_mil->_loc.template get<0>().x();"
283  ++X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())();
284  ++X_OR_Y<MaskLocator>(_mil->_loc.template get<1>())();
285  ++X_OR_Y<VarianceLocator>(_mil->_loc.template get<2>())();
286  return *this;
287  }
288 
289  bool operator==(_x_or_y_iterator const& rhs) {
290  return X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())() ==
291  X_OR_Y<ImageLocator>(rhs._mil->_loc.template get<0>())();
292  }
293  bool operator!=(_x_or_y_iterator const& rhs) {
294  return X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())() !=
295  X_OR_Y<ImageLocator>(rhs._mil->_loc.template get<0>())();
296  }
297  bool operator<(_x_or_y_iterator const& rhs) {
298  return X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())() <
299  X_OR_Y<ImageLocator>(rhs._mil->_loc.template get<0>())();
300  }
301 
302  Pixel operator*() {
303  return Pixel((*(X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())()))[0],
304  (*(X_OR_Y<MaskLocator>(_mil->_loc.template get<1>())()))[0],
305  (*(X_OR_Y<VarianceLocator>(_mil->_loc.template get<2>())()))[0]);
306  }
307 
308  typename Ref<ImagePixelT>::type image() {
309  // Equivalent to "return (*_mil->_loc.template get<0>().x())[0];"
310 
311  return (*(X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())()))[0];
312  }
313  typename Ref<MaskPixelT>::type mask() {
314  return (*(X_OR_Y<MaskLocator>(_mil->_loc.template get<1>())()))[0];
315  }
317  return (*(X_OR_Y<VarianceLocator>(_mil->_loc.template get<2>())()))[0];
318  }
319 
320  protected:
322  };
323 
324  // Two classes to provide .x() and .y() in _x_or_y_iterator
325  template <typename LocT>
326  class apply_x {
327  typedef typename LocT::x_iterator IterT;
328 
329  public:
330  apply_x(LocT& loc) : _loc(loc) {}
331  IterT& operator()() { return _loc.x(); }
332 
333  private:
334  LocT& _loc;
335  };
336 
337  template <typename LocT>
338  class apply_y {
339  typedef typename LocT::y_iterator IterT;
340 
341  public:
342  apply_y(LocT& loc) : _loc(loc) {}
343  IterT& operator()() { return _loc.y(); }
344 
345  private:
346  LocT& _loc;
347  };
348 
349  public:
350  typedef typename boost::tuple<typename ImageLocator::cached_location_t,
351  typename MaskLocator::cached_location_t,
352  typename VarianceLocator::cached_location_t>
355  typedef _x_or_y_iterator<apply_x> x_iterator;
357  typedef _x_or_y_iterator<apply_y> y_iterator;
360  public:
361  // template<typename, typename, typename, template<typename> class> friend class
362  // MaskedImageLocatorBase;
363  template <typename, typename, typename>
365 
367  cached_location_t(IMVLocator const& loc, int x, int y)
368  : _imv(loc.template get<0>().cache_location(x, y),
369  loc.template get<1>().cache_location(x, y),
370  loc.template get<2>().cache_location(x, y)) {
371  ;
372  }
373  // protected:
375  };
377  MaskedImageLocatorBase(ImageLocator const& img, MaskLocator const& msk, VarianceLocator const& var)
378  : _loc(img, msk, var) {
379  ;
380  }
381 
383  Pixel operator*() {
384  return Pixel(_loc.template get<0>().x()[0][0], _loc.template get<1>().x()[0][0],
385  _loc.template get<2>().x()[0][0]);
386  }
387 
389  Pixel operator()(int x, int y) {
390  return Pixel(_loc.template get<0>()(x, y)[0], _loc.template get<1>()(x, y)[0],
391  _loc.template get<2>()(x, y)[0]);
392  }
393 
396  Pixel operator[](cached_location_t const& cached_loc) {
397  return Pixel(_loc.template get<0>()[cached_loc._imv.template get<0>()][0],
398  _loc.template get<1>()[cached_loc._imv.template get<1>()][0],
399  _loc.template get<2>()[cached_loc._imv.template get<2>()][0]);
400  }
405  x_iterator x() { return x_iterator(this); }
406 
411  y_iterator y() { return y_iterator(this); }
412 
414  cached_location_t cache_location(int x, int y) const { return cached_location_t(_loc, x, y); }
415  //
416  // We don't want to duplicate code for image/mask/variance -- but the boost::mpl stuff isn't pretty
417  // as we can't say int_<N> within a template<int N>. So define a set of functions apply_IMV
418  // to do the dirty work
419  //
420  typedef typename boost::mpl::vector<ImagePixelT, MaskPixelT, VariancePixelT> PixelTVec;
421 
422  template <typename N>
424  cached_location_t const& cached_loc) {
425  return _loc.template get<N::value>()[cached_loc._imv.template get<N::value>()][0];
426  }
427 
428  template <typename N>
430  return _loc.template get<N::value>()[0][0];
431  }
432 
433  template <typename N>
435  return _loc.template get<N::value>()(x, y)[0];
436  }
437  //
438  // Use those templated classes to implement image/mask/variance
439  //
441  typename Ref<ImagePixelT>::type image(cached_location_t const& cached_loc) {
442  return apply_IMV<boost::mpl::int_<0>>(cached_loc);
443  }
445  typename Ref<ImagePixelT>::type image() { return apply_IMV<boost::mpl::int_<0>>(); }
447  typename Ref<ImagePixelT>::type image(int x, int y) { return apply_IMV<boost::mpl::int_<0>>(x, y); }
448 
450  typename Ref<MaskPixelT>::type mask(cached_location_t const& cached_loc) {
451  return apply_IMV<boost::mpl::int_<1>>(cached_loc);
452  }
454  typename Ref<MaskPixelT>::type mask() { return apply_IMV<boost::mpl::int_<1>>(); }
456  typename Ref<MaskPixelT>::type mask(int x, int y) { return apply_IMV<boost::mpl::int_<1>>(x, y); }
457 
459  typename Ref<VariancePixelT>::type variance(cached_location_t const& cached_loc) {
460  return apply_IMV<boost::mpl::int_<2>>(cached_loc);
461  }
463  typename Ref<VariancePixelT>::type variance() { return apply_IMV<boost::mpl::int_<2>>(); }
465  typename Ref<VariancePixelT>::type variance(int x, int y) {
466  return apply_IMV<boost::mpl::int_<2>>(x, y);
467  }
468 
471  return _loc.template get<0>() == rhs._loc.template get<0>();
472  }
474  bool operator!=(MaskedImageLocatorBase const& rhs) { return !(*this == rhs); }
477  return _loc.template get<0>() < rhs._loc.template get<0>();
478  }
479 
481  MaskedImageLocatorBase& operator+=(pair2I const& p) {
482  return operator+=(detail::difference_type(p.first, p.second));
483  }
484 
486  MaskedImageLocatorBase& operator+=(detail::difference_type p) {
487  _loc.template get<0>() += p;
488  _loc.template get<1>() += p;
489  _loc.template get<2>() += p;
490 
491  return *this;
492  }
493 
494  // Workaround for DM-5590: clang-3.8 cannot access _loc from
495  // friend class const_MaskedImageLocator.
496  IMVLocator const& getLoc() const { return _loc; }
497 
498  protected:
499  IMVLocator _loc;
500  };
501 
503  template <typename ImageLocator, typename MaskLocator, typename VarianceLocator>
504  class MaskedImageLocator : public MaskedImageLocatorBase<ImageLocator, MaskLocator, VarianceLocator> {
506 
507  public:
508  MaskedImageLocator(ImageLocator& img, MaskLocator& msk, VarianceLocator& var)
509  : MaskedImageLocatorBase_t(img, msk, var) {}
510  };
511 
513  template <typename ImageLocator, typename MaskLocator, typename VarianceLocator>
515  : public MaskedImageLocatorBase<typename detail::const_locator_type<ImageLocator>::type,
516  typename detail::const_locator_type<MaskLocator>::type,
517  typename detail::const_locator_type<VarianceLocator>::type,
518  ConstReference> {
519  typedef typename detail::const_locator_type<ImageLocator>::type const_ImageLocator;
520  typedef typename detail::const_locator_type<MaskLocator>::type const_MaskLocator;
521  typedef typename detail::const_locator_type<VarianceLocator>::type const_VarianceLocator;
522 
523  typedef MaskedImageLocatorBase<const_ImageLocator, const_MaskLocator, const_VarianceLocator,
526 
527  public:
529  : MaskedImageLocatorBase_t(const_ImageLocator(iter.getLoc().template get<0>()),
530  const_MaskLocator(iter.getLoc().template get<1>()),
531  const_VarianceLocator(iter.getLoc().template get<2>())) {
532  ;
533  }
534  };
535 
536  // An iterator to a MaskedImage
537  typedef MaskedImageIterator<typename Image::iterator, typename Mask::iterator,
538  typename Variance::iterator>
540  // A const_iterator to a MaskedImage
541  typedef const_MaskedImageIterator<typename Image::iterator, typename Mask::iterator,
542  typename Variance::iterator>
544  // A reverse_iterator to a MaskedImage
545  typedef MaskedImageIterator<typename Image::reverse_iterator, typename Mask::reverse_iterator,
548 #if 0 // doesn't compile. I should fix this, but it's low priority. RHL
549  typedef const_MaskedImageIterator<typename Image::reverse_iterator,
551  typename Mask::reverse_iterator, typename Variance::reverse_iterator> const_reverse_iterator;
552 #endif
553  typedef MaskedImageIterator<typename Image::x_iterator, typename Mask::x_iterator,
555  typename Variance::x_iterator>
558  typedef const_MaskedImageIterator<typename Image::x_iterator, typename Mask::x_iterator,
559  typename Variance::x_iterator>
566  typedef MaskedImageIterator<typename Image::y_iterator, typename Mask::y_iterator,
567  typename Variance::y_iterator>
570  typedef const_MaskedImageIterator<typename Image::y_iterator, typename Mask::y_iterator,
571  typename Variance::y_iterator>
573 
575  typedef MaskedImageLocator<typename Image::xy_locator, typename Mask::xy_locator,
576  typename Variance::xy_locator>
579  typedef const_MaskedImageLocator<typename Image::xy_locator, typename Mask::xy_locator,
580  typename Variance::xy_locator>
582 
584  typedef typename MaskedImageLocator<typename Image::xy_locator, typename Mask::xy_locator,
587  typedef typename MaskedImageLocator<typename Image::xy_locator, typename Mask::xy_locator,
589 
590  // Constructors
598  explicit MaskedImage(unsigned int width, unsigned int height,
599  MaskPlaneDict const& planeDict = MaskPlaneDict());
607  MaskPlaneDict const& planeDict = MaskPlaneDict());
616  explicit MaskedImage(ImagePtr image, MaskPtr mask = MaskPtr(), VariancePtr variance = VariancePtr());
628  explicit MaskedImage(lsst::geom::Box2I const& bbox, MaskPlaneDict const& planeDict = MaskPlaneDict());
629 
647  explicit MaskedImage(
648  std::string const& fileName,
650  lsst::geom::Box2I const& bbox = lsst::geom::Box2I(), ImageOrigin origin = PARENT,
651  bool conformMasks = false, bool needAllHdus = false,
654  std::shared_ptr<daf::base::PropertySet> varianceMetadata =
656  bool allowUnsafe = false);
657 
675  explicit MaskedImage(
676  fits::MemFileManager& manager,
678  lsst::geom::Box2I const& bbox = lsst::geom::Box2I(), ImageOrigin origin = PARENT,
679  bool conformMasks = false, bool needAllHdus = false,
682  std::shared_ptr<daf::base::PropertySet> varianceMetadata =
684  bool allowUnsafe = false);
685 
703  explicit MaskedImage(
704  fits::Fits& fitsfile,
706  lsst::geom::Box2I const& bbox = lsst::geom::Box2I(), ImageOrigin origin = PARENT,
707  bool conformMasks = false, bool needAllHdus = false,
710  std::shared_ptr<daf::base::PropertySet> varianceMetadata =
712  bool allowUnsafe = false);
713 
720  MaskedImage(MaskedImage const& rhs, bool const deep = false);
721  MaskedImage(MaskedImage&& rhs);
722 
732  MaskedImage(MaskedImage const& rhs, lsst::geom::Box2I const& bbox, ImageOrigin const origin = PARENT,
733  bool const deep = false);
739  template <typename OtherPixelT>
741 
742  const bool deep
743  )
744  : _image(), _mask(), _variance() {
745  if (!deep) {
747  "Only deep copies are permitted for MaskedImages with different pixel types");
748  }
749 
750  _image = ImagePtr(new Image(*rhs.getImage(), deep));
751  _mask = MaskPtr(new Mask(*rhs.getMask(), deep));
752  _variance = VariancePtr(new Variance(*rhs.getVariance(), deep));
753  }
754 
764  MaskedImage& operator=(MaskedImage const& rhs);
765  MaskedImage& operator=(MaskedImage&& rhs);
766 
767  virtual ~MaskedImage() = default;
768 
769  void swap(MaskedImage& rhs);
770 
771  // Operators
773  MaskedImage& operator=(Pixel const& rhs);
775  MaskedImage& operator=(SinglePixel const& rhs);
776 
790  MaskedImage subset(lsst::geom::Box2I const& bbox, ImageOrigin origin = PARENT) const {
791  return MaskedImage(*this, bbox, origin, false);
792  }
793 
795  MaskedImage operator[](lsst::geom::Box2I const& bbox) const { return subset(bbox); }
796 
804  MaskedImage& operator<<=(MaskedImage const& rhs);
805 
817  void assign(MaskedImage const& rhs, lsst::geom::Box2I const& bbox = lsst::geom::Box2I(),
818  ImageOrigin origin = PARENT);
819 
821  MaskedImage& operator+=(ImagePixelT const rhs);
831  MaskedImage& operator+=(MaskedImage const& rhs);
833  *_image += rhs;
834  return *this;
835  }
837  *_image += function;
838  return *this;
839  }
848  void scaledPlus(double const c, MaskedImage const& rhs);
849 
851  MaskedImage& operator-=(ImagePixelT const rhs);
858  MaskedImage& operator-=(MaskedImage const& rhs);
860  *_image -= rhs;
861  return *this;
862  }
864  *_image -= function;
865  return *this;
866  }
873  void scaledMinus(double const c, MaskedImage const& rhs);
874 
875  MaskedImage& operator*=(ImagePixelT const rhs);
876  MaskedImage& operator*=(MaskedImage const& rhs);
878  *_image *= rhs;
879  *_variance *= rhs; // yes, multiply twice
880  *_variance *= rhs;
881  return *this;
882  }
883  void scaledMultiplies(double const c, MaskedImage const& rhs);
884 
885  MaskedImage& operator/=(ImagePixelT const rhs);
886  MaskedImage& operator/=(MaskedImage const& rhs);
888  *_image /= rhs;
889  *_variance /= rhs; // yes, divide twice
890  *_variance /= rhs;
891  return *this;
892  }
893  void scaledDivides(double const c, MaskedImage const& rhs);
894 
909  void writeFits(std::string const& fileName,
918 
932  void writeFits(fits::MemFileManager& manager,
941 
955  void writeFits(fits::Fits& fitsfile,
964 
981  void writeFits(std::string const& fileName, fits::ImageWriteOptions const& imageOptions,
982  fits::ImageWriteOptions const& maskOptions, fits::ImageWriteOptions const& varianceOptions,
984  std::shared_ptr<daf::base::PropertySet const> imageMetadata = nullptr,
985  std::shared_ptr<daf::base::PropertySet const> maskMetadata = nullptr,
986  std::shared_ptr<daf::base::PropertySet const> varianceMetadata = nullptr) const;
987 
1004  void writeFits(fits::MemFileManager& manager, fits::ImageWriteOptions const& imageOptions,
1005  fits::ImageWriteOptions const& maskOptions, fits::ImageWriteOptions const& varianceOptions,
1007  std::shared_ptr<daf::base::PropertySet const> imageMetadata = nullptr,
1008  std::shared_ptr<daf::base::PropertySet const> maskMetadata = nullptr,
1009  std::shared_ptr<daf::base::PropertySet const> varianceMetadata = nullptr) const;
1010 
1027  void writeFits(fits::Fits& fitsfile, fits::ImageWriteOptions const& imageOptions,
1028  fits::ImageWriteOptions const& maskOptions, fits::ImageWriteOptions const& varianceOptions,
1030  std::shared_ptr<daf::base::PropertySet const> imageMetadata = nullptr,
1031  std::shared_ptr<daf::base::PropertySet const> maskMetadata = nullptr,
1032  std::shared_ptr<daf::base::PropertySet const> varianceMetadata = nullptr) const;
1033 
1039  static MaskedImage readFits(std::string const& filename) {
1041  }
1042 
1050  }
1051 
1052  // Getters
1053 
1055  ImagePtr getImage() const { return _image; }
1056 
1064  void setImage(Image const& other) { _image->assign(other); }
1065 
1067  MaskPtr getMask() const { return _mask; }
1068 
1076  void setMask(Mask const& other) { _mask->assign(other); }
1077 
1085  void setVariance(Variance const& other) { _variance->assign(other); }
1086 
1088  VariancePtr getVariance() const { return _variance; }
1089 
1091  int getWidth() const { return _image->getWidth(); }
1093  int getHeight() const { return _image->getHeight(); }
1094  lsst::geom::Extent2I getDimensions() const { return _image->getDimensions(); }
1095  lsst::geom::Box2I getBBox(ImageOrigin const origin = PARENT) const { return _image->getBBox(origin); }
1103  int getX0() const { return _image->getX0(); }
1111  int getY0() const { return _image->getY0(); }
1119  lsst::geom::Point2I getXY0() const { return _image->getXY0(); }
1120 
1129  void setXY0(int const x0, int const y0) { setXY0(lsst::geom::Point2I(x0, y0)); }
1130 
1139  void setXY0(lsst::geom::Point2I const origin) {
1140  if (_image) {
1141  _image->setXY0(origin);
1142  }
1143 
1144  if (_mask) {
1145  _mask->setXY0(origin);
1146  }
1147 
1148  if (_variance) {
1149  _variance->setXY0(origin);
1150  }
1151  }
1152 
1158  inline double indexToPosition(double ind,
1159  lsst::afw::image::xOrY const xy
1160  ) const {
1161  return getImage()->indexToPosition(ind, xy);
1162  }
1163 
1170  double const pos,
1171  lsst::afw::image::xOrY const xy
1172  ) const {
1173  return getImage()->positionToIndex(pos, xy);
1174  }
1175 
1176  //
1177  // Iterators and Locators
1178  //
1180  iterator begin() const;
1182  iterator end() const;
1184  iterator at(int const x, int const y) const;
1186  reverse_iterator rbegin() const;
1188  reverse_iterator rend() const;
1189 
1200  fast_iterator begin(bool contiguous) const;
1209  fast_iterator end(bool contiguous) const;
1210 
1212  x_iterator row_begin(int y) const;
1214  x_iterator row_end(int y) const;
1215 
1217  x_iterator x_at(int x, int y) const {
1218 #if 0
1219  typename Image::x_iterator imageEnd = getImage()->x_at(x, y);
1220  typename Mask::x_iterator maskEnd = getMask()->x_at(x, y);
1221  typename Variance::x_iterator varianceEnd = getVariance()->x_at(x, y);
1222 #else // bypass checks for non-NULL pointers
1223  typename Image::x_iterator imageEnd = _image->x_at(x, y);
1224  typename Mask::x_iterator maskEnd = _mask->x_at(x, y);
1225  typename Variance::x_iterator varianceEnd = _variance->x_at(x, y);
1226 #endif
1227 
1228  return x_iterator(imageEnd, maskEnd, varianceEnd);
1229  }
1230 
1232  y_iterator col_begin(int x) const;
1234  y_iterator col_end(int x) const;
1235 
1237  y_iterator y_at(int x, int y) const {
1238 #if 0
1239  typename Image::y_iterator imageEnd = getImage()->y_at(x, y);
1240  typename Mask::y_iterator maskEnd = getMask()->y_at(x, y);
1241  typename Variance::y_iterator varianceEnd = getVariance()->y_at(x, y);
1242 #else // bypass checks for non-NULL pointers
1243  typename Image::y_iterator imageEnd = _image->y_at(x, y);
1244  typename Mask::y_iterator maskEnd = _mask->y_at(x, y);
1245  typename Variance::y_iterator varianceEnd = _variance->y_at(x, y);
1246 #endif
1247  return y_iterator(imageEnd, maskEnd, varianceEnd);
1248  }
1249 
1251  xy_locator xy_at(int x, int y) const {
1252 #if 0
1253  typename Image::xy_locator imageEnd = getImage()->xy_at(x, y);
1254  typename Mask::xy_locator maskEnd = getMask()->xy_at(x, y);
1255  typename Variance::xy_locator varianceEnd = getVariance()->xy_at(x, y);
1256 #else // bypass checks for non-NULL pointers
1257  typename Image::xy_locator imageEnd = _image->xy_at(x, y);
1258  typename Mask::xy_locator maskEnd = _mask->xy_at(x, y);
1259  typename Variance::xy_locator varianceEnd = _variance->xy_at(x, y);
1260 #endif
1261 
1262  return xy_locator(imageEnd, maskEnd, varianceEnd);
1263  }
1264 
1265 private:
1266  void conformSizes();
1267 
1268  ImagePtr _image;
1269  MaskPtr _mask;
1270  VariancePtr _variance;
1271 };
1272 
1276 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
1278  typename std::shared_ptr<Image<ImagePixelT>> image,
1281 ) {
1283 }
1284 
1288 template <typename ImagePixelT1, typename ImagePixelT2>
1291 
1292 /*
1293  * Some metafunctions to extract an Image pointer from a MaskedImage pointer (or return the original Image
1294  * pointer)
1295  *
1296  * GetImage is the public interface (it forwards the tag --- just for the sake of the UI); the real work
1297  * is in GetImage_ which defines a typedef for the Image and a static function, getImage
1298  *
1299  * E.g.
1300  * In the function
1301  *
1302  * template<typename ImageT>
1303  * void func(shared_ptr<ImageT> image) {
1304  * typename shared_ptr<GetImage<ImageT>::type> im = GetImage<ImageT>::getImage(image);
1305  * }
1306  *
1307  * "im" is a shared_ptr<Image> irrespective of whether ImageT is Masked or not.
1308  */
1309 namespace {
1310 template <typename ImageT, typename TagT>
1311 struct GetImage_ {
1312  typedef ImageT type;
1313  static std::shared_ptr<type> getImage(std::shared_ptr<ImageT> image) { return image; }
1314 };
1315 
1316 template <typename ImageT>
1317 struct GetImage_<ImageT, typename image::detail::MaskedImage_tag> {
1318  typedef typename ImageT::Image type;
1319  static std::shared_ptr<type> getImage(std::shared_ptr<ImageT> image) { return image->getImage(); }
1320 };
1321 } // anonymous namespace
1322 
1323 template <typename ImageT>
1324 struct GetImage : public GetImage_<ImageT, typename ImageT::image_category> {};
1325 } // namespace image
1326 } // namespace afw
1327 } // namespace lsst
1328 
1329 #endif // LSST_IMAGE_MASKEDIMAGE_H
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
VariancePtr getVariance() const
Return a (shared_ptr to) the MaskedImage&#39;s variance.
Definition: MaskedImage.h:1088
MaskedImageLocatorBase & operator+=(detail::difference_type p)
Increment the locator&#39;s x and y positions by p
Definition: MaskedImage.h:486
cached_location_t cache_location(int x, int y) const
Create a cached_location_t offset by (x, y) from locator.
Definition: MaskedImage.h:414
MaskedImageIterator operator+(std::ptrdiff_t delta)
Return a MaskedImageIterator that&#39;s delta beyond this.
Definition: MaskedImage.h:217
std::pair< int, double > positionToIndex(double const pos, lsst::afw::image::xOrY const xy) const
Convert image position to index (see Image::positionToIndex)
Definition: MaskedImage.h:1169
Ref< ImagePixelT >::type image(int x, int y)
Return a reference to the image offset by (x, y) from the current position of the locator...
Definition: MaskedImage.h:447
void scaledPlus(OutImageT &outImage, double c1, InImageT const &inImage1, double c2, InImageT const &inImage2)
Compute the scaled sum of two images.
Ref< ImagePixelT >::type image(cached_location_t const &cached_loc)
Return a reference to the image at the offset set when we created the cached_location_t ...
Definition: MaskedImage.h:441
Ref< MaskPixelT >::type mask()
Return (a reference to) the mask part of the Pixel pointed at by the iterator.
Definition: MaskedImage.h:142
Ref< MaskPixelT >::type mask()
Return a reference to the mask at the current position of the locator.
Definition: MaskedImage.h:454
afw::table::Key< afw::table::Array< VariancePixelT > > variance
const_MaskedImageLocator< typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator > const_xy_locator
A const_locator for a MaskedImage.
Definition: MaskedImage.h:581
y_iterator y()
Return an iterator that can be used to move (or dereference) a locator.
Definition: MaskedImage.h:411
MaskedImageIteratorBase(ImageIterator const &img, MaskIterator const &msk, VarianceIterator const &var)
Construct a MaskedImageIteratorBase from the image/mask/variance iterators.
Definition: MaskedImage.h:135
afw::table::Key< afw::table::Array< ImagePixelT > > image
The base class for MaskedImageLocators (const and non-const)
Definition: MaskedImage.h:261
MaskedImageLocator(ImageLocator &img, MaskLocator &msk, VarianceLocator &var)
Definition: MaskedImage.h:508
Definition: Polygon.cc:25
MaskedImage & operator-=(lsst::afw::math::Function2< double > const &function)
Definition: MaskedImage.h:863
Ref< typename boost::mpl::at< PixelTVec, N >::type >::type apply_IMV(int x, int y)
Definition: MaskedImage.h:434
boost::mpl::vector< ImagePixelT, MaskPixelT, VariancePixelT > PixelTVec
Definition: MaskedImage.h:420
_view_t::reverse_iterator reverse_iterator
An STL compliant reverse iterator.
Definition: ImageBase.h:129
std::shared_ptr< image::Mask< MaskPixelT > > MaskPtr
shared pointer to the Mask
Definition: MaskedImage.h:78
const_MaskedImageIterator< typename Image::iterator, typename Mask::iterator, typename Variance::iterator > const_iterator
Definition: MaskedImage.h:543
boost::zip_iterator< IMV_iterator_tuple > _iter
Definition: MaskedImage.h:203
Image< LhsPixelT > & operator+=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Add lhs to Image rhs (i.e. pixel-by-pixel addition) where types are different.
Definition: Image.cc:671
afw::table::Key< afw::table::Array< MaskPixelT > > mask
float Pixel
Typedefs to be used for pixel values.
Definition: common.h:37
Pixel type
Type pointed to by the iterator.
Definition: MaskedImage.h:132
A templated class to return this classes&#39; type (present in Image/Mask/MaskedImage) ...
Definition: MaskedImage.h:92
Pixel operator()(int x, int y)
Dereference a locator, returning a Pixel offset by (x, y) from the locator.
Definition: MaskedImage.h:389
lsst::afw::image::pixel::Pixel< ImagePixelT, MaskPixelT, VariancePixelT > Pixel
A Pixel in the MaskedImage.
Definition: MaskedImage.h:108
x_iterator fast_iterator
A fast STL compliant iterator for contiguous images N.b.
Definition: MaskedImage.h:564
const_MaskedImageLocator(MaskedImageLocator< ImageLocator, MaskLocator, VarianceLocator > const &iter)
Definition: MaskedImage.h:528
boost::tuple< typename ImageLocator::cached_location_t, typename MaskLocator::cached_location_t, typename VarianceLocator::cached_location_t > IMVCachedLocation
Definition: MaskedImage.h:353
y_iterator y_at(int x, int y) const
Return an y_iterator at the point (x, y)
Definition: MaskedImage.h:1237
std::map< std::string, int > MaskPlaneDict
Definition: Mask.h:58
std::shared_ptr< Image< PixelT > > operator*(Image< PixelT > const &img, ImageSlice< PixelT > const &slc)
Overload operator*()
Definition: ImageSlice.cc:104
Pixel operator*()
Dereference a locator, returning a Pixel.
Definition: MaskedImage.h:383
Options for writing an image to FITS.
Definition: fits.h:219
Ref< VariancePixelT >::type variance(int x, int y)
Return a reference to the variance offset by (x, y) from the current position of the locator...
Definition: MaskedImage.h:465
bool operator==(MaskedImageIteratorBase const &rhs)
Return true if the lhs equals the rhs.
Definition: MaskedImage.h:180
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
Definition: ImageBase.h:133
Pixel operator[](cached_location_t const &cached_loc)
Dereference a locator, returning a Pixel offset by the amount set when we created the cached_location...
Definition: MaskedImage.h:396
Ref< typename boost::mpl::at< PixelTVec, N >::type >::type apply_IMV(cached_location_t const &cached_loc)
Definition: MaskedImage.h:423
int y
Definition: SpanSet.cc:49
The base class for MaskedImageIterators (const and non-const)
Definition: MaskedImage.h:118
MaskedImage operator[](lsst::geom::Box2I const &bbox) const
Return a subimage corresponding to the given box (interpreted as PARENT coordinates).
Definition: MaskedImage.h:795
MaskedImageIterator< typename Image::x_iterator, typename Mask::x_iterator, typename Variance::x_iterator > x_iterator
An iterator to a row of a MaskedImage.
Definition: MaskedImage.h:556
Ref< MaskPixelT >::type mask(cached_location_t const &cached_loc)
Return a reference to the mask at the offset set when we created the cached_location_t ...
Definition: MaskedImage.h:450
void setXY0(lsst::geom::Point2I const origin)
Set the MaskedImage&#39;s origin.
Definition: MaskedImage.h:1139
lsst::afw::image::pixel::SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > SinglePixel
A single Pixel of the same type as those in the MaskedImage.
Definition: MaskedImage.h:113
A single pixel of the same type as a MaskedImage.
Definition: Pixel.h:73
std::shared_ptr< image::Image< VariancePixelT > > VariancePtr
shared pointer to the variance Image
Definition: MaskedImage.h:80
MaskedImageIteratorBase operator++(int)
Increment the iterator (postfix)
Definition: MaskedImage.h:170
ItemVariant const * other
Definition: Schema.cc:56
MaskedImage & operator-=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:859
cached_location_t(IMVLocator const &loc, int x, int y)
Create a cached_location_t that can be used to access pixels (x, y) away from loc ...
Definition: MaskedImage.h:367
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:297
lsst::geom::Point2I getXY0() const
Return the image&#39;s origin.
Definition: MaskedImage.h:1119
lsst::afw::image::Mask< MaskPixelT > Mask
Definition: MaskedImage.h:86
MaskedImageIteratorBase & operator+=(std::ptrdiff_t delta)
Increment the iterator by delta
Definition: MaskedImage.h:153
A Function taking two arguments.
Definition: Function.h:259
MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > * makeMaskedImage(typename std::shared_ptr< Image< ImagePixelT >> image, typename std::shared_ptr< Mask< MaskPixelT >> mask=Mask< MaskPixelT >(), typename std::shared_ptr< Image< VariancePixelT >> variance=Image< VariancePixelT >())
A function to return a MaskedImage of the correct type (cf.
Definition: MaskedImage.h:1277
x_iterator x_at(int x, int y) const
Return an x_iterator at the point (x, y)
Definition: MaskedImage.h:1217
const_MaskedImageIterator & operator+(std::ptrdiff_t delta)
Return a const_MaskedImageIterator that&#39;s delta beyond this.
Definition: MaskedImage.h:250
MaskedImageIterator< typename Image::iterator, typename Mask::iterator, typename Variance::iterator > iterator
Definition: MaskedImage.h:539
Ref< VariancePixelT >::type variance()
Return (a reference to) the variance part of the Pixel pointed at by the iterator.
Definition: MaskedImage.h:145
bool operator==(MaskedImageLocatorBase const &rhs)
Return true iff two locators are equal.
Definition: MaskedImage.h:470
Mask< MaskPixelT >::MaskPlaneDict MaskPlaneDict
The Mask&#39;s MaskPlaneDict.
Definition: MaskedImage.h:82
lsst::geom::Extent2I getDimensions() const
Definition: MaskedImage.h:1094
ImagePtr getImage() const
Return a (shared_ptr to) the MaskedImage&#39;s image.
Definition: MaskedImage.h:1055
STL class.
An iterator to the MaskedImage.
Definition: MaskedImage.h:99
MaskedImage & operator/=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:887
bool operator!=(MaskedImageIteratorBase const &rhs)
Return true if the lhs doesn&#39;t equal the rhs.
Definition: MaskedImage.h:184
MaskedImage & operator+=(lsst::afw::math::Function2< double > const &function)
Definition: MaskedImage.h:836
_view_t::iterator iterator
An STL compliant iterator.
Definition: ImageBase.h:125
double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const
Convert image index to image position (see Image::indexToPosition)
Definition: MaskedImage.h:1158
_x_or_y_iterator< apply_x > x_iterator
An x_iterator that provides a view of the xy_locator (i.e. advancing one advances the other) ...
Definition: MaskedImage.h:355
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:49
int getHeight() const
Return the number of rows in the image.
Definition: MaskedImage.h:1093
MaskedImage(MaskedImage< OtherPixelT, MaskPixelT, VariancePixelT > const &rhs, const bool deep)
generalised copy constructor; defined here in the header so that the compiler can instantiate N(N-1)/...
Definition: MaskedImage.h:740
A base class for image defects.
table::Key< int > type
Definition: Detector.cc:163
int getX0() const
Return the image&#39;s column-origin.
Definition: MaskedImage.h:1103
static MaskedImage readFits(fits::MemFileManager &manager)
Read a MaskedImage from a FITS RAM file.
Definition: MaskedImage.h:1048
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:77
MaskedImageIterator< typename Image::y_iterator, typename Mask::y_iterator, typename Variance::y_iterator > y_iterator
An iterator to a column of a MaskedImage.
Definition: MaskedImage.h:568
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:121
const_MaskedImageIterator< typename Image::y_iterator, typename Mask::y_iterator, typename Variance::y_iterator > const_y_iterator
A const_iterator to a column of a MaskedImage.
Definition: MaskedImage.h:572
A traits class for MaskedImage.
Definition: MaskedImage.h:50
_x_or_y_iterator< apply_y > y_iterator
A y_iterator that provides a view of the xy_locator (i.e. advancing one advances the other) ...
Definition: MaskedImage.h:357
const IMV_iterator_tuple get_iterator_tuple() const
Return the underlying iterator tuple.
Definition: MaskedImage.h:150
const Pixel operator*() const
Dereference the iterator, returning a const Pixel.
Definition: MaskedImage.h:200
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:73
_view_t::y_iterator y_iterator
An iterator for traversing the pixels in a column.
Definition: ImageBase.h:143
MaskedImageIterator< typename Image::reverse_iterator, typename Mask::reverse_iterator, typename Variance::reverse_iterator > reverse_iterator
Definition: MaskedImage.h:547
std::shared_ptr< image::Image< ImagePixelT > > ImagePtr
shared pointer to the Image
Definition: MaskedImage.h:76
bool imagesOverlap(ImageBase< T1 > const &image1, ImageBase< T2 > const &image2)
Return true if the pixels for two images or masks overlap in memory.
Definition: Image.cc:706
detail::MaskedImage_tag image_category
Definition: MaskedImage.h:88
boost::zip_iterator< IMV_iterator_tuple >::reference IMV_tuple
The underlying iterator tuple.
Definition: MaskedImage.h:125
Ref< ImagePixelT >::type image()
Return (a reference to) the image part of the Pixel pointed at by the iterator.
Definition: MaskedImage.h:139
A saved relative position, providing efficient access to neighbouring pixels.
Definition: MaskedImage.h:359
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks
Pixel operator*()
Dereference the iterator, returning a Pixel.
Definition: MaskedImage.h:198
double x
void setMask(Mask const &other)
Set the mask plane&#39;s pixel values to those of another Mask.
Definition: MaskedImage.h:1076
bool operator!=(MaskedImageLocatorBase const &rhs)
Return true iff two locators are not equal.
Definition: MaskedImage.h:474
lsst::afw::image::Image< VariancePixelT > Variance
Definition: MaskedImage.h:84
MaskPtr getMask() const
Return a (shared_ptr to) the MaskedImage&#39;s mask.
Definition: MaskedImage.h:1067
std::string const compressedFileNoMEF_RE
regexp to identify compressed files that we can&#39;t write MEFs to
Definition: MaskedImage.h:57
void swap(Image< PixelT > &a, Image< PixelT > &b)
Definition: Image.cc:456
int getY0() const
Return the image&#39;s row-origin.
Definition: MaskedImage.h:1111
std::ptrdiff_t operator-(MaskedImageIteratorBase const &rhs)
Return the distance between two iterators.
Definition: MaskedImage.h:176
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
Ref< ImagePixelT >::type image()
Return a reference to the image at the current position of the locator.
Definition: MaskedImage.h:445
x_iterator x()
Return an iterator that can be used to move (or dereference) a locator.
Definition: MaskedImage.h:405
A pixel of a MaskedImage.
Definition: Pixel.h:148
MaskedImageIteratorBase & operator++()
Increment the iterator (prefix)
Definition: MaskedImage.h:165
An const iterator to the MaskedImage.
Definition: MaskedImage.h:102
MaskedImage & operator+=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:832
Image< LhsPixelT > & operator*=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Multiply lhs by Image rhs (i.e. pixel-by-pixel multiplication) where types are different.
Definition: Image.cc:683
std::string const fitsFile_RE
regexp to identify when MaskedImages should be written as MEFs
Definition: MaskedImage.h:55
MaskedImageIterator(ImageIterator &img, MaskIterator &msk, VarianceIterator &var)
Definition: MaskedImage.h:214
MaskedImageIteratorBase & operator-=(std::ptrdiff_t delta)
Decrement the iterator by delta
Definition: MaskedImage.h:159
const_MaskedImageIterator(MaskedImageIterator< ImageIterator, MaskIterator, VarianceIterator > const &iter)
Definition: MaskedImage.h:241
void setXY0(int const x0, int const y0)
Set the MaskedImage&#39;s origin.
Definition: MaskedImage.h:1129
Image< LhsPixelT > & operator-=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Subtract lhs from Image rhs (i.e. pixel-by-pixel subtraction) where types are different.
Definition: Image.cc:677
bool operator<(MaskedImageLocatorBase const &rhs)
Return true iff lhs is less than rhs.
Definition: MaskedImage.h:476
Ref< MaskPixelT >::type mask(int x, int y)
Return a reference to the mask offset by (x, y) from the current position of the locator.
Definition: MaskedImage.h:456
void setImage(Image const &other)
Set the image plane&#39;s pixel values to those of another Image.
Definition: MaskedImage.h:1064
Ref< VariancePixelT >::type variance()
Return a reference to the variance at the current position of the locator.
Definition: MaskedImage.h:463
MaskedImage subset(lsst::geom::Box2I const &bbox, ImageOrigin origin=PARENT) const
Return a subimage corresponding to the given box.
Definition: MaskedImage.h:790
Reports invalid arguments.
Definition: Runtime.h:66
void setVariance(Variance const &other)
Set the variance plane&#39;s pixel values to those of another Image.
Definition: MaskedImage.h:1085
int getWidth() const
Return the number of columns in the image.
Definition: MaskedImage.h:1091
MaskedImageLocator< typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator >::x_iterator xy_x_iterator
an x_iterator associated with an xy_locator
Definition: MaskedImage.h:585
static MaskedImage readFits(std::string const &filename)
Read a MaskedImage from a regular FITS file.
Definition: MaskedImage.h:1039
MaskedImage & operator*=(lsst::afw::image::Image< ImagePixelT > const &rhs)
Definition: MaskedImage.h:877
MaskedImage< ImagePT, MaskPT, VarPT > type
Return the desired type.
Definition: MaskedImage.h:94
Image< LhsPixelT > & operator/=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Divide lhs by Image rhs (i.e. pixel-by-pixel division) where types are different. ...
Definition: Image.cc:689
lsst::afw::image::Image< ImagePixelT > Image
Definition: MaskedImage.h:85
MaskedImageLocator< typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator > xy_locator
A locator for a MaskedImage.
Definition: MaskedImage.h:577
MaskedImageLocator< typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator >::y_iterator xy_y_iterator
an y_iterator associated with an xy_locator
Definition: MaskedImage.h:588
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...
bool operator<(MaskedImageIteratorBase const &rhs)
Return true if the lhs is less than the rhs.
Definition: MaskedImage.h:188
Ref< VariancePixelT >::type variance(cached_location_t const &cached_loc)
Return a reference to the variance at the offset set when we created the cached_location_t ...
Definition: MaskedImage.h:459
float VariancePixel
default type for MaskedImage variance images
lsst::geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: MaskedImage.h:1095
A class used to identify classes that represent MaskedImage pixels.
Definition: MaskedImage.h:52
MaskedImageLocatorBase(ImageLocator const &img, MaskLocator const &msk, VarianceLocator const &var)
Construct a MaskedImageLocator from image/mask/variance locators.
Definition: MaskedImage.h:377
_view_t::xy_locator xy_locator
An xy_locator.
Definition: ImageBase.h:121
An integer coordinate rectangle.
Definition: Box.h:55
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:58
MaskedImageLocatorBase & operator+=(pair2I const &p)
Increment the locator&#39;s x and y positions by p
Definition: MaskedImage.h:481
int end
const_MaskedImageIterator< typename Image::x_iterator, typename Mask::x_iterator, typename Variance::x_iterator > const_x_iterator
A const_iterator to a row of a MaskedImage.
Definition: MaskedImage.h:560
xy_locator xy_at(int x, int y) const
Return an xy_locator at the point (x, y)
Definition: MaskedImage.h:1251
A const locator for the MaskedImage.
Definition: MaskedImage.h:108
metafunction to extract reference type from PixelT
Definition: ImageBase.h:85
Ref< typename boost::mpl::at< PixelTVec, N >::type >::type apply_IMV()
Definition: MaskedImage.h:429
metafunction to extract const reference type from PixelT
Definition: ImageBase.h:90