LSST Applications  21.0.0+04719a4bac,21.0.0-1-ga51b5d4+f5e6047307,21.0.0-11-g2b59f77+a9c1acf22d,21.0.0-11-ga42c5b2+86977b0b17,21.0.0-12-gf4ce030+76814010d2,21.0.0-13-g1721dae+760e7a6536,21.0.0-13-g3a573fe+768d78a30a,21.0.0-15-g5a7caf0+f21cbc5713,21.0.0-16-g0fb55c1+b60e2d390c,21.0.0-19-g4cded4ca+71a93a33c0,21.0.0-2-g103fe59+bb20972958,21.0.0-2-g45278ab+04719a4bac,21.0.0-2-g5242d73+3ad5d60fb1,21.0.0-2-g7f82c8f+8babb168e8,21.0.0-2-g8f08a60+06509c8b61,21.0.0-2-g8faa9b5+616205b9df,21.0.0-2-ga326454+8babb168e8,21.0.0-2-gde069b7+5e4aea9c2f,21.0.0-2-gecfae73+1d3a86e577,21.0.0-2-gfc62afb+3ad5d60fb1,21.0.0-25-g1d57be3cd+e73869a214,21.0.0-3-g357aad2+ed88757d29,21.0.0-3-g4a4ce7f+3ad5d60fb1,21.0.0-3-g4be5c26+3ad5d60fb1,21.0.0-3-g65f322c+e0b24896a3,21.0.0-3-g7d9da8d+616205b9df,21.0.0-3-ge02ed75+a9c1acf22d,21.0.0-4-g591bb35+a9c1acf22d,21.0.0-4-g65b4814+b60e2d390c,21.0.0-4-gccdca77+0de219a2bc,21.0.0-4-ge8a399c+6c55c39e83,21.0.0-5-gd00fb1e+05fce91b99,21.0.0-6-gc675373+3ad5d60fb1,21.0.0-64-g1122c245+4fb2b8f86e,21.0.0-7-g04766d7+cd19d05db2,21.0.0-7-gdf92d54+04719a4bac,21.0.0-8-g5674e7b+d1bd76f71f,master-gac4afde19b+a9c1acf22d,w.2021.13
LSST Data Management Base Package
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Related Functions | List of all members
lsst::afw::image::ImageSlice< PixelT > Class Template Reference

A class to specify a slice of an image. More...

#include <ImageSlice.h>

Inheritance diagram for lsst::afw::image::ImageSlice< PixelT >:
lsst::afw::image::Image< PixelT > lsst::afw::image::ImageBase< PixelT >

Public Types

enum  ImageSliceType { ROW , COLUMN }
 
typedef detail::Image_tag image_category
 
typedef PixelT SinglePixel
 A single Pixel of the same type as those in the ImageBase. More...
 
typedef PixelT Pixel
 A pixel in this ImageBase. More...
 
typedef Reference< PixelT >::type PixelReference
 A Reference to a PixelT. More...
 
typedef ConstReference< PixelT >::type PixelConstReference
 A ConstReference to a PixelT. More...
 
typedef _view_t::xy_locator xy_locator
 An xy_locator. More...
 
typedef _view_t::xy_locator::const_t const_xy_locator
 A const_xy_locator. More...
 
typedef _view_t::iterator iterator
 An STL compliant iterator. More...
 
typedef _const_view_t::iterator const_iterator
 An STL compliant const iterator. More...
 
typedef _view_t::reverse_iterator reverse_iterator
 An STL compliant reverse iterator. More...
 
typedef _const_view_t::reverse_iterator const_reverse_iterator
 An STL compliant const reverse iterator. More...
 
typedef _view_t::x_iterator x_iterator
 An iterator for traversing the pixels in a row. More...
 
typedef x_iterator fast_iterator
 A fast STL compliant iterator for contiguous images N.b. More...
 
typedef _view_t::x_iterator xy_x_iterator
 An iterator for traversing the pixels in a row, created from an xy_locator. More...
 
typedef _const_view_t::x_iterator const_x_iterator
 A const iterator for traversing the pixels in a row. More...
 
typedef _view_t::y_iterator y_iterator
 An iterator for traversing the pixels in a column. More...
 
typedef _view_t::y_iterator xy_y_iterator
 An iterator for traversing the pixels in a row, created from an xy_locator. More...
 
typedef _const_view_t::y_iterator const_y_iterator
 A const iterator for traversing the pixels in a column. More...
 
typedef ndarray::Array< PixelT, 2, 1 > Array
 A mutable ndarray representation of the image. More...
 
typedef ndarray::Array< PixelT const, 2, 1 > ConstArray
 An immutable ndarray representation of the image. More...
 

Public Member Functions

 ImageSlice (Image< PixelT > const &img)
 Constructor for ImageSlice. More...
 
 ~ImageSlice () override
 
ImageSliceType getImageSliceType () const
 
Image subset (lsst::geom::Box2I const &bbox, ImageOrigin origin=PARENT) const
 Return a subimage corresponding to the given box. More...
 
Image operator[] (lsst::geom::Box2I const &bbox) const
 Return a subimage corresponding to the given box (interpreted as PARENT coordinates). More...
 
PixelReference operator[] (lsst::geom::Point2I const &index)
 Return a reference to a single pixel in PARENT coordinates (with no bounds check). More...
 
PixelConstReference operator[] (lsst::geom::Point2I const &index) const
 Return a reference to a single pixel in PARENT coordinates (with no bounds check). More...
 
void writeFits (std::string const &fileName, std::shared_ptr< lsst::daf::base::PropertySet const > metadata=std::shared_ptr< lsst::daf::base::PropertySet const >(), std::string const &mode="w") const
 Write an image to a regular FITS file. More...
 
void writeFits (fits::MemFileManager &manager, std::shared_ptr< lsst::daf::base::PropertySet const > metadata=std::shared_ptr< lsst::daf::base::PropertySet const >(), std::string const &mode="w") const
 Write an image to a FITS RAM file. More...
 
void writeFits (fits::Fits &fitsfile, std::shared_ptr< lsst::daf::base::PropertySet const > metadata=std::shared_ptr< lsst::daf::base::PropertySet const >()) const
 Write an image to an open FITS file object. More...
 
void writeFits (std::string const &filename, fits::ImageWriteOptions const &options, std::string const &mode="w", std::shared_ptr< daf::base::PropertySet const > header=nullptr, std::shared_ptr< Mask< MaskPixel > const > mask=nullptr) const
 Write an image to a regular FITS file. More...
 
void writeFits (fits::MemFileManager &manager, fits::ImageWriteOptions const &options, std::string const &mode="w", std::shared_ptr< daf::base::PropertySet const > header=nullptr, std::shared_ptr< Mask< MaskPixel > const > mask=nullptr) const
 Write an image to a FITS RAM file. More...
 
void writeFits (fits::Fits &fitsfile, fits::ImageWriteOptions const &options, std::shared_ptr< daf::base::PropertySet const > header=nullptr, std::shared_ptr< Mask< MaskPixel > const > mask=nullptr) const
 Write an image to an open FITS file object. More...
 
void swap (Image &rhs)
 
void swap (ImageBase &rhs)
 
Imageoperator+= (PixelT const rhs)
 Add scalar rhs to lhs. More...
 
virtual Imageoperator+= (Image< PixelT > const &rhs)
 Add Image rhs to lhs. More...
 
Imageoperator+= (lsst::afw::math::Function2< double > const &function)
 Add a Function2(x, y) to an Image. More...
 
void scaledPlus (double const c, Image< PixelT > const &rhs)
 Add Image c*rhs to lhs. More...
 
Imageoperator-= (PixelT const rhs)
 Subtract scalar rhs from lhs. More...
 
Imageoperator-= (Image< PixelT > const &rhs)
 Subtract Image rhs from lhs. More...
 
Imageoperator-= (lsst::afw::math::Function2< double > const &function)
 Subtract a Function2(x, y) from an Image. More...
 
void scaledMinus (double const c, Image< PixelT > const &rhs)
 Subtract Image c*rhs from lhs. More...
 
Imageoperator*= (PixelT const rhs)
 Multiply lhs by scalar rhs. More...
 
Imageoperator*= (Image< PixelT > const &rhs)
 Multiply lhs by Image rhs (i.e. pixel-by-pixel multiplication) More...
 
void scaledMultiplies (double const c, Image< PixelT > const &rhs)
 Multiply lhs by Image c*rhs (i.e. pixel-by-pixel multiplication) More...
 
Imageoperator/= (PixelT const rhs)
 Divide lhs by scalar rhs. More...
 
Imageoperator/= (Image< PixelT > const &rhs)
 Divide lhs by Image rhs (i.e. pixel-by-pixel division) More...
 
Image< double > & operator/= (double const rhs)
 
Image< float > & operator/= (float const rhs)
 
void scaledDivides (double const c, Image< PixelT > const &rhs)
 Divide lhs by Image c*rhs (i.e. pixel-by-pixel division) More...
 
void sqrt ()
 
void assign (ImageBase const &rhs, lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT)
 Copy pixels from another image to a specified subregion of this image. More...
 
PixelReference operator() (int x, int y)
 Return a reference to the pixel (x, y) in LOCAL coordinates. More...
 
PixelReference operator() (int x, int y, CheckIndices const &)
 Return a reference to the pixel (x, y) in LOCAL coordinates with bounds checking. More...
 
PixelConstReference operator() (int x, int y) const
 Return a const reference to the pixel (x, y) in LOCAL coordinates. More...
 
PixelConstReference operator() (int x, int y, CheckIndices const &) const
 Return a const reference to the pixel (x, y) in LOCAL coordinates with bounds checking. More...
 
PixelReference get (lsst::geom::Point2I const &index, ImageOrigin origin)
 Return a reference to a single pixel (with no bounds check). More...
 
PixelConstReference get (lsst::geom::Point2I const &index, ImageOrigin origin) const
 Return a const reference to a single pixel (with no bounds check). More...
 
int getWidth () const
 Return the number of columns in the image. More...
 
int getHeight () const
 Return the number of rows in the image. More...
 
int getArea () const
 Return the area of the image. More...
 
int getX0 () const
 Return the image's column-origin. More...
 
int getY0 () const
 Return the image's row-origin. More...
 
lsst::geom::Point2I getXY0 () const
 Return the image's origin. More...
 
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) More...
 
double indexToPosition (double ind, lsst::afw::image::xOrY const xy) const
 Convert image index to image position. More...
 
lsst::geom::Extent2I getDimensions () const
 Return the image's size; useful for passing to constructors. More...
 
Array getArray ()
 
ConstArray getArray () const
 
iterator begin () const
 Return an STL compliant iterator to the start of the image. More...
 
fast_iterator begin (bool contiguous) const
 Return a fast STL compliant iterator to the start of the image which must be contiguous. More...
 
iterator end () const
 Return an STL compliant iterator to the end of the image. More...
 
fast_iterator end (bool contiguous) const
 Return a fast STL compliant iterator to the end of the image which must be contiguous. More...
 
reverse_iterator rbegin () const
 Return an STL compliant reverse iterator to the start of the image. More...
 
reverse_iterator rend () const
 Return an STL compliant reverse iterator to the end of the image. More...
 
iterator at (int x, int y) const
 Return an STL compliant iterator at the point (x, y) More...
 
x_iterator row_begin (int y) const
 Return an x_iterator to the start of the y'th row. More...
 
x_iterator row_end (int y) const
 Return an x_iterator to the end of the y'th row. More...
 
x_iterator x_at (int x, int y) const
 Return an x_iterator to the point (x, y) in the image. More...
 
y_iterator col_begin (int x) const
 Return an y_iterator to the start of the y'th row. More...
 
y_iterator col_end (int x) const
 Return an y_iterator to the start of the y'th row. More...
 
y_iterator y_at (int x, int y) const
 Return an y_iterator to the point (x, y) in the image. More...
 
xy_locator xy_at (int x, int y) const
 Return an xy_locator at the point (x, y) in the image. More...
 
void setXY0 (lsst::geom::Point2I const origin)
 Set the ImageBase's origin. More...
 
void setXY0 (int const x0, int const y0)
 Set the ImageBase's origin. More...
 
lsst::geom::Box2I getBBox (ImageOrigin origin=PARENT) const
 

Static Public Member Functions

static Image readFits (std::string const &filename, int hdu=fits::DEFAULT_HDU)
 Read an Image from a regular FITS file. More...
 
static Image readFits (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU)
 Read an Image from a FITS RAM file. More...
 
template<typename SinglePixelT >
static SinglePixel PixelCast (SinglePixelT rhs)
 Convert a type to our SinglePixel type. More...
 

Protected Member Functions

_view_t _getRawView () const
 
bool isContiguous () const
 

Static Protected Member Functions

static _view_t _allocateView (lsst::geom::Extent2I const &dimensions, Manager::Ptr &manager)
 
static _view_t _makeSubView (lsst::geom::Extent2I const &dimensions, lsst::geom::Extent2I const &offset, const _view_t &view)
 

Related Functions

(Note that these are not member functions.)

template<typename ImageT >
ImageT::SinglePixel badPixel (typename ImageT::Pixel bad=0)
 Return a value indicating a bad pixel for the given Image type. More...
 

Detailed Description

template<typename PixelT>
class lsst::afw::image::ImageSlice< PixelT >

A class to specify a slice of an image.

Definition at line 46 of file ImageSlice.h.

Member Typedef Documentation

◆ Array

template<typename PixelT >
typedef ndarray::Array<PixelT, 2, 1> lsst::afw::image::ImageBase< PixelT >::Array
inherited

A mutable ndarray representation of the image.

Definition at line 149 of file ImageBase.h.

◆ const_iterator

template<typename PixelT >
typedef _const_view_t::iterator lsst::afw::image::ImageBase< PixelT >::const_iterator
inherited

An STL compliant const iterator.

Definition at line 127 of file ImageBase.h.

◆ const_reverse_iterator

template<typename PixelT >
typedef _const_view_t::reverse_iterator lsst::afw::image::ImageBase< PixelT >::const_reverse_iterator
inherited

An STL compliant const reverse iterator.

Definition at line 131 of file ImageBase.h.

◆ const_x_iterator

template<typename PixelT >
typedef _const_view_t::x_iterator lsst::afw::image::ImageBase< PixelT >::const_x_iterator
inherited

A const iterator for traversing the pixels in a row.

Definition at line 141 of file ImageBase.h.

◆ const_xy_locator

template<typename PixelT >
typedef _view_t::xy_locator::const_t lsst::afw::image::ImageBase< PixelT >::const_xy_locator
inherited

A const_xy_locator.

Definition at line 123 of file ImageBase.h.

◆ const_y_iterator

template<typename PixelT >
typedef _const_view_t::y_iterator lsst::afw::image::ImageBase< PixelT >::const_y_iterator
inherited

A const iterator for traversing the pixels in a column.

Definition at line 147 of file ImageBase.h.

◆ ConstArray

template<typename PixelT >
typedef ndarray::Array<PixelT const, 2, 1> lsst::afw::image::ImageBase< PixelT >::ConstArray
inherited

An immutable ndarray representation of the image.

Definition at line 151 of file ImageBase.h.

◆ fast_iterator

template<typename PixelT >
typedef x_iterator lsst::afw::image::ImageBase< PixelT >::fast_iterator
inherited

A fast STL compliant iterator for contiguous images N.b.

The order of pixel access is undefined

Definition at line 137 of file ImageBase.h.

◆ image_category

template<typename PixelT >
typedef detail::Image_tag lsst::afw::image::Image< PixelT >::image_category
inherited

Definition at line 63 of file Image.h.

◆ iterator

template<typename PixelT >
typedef _view_t::iterator lsst::afw::image::ImageBase< PixelT >::iterator
inherited

An STL compliant iterator.

Definition at line 125 of file ImageBase.h.

◆ Pixel

template<typename PixelT >
typedef PixelT lsst::afw::image::ImageBase< PixelT >::Pixel
inherited

A pixel in this ImageBase.

Definition at line 115 of file ImageBase.h.

◆ PixelConstReference

template<typename PixelT >
typedef ConstReference<PixelT>::type lsst::afw::image::ImageBase< PixelT >::PixelConstReference
inherited

A ConstReference to a PixelT.

Definition at line 119 of file ImageBase.h.

◆ PixelReference

template<typename PixelT >
typedef Reference<PixelT>::type lsst::afw::image::ImageBase< PixelT >::PixelReference
inherited

A Reference to a PixelT.

Definition at line 117 of file ImageBase.h.

◆ reverse_iterator

template<typename PixelT >
typedef _view_t::reverse_iterator lsst::afw::image::ImageBase< PixelT >::reverse_iterator
inherited

An STL compliant reverse iterator.

Definition at line 129 of file ImageBase.h.

◆ SinglePixel

template<typename PixelT >
typedef PixelT lsst::afw::image::ImageBase< PixelT >::SinglePixel
inherited

A single Pixel of the same type as those in the ImageBase.

Definition at line 113 of file ImageBase.h.

◆ x_iterator

template<typename PixelT >
typedef _view_t::x_iterator lsst::afw::image::ImageBase< PixelT >::x_iterator
inherited

An iterator for traversing the pixels in a row.

Definition at line 133 of file ImageBase.h.

◆ xy_locator

template<typename PixelT >
typedef _view_t::xy_locator lsst::afw::image::ImageBase< PixelT >::xy_locator
inherited

An xy_locator.

Definition at line 121 of file ImageBase.h.

◆ xy_x_iterator

template<typename PixelT >
typedef _view_t::x_iterator lsst::afw::image::ImageBase< PixelT >::xy_x_iterator
inherited

An iterator for traversing the pixels in a row, created from an xy_locator.

Definition at line 139 of file ImageBase.h.

◆ xy_y_iterator

template<typename PixelT >
typedef _view_t::y_iterator lsst::afw::image::ImageBase< PixelT >::xy_y_iterator
inherited

An iterator for traversing the pixels in a row, created from an xy_locator.

Definition at line 145 of file ImageBase.h.

◆ y_iterator

template<typename PixelT >
typedef _view_t::y_iterator lsst::afw::image::ImageBase< PixelT >::y_iterator
inherited

An iterator for traversing the pixels in a column.

Definition at line 143 of file ImageBase.h.

Member Enumeration Documentation

◆ ImageSliceType

template<typename PixelT >
enum lsst::afw::image::ImageSlice::ImageSliceType
Enumerator
ROW 
COLUMN 

Definition at line 48 of file ImageSlice.h.

Constructor & Destructor Documentation

◆ ImageSlice()

template<typename PixelT >
lsst::afw::image::ImageSlice< PixelT >::ImageSlice ( image::Image< PixelT > const &  img)
explicit

Constructor for ImageSlice.

Parameters
imgThe image to represent as a slice.

Definition at line 41 of file ImageSlice.cc.

41  : Image<PixelT>(img), _sliceType(ROW) {
42  // verify the img is a slice (row or column)
43  if (img.getWidth() != 1 && img.getHeight() != 1) {
44  throw LSST_EXCEPT(ex::OutOfRangeError, "Input image must be a slice (width or height == 1)");
45  } else if (img.getWidth() == 1 && img.getHeight() == 1) {
47  "1x1 image ambiguous (could be row or column). "
48  "Perhaps a constant would be better than a slice? ");
49  } else if (img.getWidth() == 1 && img.getHeight() != 1) {
50  _sliceType = COLUMN;
51  } else if (img.getHeight() == 1 && img.getWidth() != 1) {
52  _sliceType = ROW;
53  }
54 
55  // what about 1xn images where a 1x1 row slice is desired? ... use a constant instead of a slice
56  // what about nx1 images wehre a 1x1 column slice is desired? ... use a constant instead of a slice
57 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
int getWidth() const
Return the number of columns in the image.
Definition: ImageBase.h:294
int getHeight() const
Return the number of rows in the image.
Definition: ImageBase.h:296
Reports invalid arguments.
Definition: Runtime.h:66
Reports attempts to access elements outside a valid range of indices.
Definition: Runtime.h:89

◆ ~ImageSlice()

template<typename PixelT >
lsst::afw::image::ImageSlice< PixelT >::~ImageSlice ( )
inlineoverride

Definition at line 56 of file ImageSlice.h.

56 {}

Member Function Documentation

◆ _allocateView()

template<typename PixelT >
ImageBase< PixelT >::_view_t lsst::afw::image::ImageBase< PixelT >::_allocateView ( lsst::geom::Extent2I const &  dimensions,
Manager::Ptr &  manager 
)
staticprotectedinherited

Definition at line 58 of file Image.cc.

59  {
60  if (dimensions.getX() < 0 || dimensions.getY() < 0) {
61  throw LSST_EXCEPT(pex::exceptions::LengthError,
62  str(boost::format("Both width and height must be non-negative: %d, %d") %
63  dimensions.getX() % dimensions.getY()));
64  }
65  if (dimensions.getX() != 0 && dimensions.getY() > std::numeric_limits<int>::max() / dimensions.getX()) {
66  throw LSST_EXCEPT(pex::exceptions::LengthError,
67  str(boost::format("Image dimensions (%d x %d) too large; int overflow detected.") %
68  dimensions.getX() % dimensions.getY()));
69  }
71  ndarray::SimpleManager<PixelT>::allocate(dimensions.getX() * dimensions.getY());
72  manager = r.first;
73  return boost::gil::interleaved_view(dimensions.getX(), dimensions.getY(),
74  (typename _view_t::value_type*)r.second,
75  dimensions.getX() * sizeof(PixelT));
76 }
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:49
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174

◆ _getRawView()

template<typename PixelT >
_view_t lsst::afw::image::ImageBase< PixelT >::_getRawView ( ) const
inlineprotectedinherited

Definition at line 465 of file ImageBase.h.

465 { return _gilView; }

◆ _makeSubView()

template<typename PixelT >
ImageBase< PixelT >::_view_t lsst::afw::image::ImageBase< PixelT >::_makeSubView ( lsst::geom::Extent2I const &  dimensions,
lsst::geom::Extent2I const &  offset,
const _view_t &  view 
)
staticprotectedinherited

Definition at line 78 of file Image.cc.

80  {
81  if (offset.getX() < 0 || offset.getY() < 0 || offset.getX() + dimensions.getX() > view.width() ||
82  offset.getY() + dimensions.getY() > view.height()) {
83  throw LSST_EXCEPT(
84  pex::exceptions::LengthError,
86  "Box2I(Point2I(%d,%d),lsst::geom::Extent2I(%d,%d)) doesn't fit in image %dx%d") %
87  offset.getX() % offset.getY() % dimensions.getX() % dimensions.getY() % view.width() %
88  view.height())
89  .str());
90  }
91  if (dimensions.getX() == 0 && dimensions.getY() == 0
92  && view.width() == 0 && view.height() == 0) {
93  // Getting a zero-extent subview of a zero-extent view returns itself
94  return view;
95  } else {
96  return boost::gil::subimage_view(view, offset.getX(), offset.getY(), dimensions.getX(),
97  dimensions.getY());
98  }
99 }

◆ assign()

template<typename PixelT >
void lsst::afw::image::ImageBase< PixelT >::assign ( ImageBase< PixelT > const &  rhs,
lsst::geom::Box2I const &  bbox = lsst::geom::Box2I(),
ImageOrigin  origin = PARENT 
)
inherited

Copy pixels from another image to a specified subregion of this image.

Parameters
[in]rhssource image whose pixels are to be copied into this image (the destination)
[in]bboxsubregion of this image to set; if empty (the default) then all pixels are set
[in]originorigin of bbox: if PARENT then the lower left pixel of this image is at xy0 if LOCAL then the lower left pixel of this image is at 0,0
Exceptions
lsst::pex::exceptions::LengthErrorif the dimensions of rhs and the specified subregion of this image do not match.

Definition at line 166 of file Image.cc.

166  {
167  auto lhsDim = bbox.isEmpty() ? getDimensions() : bbox.getDimensions();
168  if (lhsDim != rhs.getDimensions()) {
169  throw LSST_EXCEPT(pex::exceptions::LengthError,
170  (boost::format("Dimension mismatch: %dx%d v. %dx%d") % lhsDim.getX() %
171  lhsDim.getY() % rhs.getWidth() % rhs.getHeight())
172  .str());
173  }
174  if (bbox.isEmpty()) {
175  copy_pixels(rhs._gilView, _gilView);
176  } else {
177  auto lhsOff = (origin == PARENT) ? bbox.getMin() - _origin : lsst::geom::Extent2I(bbox.getMin());
178  auto lhsGilView = _makeSubView(lhsDim, lhsOff, _gilView);
179  copy_pixels(rhs._gilView, lhsGilView);
180  }
181 }
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
static _view_t _makeSubView(lsst::geom::Extent2I const &dimensions, lsst::geom::Extent2I const &offset, const _view_t &view)
Definition: Image.cc:78
lsst::geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
Definition: ImageBase.h:356
Extent< int, 2 > Extent2I
Definition: Extent.h:397

◆ at()

template<typename PixelT >
ImageBase< PixelT >::iterator lsst::afw::image::ImageBase< PixelT >::at ( int  x,
int  y 
) const
inherited

Return an STL compliant iterator at the point (x, y)

Definition at line 283 of file Image.cc.

283  {
284  return _gilView.at(x, y);
285 }
double x
int y
Definition: SpanSet.cc:49

◆ begin() [1/2]

template<typename PixelT >
ImageBase< PixelT >::iterator lsst::afw::image::ImageBase< PixelT >::begin
inherited

Return an STL compliant iterator to the start of the image.

Note that this isn't especially efficient; see Image Iterators for a discussion

Definition at line 263 of file Image.cc.

263  {
264  return _gilView.begin();
265 }

◆ begin() [2/2]

template<typename PixelT >
ImageBase< PixelT >::fast_iterator lsst::afw::image::ImageBase< PixelT >::begin ( bool  contiguous) const
inherited

Return a fast STL compliant iterator to the start of the image which must be contiguous.

Parameters
contiguousPixels are contiguous (must be true)
Exceptions
lsst::pex::exceptions::RuntimeErrorArgument contiguous is false, or the pixels are not in fact contiguous

Definition at line 288 of file Image.cc.

288  {
289  if (!contiguous) {
290  throw LSST_EXCEPT(pex::exceptions::RuntimeError, "Only contiguous == true makes sense");
291  }
292  if (!this->isContiguous()) {
293  throw LSST_EXCEPT(pex::exceptions::RuntimeError, "Image's pixels are not contiguous");
294  }
295 
296  return row_begin(0);
297 }
x_iterator row_begin(int y) const
Return an x_iterator to the start of the y'th row.
Definition: ImageBase.h:401

◆ col_begin()

template<typename PixelT >
y_iterator lsst::afw::image::ImageBase< PixelT >::col_begin ( int  x) const
inlineinherited

Return an y_iterator to the start of the y'th row.

Incrementing an y_iterator moves it up the column

Definition at line 413 of file ImageBase.h.

413 { return _gilView.col_begin(x); }

◆ col_end()

template<typename PixelT >
y_iterator lsst::afw::image::ImageBase< PixelT >::col_end ( int  x) const
inlineinherited

Return an y_iterator to the start of the y'th row.

Definition at line 416 of file ImageBase.h.

416 { return _gilView.col_end(x); }

◆ end() [1/2]

template<typename PixelT >
ImageBase< PixelT >::iterator lsst::afw::image::ImageBase< PixelT >::end
inherited

Return an STL compliant iterator to the end of the image.

Definition at line 268 of file Image.cc.

268  {
269  return _gilView.end();
270 }

◆ end() [2/2]

template<typename PixelT >
ImageBase< PixelT >::fast_iterator lsst::afw::image::ImageBase< PixelT >::end ( bool  contiguous) const
inherited

Return a fast STL compliant iterator to the end of the image which must be contiguous.

Parameters
contiguousPixels are contiguous (must be true)
Exceptions
lsst::pex::exceptions::RuntimeErrorArgument contiguous is false, or the pixels are not in fact contiguous

Definition at line 300 of file Image.cc.

300  {
301  if (!contiguous) {
302  throw LSST_EXCEPT(pex::exceptions::RuntimeError, "Only contiguous == true makes sense");
303  }
304  if (!this->isContiguous()) {
305  throw LSST_EXCEPT(pex::exceptions::RuntimeError, "Image's pixels are not contiguous");
306  }
307 
308  return row_end(getHeight() - 1);
309 }
x_iterator row_end(int y) const
Return an x_iterator to the end of the y'th row.
Definition: ImageBase.h:404

◆ get() [1/2]

template<typename PixelT >
ImageBase< PixelT >::PixelReference lsst::afw::image::ImageBase< PixelT >::get ( lsst::geom::Point2I const &  index,
ImageOrigin  origin 
)
inherited

Return a reference to a single pixel (with no bounds check).

Definition at line 222 of file Image.cc.

223  {
224  int x = index.getX();
225  int y = index.getY();
226  if (origin == PARENT) {
227  x -= getX0();
228  y -= getY0();
229  }
230  return _gilView(x, y)[0];
231 }
int getX0() const
Return the image's column-origin.
Definition: ImageBase.h:306
int getY0() const
Return the image's row-origin.
Definition: ImageBase.h:314

◆ get() [2/2]

template<typename PixelT >
ImageBase< PixelT >::PixelConstReference lsst::afw::image::ImageBase< PixelT >::get ( lsst::geom::Point2I const &  index,
ImageOrigin  origin 
) const
inherited

Return a const reference to a single pixel (with no bounds check).

Definition at line 234 of file Image.cc.

235  {
236  int x = index.getX();
237  int y = index.getY();
238  if (origin == PARENT) {
239  x -= getX0();
240  y -= getY0();
241  }
242  return _gilView(x, y)[0];
243 }

◆ getArea()

template<typename PixelT >
int lsst::afw::image::ImageBase< PixelT >::getArea ( ) const
inlineinherited

Return the area of the image.

Definition at line 298 of file ImageBase.h.

298 { return getWidth()*getHeight(); }

◆ getArray() [1/2]

template<typename PixelT >
ImageBase< PixelT >::Array lsst::afw::image::ImageBase< PixelT >::getArray
inherited

Definition at line 476 of file ImageBase.h.

476  {
477  int rowStride = 1;
478  PixelT * data = nullptr;
479  if (getArea() > 0) {
480  data = reinterpret_cast<PixelT*>(row_begin(0));
481  }
482  if (getHeight() > 1) {
483  rowStride = reinterpret_cast<PixelT*>(row_begin(1)) - reinterpret_cast<PixelT*>(row_begin(0));
484  }
485  return ndarray::external(data,
486  ndarray::makeVector(getHeight(), getWidth()), ndarray::makeVector(rowStride, 1),
487  this->_manager);
488 }
char * data
Definition: BaseRecord.cc:62
int getArea() const
Return the area of the image.
Definition: ImageBase.h:298

◆ getArray() [2/2]

template<typename PixelT >
ImageBase< PixelT >::ConstArray lsst::afw::image::ImageBase< PixelT >::getArray
inherited

Definition at line 491 of file ImageBase.h.

491  {
492  int rowStride = 1;
493  PixelT * data = nullptr;
494  if (getArea() > 0) {
495  data = reinterpret_cast<PixelT*>(row_begin(0));
496  }
497  if (getHeight() > 1) {
498  rowStride = reinterpret_cast<PixelT*>(row_begin(1)) - reinterpret_cast<PixelT*>(row_begin(0));
499  }
500  return ndarray::external(data,
501  ndarray::makeVector(getHeight(), getWidth()), ndarray::makeVector(rowStride, 1),
502  this->_manager);
503 }

◆ getBBox()

template<typename PixelT >
lsst::geom::Box2I lsst::afw::image::ImageBase< PixelT >::getBBox ( ImageOrigin  origin = PARENT) const
inlineinherited

Definition at line 445 of file ImageBase.h.

445  {
446  if (origin == PARENT) {
447  return lsst::geom::Box2I(_origin, getDimensions());
448  } else
450  }
An integer coordinate rectangle.
Definition: Box.h:55

◆ getDimensions()

template<typename PixelT >
lsst::geom::Extent2I lsst::afw::image::ImageBase< PixelT >::getDimensions ( ) const
inlineinherited

Return the image's size; useful for passing to constructors.

Definition at line 356 of file ImageBase.h.

356 { return lsst::geom::Extent2I(getWidth(), getHeight()); }

◆ getHeight()

template<typename PixelT >
int lsst::afw::image::ImageBase< PixelT >::getHeight ( ) const
inlineinherited

Return the number of rows in the image.

Definition at line 296 of file ImageBase.h.

296 { return _gilView.height(); }

◆ getImageSliceType()

template<typename PixelT >
ImageSliceType lsst::afw::image::ImageSlice< PixelT >::getImageSliceType ( ) const
inline

Definition at line 57 of file ImageSlice.h.

57 { return _sliceType; }

◆ getWidth()

template<typename PixelT >
int lsst::afw::image::ImageBase< PixelT >::getWidth ( ) const
inlineinherited

Return the number of columns in the image.

Definition at line 294 of file ImageBase.h.

294 { return _gilView.width(); }

◆ getX0()

template<typename PixelT >
int lsst::afw::image::ImageBase< PixelT >::getX0 ( ) const
inlineinherited

Return the image's column-origin.

This will usually be 0 except for images created using the ImageBase(fileName, hdu, BBox, mode) ctor or ImageBase(ImageBase, BBox) cctor The origin can be reset with setXY0

Definition at line 306 of file ImageBase.h.

306 { return _origin.getX(); }

◆ getXY0()

template<typename PixelT >
lsst::geom::Point2I lsst::afw::image::ImageBase< PixelT >::getXY0 ( ) const
inlineinherited

Return the image's origin.

This will usually be (0, 0) except for images created using the ImageBase(fileName, hdu, BBox, mode) ctor or ImageBase(ImageBase, BBox) cctor The origin can be reset with setXY0

Definition at line 323 of file ImageBase.h.

323 { return _origin; }

◆ getY0()

template<typename PixelT >
int lsst::afw::image::ImageBase< PixelT >::getY0 ( ) const
inlineinherited

Return the image's row-origin.

This will usually be 0 except for images created using the ImageBase(fileName, hdu, BBox, mode) ctor or ImageBase(ImageBase, BBox) cctor The origin can be reset with setXY0

Definition at line 314 of file ImageBase.h.

314 { return _origin.getY(); }

◆ indexToPosition()

template<typename PixelT >
double lsst::afw::image::ImageBase< PixelT >::indexToPosition ( double  ind,
lsst::afw::image::xOrY const  xy 
) const
inlineinherited

Convert image index to image position.

The LSST indexing convention is:

  • the index of the bottom left pixel is 0,0
  • the position of the center of the bottom left pixel is PixelZeroPos, PixelZeroPos
Returns
image position
Parameters
indimage index
xyIs this a column or row coordinate?

Definition at line 349 of file ImageBase.h.

351  {
352  return ind + PixelZeroPos + (xy == X ? getX0() : getY0());
353  }
const double PixelZeroPos
position of center of pixel 0
Definition: ImageUtils.h:44

◆ isContiguous()

template<typename PixelT >
bool lsst::afw::image::ImageBase< PixelT >::isContiguous ( ) const
inlineprotectedinherited

Definition at line 467 of file ImageBase.h.

467 { return begin() + getWidth() * getHeight() == end(); }
iterator end() const
Return an STL compliant iterator to the end of the image.
Definition: Image.cc:268
iterator begin() const
Return an STL compliant iterator to the start of the image.
Definition: Image.cc:263

◆ operator()() [1/4]

template<typename PixelT >
ImageBase< PixelT >::PixelReference lsst::afw::image::ImageBase< PixelT >::operator() ( int  x,
int  y 
)
inherited

Return a reference to the pixel (x, y) in LOCAL coordinates.

Definition at line 184 of file Image.cc.

184  {
185  return const_cast<typename ImageBase<PixelT>::PixelReference>(
186  static_cast<typename ImageBase<PixelT>::PixelConstReference>(_gilView(x, y)[0]));
187 }
Reference< PixelT >::type PixelReference
A Reference to a PixelT.
Definition: ImageBase.h:117
ConstReference< PixelT >::type PixelConstReference
A ConstReference to a PixelT.
Definition: ImageBase.h:119

◆ operator()() [2/4]

template<typename PixelT >
ImageBase< PixelT >::PixelConstReference lsst::afw::image::ImageBase< PixelT >::operator() ( int  x,
int  y 
) const
inherited

Return a const reference to the pixel (x, y) in LOCAL coordinates.

Definition at line 204 of file Image.cc.

204  {
205  return _gilView(x, y)[0];
206 }

◆ operator()() [3/4]

template<typename PixelT >
ImageBase< PixelT >::PixelReference lsst::afw::image::ImageBase< PixelT >::operator() ( int  x,
int  y,
CheckIndices const &  check 
)
inherited

Return a reference to the pixel (x, y) in LOCAL coordinates with bounds checking.

Definition at line 190 of file Image.cc.

191  {
192  if (check && (x < 0 || x >= getWidth() || y < 0 || y >= getHeight())) {
193  throw LSST_EXCEPT(pex::exceptions::LengthError,
194  (boost::format("Index (%d, %d) is out of range [0--%d], [0--%d]") % x % y %
195  (getWidth() - 1) % (getHeight() - 1))
196  .str());
197  }
198 
199  return const_cast<typename ImageBase<PixelT>::PixelReference>(
200  static_cast<typename ImageBase<PixelT>::PixelConstReference>(_gilView(x, y)[0]));
201 }

◆ operator()() [4/4]

template<typename PixelT >
ImageBase< PixelT >::PixelConstReference lsst::afw::image::ImageBase< PixelT >::operator() ( int  x,
int  y,
CheckIndices const &  check 
) const
inherited

Return a const reference to the pixel (x, y) in LOCAL coordinates with bounds checking.

Definition at line 209 of file Image.cc.

210  {
211  if (check && (x < 0 || x >= getWidth() || y < 0 || y >= getHeight())) {
212  throw LSST_EXCEPT(pex::exceptions::LengthError,
213  (boost::format("Index (%d, %d) is out of range [0--%d], [0--%d]") % x % y %
214  (this->getWidth() - 1) % (this->getHeight() - 1))
215  .str());
216  }
217 
218  return _gilView(x, y)[0];
219 }

◆ operator*=() [1/2]

template<typename PixelT >
Image< PixelT > & lsst::afw::image::Image< PixelT >::operator*= ( Image< PixelT > const &  rhs)
inherited

Multiply lhs by Image rhs (i.e. pixel-by-pixel multiplication)

Definition at line 564 of file Image.cc.

564  {
565  if (this->getDimensions() != rhs.getDimensions()) {
566  throw LSST_EXCEPT(pex::exceptions::LengthError,
567  (boost::format("Images are of different size, %dx%d v %dx%d") % this->getWidth() %
568  this->getHeight() % rhs.getWidth() % rhs.getHeight())
569  .str());
570  }
571  transform_pixels(_getRawView(), rhs._getRawView(), _getRawView(),
572  [](PixelT const& l, PixelT const& r) -> PixelT { return l * r; });
573  return *this;
574 }
_view_t _getRawView() const
Definition: ImageBase.h:465

◆ operator*=() [2/2]

template<typename PixelT >
Image< PixelT > & lsst::afw::image::Image< PixelT >::operator*= ( PixelT const  rhs)
inherited

Multiply lhs by scalar rhs.

Definition at line 558 of file Image.cc.

558  {
559  transform_pixels(_getRawView(), _getRawView(), [&rhs](PixelT const& l) -> PixelT { return l * rhs; });
560  return *this;
561 }

◆ operator+=() [1/3]

template<typename PixelT >
Image< PixelT > & lsst::afw::image::Image< PixelT >::operator+= ( Image< PixelT > const &  rhs)
virtualinherited

Add Image rhs to lhs.

Definition at line 474 of file Image.cc.

474  {
475  if (this->getDimensions() != rhs.getDimensions()) {
476  throw LSST_EXCEPT(pex::exceptions::LengthError,
477  (boost::format("Images are of different size, %dx%d v %dx%d") % this->getWidth() %
478  this->getHeight() % rhs.getWidth() % rhs.getHeight())
479  .str());
480  }
481  transform_pixels(_getRawView(), rhs._getRawView(), _getRawView(),
482  [](PixelT const& l, PixelT const& r) -> PixelT { return l + r; });
483  return *this;
484 }

◆ operator+=() [2/3]

template<typename PixelT >
Image< PixelT > & lsst::afw::image::Image< PixelT >::operator+= ( lsst::afw::math::Function2< double > const &  function)
inherited

Add a Function2(x, y) to an Image.

Parameters
functionfunction to add

Definition at line 487 of file Image.cc.

487  {
488  for (int y = 0; y != this->getHeight(); ++y) {
489  double const yPos = this->indexToPosition(y, Y);
490  double xPos = this->indexToPosition(0, X);
491  for (typename Image<PixelT>::x_iterator ptr = this->row_begin(y), end = this->row_end(y); ptr != end;
492  ++ptr, ++xPos) {
493  *ptr += function(xPos, yPos);
494  }
495  }
496  return *this;
497 }
uint64_t * ptr
Definition: RangeSet.cc:88
double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const
Convert image index to image position.
Definition: ImageBase.h:349
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
Definition: ImageBase.h:133

◆ operator+=() [3/3]

template<typename PixelT >
Image< PixelT > & lsst::afw::image::Image< PixelT >::operator+= ( PixelT const  rhs)
inherited

Add scalar rhs to lhs.

Definition at line 468 of file Image.cc.

468  {
469  transform_pixels(_getRawView(), _getRawView(), [&rhs](PixelT const& l) -> PixelT { return l + rhs; });
470  return *this;
471 }

◆ operator-=() [1/3]

template<typename PixelT >
Image< PixelT > & lsst::afw::image::Image< PixelT >::operator-= ( Image< PixelT > const &  rhs)
inherited

Subtract Image rhs from lhs.

Definition at line 519 of file Image.cc.

519  {
520  if (this->getDimensions() != rhs.getDimensions()) {
521  throw LSST_EXCEPT(pex::exceptions::LengthError,
522  (boost::format("Images are of different size, %dx%d v %dx%d") % this->getWidth() %
523  this->getHeight() % rhs.getWidth() % rhs.getHeight())
524  .str());
525  }
526  transform_pixels(_getRawView(), rhs._getRawView(), _getRawView(),
527  [](PixelT const& l, PixelT const& r) -> PixelT { return l - r; });
528  return *this;
529 }

◆ operator-=() [2/3]

template<typename PixelT >
Image< PixelT > & lsst::afw::image::Image< PixelT >::operator-= ( lsst::afw::math::Function2< double > const &  function)
inherited

Subtract a Function2(x, y) from an Image.

Parameters
functionfunction to add

Definition at line 545 of file Image.cc.

545  {
546  for (int y = 0; y != this->getHeight(); ++y) {
547  double const yPos = this->indexToPosition(y, Y);
548  double xPos = this->indexToPosition(0, X);
549  for (typename Image<PixelT>::x_iterator ptr = this->row_begin(y), end = this->row_end(y); ptr != end;
550  ++ptr, ++xPos) {
551  *ptr -= function(xPos, yPos);
552  }
553  }
554  return *this;
555 }

◆ operator-=() [3/3]

template<typename PixelT >
Image< PixelT > & lsst::afw::image::Image< PixelT >::operator-= ( PixelT const  rhs)
inherited

Subtract scalar rhs from lhs.

Definition at line 513 of file Image.cc.

513  {
514  transform_pixels(_getRawView(), _getRawView(), [&rhs](PixelT const& l) -> PixelT { return l - rhs; });
515  return *this;
516 }

◆ operator/=() [1/4]

Image< double > & lsst::afw::image::Image< double >::operator/= ( double const  rhs)
inherited

Definition at line 598 of file Image.cc.

598  {
599  double const irhs = 1 / rhs;
600  *this *= irhs;
601  return *this;
602 }

◆ operator/=() [2/4]

Image< float > & lsst::afw::image::Image< float >::operator/= ( float const  rhs)
inherited

Definition at line 605 of file Image.cc.

605  {
606  float const irhs = 1 / rhs;
607  *this *= irhs;
608  return *this;
609 }

◆ operator/=() [3/4]

template<typename PixelT >
Image< PixelT > & lsst::afw::image::Image< PixelT >::operator/= ( Image< PixelT > const &  rhs)
inherited

Divide lhs by Image rhs (i.e. pixel-by-pixel division)

Definition at line 612 of file Image.cc.

612  {
613  if (this->getDimensions() != rhs.getDimensions()) {
614  throw LSST_EXCEPT(pex::exceptions::LengthError,
615  (boost::format("Images are of different size, %dx%d v %dx%d") % this->getWidth() %
616  this->getHeight() % rhs.getWidth() % rhs.getHeight())
617  .str());
618  }
619  transform_pixels(_getRawView(), rhs._getRawView(), _getRawView(),
620  [](PixelT const& l, PixelT const& r) -> PixelT { return l / r; });
621  return *this;
622 }

◆ operator/=() [4/4]

template<typename PixelT >
Image< PixelT > & lsst::afw::image::Image< PixelT >::operator/= ( PixelT const  rhs)
inherited

Divide lhs by scalar rhs.

Note
Floating point types implement this by multiplying by the 1/rhs

Definition at line 590 of file Image.cc.

590  {
591  transform_pixels(_getRawView(), _getRawView(), [&rhs](PixelT const& l) -> PixelT { return l / rhs; });
592  return *this;
593 }

◆ operator[]() [1/3]

template<typename PixelT >
Image lsst::afw::image::Image< PixelT >::operator[] ( lsst::geom::Box2I const &  bbox) const
inlineinherited

Return a subimage corresponding to the given box (interpreted as PARENT coordinates).

Definition at line 231 of file Image.h.

231 { return subset(bbox); }
Image subset(lsst::geom::Box2I const &bbox, ImageOrigin origin=PARENT) const
Return a subimage corresponding to the given box.
Definition: Image.h:226

◆ operator[]() [2/3]

template<typename PixelT >
PixelReference lsst::afw::image::ImageBase< PixelT >::operator[] ( lsst::geom::Point2I const &  index)
inlineinherited

Return a reference to a single pixel in PARENT coordinates (with no bounds check).

Definition at line 288 of file ImageBase.h.

288 { return get(index, PARENT); }
PixelReference get(lsst::geom::Point2I const &index, ImageOrigin origin)
Return a reference to a single pixel (with no bounds check).
Definition: Image.cc:222

◆ operator[]() [3/3]

template<typename PixelT >
PixelConstReference lsst::afw::image::ImageBase< PixelT >::operator[] ( lsst::geom::Point2I const &  index) const
inlineinherited

Return a reference to a single pixel in PARENT coordinates (with no bounds check).

Definition at line 291 of file ImageBase.h.

291 { return get(index, PARENT); }

◆ PixelCast()

template<typename PixelT >
template<typename SinglePixelT >
static SinglePixel lsst::afw::image::ImageBase< PixelT >::PixelCast ( SinglePixelT  rhs)
inlinestaticinherited

Convert a type to our SinglePixel type.

Definition at line 158 of file ImageBase.h.

158  {
159  return SinglePixel(rhs);
160  }
PixelT SinglePixel
A single Pixel of the same type as those in the ImageBase.
Definition: ImageBase.h:113

◆ positionToIndex()

template<typename PixelT >
std::pair<int, double> lsst::afw::image::ImageBase< PixelT >::positionToIndex ( double const  pos,
lsst::afw::image::xOrY const  xy 
) const
inlineinherited

Convert image position to index (nearest integer and fractional parts)

Returns
std::pair(nearest integer index, fractional part)
Parameters
posimage position
xyIs this a column or row coordinate?

Definition at line 330 of file ImageBase.h.

333  {
334  double const fullIndex = pos - PixelZeroPos - (xy == X ? getX0() : getY0());
335  int const roundedIndex = static_cast<int>(fullIndex + 0.5);
336  double const residual = fullIndex - roundedIndex;
337  return std::pair<int, double>(roundedIndex, residual);
338  }

◆ rbegin()

template<typename PixelT >
ImageBase< PixelT >::reverse_iterator lsst::afw::image::ImageBase< PixelT >::rbegin
inherited

Return an STL compliant reverse iterator to the start of the image.

Definition at line 273 of file Image.cc.

273  {
274  return _gilView.rbegin();
275 }

◆ readFits() [1/2]

template<typename PixelT >
static Image lsst::afw::image::Image< PixelT >::readFits ( fits::MemFileManager manager,
int  hdu = fits::DEFAULT_HDU 
)
inlinestaticinherited

Read an Image from a FITS RAM file.

Parameters
[in]managerObject that manages the memory to be read.
[in]hduNumber of the "header-data unit" to read (where 0 is the Primary HDU). The default value of afw::fits::DEFAULT_HDU is interpreted as "the first HDU with NAXIS != 0".

Definition at line 328 of file Image.h.

328  {
329  return Image<PixelT>(manager, hdu);
330  }

◆ readFits() [2/2]

template<typename PixelT >
static Image lsst::afw::image::Image< PixelT >::readFits ( std::string const &  filename,
int  hdu = fits::DEFAULT_HDU 
)
inlinestaticinherited

Read an Image from a regular FITS file.

Parameters
[in]filenameName of the file to read.
[in]hduNumber of the "header-data unit" to read (where 0 is the Primary HDU). The default value of afw::fits::DEFAULT_HDU is interpreted as "the first HDU with NAXIS != 0".

Definition at line 316 of file Image.h.

316  {
317  return Image<PixelT>(filename, hdu);
318  }

◆ rend()

template<typename PixelT >
ImageBase< PixelT >::reverse_iterator lsst::afw::image::ImageBase< PixelT >::rend
inherited

Return an STL compliant reverse iterator to the end of the image.

Definition at line 278 of file Image.cc.

278  {
279  return _gilView.rend();
280 }

◆ row_begin()

template<typename PixelT >
x_iterator lsst::afw::image::ImageBase< PixelT >::row_begin ( int  y) const
inlineinherited

Return an x_iterator to the start of the y'th row.

Incrementing an x_iterator moves it across the row

Definition at line 401 of file ImageBase.h.

401 { return _gilView.row_begin(y); }

◆ row_end()

template<typename PixelT >
x_iterator lsst::afw::image::ImageBase< PixelT >::row_end ( int  y) const
inlineinherited

Return an x_iterator to the end of the y'th row.

Definition at line 404 of file ImageBase.h.

404 { return _gilView.row_end(y); }

◆ scaledDivides()

template<typename PixelT >
void lsst::afw::image::Image< PixelT >::scaledDivides ( double const  c,
Image< PixelT > const &  rhs 
)
inherited

Divide lhs by Image c*rhs (i.e. pixel-by-pixel division)

Definition at line 625 of file Image.cc.

625  {
626  if (this->getDimensions() != rhs.getDimensions()) {
627  throw LSST_EXCEPT(pex::exceptions::LengthError,
628  (boost::format("Images are of different size, %dx%d v %dx%d") % this->getWidth() %
629  this->getHeight() % rhs.getWidth() % rhs.getHeight())
630  .str());
631  }
632  transform_pixels(
633  _getRawView(), rhs._getRawView(), _getRawView(),
634  [&c](PixelT const& l, PixelT const& r) -> PixelT { return l / static_cast<PixelT>(c * r); });
635 }

◆ scaledMinus()

template<typename PixelT >
void lsst::afw::image::Image< PixelT >::scaledMinus ( double const  c,
Image< PixelT > const &  rhs 
)
inherited

Subtract Image c*rhs from lhs.

Definition at line 532 of file Image.cc.

532  {
533  if (this->getDimensions() != rhs.getDimensions()) {
534  throw LSST_EXCEPT(pex::exceptions::LengthError,
535  (boost::format("Images are of different size, %dx%d v %dx%d") % this->getWidth() %
536  this->getHeight() % rhs.getWidth() % rhs.getHeight())
537  .str());
538  }
539  transform_pixels(
540  _getRawView(), rhs._getRawView(), _getRawView(),
541  [&c](PixelT const& l, PixelT const& r) -> PixelT { return l - static_cast<PixelT>(c * r); });
542 }

◆ scaledMultiplies()

template<typename PixelT >
void lsst::afw::image::Image< PixelT >::scaledMultiplies ( double const  c,
Image< PixelT > const &  rhs 
)
inherited

Multiply lhs by Image c*rhs (i.e. pixel-by-pixel multiplication)

Definition at line 577 of file Image.cc.

577  {
578  if (this->getDimensions() != rhs.getDimensions()) {
579  throw LSST_EXCEPT(pex::exceptions::LengthError,
580  (boost::format("Images are of different size, %dx%d v %dx%d") % this->getWidth() %
581  this->getHeight() % rhs.getWidth() % rhs.getHeight())
582  .str());
583  }
584  transform_pixels(
585  _getRawView(), rhs._getRawView(), _getRawView(),
586  [&c](PixelT const& l, PixelT const& r) -> PixelT { return l * static_cast<PixelT>(c * r); });
587 }

◆ scaledPlus()

template<typename PixelT >
void lsst::afw::image::Image< PixelT >::scaledPlus ( double const  c,
Image< PixelT > const &  rhs 
)
inherited

Add Image c*rhs to lhs.

Definition at line 500 of file Image.cc.

500  {
501  if (this->getDimensions() != rhs.getDimensions()) {
502  throw LSST_EXCEPT(pex::exceptions::LengthError,
503  (boost::format("Images are of different size, %dx%d v %dx%d") % this->getWidth() %
504  this->getHeight() % rhs.getWidth() % rhs.getHeight())
505  .str());
506  }
507  transform_pixels(
508  _getRawView(), rhs._getRawView(), _getRawView(),
509  [&c](PixelT const& l, PixelT const& r) -> PixelT { return l + static_cast<PixelT>(c * r); });
510 }

◆ setXY0() [1/2]

template<typename PixelT >
void lsst::afw::image::ImageBase< PixelT >::setXY0 ( int const  x0,
int const  y0 
)
inlineinherited

Set the ImageBase's origin.

The origin is usually set by the constructor, so you shouldn't need this function

Note
There are use cases (e.g. memory overlays) that may want to set these values, but don't do so unless you are an Expert.

Definition at line 443 of file ImageBase.h.

443 { setXY0(lsst::geom::Point2I(x0, y0)); }
void setXY0(lsst::geom::Point2I const origin)
Set the ImageBase's origin.
Definition: ImageBase.h:434

◆ setXY0() [2/2]

template<typename PixelT >
void lsst::afw::image::ImageBase< PixelT >::setXY0 ( lsst::geom::Point2I const  origin)
inlineinherited

Set the ImageBase's origin.

The origin is usually set by the constructor, so you shouldn't need this function

Note
There are use cases (e.g. memory overlays) that may want to set these values, but don't do so unless you are an Expert.

Definition at line 434 of file ImageBase.h.

434 { _origin = origin; }

◆ sqrt()

template<typename PixelT >
void lsst::afw::image::Image< PixelT >::sqrt
inherited

Definition at line 462 of file Image.cc.

462  {
463  transform_pixels(_getRawView(), _getRawView(),
464  [](PixelT const& l) -> PixelT { return static_cast<PixelT>(std::sqrt(l)); });
465 }
T sqrt(T... args)

◆ subset()

template<typename PixelT >
Image lsst::afw::image::Image< PixelT >::subset ( lsst::geom::Box2I const &  bbox,
ImageOrigin  origin = PARENT 
) const
inlineinherited

Return a subimage corresponding to the given box.

Parameters
bboxBounding box of the subimage returned.
originOrigin bbox is rleative to; PARENT accounts for xy0, LOCAL does not.
Returns
A subimage view into this.

This method is wrapped as getitem in Python.

Note
This method permits mutable views to be obtained from const references to images (just as the copy constructor does). This is an intrinsic flaw in Image's design.

Definition at line 226 of file Image.h.

226  {
227  return Image(*this, bbox, origin, false);
228  }
friend class Image
Definition: Image.h:72

◆ swap() [1/2]

template<typename PixelT >
void lsst::afw::image::Image< PixelT >::swap ( Image< PixelT > &  rhs)
inherited

Definition at line 449 of file Image.cc.

449  {
450  using std::swap; // See Meyers, Effective C++, Item 25
452  ; // no private variables to swap
453 }
void swap(ImageBase &rhs)
Definition: Image.cc:246
T swap(T... args)

◆ swap() [2/2]

template<typename PixelT >
void lsst::afw::image::ImageBase< PixelT >::swap ( ImageBase< PixelT > &  rhs)
inherited

Definition at line 246 of file Image.cc.

246  {
247  using std::swap; // See Meyers, Effective C++, Item 25
248 
249  swap(_manager, rhs._manager); // just swapping the pointers
250  swap(_gilView, rhs._gilView);
251  swap(_origin, rhs._origin);
252 }

◆ writeFits() [1/6]

template<typename PixelT >
void lsst::afw::image::Image< PixelT >::writeFits ( fits::Fits fitsfile,
fits::ImageWriteOptions const &  options,
std::shared_ptr< daf::base::PropertySet const >  header = nullptr,
std::shared_ptr< Mask< MaskPixel > const >  mask = nullptr 
) const
inherited

Write an image to an open FITS file object.

Parameters
[in]fitsfileA FITS file already open to the desired HDU.
[in]optionsOptions controlling writing of FITS image.
[in]headerAdditional values to write to the header (may be null).
[in]maskMask, for calculation of statistics.

◆ writeFits() [2/6]

template<typename PixelT >
void lsst::afw::image::Image< PixelT >::writeFits ( fits::Fits fitsfile,
std::shared_ptr< lsst::daf::base::PropertySet const >  metadata = std::shared_ptrlsst::daf::base::PropertySet const >() 
) const
inherited

Write an image to an open FITS file object.

Parameters
[in]fitsfileA FITS file already open to the desired HDU.
[in]metadataAdditional values to write to the header (may be null).

◆ writeFits() [3/6]

template<typename PixelT >
void lsst::afw::image::Image< PixelT >::writeFits ( fits::MemFileManager manager,
fits::ImageWriteOptions const &  options,
std::string const &  mode = "w",
std::shared_ptr< daf::base::PropertySet const >  header = nullptr,
std::shared_ptr< Mask< MaskPixel > const >  mask = nullptr 
) const
inherited

Write an image to a FITS RAM file.

Parameters
[in]managerManager object for the memory block to write to.
[in]optionsOptions controlling writing of FITS image.
[in]headerAdditional values to write to the header (may be null).
[in]mode"w"=Create a new file; "a"=Append a new HDU.
[in]maskMask, for calculation of statistics.

◆ writeFits() [4/6]

template<typename PixelT >
void lsst::afw::image::Image< PixelT >::writeFits ( fits::MemFileManager manager,
std::shared_ptr< lsst::daf::base::PropertySet const >  metadata = std::shared_ptrlsst::daf::base::PropertySet const >(),
std::string const &  mode = "w" 
) const
inherited

Write an image to a FITS RAM file.

Parameters
[in]managerManager object for the memory block to write to.
[in]metadataAdditional values to write to the header (may be null).
[in]mode"w"=Create a new file; "a"=Append a new HDU.

◆ writeFits() [5/6]

template<typename PixelT >
void lsst::afw::image::Image< PixelT >::writeFits ( std::string const &  filename,
fits::ImageWriteOptions const &  options,
std::string const &  mode = "w",
std::shared_ptr< daf::base::PropertySet const >  header = nullptr,
std::shared_ptr< Mask< MaskPixel > const >  mask = nullptr 
) const
inherited

Write an image to a regular FITS file.

Parameters
[in]filenameName of the file to write.
[in]optionsOptions controlling writing of FITS image.
[in]mode"w"=Create a new file; "a"=Append a new HDU.
[in]headerAdditional values to write to the header (may be null).
[in]maskMask, for calculation of statistics.

◆ writeFits() [6/6]

template<typename PixelT >
void lsst::afw::image::Image< PixelT >::writeFits ( std::string const &  fileName,
std::shared_ptr< lsst::daf::base::PropertySet const >  metadata = std::shared_ptrlsst::daf::base::PropertySet const >(),
std::string const &  mode = "w" 
) const
inherited

Write an image to a regular FITS file.

Parameters
[in]fileNameName of the file to write.
[in]metadataAdditional values to write to the header (may be null).
[in]mode"w"=Create a new file; "a"=Append a new HDU.

◆ x_at()

template<typename PixelT >
x_iterator lsst::afw::image::ImageBase< PixelT >::x_at ( int  x,
int  y 
) const
inlineinherited

Return an x_iterator to the point (x, y) in the image.

Definition at line 407 of file ImageBase.h.

407 { return _gilView.x_at(x, y); }

◆ xy_at()

template<typename PixelT >
xy_locator lsst::afw::image::ImageBase< PixelT >::xy_at ( int  x,
int  y 
) const
inlineinherited

Return an xy_locator at the point (x, y) in the image.

Locators may be used to access a patch in an image

Definition at line 425 of file ImageBase.h.

425 { return xy_locator(_gilView.xy_at(x, y)); }
_view_t::xy_locator xy_locator
An xy_locator.
Definition: ImageBase.h:121

◆ y_at()

template<typename PixelT >
y_iterator lsst::afw::image::ImageBase< PixelT >::y_at ( int  x,
int  y 
) const
inlineinherited

Return an y_iterator to the point (x, y) in the image.

Definition at line 419 of file ImageBase.h.

419 { return _gilView.y_at(x, y); }

Friends And Related Function Documentation

◆ badPixel()

template<typename ImageT >
ImageT::SinglePixel badPixel ( typename ImageT::Pixel  bad = 0)
related

Return a value indicating a bad pixel for the given Image type.

A quiet NaN is returned for types that support it otherwise bad

Parameters
badThe bad value if NaN isn't supported

Definition at line 60 of file Utils.h.

62  {
63  typedef typename ImageT::SinglePixel SinglePixelT;
66  : bad);
67 }

The documentation for this class was generated from the following files: