File Image.h

namespace lsst

Class for a simple mapping implementing a generic AstrometryTransform.

Remove all non-astronomical counts from the Chunk Exposure’s pixels.

Forward declarations for lsst::utils::Cache

For details on the Cache class, see the Cache.h file.

It uses a template rather than a pointer so that the derived classes can use the specifics of the transform. The class simplePolyMapping overloads a few routines.

A base class for image defects

Numeric constants used by the Integrate.h integrator routines.

Compute Image Statistics

Note

Gauss-Kronrod-Patterson quadrature coefficients for use in quadpack routine qng. These coefficients were calculated with 101 decimal digit arithmetic by L. W. Fullerton, Bell Labs, Nov 1981.

Note

The Statistics class itself can only handle lsst::afw::image::MaskedImage() types. The philosophy has been to handle other types by making them look like lsst::afw::image::MaskedImage() and reusing that code. Users should have no need to instantiate a Statistics object directly, but should use the overloaded makeStatistics() factory functions.

namespace afw
namespace image

Functions

template<typename LhsPixelT, typename RhsPixelT>
Image<LhsPixelT> &operator+=(Image<LhsPixelT> &lhs, Image<RhsPixelT> const &rhs)

Add lhs to Image rhs (i.e. pixel-by-pixel addition) where types are different.

template<typename LhsPixelT, typename RhsPixelT>
Image<LhsPixelT> &operator-=(Image<LhsPixelT> &lhs, Image<RhsPixelT> const &rhs)

Subtract lhs from Image rhs (i.e. pixel-by-pixel subtraction) where types are different.

template<typename LhsPixelT, typename RhsPixelT>
Image<LhsPixelT> &operator*=(Image<LhsPixelT> &lhs, Image<RhsPixelT> const &rhs)

Multiply lhs by Image rhs (i.e. pixel-by-pixel multiplication) where types are different.

template<typename LhsPixelT, typename RhsPixelT>
Image<LhsPixelT> &operator/=(Image<LhsPixelT> &lhs, Image<RhsPixelT> const &rhs)

Divide lhs by Image rhs (i.e. pixel-by-pixel division) where types are different.

template<typename PixelT>
void swap(Image<PixelT> &a, Image<PixelT> &b)
template<typename PixelT>
void swap(DecoratedImage<PixelT> &a, DecoratedImage<PixelT> &b)
lsst::geom::Box2I bboxFromMetadata(daf::base::PropertySet &metadata)

Determine the image bounding box from its metadata (FITS header)

Note that this modifies the metadata, stripping the WCS headers that provide the xy0.

template<typename T1, typename T2>
bool imagesOverlap(ImageBase<T1> const &image1, ImageBase<T2> const &image2)

Return true if the pixels for two images or masks overlap in memory.

template<typename PixelT>
class DecoratedImage
#include <Image.h>

A container for an Image and its associated metadata

Public Functions

DecoratedImage(const lsst::geom::Extent2I &dimensions = lsst::geom::Extent2I())

Create an image of the specified size

Parameters
  • dimensions: desired number of columns. rows

DecoratedImage(const lsst::geom::Box2I &bbox)

Create an image of the specified size

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

Parameters
  • bbox: (width, height) and origin of the desired Image

DecoratedImage(std::shared_ptr<Image<PixelT>> rhs)

Create a DecoratedImage wrapping rhs

Note that this ctor shares pixels with the rhs; it isn’t a deep copy

Parameters

DecoratedImage(DecoratedImage const &rhs, const bool deep = false)

Copy constructor

Note that the lhs will share memory with the rhs unless deep is true

Parameters
  • rhs: right hand side

  • deep: Make deep copy?

DecoratedImage(std::string const &fileName, const int hdu = fits::DEFAULT_HDU, lsst::geom::Box2I const &bbox = lsst::geom::Box2I(), ImageOrigin const origin = PARENT, bool allowUnsafe = false)

Create a DecoratedImage from a FITS file

Parameters
  • fileName: File to read

  • hdu: The HDU to read

  • bbox: Only read these pixels

  • origin: Coordinate system of the bbox

  • allowUnsafe: Permit reading into the requested pixel type even when on-disk values may overflow or truncate.

DecoratedImage &operator=(const DecoratedImage &image)

Assignment operator

N.b. this is a shallow assignment; use set(src) if you want to copy the pixels

std::shared_ptr<lsst::daf::base::PropertySet> getMetadata() const
void setMetadata(std::shared_ptr<lsst::daf::base::PropertySet> metadata)
int getWidth() const

Return the number of columns in the image.

int getHeight() const

Return the number of rows in the image.

int getX0() const

Return the image’s column-origin.

int getY0() const

Return the image’s row-origin.

const lsst::geom::Extent2I getDimensions() const

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

void swap(DecoratedImage &rhs)
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 a FITS file

Parameters
  • fileName: the file to write

  • metadata: metadata to write to header; or NULL

  • mode: “w” to write a new file; “a” to append

void writeFits(std::string const &fileName, fits::ImageWriteOptions const &options, std::shared_ptr<lsst::daf::base::PropertySet const> metadata = std::shared_ptr<lsst::daf::base::PropertySet const>(), std::string const &mode = "w") const

Write a FITS file

Parameters
  • [in] fileName: the file to write

  • [in] options: Options controlling writing of FITS image.

  • [in] metadata: metadata to write to header; or NULL

  • [in] mode: “w” to write a new file; “a” to append

std::shared_ptr<Image<PixelT>> getImage()

Return a shared_ptr to the DecoratedImage’s Image.

std::shared_ptr<Image<PixelT> const> getImage() const

Return a shared_ptr to the DecoratedImage’s Image as const.

double getGain() const

Return the DecoratedImage’s gain

Note

This is mostly just a place holder for other properties that we might want to associate with a DecoratedImage

void setGain(double gain)

Set the DecoratedImage’s gain.

Private Functions

void init()

Private Members

std::shared_ptr<Image<PixelT>> _image
std::shared_ptr<lsst::daf::base::PropertySet> _metadata
double _gain
template<typename PixelT>
class Image : public lsst::afw::image::ImageBase<PixelT>
#include <Image.h>

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

Subclassed by lsst::afw::image::ImageSlice< PixelT >

Public Types

typedef detail::Image_tag image_category

Public Functions

Image(unsigned int width, unsigned int height, PixelT initialValue = 0)

Create an initialised Image of the specified size

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

Parameters
  • width: number of columns

  • height: number of rows

  • initialValue: Initial value

Image(lsst::geom::Extent2I const &dimensions = lsst::geom::Extent2I(), PixelT initialValue = 0)

Create an initialised Image of the specified size

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

Parameters
  • dimensions: Number of columns, rows

  • initialValue: Initial value

Image(lsst::geom::Box2I const &bbox, PixelT initialValue = 0)

Create an initialized Image of the specified size

Parameters
  • bbox: dimensions and origin of desired Image

  • initialValue: Initial value

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.

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

Note

Unless deep is true, the new image will share the old image’s pixels; this is probably what you want

Parameters
  • rhs: Right-hand-side Image

  • bbox: Specify desired region

  • origin: Coordinate system of the bbox

  • deep: If false, new ImageBase shares storage with rhs; if true make a new, standalone, ImageBase

Image(const Image &rhs, const bool deep = false)

Copy constructor.

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

Parameters
  • rhs: Right-hand-side Image

  • deep: If false, new Image shares storage with rhs; if true make a new, standalone, ImageBase

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.

Parameters
  • [in] fileName: File to read.

  • [in] hdu: HDU 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.

  • [inout] metadata: Metadata read from the header (may be null).

  • [in] bbox: If non-empty, read only the pixels within the bounding box.

  • [in] origin: Coordinate system of the bounding box; if PARENT, the bounding box should take into account the xy0 saved with the image.

  • [in] allowUnsafe: Permit reading into the requested pixel type even when on-disk values may overflow or truncate.

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.

Parameters
  • [in] manager: An object that manages the memory buffer to read.

  • [in] hdu: HDU 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.

  • [inout] metadata: Metadata read from the header (may be null).

  • [in] bbox: If non-empty, read only the pixels within the bounding box.

  • [in] origin: Coordinate system of the bounding box; if PARENT, the bounding box should take into account the xy0 saved with the image.

  • [in] allowUnsafe: Permit reading into the requested pixel type even when on-disk values may overflow or truncate.

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.

Parameters
  • [in] fitsfile: A FITS object to read from, already at the desired HDU.

  • [inout] metadata: Metadata read from the header (may be null).

  • [in] bbox: If non-empty, read only the pixels within the bounding box.

  • [in] origin: Coordinate system of the bounding box; if PARENT, the bounding box should take into account the xy0 saved with the image.

  • [in] allowUnsafe: Permit reading into the requested pixel type even when on-disk values may overflow or truncate.

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()
Image &operator=(const PixelT rhs)

Set the image’s pixels to rhs.

Image &operator=(const Image &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)

Note

this behaviour is required to make the swig interface work, otherwise I’d declare this function private

Image &operator=(Image &&rhs)
Image subset(lsst::geom::Box2I const &bbox, ImageOrigin origin = PARENT) const

Return a subimage corresponding to the given box.

This method is wrapped as

getitem in Python.
Return

A subimage view into this.

Parameters
  • bbox: Bounding box of the subimage returned.

  • origin: Origin bbox is rleative to; PARENT accounts for xy0, LOCAL does not.

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.

Image operator[](lsst::geom::Box2I const &bbox) const

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

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.

Parameters
  • [in] fileName: Name of the file to write.

  • [in] metadata: Additional values to write to the header (may be null).

  • [in] mode: “w”=Create a new file; “a”=Append a new HDU.

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.

Parameters
  • [in] manager: Manager object for the memory block to write to.

  • [in] metadata: Additional values to write to the header (may be null).

  • [in] mode: “w”=Create a new file; “a”=Append a new HDU.

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.

Parameters
  • [in] fitsfile: A FITS file already open to the desired HDU.

  • [in] metadata: Additional values to write to the header (may be null).

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.

Parameters
  • [in] filename: Name of the file to write.

  • [in] options: Options controlling writing of FITS image.

  • [in] mode: “w”=Create a new file; “a”=Append a new HDU.

  • [in] header: Additional values to write to the header (may be null).

  • [in] mask: Mask, for calculation of statistics.

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.

Parameters
  • [in] manager: Manager object for the memory block to write to.

  • [in] options: Options controlling writing of FITS image.

  • [in] header: Additional values to write to the header (may be null).

  • [in] mode: “w”=Create a new file; “a”=Append a new HDU.

  • [in] mask: Mask, for calculation of statistics.

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.

Parameters
  • [in] fitsfile: A FITS file already open to the desired HDU.

  • [in] options: Options controlling writing of FITS image.

  • [in] header: Additional values to write to the header (may be null).

  • [in] mask: Mask, for calculation of statistics.

void swap(Image &rhs)
Image &operator+=(PixelT const rhs)

Add scalar rhs to lhs.

virtual Image &operator+=(Image<PixelT> const &rhs)

Add Image rhs to lhs.

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

Add a Function2(x, y) to an Image

Parameters
  • function: function to add

void scaledPlus(double const c, Image<PixelT> const &rhs)

Add Image c*rhs to lhs.

Image &operator-=(PixelT const rhs)

Subtract scalar rhs from lhs.

Image &operator-=(Image<PixelT> const &rhs)

Subtract Image rhs from lhs.

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

Subtract a Function2(x, y) from an Image

Parameters
  • function: function to add

void scaledMinus(double const c, Image<PixelT> const &rhs)

Subtract Image c*rhs from lhs.

Image &operator*=(PixelT const rhs)

Multiply lhs by scalar rhs.

Image &operator*=(Image<PixelT> const &rhs)

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

void scaledMultiplies(double const c, Image<PixelT> const &rhs)

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

Image &operator/=(PixelT const rhs)

Divide lhs by scalar rhs

Note

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

Image &operator/=(Image<PixelT> const &rhs)

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

void scaledDivides(double const c, Image<PixelT> const &rhs)

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

void sqrt()

Public Static Functions

static Image readFits(std::string const &filename, int hdu = fits::DEFAULT_HDU)

Read an Image from a regular FITS file.

Parameters
  • [in] filename: Name of the file to read.

  • [in] hdu: Number 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”.

static Image readFits(fits::MemFileManager &manager, int hdu = fits::DEFAULT_HDU)

Read an Image from a FITS RAM file.

Parameters
  • [in] manager: Object that manages the memory to be read.

  • [in] hdu: Number 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”.

Friends

friend lsst::afw::image::MaskedImage
friend lsst::afw::image::Image
template<typename ImagePT = PixelT>
struct ImageTypeFactory
#include <Image.h>

A templated class to return this classes’ type (present in Image/Mask/MaskedImage)

Public Types

template<>
typedef Image<ImagePT> type

Return the desired type.