LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
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"
48 #include "lsst/afw/math/Function.h"
49 #include "lsst/daf/base.h"
50 #include "lsst/daf/base/Citizen.h"
51 #include "lsst/pex/exceptions.h"
52 #include "ndarray.h"
53 
54 namespace lsst { namespace afw {
55 
56 namespace formatters {
57  template <typename PixelT> class ImageFormatter;
58  template <typename PixelT> class DecoratedImageFormatter;
59 }
60 
61 namespace fits {
62 class Fits;
63 class MemFileManager;
64 }
65 
66 namespace image {
67  namespace detail {
68  //
69  // Traits for image types
70  //
72  struct basic_tag { };
74  struct Image_tag : public basic_tag { };
76  template<typename ImageT>
77  struct image_traits {
78  typedef typename ImageT::image_category image_category;
79  };
80  //
81  std::string const wcsNameForXY0 = "A"; // the name of the WCS to use to save (X0, Y0) to FITS files; e.g. "A"
82  }
83 
84  /*********************************************************************************************************/
86  class CheckIndices {
87  public:
88  explicit CheckIndices(bool check=true) : _check(check) {}
89  operator bool() const { return _check; }
90  private:
91  bool _check;
92  };
93 
94  /*********************************************************************************************************/
96  template<typename PixelT>
97  struct Reference {
98  typedef typename boost::gil::channel_traits<PixelT>::reference type;
99  };
101  template<typename PixelT>
102  struct ConstReference {
103  typedef typename boost::gil::channel_traits<PixelT>::const_reference type;
104  };
105 
107 
109  //
110  // You are not expected to use this class directly in your own code; use one of the
111  // specialised subclasses
112  //
113  template<typename PixelT>
115  public lsst::daf::base::Citizen {
116  private:
117  typedef typename lsst::afw::image::detail::types_traits<PixelT>::view_t _view_t;
118  typedef typename lsst::afw::image::detail::types_traits<PixelT>::const_view_t _const_view_t;
119 
120 
121  typedef ndarray::Manager Manager;
122  public:
123 
124  typedef std::shared_ptr<ImageBase<PixelT> > Ptr;
125  typedef std::shared_ptr<const ImageBase<PixelT> > ConstPtr;
126 
128 
132  typedef PixelT Pixel;
138  typedef typename _view_t::xy_locator xy_locator;
140  typedef typename _view_t::xy_locator::const_t const_xy_locator;
142  typedef typename _view_t::iterator iterator;
144  typedef typename _const_view_t::iterator const_iterator;
146  typedef typename _view_t::reverse_iterator reverse_iterator;
148  typedef typename _const_view_t::reverse_iterator const_reverse_iterator;
150  typedef typename _view_t::x_iterator x_iterator;
155  typedef typename _view_t::x_iterator xy_x_iterator;
157  typedef typename _const_view_t::x_iterator const_x_iterator;
159  typedef typename _view_t::y_iterator y_iterator;
161  typedef typename _view_t::y_iterator xy_y_iterator;
163  typedef typename _const_view_t::y_iterator const_y_iterator;
165  typedef typename ndarray::Array<PixelT, 2, 1> Array;
167  typedef typename ndarray::Array<PixelT const, 2, 1> ConstArray;
168 
169  template<typename OtherPixelT> friend class ImageBase; // needed by generalised copy constructors
170  //
172  //
173  template<typename SinglePixelT>
174  static SinglePixel PixelCast(SinglePixelT rhs) {
175  return SinglePixel(rhs);
176  }
177  //
178  // DecoratedImage needs enough access to ImageBase to read data from disk; we might be able to design around this
179  //
180  template<typename> friend class DecoratedImage;
181  template<typename, typename, typename> friend class MaskedImage;
183  explicit ImageBase(const geom::Box2I &bbox);
184  ImageBase(const ImageBase& src, const bool deep=false);
185  explicit ImageBase(const ImageBase& src, const geom::Box2I& bbox,
186  const ImageOrigin origin=PARENT, const bool deep=false);
191  template<typename OtherPixelT>
192  ImageBase(const ImageBase<OtherPixelT>& rhs, const bool deep) :
193  lsst::daf::base::Citizen(typeid(this)) {
194  if (!deep) {
195  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
196  "Only deep copies are permitted for ImageBases with different pixel types");
197  }
198 
199  ImageBase<PixelT> tmp(rhs.getBBox());
200  copy_and_convert_pixels(rhs._gilView, tmp._gilView); // from boost::gil
201 
202  using std::swap; // See Meyers, Effective C++, Item 25
203  ImageBase<PixelT>::swap(tmp); // See Meyers, Effective C++, Items 11 and 43
204  }
205 
206  explicit ImageBase(
207  Array const & array, bool deep = false, geom::Point2I const & xy0 = geom::Point2I()
208  );
209 
210  virtual ~ImageBase() { }
211  ImageBase& operator=(const ImageBase& rhs);
212  ImageBase& operator=(const PixelT rhs);
213  void operator<<=(const ImageBase& rhs);
214 
215  void assign(ImageBase const &rsh, geom::Box2I const &bbox = geom::Box2I(), ImageOrigin origin=PARENT);
216  //
217  // Operators etc.
218  //
219  PixelReference operator()(int x, int y);
220  PixelReference operator()(int x, int y, CheckIndices const&);
221  PixelConstReference operator()(int x, int y) const;
222  PixelConstReference operator()(int x, int y, CheckIndices const&) const;
223 
224  PixelConstReference get0(int x, int y) const {
225  return operator()(x-getX0(), y-getY0());
226  }
227  PixelConstReference get0(int x, int y, CheckIndices const& check) const {
228  return operator()(x-getX0(), y-getY0(), check);
229  }
230  void set0(int x, int y, const PixelT v) {
231  operator()(x-getX0(), y-getY0()) = v;
232  }
233  void set0(int x, int y, const PixelT v, CheckIndices const& check) {
234  operator()(x-getX0(), y-getY0(), check) = v;
235  }
236 
238  int getWidth() const { return _gilView.width(); }
240  int getHeight() const { return _gilView.height(); }
248  int getX0() const { return _origin.getX(); }
256  int getY0() const { return _origin.getY(); }
257 
265  geom::Point2I getXY0() const { return _origin; }
266 
272  std::pair<int, double> positionToIndex(
273  double const pos,
274  lsst::afw::image::xOrY const xy
275  ) const {
276  double const fullIndex = pos - PixelZeroPos - (xy == X ? getX0() : getY0());
277  int const roundedIndex = static_cast<int>(fullIndex + 0.5);
278  double const residual = fullIndex - roundedIndex;
279  return std::pair<int, double>(roundedIndex, residual);
280  }
281 
291  inline double indexToPosition(
292  double ind,
293  lsst::afw::image::xOrY const xy
294  ) const {
295  return ind + PixelZeroPos + (xy == X ? getX0() : getY0());
296  }
297 
300 
301  void swap(ImageBase &rhs);
302 
303  Array getArray();
304  ConstArray getArray() const;
305  //
306  // Iterators and Locators
307  //
308  iterator begin() const;
309  iterator end() const;
310  reverse_iterator rbegin() const;
311  reverse_iterator rend() const;
312  iterator at(int x, int y) const;
313 
314  fast_iterator begin(bool) const;
315  fast_iterator end(bool) const;
316 
320  x_iterator row_begin(int y) const {
321  return _gilView.row_begin(y);
322  }
323 
325  x_iterator row_end(int y) const {
326  return _gilView.row_end(y);
327  }
328 
330  x_iterator x_at(int x, int y) const { return _gilView.x_at(x, y); }
331 
335  y_iterator col_begin(int x) const {
336  return _gilView.col_begin(x);
337  }
338 
340  y_iterator col_end(int x) const {
341  return _gilView.col_end(x);
342  }
343 
345  y_iterator y_at(int x, int y) const {
346  return _gilView.y_at(x, y);
347  }
348 
352  xy_locator xy_at(int x, int y) const {
353  return xy_locator(_gilView.xy_at(x, y));
354  }
363  void setXY0(geom::Point2I const origin) {
364  _origin=origin;
365  }
374  void setXY0(int const x0, int const y0) {
375  setXY0(geom::Point2I(x0,y0));
376  }
377 
379  if (origin == PARENT) {
380  return geom::Box2I(_origin, getDimensions());
381  }
382  else return geom::Box2I(geom::Point2I(0,0), getDimensions());
383  }
384  private:
386  Manager::Ptr _manager;
388 
389  //oring of ImageBase in some larger image as returned to and manipulated
390  //by the user
391 
392 
393  protected:
394 #if !defined(SWIG)
395  static _view_t _allocateView(geom::Extent2I const & dimensions, Manager::Ptr & manager);
396  static _view_t _makeSubView(
397  geom::Extent2I const & dimensions,
398  geom::Extent2I const & offset,
399  const _view_t & view
400  );
401 
402  _view_t _getRawView() const { return _gilView; }
403 
404 #endif
405  inline bool isContiguous() const {
406  return begin()+getWidth()*getHeight() == end();
407  }
408  };
409 
410  template<typename PixelT>
411  void swap(ImageBase<PixelT>& a, ImageBase<PixelT>& b);
412 
413  /************************************************************************************************************/
415  template<typename PixelT>
416  class Image : public ImageBase<PixelT> {
417  public:
418  template<typename, typename, typename> friend class MaskedImage;
419  typedef std::shared_ptr<Image<PixelT> > Ptr;
420  typedef std::shared_ptr<const Image<PixelT> > ConstPtr;
421 
423 
424 #if !defined(SWIG)
425  template<typename ImagePT=PixelT>
430  };
431 #endif
432  template<typename OtherPixelT> friend class Image; // needed by generalised copy constructors
433 
434  explicit Image(unsigned int width, unsigned int height, PixelT initialValue=0);
435  explicit Image(geom::Extent2I const & dimensions=geom::Extent2I(), PixelT initialValue=0);
436  explicit Image(geom::Box2I const & bbox, PixelT initialValue=0);
437 
438  explicit Image(Image const & rhs, geom::Box2I const & bbox, ImageOrigin const origin=PARENT,
439  const bool deep=false);
440  Image(const Image& rhs, const bool deep=false);
441 
454  explicit Image(
455  std::string const & fileName, int hdu=0,
457  geom::Box2I const & bbox=geom::Box2I(),
458  ImageOrigin origin=PARENT
459  );
460 
473  explicit Image(
474  fits::MemFileManager & manager, int hdu=0,
476  geom::Box2I const & bbox=geom::Box2I(),
477  ImageOrigin origin=PARENT
478  );
479 
489  explicit Image(
490  fits::Fits & fitsfile,
492  geom::Box2I const & bbox=geom::Box2I(),
493  ImageOrigin origin=PARENT
494  );
495 
496  // generalised copy constructor
497  template<typename OtherPixelT>
498  Image(Image<OtherPixelT> const& rhs, const bool deep) :
499  image::ImageBase<PixelT>(rhs, deep) {}
500 
501  explicit Image(ndarray::Array<PixelT,2,1> const & array, bool deep = false,
502  geom::Point2I const & xy0 = geom::Point2I()) :
503  image::ImageBase<PixelT>(array, deep, xy0) {}
504 
505  virtual ~Image() { }
506  //
507  // Assignment operators are not inherited
508  //
509  Image& operator=(const PixelT rhs);
510  Image& operator=(const Image& rhs);
511 
519  void writeFits(
520  std::string const& fileName,
522  std::string const& mode="w"
523  ) const;
524 
532  void writeFits(
533  fits::MemFileManager & manager,
535  std::string const& mode="w"
536  ) const;
537 
544  void writeFits(
545  fits::Fits & fitsfile,
547  ) const;
548 
556  static Image readFits(std::string const & filename, int hdu=0) {
557  return Image<PixelT>(filename, hdu);
558  }
559 
567  static Image readFits(fits::MemFileManager & manager, int hdu=0) {
568  return Image<PixelT>(manager, hdu);
569  }
570 
571  void swap(Image &rhs);
572  //
573  // Operators etc.
574  //
575  void operator+=(PixelT const rhs);
576  virtual void operator+=(Image<PixelT>const & rhs);
577  void operator+=(lsst::afw::math::Function2<double> const& function);
578  void scaledPlus(double const c, Image<PixelT>const & rhs);
579  void operator-=(PixelT const rhs);
580  void operator-=(Image<PixelT> const& rhs);
581  void operator-=(lsst::afw::math::Function2<double> const& function);
582  void scaledMinus(double const c, Image<PixelT>const & rhs);
583  void operator*=(PixelT const rhs);
584  void operator*=(Image<PixelT> const& rhs);
585  void scaledMultiplies(double const c, Image<PixelT>const & rhs);
586  void operator/=(PixelT const rhs);
587  void operator/=(Image<PixelT> const& rhs);
588  void scaledDivides(double const c, Image<PixelT>const & rhs);
589 
590  // In-place per-pixel sqrt(). Useful when handling variance planes.
591  void sqrt();
592  protected:
594  private:
596  };
597 
598  template<typename LhsPixelT, typename RhsPixelT>
599  void operator+=(Image<LhsPixelT> &lhs, Image<RhsPixelT> const& rhs);
600  template<typename LhsPixelT, typename RhsPixelT>
601  void operator-=(Image<LhsPixelT> &lhs, Image<RhsPixelT> const& rhs);
602  template<typename LhsPixelT, typename RhsPixelT>
603  void operator*=(Image<LhsPixelT> &lhs, Image<RhsPixelT> const& rhs);
604  template<typename LhsPixelT, typename RhsPixelT>
605  void operator/=(Image<LhsPixelT> &lhs, Image<RhsPixelT> const& rhs);
606 
607  template<typename PixelT>
608  void swap(Image<PixelT>& a, Image<PixelT>& b);
609 
610 /************************************************************************************************************/
614  template<typename PixelT>
616  public lsst::daf::base::Citizen {
617  public:
619  typedef std::shared_ptr<DecoratedImage> Ptr;
621  typedef std::shared_ptr<const DecoratedImage> ConstPtr;
626 
627  explicit DecoratedImage(const geom::Extent2I & dimensions=geom::Extent2I());
628  explicit DecoratedImage(const geom::Box2I & bbox);
629  explicit DecoratedImage(PTR(Image<PixelT>) rhs);
630  DecoratedImage(DecoratedImage const& rhs, const bool deep=false);
631  explicit DecoratedImage(
632  std::string const& fileName,
633  const int hdu=0,
634  geom::Box2I const& bbox=geom::Box2I(),
635  ImageOrigin const origin = PARENT
636  );
637 
638  DecoratedImage& operator=(const DecoratedImage& image);
639 
640  PTR(lsst::daf::base::PropertySet) getMetadata() const { return _metadata; }
641  void setMetadata(PTR(lsst::daf::base::PropertySet) metadata) { _metadata = metadata; }
642 
644  int getWidth() const { return _image->getWidth(); }
646  int getHeight() const { return _image->getHeight(); }
647 
649  int getX0() const { return _image->getX0(); }
651  int getY0() const { return _image->getY0(); }
652 
654  const geom::Extent2I getDimensions() const { return _image->getDimensions(); }
655 
656  void swap(DecoratedImage &rhs);
657 
658  void writeFits(
659  std::string const& fileName,
661  std::string const& mode="w"
662  ) const;
663 
665  ImagePtr getImage() { return _image; }
667  ImageConstPtr getImage() const { return _image; }
668 
674  double getGain() const { return _gain; }
676  void setGain(double gain) { _gain = gain; }
677  private:
680  PTR(lsst::daf::base::PropertySet) _metadata;
681 
682  double _gain;
683 
684  void init();
685  };
686 
687  template<typename PixelT>
689 
690 }}} // lsst::afw::image
691 
692 #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
static Image readFits(std::string const &filename, int hdu=0)
Read an Image from a regular FITS file.
Definition: Image.h:556
boost::gil::channel_traits< PixelT >::reference type
reference type
Definition: Image.h:98
PixelConstReference get0(int x, int y, CheckIndices const &check) const
Definition: Image.h:227
iterator end() const
Return an STL compliant iterator to the end of the image.
Definition: Image.cc:355
void setXY0(geom::Point2I const origin)
Set the ImageBase&#39;s origin.
Definition: Image.h:363
A templated class to return this classes&#39; type (present in Image/Mask/MaskedImage) ...
Definition: Image.h:427
_const_view_t::reverse_iterator const_reverse_iterator
An STL compliant const reverse iterator.
Definition: Image.h:148
A coordinate class intended to represent absolute positions.
x_iterator fast_iterator
A fast STL compliant iterator for contiguous images N.b.
Definition: Image.h:153
reverse_iterator rend() const
Return an STL compliant reverse iterator to the end of the image.
Definition: Image.cc:367
#define LSST_PERSIST_FORMATTER(formatter...)
Macro used to connect the persistable class with the Formatter and boost::serialization.
Definition: Persistable.h:98
ConstReference< PixelT >::type PixelConstReference
A ConstReference to a PixelT.
Definition: Image.h:136
Citizen(const std::type_info &)
Definition: Citizen.cc:174
_view_t::reverse_iterator reverse_iterator
An STL compliant reverse iterator.
Definition: Image.h:146
_view_t::x_iterator xy_x_iterator
An iterator for traversing the pixels in a row, created from an xy_locator.
Definition: Image.h:155
void set0(int x, int y, const PixelT v, CheckIndices const &check)
Definition: Image.h:233
x_iterator x_at(int x, int y) const
Return an x_iterator to the point (x, y) in the image.
Definition: Image.h:330
detail::basic_tag image_category
trait class to identify type of image
Definition: Image.h:127
Include files required for standard LSST Exception handling.
boost::shared_ptr< Image< PixelT > > _image
Definition: Image.h:679
std::shared_ptr< const Image< PixelT > > ConstPtr
Definition: Image.h:420
_const_view_t::x_iterator const_x_iterator
A const iterator for traversing the pixels in a row.
Definition: Image.h:157
bool isContiguous() const
Definition: Image.h:405
PixelT Pixel
A pixel in this ImageBase.
Definition: Image.h:132
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
Definition: Image.h:150
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:272
std::shared_ptr< const ImageBase< PixelT > > ConstPtr
A shared_ptr to a const ImageBase.
Definition: Image.h:125
double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const
Convert image index to image position.
Definition: Image.h:291
double getGain() const
Return the DecoratedImage&#39;s gain.
Definition: Image.h:674
std::shared_ptr< DecoratedImage > Ptr
shared_ptr to a DecoratedImage
Definition: Image.h:619
boost::shared_ptr< Image< PixelT > > ImagePtr
shared_ptr to the Image
Definition: Image.h:623
void operator/=(PixelT const rhs)
Divide lhs by scalar rhs.
Definition: Image.cc:781
geom::Box2I getBBox(ImageOrigin origin=PARENT) const
Definition: Image.h:378
static _view_t _makeSubView(geom::Extent2I const &dimensions, geom::Extent2I const &offset, const _view_t &view)
Definition: Image.cc:77
virtual ~Image()
Definition: Image.h:505
void swap(DecoratedImage &rhs)
void swap(Mask< PixelT > &a, Mask< PixelT > &b)
Definition: Mask.cc:524
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:202
The base class for all image classed (Image, Mask, MaskedImage, ...)
Definition: Image.h:114
void operator*=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Multiply lhs by Image rhs (i.e.
Definition: Image.cc:878
A Function taking two arguments.
Definition: Function.h:300
int getX0() const
Return the image&#39;s column-origin.
Definition: Image.h:248
std::shared_ptr< const DecoratedImage > ConstPtr
shared_ptr to a const DecoratedImage
Definition: Image.h:621
int const x0
Definition: saturated.cc:45
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.
Image utility functions.
static Image readFits(fits::MemFileManager &manager, int hdu=0)
Read an Image from a FITS RAM file.
Definition: Image.h:567
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:644
_const_view_t::iterator const_iterator
An STL compliant const iterator.
Definition: Image.h:144
An integer coordinate rectangle.
Definition: Box.h:53
void operator<<=(const ImageBase &rhs)
Set the lhs&#39;s pixel values to equal the rhs&#39;s.
Definition: Image.cc:226
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:640
_view_t::iterator iterator
An STL compliant iterator.
Definition: Image.h:142
geom::Point2I _origin
Definition: Image.h:385
lsst::afw::image::detail::types_traits< PixelT >::const_view_t _const_view_t
Definition: Image.h:118
geom::Point2I getXY0() const
Return the image&#39;s origin.
Definition: Image.h:265
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
void ImageT ImageT int float saturatedPixelValue int const width
Definition: saturated.cc:44
lsst::afw::image::detail::types_traits< PixelT >::view_t _view_t
Definition: Image.h:117
geom::Extent2I getDimensions() const
Return the image&#39;s size; useful for passing to constructors.
Definition: Image.h:299
void set0(int x, int y, const PixelT v)
Definition: Image.h:230
x_iterator row_end(int y) const
Return an x_iterator to the end of the y&#39;th row.
Definition: Image.h:325
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:106
std::shared_ptr< ImageBase< PixelT > > Ptr
A shared_ptr to an ImageBase.
Definition: Image.h:124
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)
Copy pixels from another image to a specified subregion of this image.
Definition: Image.cc:242
_view_t _getRawView() const
Definition: Image.h:402
ImagePtr getImage()
Return a shared_ptr to the DecoratedImage&#39;s Image.
Definition: Image.h:665
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:159
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:646
friend class ImageBase
Definition: Image.h:169
traits class for image categories
Definition: Image.h:77
A class used to request that array accesses be checked.
Definition: Image.h:86
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:240
std::shared_ptr< Image< PixelT > > Ptr
Definition: Image.h:419
void setGain(double gain)
Set the DecoratedImage&#39;s gain.
Definition: Image.h:676
double x
void operator+=(PixelT const rhs)
Add scalar rhs to lhs.
Definition: Image.cc:652
Class implementing persistence and retrieval for Images.
Image(ndarray::Array< PixelT, 2, 1 > const &array, bool deep=false, geom::Point2I const &xy0=geom::Point2I())
Definition: Image.h:501
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:340
void operator-=(PixelT const rhs)
Subtract scalar rhs from lhs.
Definition: Image.cc:700
void ImageT ImageT int float saturatedPixelValue int const height
Definition: saturated.cc:44
y_iterator y_at(int x, int y) const
Return an y_iterator to the point (x, y) in the image.
Definition: Image.h:345
ndarray::Array< PixelT const, 2, 1 > ConstArray
An immutable ndarray representation of the image.
Definition: Image.h:167
ndarray::Manager Manager
Definition: Image.h:121
PixelConstReference get0(int x, int y) const
Definition: Image.h:224
void setXY0(int const x0, int const y0)
Set the ImageBase&#39;s origin.
Definition: Image.h:374
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 a FITS file.
_view_t::xy_locator::const_t const_xy_locator
A const_xy_locator.
Definition: Image.h:140
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
Manager::Ptr _manager
Definition: Image.h:386
y_iterator col_begin(int x) const
Return an y_iterator to the start of the y&#39;th row.
Definition: Image.h:335
boost::shared_ptr< lsst::daf::base::PropertySet > _metadata
Definition: Image.h:680
#define PTR(...)
Definition: base.h:41
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:667
_const_view_t::y_iterator const_y_iterator
A const iterator for traversing the pixels in a column.
Definition: Image.h:163
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
void operator/=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Divide lhs by Image rhs (i.e.
Definition: Image.cc:885
Reference< PixelT >::type PixelReference
A Reference to a PixelT.
Definition: Image.h:134
int getX0() const
Return the image&#39;s column-origin.
Definition: Image.h:649
boost::shared_ptr< Image< PixelT > const > ImageConstPtr
shared_ptr to the Image as const
Definition: Image.h:625
Define the basic Function classes.
static SinglePixel PixelCast(SinglePixelT rhs)
Convert a type to our SinglePixel type.
Definition: Image.h:174
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:78
xy_locator xy_at(int x, int y) const
Return an xy_locator at the point (x, y) in the image.
Definition: Image.h:352
void operator-=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Subtract lhs from Image rhs (i.e.
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:641
Class implementing persistence and retrieval for DecoratedImages.
x_iterator row_begin(int y) const
Return an x_iterator to the start of the y&#39;th row.
Definition: Image.h:320
const geom::Extent2I getDimensions() const
Return the image&#39;s size; useful for passing to constructors.
Definition: Image.h:654
iterator begin() const
Return an STL compliant iterator to the start of the image.
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
#define CONST_PTR(...)
A shared pointer to a const object.
Definition: base.h:47
int const y0
Definition: saturated.cc:45
friend class Image
Definition: Image.h:432
const double PixelZeroPos
position of center of pixel 0
Definition: ImageUtils.h:42
_view_t::xy_locator xy_locator
An xy_locator.
Definition: Image.h:138
ImageBase(const ImageBase< OtherPixelT > &rhs, const bool deep)
generalised copy constructor
Definition: Image.h:192
Image(Image< OtherPixelT > const &rhs, const bool deep)
Definition: Image.h:498
A coordinate class intended to represent offsets and dimensions.
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:238
ndarray::Array< PixelT, 2, 1 > Array
A mutable ndarray representation of the image.
Definition: Image.h:165
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:130
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:416
CheckIndices(bool check=true)
Definition: Image.h:88
Extent< int, 2 > Extent2I
Definition: Extent.h:358
detail::Image_tag image_category
Definition: Image.h:422
std::string const wcsNameForXY0
Definition: Image.h:81
boost::gil::channel_traits< PixelT >::const_reference type
const reference type
Definition: Image.h:103
ImageBase & operator=(const ImageBase &rhs)
Shallow assignment operator.
Definition: Image.cc:215
PixelReference operator()(int x, int y)
Return a reference to the pixel (x, y)
Definition: Image.cc:260
Image< ImagePT > type
Return the desired type.
Definition: Image.h:429
A container for an Image and its associated metadata.
Definition: Image.h:615
void operator+=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Add lhs to Image rhs (i.e.
Definition: Image.cc:864
metafunction to extract reference type from PixelT
Definition: Image.h:97
int getY0() const
Return the image&#39;s row-origin.
Definition: Image.h:256
_view_t::y_iterator xy_y_iterator
An iterator for traversing the pixels in a row, created from an xy_locator.
Definition: Image.h:161
int getY0() const
Return the image&#39;s row-origin.
Definition: Image.h:651
metafunction to extract const reference type from PixelT
Definition: Image.h:102