LSSTApplications  11.0-13-gbb96280,12.1.rc1,12.1.rc1+1,12.1.rc1+2,12.1.rc1+5,12.1.rc1+8,12.1.rc1-1-g06d7636+1,12.1.rc1-1-g253890b+5,12.1.rc1-1-g3d31b68+7,12.1.rc1-1-g3db6b75+1,12.1.rc1-1-g5c1385a+3,12.1.rc1-1-g83b2247,12.1.rc1-1-g90cb4cf+6,12.1.rc1-1-g91da24b+3,12.1.rc1-2-g3521f8a,12.1.rc1-2-g39433dd+4,12.1.rc1-2-g486411b+2,12.1.rc1-2-g4c2be76,12.1.rc1-2-gc9c0491,12.1.rc1-2-gda2cd4f+6,12.1.rc1-3-g3391c73+2,12.1.rc1-3-g8c1bd6c+1,12.1.rc1-3-gcf4b6cb+2,12.1.rc1-4-g057223e+1,12.1.rc1-4-g19ed13b+2,12.1.rc1-4-g30492a7
LSSTDataManagementBasePackage
Image.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 
31 #ifndef LSST_AFW_IMAGE_IMAGE_H
32 #define LSST_AFW_IMAGE_IMAGE_H
33 
34 #include <list>
35 #include <map>
36 #include <string>
37 #include <utility>
38 #include <functional>
39 
40 #include "boost/mpl/bool.hpp"
41 #include <memory>
42 
43 #include "lsst/afw/geom/Extent.h"
44 #include "lsst/afw/geom/Box.h"
45 #include "lsst/afw/geom/Point.h"
46 #include "lsst/afw/image/lsstGil.h"
47 #include "lsst/afw/image/Utils.h"
49 #include "lsst/afw/math/Function.h"
50 #include "lsst/daf/base.h"
51 #include "lsst/daf/base/Citizen.h"
52 #include "lsst/pex/exceptions.h"
53 #include "ndarray.h"
54 
55 namespace lsst { namespace afw {
56 
57 namespace formatters {
58  template <typename PixelT> class ImageFormatter;
59  template <typename PixelT> class DecoratedImageFormatter;
60 }
61 
62 namespace fits {
63 class Fits;
64 class MemFileManager;
65 }
66 
67 namespace image {
68  namespace detail {
69  //
70  // Traits for image types
71  //
73  struct basic_tag { };
75  struct Image_tag : public basic_tag { };
77  template<typename ImageT>
78  struct image_traits {
79  typedef typename ImageT::image_category image_category;
80  };
81  //
82  std::string const wcsNameForXY0 = "A"; // the name of the WCS to use to save (X0, Y0) to FITS files; e.g. "A"
83  }
84 
85  /*********************************************************************************************************/
87  class CheckIndices {
88  public:
89  explicit CheckIndices(bool check=true) : _check(check) {}
90  operator bool() const { return _check; }
91  private:
92  bool _check;
93  };
94 
95  /*********************************************************************************************************/
97  template<typename PixelT>
98  struct Reference {
99  typedef typename boost::gil::channel_traits<PixelT>::reference type;
100  };
102  template<typename PixelT>
103  struct ConstReference {
104  typedef typename boost::gil::channel_traits<PixelT>::const_reference type;
105  };
106 
108 
110  //
111  // You are not expected to use this class directly in your own code; use one of the
112  // specialised subclasses
113  //
114  template<typename PixelT>
116  public lsst::daf::base::Citizen {
117  private:
118  typedef typename lsst::afw::image::detail::types_traits<PixelT>::view_t _view_t;
119  typedef typename lsst::afw::image::detail::types_traits<PixelT>::const_view_t _const_view_t;
120 
121 
122  typedef ndarray::Manager Manager;
123  public:
124 
125  typedef std::shared_ptr<ImageBase<PixelT> > Ptr;
126  typedef std::shared_ptr<const ImageBase<PixelT> > ConstPtr;
127 
129 
133  typedef PixelT Pixel;
139  typedef typename _view_t::xy_locator xy_locator;
141  typedef typename _view_t::xy_locator::const_t const_xy_locator;
143  typedef typename _view_t::iterator iterator;
145  typedef typename _const_view_t::iterator const_iterator;
147  typedef typename _view_t::reverse_iterator reverse_iterator;
149  typedef typename _const_view_t::reverse_iterator const_reverse_iterator;
151  typedef typename _view_t::x_iterator x_iterator;
156  typedef typename _view_t::x_iterator xy_x_iterator;
158  typedef typename _const_view_t::x_iterator const_x_iterator;
160  typedef typename _view_t::y_iterator y_iterator;
162  typedef typename _view_t::y_iterator xy_y_iterator;
164  typedef typename _const_view_t::y_iterator const_y_iterator;
166  typedef typename ndarray::Array<PixelT, 2, 1> Array;
168  typedef typename ndarray::Array<PixelT const, 2, 1> ConstArray;
169 
170  template<typename OtherPixelT> friend class ImageBase; // needed by generalised copy constructors
171  //
173  //
174  template<typename SinglePixelT>
175  static SinglePixel PixelCast(SinglePixelT rhs) {
176  return SinglePixel(rhs);
177  }
178  //
179  // DecoratedImage needs enough access to ImageBase to read data from disk; we might be able to design around this
180  //
181  template<typename> friend class DecoratedImage;
182  template<typename, typename, typename> friend class MaskedImage;
184  explicit ImageBase(const geom::Box2I &bbox);
185  ImageBase(const ImageBase& src, const bool deep=false);
186  explicit ImageBase(const ImageBase& src, const geom::Box2I& bbox,
187  const ImageOrigin origin=PARENT, const bool deep=false);
192  template<typename OtherPixelT>
193  ImageBase(const ImageBase<OtherPixelT>& rhs, const bool deep) :
194  lsst::daf::base::Citizen(typeid(this)) {
195  if (!deep) {
196  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
197  "Only deep copies are permitted for ImageBases with different pixel types");
198  }
199 
200  ImageBase<PixelT> tmp(rhs.getBBox());
201  copy_and_convert_pixels(rhs._gilView, tmp._gilView); // from boost::gil
202 
203  using std::swap; // See Meyers, Effective C++, Item 25
204  ImageBase<PixelT>::swap(tmp); // See Meyers, Effective C++, Items 11 and 43
205  }
206 
207  explicit ImageBase(
208  Array const & array, bool deep = false, geom::Point2I const & xy0 = geom::Point2I()
209  );
210 
211  virtual ~ImageBase() { }
212  ImageBase& operator=(const ImageBase& rhs);
213  ImageBase& operator=(const PixelT rhs);
214  void operator<<=(const ImageBase& rhs);
215 
216  void assign(ImageBase const &rsh, geom::Box2I const &bbox = geom::Box2I(), ImageOrigin origin=PARENT);
217  //
218  // Operators etc.
219  //
220  PixelReference operator()(int x, int y);
221  PixelReference operator()(int x, int y, CheckIndices const&);
222  PixelConstReference operator()(int x, int y) const;
223  PixelConstReference operator()(int x, int y, CheckIndices const&) const;
224 
225  PixelConstReference get0(int x, int y) const {
226  return operator()(x-getX0(), y-getY0());
227  }
228  PixelConstReference get0(int x, int y, CheckIndices const& check) const {
229  return operator()(x-getX0(), y-getY0(), check);
230  }
231  void set0(int x, int y, const PixelT v) {
232  operator()(x-getX0(), y-getY0()) = v;
233  }
234  void set0(int x, int y, const PixelT v, CheckIndices const& check) {
235  operator()(x-getX0(), y-getY0(), check) = v;
236  }
237 
239  int getWidth() const { return _gilView.width(); }
241  int getHeight() const { return _gilView.height(); }
249  int getX0() const { return _origin.getX(); }
257  int getY0() const { return _origin.getY(); }
258 
266  geom::Point2I getXY0() const { return _origin; }
267 
273  std::pair<int, double> positionToIndex(
274  double const pos,
275  lsst::afw::image::xOrY const xy
276  ) const {
277  double const fullIndex = pos - PixelZeroPos - (xy == X ? getX0() : getY0());
278  int const roundedIndex = static_cast<int>(fullIndex + 0.5);
279  double const residual = fullIndex - roundedIndex;
280  return std::pair<int, double>(roundedIndex, residual);
281  }
282 
292  inline double indexToPosition(
293  double ind,
294  lsst::afw::image::xOrY const xy
295  ) const {
296  return ind + PixelZeroPos + (xy == X ? getX0() : getY0());
297  }
298 
301 
302  void swap(ImageBase &rhs);
303 
304  Array getArray();
305  ConstArray getArray() const;
306  //
307  // Iterators and Locators
308  //
309  iterator begin() const;
310  iterator end() const;
311  reverse_iterator rbegin() const;
312  reverse_iterator rend() const;
313  iterator at(int x, int y) const;
314 
315  fast_iterator begin(bool) const;
316  fast_iterator end(bool) const;
317 
321  x_iterator row_begin(int y) const {
322  return _gilView.row_begin(y);
323  }
324 
326  x_iterator row_end(int y) const {
327  return _gilView.row_end(y);
328  }
329 
331  x_iterator x_at(int x, int y) const { return _gilView.x_at(x, y); }
332 
336  y_iterator col_begin(int x) const {
337  return _gilView.col_begin(x);
338  }
339 
341  y_iterator col_end(int x) const {
342  return _gilView.col_end(x);
343  }
344 
346  y_iterator y_at(int x, int y) const {
347  return _gilView.y_at(x, y);
348  }
349 
353  xy_locator xy_at(int x, int y) const {
354  return xy_locator(_gilView.xy_at(x, y));
355  }
364  void setXY0(geom::Point2I const origin) {
365  _origin=origin;
366  }
375  void setXY0(int const x0, int const y0) {
376  setXY0(geom::Point2I(x0,y0));
377  }
378 
380  if (origin == PARENT) {
381  return geom::Box2I(_origin, getDimensions());
382  }
383  else return geom::Box2I(geom::Point2I(0,0), getDimensions());
384  }
385  private:
387  Manager::Ptr _manager;
389 
390  //oring of ImageBase in some larger image as returned to and manipulated
391  //by the user
392 
393 
394  protected:
395 #if !defined(SWIG)
396  static _view_t _allocateView(geom::Extent2I const & dimensions, Manager::Ptr & manager);
397  static _view_t _makeSubView(
398  geom::Extent2I const & dimensions,
399  geom::Extent2I const & offset,
400  const _view_t & view
401  );
402 
403  _view_t _getRawView() const { return _gilView; }
404 
405 #endif
406  inline bool isContiguous() const {
407  return begin()+getWidth()*getHeight() == end();
408  }
409  };
410 
411  template<typename PixelT>
412  void swap(ImageBase<PixelT>& a, ImageBase<PixelT>& b);
413 
414  /************************************************************************************************************/
416  template<typename PixelT>
417  class Image : public ImageBase<PixelT> {
418  public:
419  template<typename, typename, typename> friend class MaskedImage;
420  typedef std::shared_ptr<Image<PixelT> > Ptr;
421  typedef std::shared_ptr<const Image<PixelT> > ConstPtr;
422 
424 
425 #if !defined(SWIG)
426  template<typename ImagePT=PixelT>
431  };
432 #endif
433  template<typename OtherPixelT> friend class Image; // needed by generalised copy constructors
434 
435  explicit Image(unsigned int width, unsigned int height, PixelT initialValue=0);
436  explicit Image(geom::Extent2I const & dimensions=geom::Extent2I(), PixelT initialValue=0);
437  explicit Image(geom::Box2I const & bbox, PixelT initialValue=0);
438 
439  explicit Image(Image const & rhs, geom::Box2I const & bbox, ImageOrigin const origin=PARENT,
440  const bool deep=false);
441  Image(const Image& rhs, const bool deep=false);
442 
455  explicit Image(
456  std::string const & fileName, int hdu=0,
458  geom::Box2I const & bbox=geom::Box2I(),
459  ImageOrigin origin=PARENT
460  );
461 
474  explicit Image(
475  fits::MemFileManager & manager, int hdu=0,
477  geom::Box2I const & bbox=geom::Box2I(),
478  ImageOrigin origin=PARENT
479  );
480 
490  explicit Image(
491  fits::Fits & fitsfile,
493  geom::Box2I const & bbox=geom::Box2I(),
494  ImageOrigin origin=PARENT
495  );
496 
497  // generalised copy constructor
498  template<typename OtherPixelT>
499  Image(Image<OtherPixelT> const& rhs, const bool deep) :
500  image::ImageBase<PixelT>(rhs, deep) {}
501 
502  explicit Image(ndarray::Array<PixelT,2,1> const & array, bool deep = false,
503  geom::Point2I const & xy0 = geom::Point2I()) :
504  image::ImageBase<PixelT>(array, deep, xy0) {}
505 
506  virtual ~Image() { }
507  //
508  // Assignment operators are not inherited
509  //
510  Image& operator=(const PixelT rhs);
511  Image& operator=(const Image& rhs);
512 
520  void writeFits(
521  std::string const& fileName,
523  std::string const& mode="w"
524  ) const;
525 
533  void writeFits(
534  fits::MemFileManager & manager,
536  std::string const& mode="w"
537  ) const;
538 
545  void writeFits(
546  fits::Fits & fitsfile,
548  ) const;
549 
557  static Image readFits(std::string const & filename, int hdu=0) {
558  return Image<PixelT>(filename, hdu);
559  }
560 
568  static Image readFits(fits::MemFileManager & manager, int hdu=0) {
569  return Image<PixelT>(manager, hdu);
570  }
571 
572  void swap(Image &rhs);
573  //
574  // Operators etc.
575  //
576  void operator+=(PixelT const rhs);
577  virtual void operator+=(Image<PixelT>const & rhs);
578  void operator+=(lsst::afw::math::Function2<double> const& function);
579  void scaledPlus(double const c, Image<PixelT>const & rhs);
580  void operator-=(PixelT const rhs);
581  void operator-=(Image<PixelT> const& rhs);
582  void operator-=(lsst::afw::math::Function2<double> const& function);
583  void scaledMinus(double const c, Image<PixelT>const & rhs);
584  void operator*=(PixelT const rhs);
585  void operator*=(Image<PixelT> const& rhs);
586  void scaledMultiplies(double const c, Image<PixelT>const & rhs);
587  void operator/=(PixelT const rhs);
588  void operator/=(Image<PixelT> const& rhs);
589  void scaledDivides(double const c, Image<PixelT>const & rhs);
590 
591  // In-place per-pixel sqrt(). Useful when handling variance planes.
592  void sqrt();
593  protected:
595  private:
597  };
598 
599  template<typename LhsPixelT, typename RhsPixelT>
600  void operator+=(Image<LhsPixelT> &lhs, Image<RhsPixelT> const& rhs);
601  template<typename LhsPixelT, typename RhsPixelT>
602  void operator-=(Image<LhsPixelT> &lhs, Image<RhsPixelT> const& rhs);
603  template<typename LhsPixelT, typename RhsPixelT>
604  void operator*=(Image<LhsPixelT> &lhs, Image<RhsPixelT> const& rhs);
605  template<typename LhsPixelT, typename RhsPixelT>
606  void operator/=(Image<LhsPixelT> &lhs, Image<RhsPixelT> const& rhs);
607 
608  template<typename PixelT>
609  void swap(Image<PixelT>& a, Image<PixelT>& b);
610 
611 /************************************************************************************************************/
615  template<typename PixelT>
617  public lsst::daf::base::Citizen {
618  public:
620  typedef std::shared_ptr<DecoratedImage> Ptr;
622  typedef std::shared_ptr<const DecoratedImage> ConstPtr;
627 
628  explicit DecoratedImage(const geom::Extent2I & dimensions=geom::Extent2I());
629  explicit DecoratedImage(const geom::Box2I & bbox);
630  explicit DecoratedImage(PTR(Image<PixelT>) rhs);
631  DecoratedImage(DecoratedImage const& rhs, const bool deep=false);
632  explicit DecoratedImage(
633  std::string const& fileName,
634  const int hdu=0,
635  geom::Box2I const& bbox=geom::Box2I(),
636  ImageOrigin const origin = PARENT
637  );
638 
639  DecoratedImage& operator=(const DecoratedImage& image);
640 
641  PTR(lsst::daf::base::PropertySet) getMetadata() const { return _metadata; }
642  void setMetadata(PTR(lsst::daf::base::PropertySet) metadata) { _metadata = metadata; }
643 
645  int getWidth() const { return _image->getWidth(); }
647  int getHeight() const { return _image->getHeight(); }
648 
650  int getX0() const { return _image->getX0(); }
652  int getY0() const { return _image->getY0(); }
653 
655  const geom::Extent2I getDimensions() const { return _image->getDimensions(); }
656 
657  void swap(DecoratedImage &rhs);
658 
659  void writeFits(
660  std::string const& fileName,
662  std::string const& mode="w"
663  ) const;
664 
666  ImagePtr getImage() { return _image; }
668  ImageConstPtr getImage() const { return _image; }
669 
675  double getGain() const { return _gain; }
677  void setGain(double gain) { _gain = gain; }
678  private:
681  PTR(lsst::daf::base::PropertySet) _metadata;
682 
683  double _gain;
684 
685  void init();
686  };
687 
688  template<typename PixelT>
690 
691 }}} // lsst::afw::image
692 
693 #endif
int y
iterator at(int x, int y) const
Return an STL compliant iterator at the point (x, y)
Definition: Image.cc:373
void scaledDivides(double const c, Image< PixelT >const &rhs)
Divide lhs by Image c*rhs (i.e. pixel-by-pixel division)
Definition: Image.cc:816
boost::gil::channel_traits< PixelT >::reference type
reference type
Definition: Image.h:99
PixelConstReference get0(int x, int y, CheckIndices const &check) const
Definition: Image.h:228
iterator end() const
Return an STL compliant iterator to the end of the image.
Definition: Image.cc:355
void setXY0(geom::Point2I const origin)
Definition: Image.h:364
A templated class to return this classes&#39; type (present in Image/Mask/MaskedImage) ...
Definition: Image.h:428
_const_view_t::reverse_iterator const_reverse_iterator
An STL compliant const reverse iterator.
Definition: Image.h:149
A coordinate class intended to represent absolute positions.
x_iterator fast_iterator
Definition: Image.h:154
A set of classes of general utility in connection with images.
reverse_iterator rend() const
Return an STL compliant reverse iterator to the end of the image.
Definition: Image.cc:367
ConstReference< PixelT >::type PixelConstReference
A ConstReference to a PixelT.
Definition: Image.h:137
#define LSST_PERSIST_FORMATTER(formatter...)
Definition: Persistable.h:98
_view_t::reverse_iterator reverse_iterator
An STL compliant reverse iterator.
Definition: Image.h:147
_view_t::x_iterator xy_x_iterator
An iterator for traversing the pixels in a row, created from an xy_locator.
Definition: Image.h:156
void set0(int x, int y, const PixelT v, CheckIndices const &check)
Definition: Image.h:234
x_iterator x_at(int x, int y) const
Return an x_iterator to the point (x, y) in the image.
Definition: Image.h:331
detail::basic_tag image_category
trait class to identify type of image
Definition: Image.h:128
boost::shared_ptr< Image< PixelT > > _image
Definition: Image.h:680
_const_view_t::x_iterator const_x_iterator
A const iterator for traversing the pixels in a row.
Definition: Image.h:158
bool isContiguous() const
Definition: Image.h:406
PixelT Pixel
A pixel in this ImageBase.
Definition: Image.h:133
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
Definition: Image.h:151
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: Image.h:273
std::shared_ptr< const ImageBase< PixelT > > ConstPtr
A shared_ptr to a const ImageBase.
Definition: Image.h:126
double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const
Convert image index to image position.
Definition: Image.h:292
double getGain() const
Definition: Image.h:675
std::shared_ptr< DecoratedImage > Ptr
shared_ptr to a DecoratedImage
Definition: Image.h:620
boost::shared_ptr< Image< PixelT > > ImagePtr
shared_ptr to the Image
Definition: Image.h:624
Image< ImagePT > type
Return the desired type.
Definition: Image.h:430
void operator/=(PixelT const rhs)
Definition: Image.cc:781
geom::Box2I getBBox(ImageOrigin origin=PARENT) const
Definition: Image.h:379
static _view_t _makeSubView(geom::Extent2I const &dimensions, geom::Extent2I const &offset, const _view_t &view)
Definition: Image.cc:77
void swap(DecoratedImage &rhs)
void swap(Mask< PixelT > &a, Mask< PixelT > &b)
Definition: Mask.cc:524
#define CONST_PTR(...)
Definition: base.h:47
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:201
The base class for all image classed (Image, Mask, MaskedImage, ...)
Definition: Image.h:115
Extent< int, 2 > Extent2I
Definition: Extent.h:358
void operator*=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Definition: Image.cc:878
int getX0() const
Definition: Image.h:249
std::shared_ptr< const DecoratedImage > ConstPtr
shared_ptr to a const DecoratedImage
Definition: Image.h:622
int const x0
Definition: saturated.cc:45
Image utility functions.
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:645
_const_view_t::iterator const_iterator
An STL compliant const iterator.
Definition: Image.h:145
An integer coordinate rectangle.
Definition: Box.h:53
void operator<<=(const ImageBase &rhs)
Definition: Image.cc:226
Image(ndarray::Array< PixelT, 2, 1 > const &array, bool deep=false, geom::Point2I const &xy0=geom::Point2I())
Definition: Image.h:502
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
void scaledPlus(double const c, Image< PixelT >const &rhs)
Add Image c*rhs to lhs.
Definition: Image.cc:688
boost::shared_ptr< lsst::daf::base::PropertySet > getMetadata() const
Definition: Image.h:641
_view_t::iterator iterator
An STL compliant iterator.
Definition: Image.h:143
geom::Point2I _origin
Definition: Image.h:386
lsst::afw::image::detail::types_traits< PixelT >::const_view_t _const_view_t
Definition: Image.h:119
geom::Point2I getXY0() const
Definition: Image.h:266
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:42
Image & operator=(const PixelT rhs)
Set the image&#39;s pixels to rhs.
Definition: Image.cc:504
void operator*=(PixelT const rhs)
Multiply lhs by scalar rhs.
Definition: Image.cc:748
static Image readFits(std::string const &filename, int hdu=0)
Read an Image from a regular FITS file.
Definition: Image.h:557
lsst::afw::image::detail::types_traits< PixelT >::view_t _view_t
Definition: Image.h:118
geom::Extent2I getDimensions() const
Return the image&#39;s size; useful for passing to constructors.
Definition: Image.h:300
void set0(int x, int y, const PixelT v)
Definition: Image.h:231
x_iterator row_end(int y) const
Return an x_iterator to the end of the y&#39;th row.
Definition: Image.h:326
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:105
std::shared_ptr< ImageBase< PixelT > > Ptr
A shared_ptr to an ImageBase.
Definition: Image.h:125
Types and classes to interface lsst::afw::image to boost::gil.
void assign(ImageBase const &rsh, geom::Box2I const &bbox=geom::Box2I(), ImageOrigin origin=PARENT)
Definition: Image.cc:242
_view_t _getRawView() const
Definition: Image.h:403
ImagePtr getImage()
Return a shared_ptr to the DecoratedImage&#39;s Image.
Definition: Image.h:666
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:78
_view_t::y_iterator y_iterator
An iterator for traversing the pixels in a column.
Definition: Image.h:160
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:647
friend class ImageBase
Definition: Image.h:170
traits class for image categories
Definition: Image.h:78
A class used to request that array accesses be checked.
Definition: Image.h:87
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:241
void setGain(double gain)
Set the DecoratedImage&#39;s gain.
Definition: Image.h:677
double x
void operator+=(PixelT const rhs)
Add scalar rhs to lhs.
Definition: Image.cc:652
Class implementing persistence and retrieval for Images.
void swap(ImageBase &rhs)
Definition: Image.cc:306
y_iterator col_end(int x) const
Return an y_iterator to the end of the y&#39;th row.
Definition: Image.h:341
void operator-=(PixelT const rhs)
Subtract scalar rhs from lhs.
Definition: Image.cc:700
static Image readFits(fits::MemFileManager &manager, int hdu=0)
Read an Image from a FITS RAM file.
Definition: Image.h:568
std::shared_ptr< Image< PixelT > > Ptr
Definition: Image.h:420
y_iterator y_at(int x, int y) const
Return an y_iterator to the point (x, y) in the image.
Definition: Image.h:346
ndarray::Array< PixelT const, 2, 1 > ConstArray
An immutable ndarray representation of the image.
Definition: Image.h:168
ndarray::Manager Manager
Definition: Image.h:122
PixelConstReference get0(int x, int y) const
Definition: Image.h:225
void setXY0(int const x0, int const y0)
Definition: Image.h:375
virtual ~Image()
Definition: Image.h:506
void writeFits(std::string const &fileName, boost::shared_ptr< lsst::daf::base::PropertySet const > metadata=boost::shared_ptr< lsst::daf::base::PropertySet const >(), std::string const &mode="w") const
_view_t::xy_locator::const_t const_xy_locator
A const_xy_locator.
Definition: Image.h:141
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
Image(Image< OtherPixelT > const &rhs, const bool deep)
Definition: Image.h:499
Manager::Ptr _manager
Definition: Image.h:387
y_iterator col_begin(int x) const
Definition: Image.h:336
boost::shared_ptr< lsst::daf::base::PropertySet > _metadata
Definition: Image.h:681
Citizen(const std::type_info &)
Definition: Citizen.cc:174
static _view_t _allocateView(geom::Extent2I const &dimensions, Manager::Ptr &manager)
Definition: Image.cc:52
ImageConstPtr getImage() const
Return a shared_ptr to the DecoratedImage&#39;s Image as const.
Definition: Image.h:668
_const_view_t::y_iterator const_y_iterator
A const iterator for traversing the pixels in a column.
Definition: Image.h:164
void scaledMinus(double const c, Image< PixelT >const &rhs)
Subtract Image c*rhs from lhs.
Definition: Image.cc:719
Class for storing generic metadata.
Definition: PropertySet.h:82
std::shared_ptr< const Image< PixelT > > ConstPtr
Definition: Image.h:421
void operator/=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Definition: Image.cc:885
#define PTR(...)
Definition: base.h:41
Reference< PixelT >::type PixelReference
A Reference to a PixelT.
Definition: Image.h:135
int getX0() const
Return the image&#39;s column-origin.
Definition: Image.h:650
boost::shared_ptr< Image< PixelT > const > ImageConstPtr
shared_ptr to the Image as const
Definition: Image.h:626
Define the basic Function classes.
static SinglePixel PixelCast(SinglePixelT rhs)
Convert a type to our SinglePixel type.
Definition: Image.h:175
afw::table::Key< double > b
void scaledMultiplies(double const c, Image< PixelT >const &rhs)
Multiply lhs by Image c*rhs (i.e. pixel-by-pixel multiplication)
Definition: Image.cc:767
ImageT::image_category image_category
Definition: Image.h:79
xy_locator xy_at(int x, int y) const
Definition: Image.h:353
void operator-=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Definition: Image.cc:871
Base class for all persistable classes.
Definition: Persistable.h:74
void setMetadata(boost::shared_ptr< lsst::daf::base::PropertySet > metadata)
Definition: Image.h:642
Class implementing persistence and retrieval for DecoratedImages.
x_iterator row_begin(int y) const
Definition: Image.h:321
const geom::Extent2I getDimensions() const
Return the image&#39;s size; useful for passing to constructors.
Definition: Image.h:655
iterator begin() const
Definition: Image.cc:349
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Definition: Citizen.h:53
reverse_iterator rbegin() const
Return an STL compliant reverse iterator to the start of the image.
Definition: Image.cc:361
Include files required for standard LSST Exception handling.
int const y0
Definition: saturated.cc:45
friend class Image
Definition: Image.h:433
const double PixelZeroPos
FITS uses 1.0, SDSS uses 0.5, LSST uses 0.0 (http://dev.lsstcorp.org/trac/wiki/BottomLeftPixelProposa...
Definition: ImageUtils.h:42
_view_t::xy_locator xy_locator
An xy_locator.
Definition: Image.h:139
ImageBase(const ImageBase< OtherPixelT > &rhs, const bool deep)
Definition: Image.h:193
A coordinate class intended to represent offsets and dimensions.
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:239
ndarray::Array< PixelT, 2, 1 > Array
A mutable ndarray representation of the image.
Definition: Image.h:166
void swap(Image &rhs)
Definition: Image.cc:630
PixelT SinglePixel
A single Pixel of the same type as those in the ImageBase.
Definition: Image.h:131
detail::Image_tag image_category
Definition: Image.h:423
A class to represent a 2-dimensional array of pixels.
Definition: PSF.h:43
CheckIndices(bool check=true)
Definition: Image.h:89
std::string const wcsNameForXY0
Definition: Image.h:82
void writeFits(std::string const &fileName, boost::shared_ptr< lsst::daf::base::PropertySet const > metadata=boost::shared_ptr< lsst::daf::base::PropertySet const >(), std::string const &mode="w") const
Write an image to a regular FITS file.
boost::gil::channel_traits< PixelT >::const_reference type
const reference type
Definition: Image.h:104
ImageBase & operator=(const ImageBase &rhs)
Definition: Image.cc:215
PixelReference operator()(int x, int y)
Return a reference to the pixel (x, y)
Definition: Image.cc:260
A container for an Image and its associated metadata.
Definition: Image.h:616
void operator+=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Definition: Image.cc:864
metafunction to extract reference type from PixelT
Definition: Image.h:98
int getY0() const
Definition: Image.h:257
_view_t::y_iterator xy_y_iterator
An iterator for traversing the pixels in a row, created from an xy_locator.
Definition: Image.h:162
int getY0() const
Return the image&#39;s row-origin.
Definition: Image.h:652
metafunction to extract const reference type from PixelT
Definition: Image.h:103