LSSTApplications  19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
LSSTDataManagementBasePackage
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends | Related Functions | List of all members
lsst::afw::image::Image< PixelT > Class Template Reference

A class to represent a 2-dimensional array of pixels. More...

#include <Image.h>

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

Classes

struct  ImageTypeFactory
 A templated class to return this classes' type (present in Image/Mask/MaskedImage) More...
 

Public Types

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

 Image (unsigned int width, unsigned int height, PixelT initialValue=0)
 Create an initialised Image of the specified size. More...
 
 Image (lsst::geom::Extent2I const &dimensions=lsst::geom::Extent2I(), PixelT initialValue=0)
 Create an initialised Image of the specified size. More...
 
 Image (lsst::geom::Box2I const &bbox, PixelT initialValue=0)
 Create an initialized Image of the specified size. More...
 
 Image (Image const &rhs, lsst::geom::Box2I const &bbox, ImageOrigin const origin=PARENT, const bool deep=false)
 Copy constructor to make a copy of part of an Image. More...
 
 Image (const Image &rhs, const bool deep=false)
 Copy constructor. More...
 
 Image (Image &&rhs)
 
 Image (std::string const &fileName, int hdu=fits::DEFAULT_HDU, std::shared_ptr< lsst::daf::base::PropertySet > metadata=std::shared_ptr< lsst::daf::base::PropertySet >(), lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
 Construct an Image by reading a regular FITS file. More...
 
 Image (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU, std::shared_ptr< lsst::daf::base::PropertySet > metadata=std::shared_ptr< lsst::daf::base::PropertySet >(), lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
 Construct an Image by reading a FITS image in memory. More...
 
 Image (fits::Fits &fitsfile, std::shared_ptr< lsst::daf::base::PropertySet > metadata=std::shared_ptr< lsst::daf::base::PropertySet >(), lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
 Construct an Image from an already-open FITS object. More...
 
template<typename OtherPixelT >
 Image (Image< OtherPixelT > const &rhs, const bool deep)
 
 Image (ndarray::Array< PixelT, 2, 1 > const &array, bool deep=false, lsst::geom::Point2I const &xy0=lsst::geom::Point2I())
 
 ~Image () override=default
 
Imageoperator= (const PixelT rhs)
 Set the image's pixels to rhs. More...
 
Imageoperator= (const Image &rhs)
 Assignment operator. More...
 
Imageoperator= (Image &&rhs)
 
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...
 
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)
 
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...
 
void scaledDivides (double const c, Image< PixelT > const &rhs)
 Divide lhs by Image c*rhs (i.e. pixel-by-pixel division) More...
 
void sqrt ()
 
Image< double > & operator/= (double const rhs)
 
Image< float > & operator/= (float const rhs)
 
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...
 
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...
 
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 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...
 
void swap (ImageBase &rhs)
 
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)
 

Friends

template<typename , typename , typename >
class MaskedImage
 
template<typename OtherPixelT >
class Image
 

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::Image< PixelT >

A class to represent a 2-dimensional array of pixels.

Examples
forEachPixel.cc, image1.cc, and image2.cc.

Definition at line 58 of file Image.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

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.

Constructor & Destructor Documentation

◆ Image() [1/11]

template<typename PixelT >
lsst::afw::image::Image< PixelT >::Image ( unsigned int  width,
unsigned int  height,
PixelT  initialValue = 0 
)
explicit

Create an initialised Image of the specified size.

Parameters
widthnumber of columns
heightnumber of rows
initialValueInitial value
Note
Many lsst::afw::image and lsst::afw::math objects define a dimensions member which may be conveniently used to make objects of an appropriate size

Definition at line 316 of file Image.cc.

317  : ImageBase<PixelT>(lsst::geom::ExtentI(width, height)) {
318  *this = initialValue;
319 }

◆ Image() [2/11]

template<typename PixelT >
lsst::afw::image::Image< PixelT >::Image ( lsst::geom::Extent2I const &  dimensions = lsst::geom::Extent2I(),
PixelT  initialValue = 0 
)
explicit

Create an initialised Image of the specified size.

Parameters
dimensionsNumber of columns, rows
initialValueInitial value
Note
Many lsst::afw::image and lsst::afw::math objects define a dimensions member which may be conveniently used to make objects of an appropriate size

Definition at line 322 of file Image.cc.

323  : ImageBase<PixelT>(dimensions) {
324  *this = initialValue;
325 }

◆ Image() [3/11]

template<typename PixelT >
lsst::afw::image::Image< PixelT >::Image ( lsst::geom::Box2I const &  bbox,
PixelT  initialValue = 0 
)
explicit

Create an initialized Image of the specified size.

Parameters
bboxdimensions and origin of desired Image
initialValueInitial value

Definition at line 328 of file Image.cc.

328  : ImageBase<PixelT>(bbox) {
329  *this = initialValue;
330 }

◆ Image() [4/11]

template<typename PixelT >
lsst::afw::image::Image< PixelT >::Image ( Image< PixelT > const &  rhs,
lsst::geom::Box2I const &  bbox,
ImageOrigin const  origin = PARENT,
const bool  deep = false 
)
explicit

Copy constructor to make a copy of part of an Image.

The bbox ignores X0/Y0 if origin == LOCAL, and uses it if origin == PARENT.

Parameters
rhsRight-hand-side Image
bboxSpecify desired region
originCoordinate system of the bbox
deepIf false, new ImageBase shares storage with rhs; if true make a new, standalone, ImageBase
Note
Unless deep is true, the new image will share the old image's pixels; this is probably what you want

Definition at line 339 of file Image.cc.

341  : ImageBase<PixelT>(rhs, bbox, origin, deep) {}

◆ Image() [5/11]

template<typename PixelT >
lsst::afw::image::Image< PixelT >::Image ( const Image< PixelT > &  rhs,
const bool  deep = false 
)

Copy constructor.

Parameters
rhsRight-hand-side Image
deepIf false, new Image shares storage with rhs; if true make a new, standalone, ImageBase
Note
Unless deep is true, the new image will share the old image's pixels; this may not be what you want. See also assign(rhs) to copy pixels between Images

Definition at line 333 of file Image.cc.

333 : ImageBase<PixelT>(rhs, deep) {}

◆ Image() [6/11]

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

Definition at line 336 of file Image.cc.

336 : Image(rhs, false) {}

◆ Image() [7/11]

template<typename PixelT >
lsst::afw::image::Image< PixelT >::Image ( std::string const &  fileName,
int  hdu = fits::DEFAULT_HDU,
std::shared_ptr< lsst::daf::base::PropertySet metadata = std::shared_ptrlsst::daf::base::PropertySet >(),
lsst::geom::Box2I const &  bbox = lsst::geom::Box2I(),
ImageOrigin  origin = PARENT,
bool  allowUnsafe = false 
)
explicit

Construct an Image by reading a regular FITS file.

Parameters
[in]fileNameFile to read.
[in]hduHDU to read, 0-indexed (i.e. 0=Primary HDU). The special value of afw::fits::DEFAULT_HDU reads the Primary HDU unless it is empty, in which case it reads the first extension HDU.
[in,out]metadataMetadata read from the header (may be null).
[in]bboxIf non-empty, read only the pixels within the bounding box.
[in]originCoordinate system of the bounding box; if PARENT, the bounding box should take into account the xy0 saved with the image.
[in]allowUnsafePermit reading into the requested pixel type even when on-disk values may overflow or truncate.

◆ Image() [8/11]

template<typename PixelT >
lsst::afw::image::Image< PixelT >::Image ( fits::MemFileManager manager,
int  hdu = fits::DEFAULT_HDU,
std::shared_ptr< lsst::daf::base::PropertySet metadata = std::shared_ptrlsst::daf::base::PropertySet >(),
lsst::geom::Box2I const &  bbox = lsst::geom::Box2I(),
ImageOrigin  origin = PARENT,
bool  allowUnsafe = false 
)
explicit

Construct an Image by reading a FITS image in memory.

Parameters
[in]managerAn object that manages the memory buffer to read.
[in]hduHDU to read, 0-indexed (i.e. 0=Primary HDU). The special value of afw::fits::DEFAULT_HDU reads the Primary HDU unless it is empty, in which case it reads the first extension HDU.
[in,out]metadataMetadata read from the header (may be null).
[in]bboxIf non-empty, read only the pixels within the bounding box.
[in]originCoordinate system of the bounding box; if PARENT, the bounding box should take into account the xy0 saved with the image.
[in]allowUnsafePermit reading into the requested pixel type even when on-disk values may overflow or truncate.

◆ Image() [9/11]

template<typename PixelT >
lsst::afw::image::Image< PixelT >::Image ( fits::Fits fitsfile,
std::shared_ptr< lsst::daf::base::PropertySet metadata = std::shared_ptrlsst::daf::base::PropertySet >(),
lsst::geom::Box2I const &  bbox = lsst::geom::Box2I(),
ImageOrigin  origin = PARENT,
bool  allowUnsafe = false 
)
explicit

Construct an Image from an already-open FITS object.

Parameters
[in]fitsfileA FITS object to read from, already at the desired HDU.
[in,out]metadataMetadata read from the header (may be null).
[in]bboxIf non-empty, read only the pixels within the bounding box.
[in]originCoordinate system of the bounding box; if PARENT, the bounding box should take into account the xy0 saved with the image.
[in]allowUnsafePermit reading into the requested pixel type even when on-disk values may overflow or truncate.

◆ Image() [10/11]

template<typename PixelT >
template<typename OtherPixelT >
lsst::afw::image::Image< PixelT >::Image ( Image< OtherPixelT > const &  rhs,
const bool  deep 
)
inline

Definition at line 189 of file Image.h.

189 : image::ImageBase<PixelT>(rhs, deep) {}

◆ Image() [11/11]

template<typename PixelT >
lsst::afw::image::Image< PixelT >::Image ( ndarray::Array< PixelT, 2, 1 > const &  array,
bool  deep = false,
lsst::geom::Point2I const &  xy0 = lsst::geom::Point2I() 
)
inlineexplicit

Definition at line 191 of file Image.h.

193  : image::ImageBase<PixelT>(array, deep, xy0) {}

◆ ~Image()

template<typename PixelT >
lsst::afw::image::Image< PixelT >::~Image ( )
overridedefault

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 }

◆ _getRawView()

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

Definition at line 463 of file ImageBase.h.

463 { 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  return boost::gil::subimage_view(view, offset.getX(), offset.getY(), dimensions.getX(),
92  dimensions.getY());
93 }

◆ 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 160 of file Image.cc.

160  {
161  auto lhsDim = bbox.isEmpty() ? getDimensions() : bbox.getDimensions();
162  if (lhsDim != rhs.getDimensions()) {
163  throw LSST_EXCEPT(pex::exceptions::LengthError,
164  (boost::format("Dimension mismatch: %dx%d v. %dx%d") % lhsDim.getX() %
165  lhsDim.getY() % rhs.getWidth() % rhs.getHeight())
166  .str());
167  }
168  if (bbox.isEmpty()) {
169  copy_pixels(rhs._gilView, _gilView);
170  } else {
171  auto lhsOff = (origin == PARENT) ? bbox.getMin() - _origin : lsst::geom::Extent2I(bbox.getMin());
172  auto lhsGilView = _makeSubView(lhsDim, lhsOff, _gilView);
173  copy_pixels(rhs._gilView, lhsGilView);
174  }
175 }

◆ 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 277 of file Image.cc.

277  {
278  return _gilView.at(x, y);
279 }

◆ 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 imageIterators for a discussion

Definition at line 257 of file Image.cc.

257  {
258  return _gilView.begin();
259 }

◆ 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 282 of file Image.cc.

282  {
283  if (!contiguous) {
284  throw LSST_EXCEPT(pex::exceptions::RuntimeError, "Only contiguous == true makes sense");
285  }
286  if (!this->isContiguous()) {
287  throw LSST_EXCEPT(pex::exceptions::RuntimeError, "Image's pixels are not contiguous");
288  }
289 
290  return row_begin(0);
291 }

◆ 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 411 of file ImageBase.h.

411 { 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 414 of file ImageBase.h.

414 { 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 262 of file Image.cc.

262  {
263  return _gilView.end();
264 }

◆ 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 294 of file Image.cc.

294  {
295  if (!contiguous) {
296  throw LSST_EXCEPT(pex::exceptions::RuntimeError, "Only contiguous == true makes sense");
297  }
298  if (!this->isContiguous()) {
299  throw LSST_EXCEPT(pex::exceptions::RuntimeError, "Image's pixels are not contiguous");
300  }
301 
302  return row_end(getHeight() - 1);
303 }

◆ 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 216 of file Image.cc.

217  {
218  int x = index.getX();
219  int y = index.getY();
220  if (origin == PARENT) {
221  x -= getX0();
222  y -= getY0();
223  }
224  return _gilView(x, y)[0];
225 }

◆ 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 228 of file Image.cc.

229  {
230  int x = index.getX();
231  int y = index.getY();
232  if (origin == PARENT) {
233  x -= getX0();
234  y -= getY0();
235  }
236  return _gilView(x, y)[0];
237 }

◆ getArray() [1/2]

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

Definition at line 474 of file ImageBase.h.

474  {
475  int rowStride = reinterpret_cast<PixelT*>(row_begin(1)) - reinterpret_cast<PixelT*>(row_begin(0));
476  return ndarray::external(reinterpret_cast<PixelT*>(row_begin(0)),
477  ndarray::makeVector(getHeight(), getWidth()), ndarray::makeVector(rowStride, 1),
478  this->_manager);
479 }

◆ getArray() [2/2]

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

Definition at line 482 of file ImageBase.h.

482  {
483  int rowStride = reinterpret_cast<PixelT*>(row_begin(1)) - reinterpret_cast<PixelT*>(row_begin(0));
484  return ndarray::external(reinterpret_cast<PixelT*>(row_begin(0)),
485  ndarray::makeVector(getHeight(), getWidth()), ndarray::makeVector(rowStride, 1),
486  this->_manager);
487 }

◆ getBBox()

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

Definition at line 443 of file ImageBase.h.

443  {
444  if (origin == PARENT) {
445  return lsst::geom::Box2I(_origin, getDimensions());
446  } else
448  }

◆ 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 354 of file ImageBase.h.

354 { 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(); }

◆ 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 304 of file ImageBase.h.

304 { 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 321 of file ImageBase.h.

321 { 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 312 of file ImageBase.h.

312 { 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 347 of file ImageBase.h.

349  {
350  return ind + PixelZeroPos + (xy == X ? getX0() : getY0());
351  }

◆ isContiguous()

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

Definition at line 465 of file ImageBase.h.

465 { return begin() + getWidth() * getHeight() == end(); }

◆ 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 178 of file Image.cc.

178  {
179  return const_cast<typename ImageBase<PixelT>::PixelReference>(
180  static_cast<typename ImageBase<PixelT>::PixelConstReference>(_gilView(x, y)[0]));
181 }

◆ 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 198 of file Image.cc.

198  {
199  return _gilView(x, y)[0];
200 }

◆ 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 184 of file Image.cc.

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

◆ 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 203 of file Image.cc.

204  {
205  if (check && (x < 0 || x >= getWidth() || y < 0 || y >= getHeight())) {
206  throw LSST_EXCEPT(pex::exceptions::LengthError,
207  (boost::format("Index (%d, %d) is out of range [0--%d], [0--%d]") % x % y %
208  (this->getWidth() - 1) % (this->getHeight() - 1))
209  .str());
210  }
211 
212  return _gilView(x, y)[0];
213 }

◆ operator*=() [1/2]

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

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

Definition at line 558 of file Image.cc.

558  {
559  if (this->getDimensions() != rhs.getDimensions()) {
560  throw LSST_EXCEPT(pex::exceptions::LengthError,
561  (boost::format("Images are of different size, %dx%d v %dx%d") % this->getWidth() %
562  this->getHeight() % rhs.getWidth() % rhs.getHeight())
563  .str());
564  }
565  transform_pixels(_getRawView(), rhs._getRawView(), _getRawView(),
566  [](PixelT const& l, PixelT const& r) -> PixelT { return l * r; });
567  return *this;
568 }

◆ operator*=() [2/2]

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

Multiply lhs by scalar rhs.

Definition at line 552 of file Image.cc.

552  {
553  transform_pixels(_getRawView(), _getRawView(), [&rhs](PixelT const& l) -> PixelT { return l * rhs; });
554  return *this;
555 }

◆ operator+=() [1/3]

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

Add Image rhs to lhs.

Definition at line 468 of file Image.cc.

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

◆ operator+=() [2/3]

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

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

Parameters
functionfunction to add

Definition at line 481 of file Image.cc.

481  {
482  for (int y = 0; y != this->getHeight(); ++y) {
483  double const yPos = this->indexToPosition(y, Y);
484  double xPos = this->indexToPosition(0, X);
485  for (typename Image<PixelT>::x_iterator ptr = this->row_begin(y), end = this->row_end(y); ptr != end;
486  ++ptr, ++xPos) {
487  *ptr += function(xPos, yPos);
488  }
489  }
490  return *this;
491 }

◆ operator+=() [3/3]

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

Add scalar rhs to lhs.

Definition at line 462 of file Image.cc.

462  {
463  transform_pixels(_getRawView(), _getRawView(), [&rhs](PixelT const& l) -> PixelT { return l + rhs; });
464  return *this;
465 }

◆ operator-=() [1/3]

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

Subtract Image rhs from lhs.

Definition at line 513 of file Image.cc.

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

◆ operator-=() [2/3]

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

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

Parameters
functionfunction to add

Definition at line 539 of file Image.cc.

539  {
540  for (int y = 0; y != this->getHeight(); ++y) {
541  double const yPos = this->indexToPosition(y, Y);
542  double xPos = this->indexToPosition(0, X);
543  for (typename Image<PixelT>::x_iterator ptr = this->row_begin(y), end = this->row_end(y); ptr != end;
544  ++ptr, ++xPos) {
545  *ptr -= function(xPos, yPos);
546  }
547  }
548  return *this;
549 }

◆ operator-=() [3/3]

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

Subtract scalar rhs from lhs.

Definition at line 507 of file Image.cc.

507  {
508  transform_pixels(_getRawView(), _getRawView(), [&rhs](PixelT const& l) -> PixelT { return l - rhs; });
509  return *this;
510 }

◆ operator/=() [1/4]

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

Definition at line 592 of file Image.cc.

592  {
593  double const irhs = 1 / rhs;
594  *this *= irhs;
595  return *this;
596 }

◆ operator/=() [2/4]

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

Definition at line 599 of file Image.cc.

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

◆ operator/=() [3/4]

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

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

Definition at line 606 of file Image.cc.

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

◆ operator/=() [4/4]

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

Divide lhs by scalar rhs.

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

Definition at line 584 of file Image.cc.

584  {
585  transform_pixels(_getRawView(), _getRawView(), [&rhs](PixelT const& l) -> PixelT { return l / rhs; });
586  return *this;
587 }

◆ operator=() [1/3]

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

Assignment operator.

Note
that this has the effect of making the lhs share pixels with the rhs which may not be what you intended; to copy the pixels, use assign(rhs)
this behaviour is required to make the swig interface work, otherwise I'd declare this function private

Definition at line 351 of file Image.cc.

351  {
352  this->ImageBase<PixelT>::operator=(rhs);
353 
354  return *this;
355 }

◆ operator=() [2/3]

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

Set the image's pixels to rhs.

Definition at line 344 of file Image.cc.

344  {
345  this->ImageBase<PixelT>::operator=(rhs);
346 
347  return *this;
348 }

◆ operator=() [3/3]

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

Definition at line 358 of file Image.cc.

358  {
359  return *this = rhs;
360 }

◆ operator[]() [1/3]

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

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

Definition at line 231 of file Image.h.

231 { return subset(bbox); }

◆ 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); }

◆ 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  }

◆ 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 328 of file ImageBase.h.

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

◆ 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 267 of file Image.cc.

267  {
268  return _gilView.rbegin();
269 }

◆ readFits() [1/2]

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

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 
)
inlinestatic

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 272 of file Image.cc.

272  {
273  return _gilView.rend();
274 }

◆ 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 399 of file ImageBase.h.

399 { 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 402 of file ImageBase.h.

402 { return _gilView.row_end(y); }

◆ scaledDivides()

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

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

Definition at line 619 of file Image.cc.

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

◆ scaledMinus()

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

Subtract Image c*rhs from lhs.

Definition at line 526 of file Image.cc.

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

◆ scaledMultiplies()

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

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

Definition at line 571 of file Image.cc.

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

◆ scaledPlus()

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

Add Image c*rhs to lhs.

Definition at line 494 of file Image.cc.

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

◆ 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 441 of file ImageBase.h.

441 { setXY0(lsst::geom::Point2I(x0, y0)); }

◆ 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 432 of file ImageBase.h.

432 { _origin = origin; }

◆ sqrt()

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

Definition at line 456 of file Image.cc.

456  {
457  transform_pixels(_getRawView(), _getRawView(),
458  [](PixelT const& l) -> PixelT { return static_cast<PixelT>(std::sqrt(l)); });
459 }

◆ subset()

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

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  }

◆ swap() [1/2]

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

Definition at line 443 of file Image.cc.

443  {
444  using std::swap; // See Meyers, Effective C++, Item 25
446  ; // no private variables to swap
447 }

◆ swap() [2/2]

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

Definition at line 240 of file Image.cc.

240  {
241  using std::swap; // See Meyers, Effective C++, Item 25
242 
243  swap(_manager, rhs._manager); // just swapping the pointers
244  swap(_gilView, rhs._gilView);
245  swap(_origin, rhs._origin);
246 }

◆ 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

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

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

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

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

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

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 405 of file ImageBase.h.

405 { 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 423 of file ImageBase.h.

423 { return xy_locator(_gilView.xy_at(x, y)); }

◆ 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 417 of file ImageBase.h.

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

Friends And Related Function Documentation

◆ Image

template<typename PixelT >
template<typename OtherPixelT >
friend class Image
friend

Definition at line 72 of file Image.h.

◆ 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 }

◆ MaskedImage

template<typename PixelT >
template<typename , typename , typename >
friend class MaskedImage
friend

Definition at line 61 of file Image.h.


The documentation for this class was generated from the following files:
y
int y
Definition: SpanSet.cc:49
std::pair
lsst::afw::image::ImageBase::isContiguous
bool isContiguous() const
Definition: ImageBase.h:465
lsst::afw::image::PixelZeroPos
const double PixelZeroPos
position of center of pixel 0
Definition: ImageUtils.h:44
lsst::afw::image::ImageBase::end
iterator end() const
Return an STL compliant iterator to the end of the image.
Definition: Image.cc:262
lsst::afw::image::ImageBase::row_begin
x_iterator row_begin(int y) const
Return an x_iterator to the start of the y'th row.
Definition: ImageBase.h:399
lsst::ip::diffim::detail::PixelT
float PixelT
Definition: AssessSpatialKernelVisitor.cc:208
lsst::afw::image::ImageBase::_getRawView
_view_t _getRawView() const
Definition: ImageBase.h:463
lsst::afw::image::ImageBase::indexToPosition
double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const
Convert image index to image position.
Definition: ImageBase.h:347
lsst::afw::image::ImageBase::xy_locator
_view_t::xy_locator xy_locator
An xy_locator.
Definition: ImageBase.h:121
lsst.pex.config.history.format
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174
lsst::afw::image::ImageBase::operator=
ImageBase & operator=(const ImageBase &rhs)
Shallow assignment operator.
Definition: Image.cc:147
lsst::afw::image::X
@ X
Definition: ImageUtils.h:36
lsst::afw::image::ImageBase::getHeight
int getHeight() const
Return the number of rows in the image.
Definition: ImageBase.h:296
std::sqrt
T sqrt(T... args)
lsst::afw::image::ImageBase::begin
iterator begin() const
Return an STL compliant iterator to the start of the image.
Definition: Image.cc:257
lsst::afw::image::ImageBase::PixelReference
Reference< PixelT >::type PixelReference
A Reference to a PixelT.
Definition: ImageBase.h:117
lsst::afw::image::ImageBase::row_end
x_iterator row_end(int y) const
Return an x_iterator to the end of the y'th row.
Definition: ImageBase.h:402
x
double x
Definition: ChebyshevBoundedField.cc:277
lsst::afw::image::Image::Image
friend class Image
Definition: Image.h:72
lsst::afw::image::ImageBase::_makeSubView
static _view_t _makeSubView(lsst::geom::Extent2I const &dimensions, lsst::geom::Extent2I const &offset, const _view_t &view)
Definition: Image.cc:78
lsst::afw::image::Y
@ Y
Definition: ImageUtils.h:36
ptr
uint64_t * ptr
Definition: RangeSet.cc:88
dimensions
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:49
lsst::afw::image::ImageBase::x_iterator
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
Definition: ImageBase.h:133
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
std::swap
T swap(T... args)
lsst::afw::image::ImageBase::getX0
int getX0() const
Return the image's column-origin.
Definition: ImageBase.h:304
lsst::afw::image::ImageBase::SinglePixel
PixelT SinglePixel
A single Pixel of the same type as those in the ImageBase.
Definition: ImageBase.h:113
lsst::afw::image::ImageBase::getDimensions
lsst::geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
Definition: ImageBase.h:354
lsst::geom::Extent2I
Extent< int, 2 > Extent2I
Definition: Extent.h:397
lsst::geom::Point< int, 2 >
lsst::afw::image::Image::subset
Image subset(lsst::geom::Box2I const &bbox, ImageOrigin origin=PARENT) const
Return a subimage corresponding to the given box.
Definition: Image.h:226
lsst::geom::Box2I
An integer coordinate rectangle.
Definition: Box.h:55
lsst::afw::image::PARENT
@ PARENT
Definition: ImageBase.h:94
lsst::afw::image::ImageBase::setXY0
void setXY0(lsst::geom::Point2I const origin)
Set the ImageBase's origin.
Definition: ImageBase.h:432
lsst::afw::image::ImageBase::getY0
int getY0() const
Return the image's row-origin.
Definition: ImageBase.h:312
lsst::afw::image::ImageBase::swap
void swap(ImageBase &rhs)
Definition: Image.cc:240
lsst::afw::image::ImageBase::PixelConstReference
ConstReference< PixelT >::type PixelConstReference
A ConstReference to a PixelT.
Definition: ImageBase.h:119
lsst::afw::image::ImageBase
The base class for all image classed (Image, Mask, MaskedImage, ...)
Definition: ImageBase.h:102
lsst::geom::Extent< int, 2 >
std::numeric_limits
lsst::afw::image::ImageBase::get
PixelReference get(lsst::geom::Point2I const &index, ImageOrigin origin)
Return a reference to a single pixel (with no bounds check).
Definition: Image.cc:216
lsst::afw::image::ImageBase::getWidth
int getWidth() const
Return the number of columns in the image.
Definition: ImageBase.h:294
bbox
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117