Template Class Image

Nested Relationships

Inheritance Relationships

Base Type

Derived Type

Class Documentation

template<typename PixelT>
class Image : public lsst::afw::image::ImageBase<PixelT>

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::Image::MaskedImage
friend lsst::afw::image::Image::Image

Related

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

Parameters
  • bad: The bad value if NaN isn’t supported

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

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

template<typename ImagePT = PixelT>
struct ImageTypeFactory

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

Public Types

template<>
typedef Image<ImagePT> type

Return the desired type.