File MaskedImage.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 ImagePixelT, typename MaskPixelT, typename VariancePixelT>
MaskedImage<ImagePixelT, MaskPixelT, VariancePixelT> *makeMaskedImage(typename std::shared_ptr<Image<ImagePixelT>> image, typename std::shared_ptr<Mask<MaskPixelT>> mask = Mask<MaskPixelT>(), typename std::shared_ptr<Image<VariancePixelT>> variance = Image<VariancePixelT>())

Parameters
  • image: image

  • mask: mask

  • variance: variance

A function to return a MaskedImage of the correct type (cf. std::make_pair)

template<typename ImagePixelT1, typename ImagePixelT2>
bool imagesOverlap(MaskedImage<ImagePixelT1, MaskPixel, VariancePixel> const &image1, MaskedImage<ImagePixelT2, MaskPixel, VariancePixel> const &image2)

Return true if the pixels for two masked images (image, variance or mask plane) overlap in memory.

template<typename ImagePixelT, typename MaskPixelT = lsst::afw::image::MaskPixel, typename VariancePixelT = lsst::afw::image::VariancePixel>
class MaskedImage
#include <MaskedImage.h>

A class to manipulate images, masks, and variance as a single object.

Public Types

typedef std::shared_ptr<image::Image<ImagePixelT>> ImagePtr

shared pointer to the Image

typedef std::shared_ptr<image::Mask<MaskPixelT>> MaskPtr

shared pointer to the Mask

typedef std::shared_ptr<image::Image<VariancePixelT>> VariancePtr

shared pointer to the variance Image

typedef Mask<MaskPixelT>::MaskPlaneDict MaskPlaneDict

The Mask’s MaskPlaneDict.

typedef lsst::afw::image::Image<VariancePixelT> Variance
typedef lsst::afw::image::Image<ImagePixelT> Image
typedef lsst::afw::image::Mask<MaskPixelT> Mask
typedef detail::MaskedImage_tag image_category
typedef lsst::afw::image::pixel::Pixel<ImagePixelT, MaskPixelT, VariancePixelT> Pixel

A Pixel in the MaskedImage.

typedef lsst::afw::image::pixel::SinglePixel<ImagePixelT, MaskPixelT, VariancePixelT> SinglePixel

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

typedef MaskedImageIterator<typename Image::iterator, typename Mask::iterator, typename Variance::iterator> iterator
typedef const_MaskedImageIterator<typename Image::iterator, typename Mask::iterator, typename Variance::iterator> const_iterator
typedef MaskedImageIterator<typename Image::reverse_iterator, typename Mask::reverse_iterator, typename Variance::reverse_iterator> reverse_iterator
typedef MaskedImageIterator<typename Image::x_iterator, typename Mask::x_iterator, typename Variance::x_iterator> x_iterator

An iterator to a row of a MaskedImage.

typedef const_MaskedImageIterator<typename Image::x_iterator, typename Mask::x_iterator, typename Variance::x_iterator> const_x_iterator

A const_iterator to a row of a MaskedImage.

typedef x_iterator fast_iterator

A fast STL compliant iterator for contiguous images N.b. The order of pixel access is undefined

typedef MaskedImageIterator<typename Image::y_iterator, typename Mask::y_iterator, typename Variance::y_iterator> y_iterator

An iterator to a column of a MaskedImage.

typedef const_MaskedImageIterator<typename Image::y_iterator, typename Mask::y_iterator, typename Variance::y_iterator> const_y_iterator

A const_iterator to a column of a MaskedImage.

typedef MaskedImageLocator<typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator> xy_locator

A locator for a MaskedImage.

typedef const_MaskedImageLocator<typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator> const_xy_locator

A const_locator for a MaskedImage.

typedef MaskedImageLocator<typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator>::x_iterator xy_x_iterator

an x_iterator associated with an xy_locator

typedef MaskedImageLocator<typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator>::y_iterator xy_y_iterator

an y_iterator associated with an xy_locator

Public Functions

MaskedImage(unsigned int width, unsigned int height, MaskPlaneDict const &planeDict = MaskPlaneDict())

Construct from a supplied dimensions. The Image, Mask, and Variance will be set to zero

Parameters
  • width: number of columns

  • height: number of rows

  • planeDict: Make Mask conform to this mask layout (ignore if empty)

MaskedImage(lsst::geom::Extent2I const &dimensions = lsst::geom::Extent2I(), MaskPlaneDict const &planeDict = MaskPlaneDict())

Construct from a supplied dimensions. The Image, Mask, and Variance will be set to zero

Parameters
  • dimensions: Number of columns, rows in image

  • planeDict: Make Mask conform to this mask layout (ignore if empty)

MaskedImage(ImagePtr image, MaskPtr mask = MaskPtr(), VariancePtr variance = VariancePtr())

Construct from a supplied Image and optional Mask and Variance. The Mask and Variance will be set to zero if omitted

Parameters
  • image: Image

  • mask: Mask

  • variance: Variance Mask

MaskedImage(lsst::geom::Box2I const &bbox, MaskPlaneDict const &planeDict = MaskPlaneDict())

Create an MaskedImage of the specified size

The Image, Mask, and Variance will be set to zero

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: dimensions of image: width x height

  • planeDict: Make Mask conform to this mask layout (ignore if empty)

MaskedImage(std::string const &fileName, std::shared_ptr<daf::base::PropertySet> metadata = std::shared_ptr<daf::base::PropertySet>(), lsst::geom::Box2I const &bbox = lsst::geom::Box2I(), ImageOrigin origin = PARENT, bool conformMasks = false, bool needAllHdus = false, std::shared_ptr<daf::base::PropertySet> imageMetadata = std::shared_ptr<daf::base::PropertySet>(), std::shared_ptr<daf::base::PropertySet> maskMetadata = std::shared_ptr<daf::base::PropertySet>(), std::shared_ptr<daf::base::PropertySet> varianceMetadata = std::shared_ptr<daf::base::PropertySet>(), bool allowUnsafe = false)

Construct a MaskedImage by reading a regular FITS file.

Parameters
  • [in] fileName: File to read.

  • [inout] metadata: Metadata read from the primary HDU header.

  • [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] conformMasks: If true, make Mask conform to the mask layout in the file.

  • [in] needAllHdus: If true, throw fits::FitsError if the mask and/or variance plane is missing. If false, silently initialize them to zero.

  • [inout] imageMetadata: Metadata read from the image HDU header.

  • [inout] maskMetadata: Metadata read from the mask HDU header.

  • [inout] varianceMetadata: Metadata read from the variance HDU header.

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

MaskedImage(fits::MemFileManager &manager, std::shared_ptr<daf::base::PropertySet> metadata = std::shared_ptr<daf::base::PropertySet>(), lsst::geom::Box2I const &bbox = lsst::geom::Box2I(), ImageOrigin origin = PARENT, bool conformMasks = false, bool needAllHdus = false, std::shared_ptr<daf::base::PropertySet> imageMetadata = std::shared_ptr<daf::base::PropertySet>(), std::shared_ptr<daf::base::PropertySet> maskMetadata = std::shared_ptr<daf::base::PropertySet>(), std::shared_ptr<daf::base::PropertySet> varianceMetadata = std::shared_ptr<daf::base::PropertySet>(), bool allowUnsafe = false)

Construct a MaskedImage by reading a FITS image in memory.

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

  • [inout] metadata: Metadata read from the primary HDU header.

  • [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] conformMasks: If true, make Mask conform to the mask layout in the file.

  • [in] needAllHdus: If true, throw fits::FitsError if the mask and/or variance plane is missing. If false, silently initialize them to zero.

  • [inout] imageMetadata: Metadata read from the image HDU header.

  • [inout] maskMetadata: Metadata read from the mask HDU header.

  • [inout] varianceMetadata: Metadata read from the variance HDU header.

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

MaskedImage(fits::Fits &fitsfile, std::shared_ptr<daf::base::PropertySet> metadata = std::shared_ptr<daf::base::PropertySet>(), lsst::geom::Box2I const &bbox = lsst::geom::Box2I(), ImageOrigin origin = PARENT, bool conformMasks = false, bool needAllHdus = false, std::shared_ptr<daf::base::PropertySet> imageMetadata = std::shared_ptr<daf::base::PropertySet>(), std::shared_ptr<daf::base::PropertySet> maskMetadata = std::shared_ptr<daf::base::PropertySet>(), std::shared_ptr<daf::base::PropertySet> varianceMetadata = std::shared_ptr<daf::base::PropertySet>(), bool allowUnsafe = false)

Construct a MaskedImage from an already-open FITS object.

Parameters
  • [in] fitsfile: A FITS object to read from. Current HDU is ignored.

  • [inout] metadata: Metadata read from the primary HDU header.

  • [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] conformMasks: If true, make Mask conform to the mask layout in the file.

  • [in] needAllHdus: If true, throw fits::FitsError if the mask and/or variance plane is missing. If false, silently initialize them to zero.

  • [inout] imageMetadata: Metadata read from the image HDU header.

  • [inout] maskMetadata: Metadata read from the mask HDU header.

  • [inout] varianceMetadata: Metadata read from the variance HDU header.

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

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

Copy constructor; shallow, unless deep is true.

Parameters
  • rhs: Image to copy

  • deep: Make deep copy?

MaskedImage(MaskedImage &&rhs)
MaskedImage(MaskedImage const &rhs, lsst::geom::Box2I const &bbox, ImageOrigin const origin = PARENT, bool const deep = false)

Copy constructor of the pixels specified by bbox; shallow, unless deep is true.

Parameters
  • rhs: MaskedImage to copy

  • bbox: Specify desired region

  • origin: Specify the coordinate system of the bbox

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

template<typename OtherPixelT>
MaskedImage(MaskedImage<OtherPixelT, MaskPixelT, VariancePixelT> const &rhs, const bool deep)

Parameters
  • rhs: Input image

  • deep: Must be true; needed to disambiguate

generalised copy constructor; defined here in the header so that the compiler can instantiate N(N-1)/2 conversions between N ImageBase types.

We only support converting the Image part

MaskedImage &operator=(MaskedImage const &rhs)

Make the lhs use the rhs’s pixels

If you are copying a scalar value, a simple lhs = scalar; is OK, but this is probably not the function that you want to use with an image. To copy pixel values from the rhs use assign(rhs)

Parameters
  • rhs: Right hand side

MaskedImage &operator=(MaskedImage &&rhs)
virtual ~MaskedImage()
void swap(MaskedImage &rhs)
MaskedImage &operator=(Pixel const &rhs)

Set the pixels in the MaskedImage to the rhs.

MaskedImage &operator=(SinglePixel const &rhs)

Set the pixels in the MaskedImage to the rhs.

MaskedImage 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.

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

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

MaskedImage &operator<<=(MaskedImage const &rhs)

Copy the pixels from the rhs to the lhs

Note

operator=() is not equivalent to this command

void assign(MaskedImage const &rhs, lsst::geom::Box2I const &bbox = lsst::geom::Box2I(), ImageOrigin origin = PARENT)

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

Parameters
  • [in] rhs: source image whose pixels are to be copied into this image (the destination)

  • [in] bbox: subregion of this image to set; if empty (the default) then all pixels are set

  • [in] origin: origin 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::LengthError: if the dimensions of rhs and the specified subregion of this image do not match.

MaskedImage &operator+=(ImagePixelT const rhs)

Add a scalar rhs to a MaskedImage.

MaskedImage &operator+=(MaskedImage const &rhs)

Add a MaskedImage rhs to a MaskedImage

The image and variances are added; the masks are ORd together

Note

The pixels in the two images are taken to be independent. There is a Pixel operation (plus) which models the covariance, but this is not (yet?) available as full-MaskedImage operators

MaskedImage &operator+=(lsst::afw::image::Image<ImagePixelT> const &rhs)
MaskedImage &operator+=(lsst::afw::math::Function2<double> const &function)
void scaledPlus(double const c, MaskedImage const &rhs)

Add a scaled MaskedImage c*rhs to a MaskedImage

The image and variances are added; the masks are ORd together

Note

The pixels in the two images are taken to be independent. There is a Pixel operation (plus) which models the covariance, but this is not (yet?) available as full-MaskedImage operators

MaskedImage &operator-=(ImagePixelT const rhs)

Subtract a scalar rhs from a MaskedImage.

MaskedImage &operator-=(MaskedImage const &rhs)

Subtract a MaskedImage rhs from a MaskedImage

The images are subtracted; the masks are ORd together; and the variances are added

Note

the pixels in the two images are taken to be independent

MaskedImage &operator-=(lsst::afw::image::Image<ImagePixelT> const &rhs)
MaskedImage &operator-=(lsst::afw::math::Function2<double> const &function)
void scaledMinus(double const c, MaskedImage const &rhs)

Subtract a scaled MaskedImage c*rhs from a MaskedImage

The images are subtracted; the masks are ORd together; and the variances are added

Note

the pixels in the two images are taken to be independent

MaskedImage &operator*=(ImagePixelT const rhs)
MaskedImage &operator*=(MaskedImage const &rhs)
MaskedImage &operator*=(lsst::afw::image::Image<ImagePixelT> const &rhs)
void scaledMultiplies(double const c, MaskedImage const &rhs)
MaskedImage &operator/=(ImagePixelT const rhs)
MaskedImage &operator/=(MaskedImage const &rhs)
MaskedImage &operator/=(lsst::afw::image::Image<ImagePixelT> const &rhs)
void scaledDivides(double const c, MaskedImage const &rhs)
void writeFits(std::string const &fileName, std::shared_ptr<daf::base::PropertySet const> metadata = std::shared_ptr<daf::base::PropertySet const>(), std::shared_ptr<daf::base::PropertySet const> imageMetadata = std::shared_ptr<daf::base::PropertySet const>(), std::shared_ptr<daf::base::PropertySet const> maskMetadata = std::shared_ptr<daf::base::PropertySet const>(), std::shared_ptr<daf::base::PropertySet const> varianceMetadata = std::shared_ptr<daf::base::PropertySet const>()) const

Write a MaskedImage to a regular FITS file.

The FITS file will have four HDUs; the primary HDU will contain only metadata, while the image, mask, and variance HDU headers will use the “INHERIT=’T’” convention to indicate that the primary metadata applies to those HDUs as well.

Parameters
  • [in] fileName: Name of the file to write. When writing separate files, this is the “base” of the filename (e.g. foo reads foo_{img.msk.var}.fits).

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

  • [in] imageMetadata: Metadata to be written to the image header.

  • [in] maskMetadata: Metadata to be written to the mask header.

  • [in] varianceMetadata: Metadata to be written to the variance header.

void writeFits(fits::MemFileManager &manager, std::shared_ptr<daf::base::PropertySet const> metadata = std::shared_ptr<daf::base::PropertySet const>(), std::shared_ptr<daf::base::PropertySet const> imageMetadata = std::shared_ptr<daf::base::PropertySet const>(), std::shared_ptr<daf::base::PropertySet const> maskMetadata = std::shared_ptr<daf::base::PropertySet const>(), std::shared_ptr<daf::base::PropertySet const> varianceMetadata = std::shared_ptr<daf::base::PropertySet const>()) const

Write a MaskedImage to a FITS RAM file.

The FITS file will have four HDUs; the primary HDU will contain only metadata, while the image, mask, and variance HDU headers will use the “INHERIT=’T’” convention to indicate that the primary metadata applies to those HDUs as well.

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

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

  • [in] imageMetadata: Metadata to be written to the image header.

  • [in] maskMetadata: Metadata to be written to the mask header.

  • [in] varianceMetadata: Metadata to be written to the variance header.

void writeFits(fits::Fits &fitsfile, std::shared_ptr<daf::base::PropertySet const> metadata = std::shared_ptr<daf::base::PropertySet const>(), std::shared_ptr<daf::base::PropertySet const> imageMetadata = std::shared_ptr<daf::base::PropertySet const>(), std::shared_ptr<daf::base::PropertySet const> maskMetadata = std::shared_ptr<daf::base::PropertySet const>(), std::shared_ptr<daf::base::PropertySet const> varianceMetadata = std::shared_ptr<daf::base::PropertySet const>()) const

Write a MaskedImage to a FITS file.

The FITS file will have four HDUs; the primary HDU will contain only metadata, while the image, mask, and variance HDU headers will use the “INHERIT=’T’” convention to indicate that the primary metadata applies to those HDUs as well.

Parameters
  • [in] fitsfile: An empty FITS file object.

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

  • [in] imageMetadata: Metadata to be written to the image header.

  • [in] maskMetadata: Metadata to be written to the mask header.

  • [in] varianceMetadata: Metadata to be written to the variance header.

void writeFits(std::string const &fileName, fits::ImageWriteOptions const &imageOptions, fits::ImageWriteOptions const &maskOptions, fits::ImageWriteOptions const &varianceOptions, std::shared_ptr<daf::base::PropertySet const> metadata = nullptr, std::shared_ptr<daf::base::PropertySet const> imageMetadata = nullptr, std::shared_ptr<daf::base::PropertySet const> maskMetadata = nullptr, std::shared_ptr<daf::base::PropertySet const> varianceMetadata = nullptr) const

Write a MaskedImage to a FITS file.

The FITS file will have four HDUs; the primary HDU will contain only metadata, while the image, mask, and variance HDU headers will use the “INHERIT=’T’” convention to indicate that the primary metadata applies to those HDUs as well.

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

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

  • [in] maskOptions: Options controlling writing of mask as FITS.

  • [in] varianceOptions: Options controlling writing of variance as FITS.

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

  • [in] imageMetadata: Metadata to be written to the image header.

  • [in] maskMetadata: Metadata to be written to the mask header.

  • [in] varianceMetadata: Metadata to be written to the variance header.

void writeFits(fits::MemFileManager &manager, fits::ImageWriteOptions const &imageOptions, fits::ImageWriteOptions const &maskOptions, fits::ImageWriteOptions const &varianceOptions, std::shared_ptr<daf::base::PropertySet const> metadata = nullptr, std::shared_ptr<daf::base::PropertySet const> imageMetadata = nullptr, std::shared_ptr<daf::base::PropertySet const> maskMetadata = nullptr, std::shared_ptr<daf::base::PropertySet const> varianceMetadata = nullptr) const

Write a MaskedImage to a FITS file.

The FITS file will have four HDUs; the primary HDU will contain only metadata, while the image, mask, and variance HDU headers will use the “INHERIT=’T’” convention to indicate that the primary metadata applies to those HDUs as well.

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

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

  • [in] maskOptions: Options controlling writing of mask as FITS.

  • [in] varianceOptions: Options controlling writing of variance as FITS.

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

  • [in] imageMetadata: Metadata to be written to the image header.

  • [in] maskMetadata: Metadata to be written to the mask header.

  • [in] varianceMetadata: Metadata to be written to the variance header.

void writeFits(fits::Fits &fitsfile, fits::ImageWriteOptions const &imageOptions, fits::ImageWriteOptions const &maskOptions, fits::ImageWriteOptions const &varianceOptions, std::shared_ptr<daf::base::PropertySet const> metadata = nullptr, std::shared_ptr<daf::base::PropertySet const> imageMetadata = nullptr, std::shared_ptr<daf::base::PropertySet const> maskMetadata = nullptr, std::shared_ptr<daf::base::PropertySet const> varianceMetadata = nullptr) const

Write a MaskedImage to a FITS file.

The FITS file will have four HDUs; the primary HDU will contain only metadata, while the image, mask, and variance HDU headers will use the “INHERIT=’T’” convention to indicate that the primary metadata applies to those HDUs as well.

Parameters
  • [in] fitsfile: An empty FITS file object.

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

  • [in] maskOptions: Options controlling writing of mask as FITS.

  • [in] varianceOptions: Options controlling writing of variance as FITS.

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

  • [in] imageMetadata: Metadata to be written to the image header.

  • [in] maskMetadata: Metadata to be written to the mask header.

  • [in] varianceMetadata: Metadata to be written to the variance header.

ImagePtr getImage() const

Return a (shared_ptr to) the MaskedImage’s image.

void setImage(Image const &other)

Set the image plane’s pixel values to those of another Image.

This copies pixel values, not pointers.

Exceptions
  • pex::exceptions::LengthError: if dimensions do not match.

MaskPtr getMask() const

Return a (shared_ptr to) the MaskedImage’s mask.

void setMask(Mask const &other)

Set the mask plane’s pixel values to those of another Mask.

This copies pixel values, not pointers.

Exceptions
  • pex::exceptions::LengthError: if dimensions do not match.

void setVariance(Variance const &other)

Set the variance plane’s pixel values to those of another Image.

This copies pixel values, not pointers.

Exceptions
  • pex::exceptions::LengthError: if dimensions do not match.

VariancePtr getVariance() const

Return a (shared_ptr to) the MaskedImage’s variance.

int getWidth() const

Return the number of columns in the image.

int getHeight() const

Return the number of rows in the image.

lsst::geom::Extent2I getDimensions() const
lsst::geom::Box2I getBBox(ImageOrigin const origin = PARENT) const
int getX0() const

Return the image’s column-origin

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

int getY0() const

Return the image’s row-origin

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

lsst::geom::Point2I getXY0() const

Return the image’s origin

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

void setXY0(int const x0, int const y0)

Set the MaskedImage’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.

void setXY0(lsst::geom::Point2I const origin)

Set the MaskedImage’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.

double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const

Parameters
  • ind: image index

  • xy: Is this a column or row coordinate?

Convert image index to image position (see Image::indexToPosition)

Return

image position

std::pair<int, double> positionToIndex(double const pos, lsst::afw::image::xOrY const xy) const

Parameters
  • pos: image position

  • xy: Is this a column or row coordinate?

Convert image position to index (see Image::positionToIndex)

Return

std::pair(nearest integer index, fractional part)

iterator begin() const

Return an iterator to the start of the image.

iterator end() const

Return an iterator to the end of the image.

iterator at(int const x, int const y) const

Return an iterator at the point (x, y)

reverse_iterator rbegin() const

Return a reverse_iterator to the start of the image.

reverse_iterator rend() const

Return a reverse_iterator to the end of the image.

fast_iterator begin(bool contiguous) const

Fast iterators to contiguous images

Return a fast iterator to the start of the image, which must be contiguous Note that the order in which pixels are visited is undefined.

Parameters
  • contiguous: Pixels are contiguous (must be true)

Exceptions
  • lsst::pex::exceptions::RuntimeError: Argument contiguous is false, or the pixels are not in fact contiguous

fast_iterator end(bool contiguous) const

Return a fast iterator to the end of the image, which must be contiguous Note that the order in which pixels are visited is undefined.

Parameters
  • contiguous: Pixels are contiguous (must be true)

Exceptions
  • lsst::pex::exceptions::RuntimeError: Argument contiguous is false, or the pixels are not in fact contiguous

x_iterator row_begin(int y) const

Return an x_iterator to the start of the image.

x_iterator row_end(int y) const

Return an x_iterator to the end of the image.

x_iterator x_at(int x, int y) const

Return an x_iterator at the point (x, y)

y_iterator col_begin(int x) const

Return an y_iterator to the start of the image.

y_iterator col_end(int x) const

Return an y_iterator to the end of the image.

y_iterator y_at(int x, int y) const

Return an y_iterator at the point (x, y)

xy_locator xy_at(int x, int y) const

Return an xy_locator at the point (x, y)

Public Static Functions

static MaskedImage readFits(std::string const &filename)

Read a MaskedImage from a regular FITS file.

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

static MaskedImage readFits(fits::MemFileManager &manager)

Read a MaskedImage from a FITS RAM file.

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

Private Functions

void conformSizes()

Private Members

ImagePtr _image
MaskPtr _mask
VariancePtr _variance
template<typename ImageIterator, typename MaskIterator, typename VarianceIterator>
class const_MaskedImageIterator : public lsst::afw::image::MaskedImage<ImagePixelT, MaskPixelT, VariancePixelT>::MaskedImageIteratorBase<detail::const_iterator_type<ImageIterator>::type, detail::const_iterator_type<MaskIterator>::type, detail::const_iterator_type<VarianceIterator>::type, ConstReference>
#include <MaskedImage.h>

An const iterator to the MaskedImage.

An const iterator for a MaskedImage.

Public Functions

template<>
const_MaskedImageIterator(MaskedImageIterator<ImageIterator, MaskIterator, VarianceIterator> const &iter)
template<>
const_MaskedImageIterator &operator+(std::ptrdiff_t delta)

Return a const_MaskedImageIterator that’s delta beyond this.

Private Types

template<>
typedef detail::const_iterator_type<ImageIterator>::type const_ImageIterator
template<>
typedef detail::const_iterator_type<MaskIterator>::type const_MaskIterator
template<>
typedef detail::const_iterator_type<VarianceIterator>::type const_VarianceIterator
template<>
typedef MaskedImageIteratorBase<const_ImageIterator, const_MaskIterator, const_VarianceIterator, ConstReference> MaskedImageIteratorBase_t
template<typename ImageLocator, typename MaskLocator, typename VarianceLocator>
class const_MaskedImageLocator : public lsst::afw::image::MaskedImage<ImagePixelT, MaskPixelT, VariancePixelT>::MaskedImageLocatorBase<detail::const_locator_type<ImageLocator>::type, detail::const_locator_type<MaskLocator>::type, detail::const_locator_type<VarianceLocator>::type, ConstReference>
#include <MaskedImage.h>

A const locator for the MaskedImage.

A const locator for a MaskedImage.

Public Functions

template<>
const_MaskedImageLocator(MaskedImageLocator<ImageLocator, MaskLocator, VarianceLocator> const &iter)

Private Types

template<>
typedef detail::const_locator_type<ImageLocator>::type const_ImageLocator
template<>
typedef detail::const_locator_type<MaskLocator>::type const_MaskLocator
template<>
typedef detail::const_locator_type<VarianceLocator>::type const_VarianceLocator
template<>
typedef MaskedImageLocatorBase<const_ImageLocator, const_MaskLocator, const_VarianceLocator, ConstReference> MaskedImageLocatorBase_t
template<typename ImagePT = ImagePixelT, typename MaskPT = MaskPixelT, typename VarPT = VariancePixelT>
struct ImageTypeFactory
#include <MaskedImage.h>

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

Public Types

template<>
typedef MaskedImage<ImagePT, MaskPT, VarPT> type

Return the desired type.

template<typename ImageIterator, typename MaskIterator, typename VarianceIterator>
class MaskedImageIterator : public lsst::afw::image::MaskedImage<ImagePixelT, MaskPixelT, VariancePixelT>::MaskedImageIteratorBase<ImageIterator, MaskIterator, VarianceIterator>
#include <MaskedImage.h>

An iterator to the MaskedImage.

An iterator for a MaskedImage.

Subclassed by lsst::afw::math::MaskedVector< EntryT >::iterator

Public Functions

template<>
MaskedImageIterator(ImageIterator &img, MaskIterator &msk, VarianceIterator &var)
template<>
MaskedImageIterator operator+(std::ptrdiff_t delta)

Return a MaskedImageIterator that’s delta beyond this.

Private Types

template<>
typedef MaskedImageIteratorBase<ImageIterator, MaskIterator, VarianceIterator> MaskedImageIteratorBase_t
template<typename ImageIterator, typename MaskIterator, typename VarianceIterator, template<typename> class Ref = Reference>
class MaskedImageIteratorBase
#include <MaskedImage.h>

The base class for MaskedImageIterators (const and non-const)

Public Types

template<>
typedef boost::zip_iterator<IMV_iterator_tuple>::reference IMV_tuple

The underlying iterator tuple

Note

not really for public consumption; could be made protected

template<>
typedef Pixel type

Type pointed to by the iterator.

Public Functions

template<>
MaskedImageIteratorBase(ImageIterator const &img, MaskIterator const &msk, VarianceIterator const &var)

Construct a MaskedImageIteratorBase from the image/mask/variance iterators.

template<>
Ref<ImagePixelT>::type image()

Return (a reference to) the image part of the Pixel pointed at by the iterator.

template<>
Ref<MaskPixelT>::type mask()

Return (a reference to) the mask part of the Pixel pointed at by the iterator.

template<>
Ref<VariancePixelT>::type variance()

Return (a reference to) the variance part of the Pixel pointed at by the iterator.

template<>
const IMV_iterator_tuple get_iterator_tuple() const

Return the underlying iterator tuple

Note

not really for public consumption; could be made protected

template<>
MaskedImageIteratorBase &operator+=(std::ptrdiff_t delta)

Increment the iterator by delta

Parameters
  • delta: how far to move the iterator

template<>
MaskedImageIteratorBase &operator-=(std::ptrdiff_t delta)

Decrement the iterator by delta

Parameters
  • delta: how far to move the iterator

template<>
MaskedImageIteratorBase &operator++()

Increment the iterator (prefix)

template<>
MaskedImageIteratorBase operator++(int)

Increment the iterator (postfix)

template<>
std::ptrdiff_t operator-(MaskedImageIteratorBase const &rhs)

Return the distance between two iterators.

template<>
bool operator==(MaskedImageIteratorBase const &rhs)

Return true if the lhs equals the rhs.

template<>
bool operator!=(MaskedImageIteratorBase const &rhs)

Return true if the lhs doesn’t equal the rhs.

template<>
bool operator<(MaskedImageIteratorBase const &rhs)

Return true if the lhs is less than the rhs.

template<>
operator Pixel() const

Convert an iterator to a Pixel.

template<>
Pixel operator*()

Dereference the iterator, returning a Pixel.

template<>
const Pixel operator*() const

Dereference the iterator, returning a const Pixel.

Protected Attributes

template<>
boost::zip_iterator<IMV_iterator_tuple> _iter

Private Types

template<>
typedef boost::tuple<ImageIterator, MaskIterator, VarianceIterator> IMV_iterator_tuple

Friends

friend lsst::afw::image::const_MaskedImageIterator

The underlying const iterator tuple

Note

not really for public consumption; could be made protected

template<typename ImageLocator, typename MaskLocator, typename VarianceLocator>
class MaskedImageLocator : public lsst::afw::image::MaskedImage<ImagePixelT, MaskPixelT, VariancePixelT>::MaskedImageLocatorBase<ImageLocator, MaskLocator, VarianceLocator>
#include <MaskedImage.h>

A locator for the MaskedImage.

A locator for a MaskedImage.

Public Functions

template<>
MaskedImageLocator(ImageLocator &img, MaskLocator &msk, VarianceLocator &var)

Private Types

template<>
typedef MaskedImageLocatorBase<ImageLocator, MaskLocator, VarianceLocator> MaskedImageLocatorBase_t
template<typename ImageLocator, typename MaskLocator, typename VarianceLocator, template<typename> class Ref = Reference>
class MaskedImageLocatorBase
#include <MaskedImage.h>

The base class for MaskedImageLocators (const and non-const)

Public Types

template<>
typedef boost::tuple<typename ImageLocator::cached_location_t, typename MaskLocator::cached_location_t, typename VarianceLocator::cached_location_t> IMVCachedLocation
template<>
typedef _x_or_y_iterator<apply_x> x_iterator

An x_iterator that provides a view of the xy_locator (i.e. advancing one advances the other)

template<>
typedef _x_or_y_iterator<apply_y> y_iterator

A y_iterator that provides a view of the xy_locator (i.e. advancing one advances the other)

template<>
typedef boost::mpl::vector<ImagePixelT, MaskPixelT, VariancePixelT> PixelTVec

Public Functions

template<>
MaskedImageLocatorBase(ImageLocator const &img, MaskLocator const &msk, VarianceLocator const &var)

Construct a MaskedImageLocator from image/mask/variance locators.

template<>
Pixel operator*()

Dereference a locator, returning a Pixel.

template<>
Pixel operator()(int x, int y)

Dereference a locator, returning a Pixel offset by (x, y) from the locator.

template<>
Pixel operator[](cached_location_t const &cached_loc)

Dereference a locator, returning a Pixel offset by the amount set when we created the cached_location_t

template<>
x_iterator x()

Return an iterator that can be used to move (or dereference) a locator

Note

this x_locator is xy_locator::x_locator, not MaskedImage::x_locator

template<>
y_iterator y()

Return an iterator that can be used to move (or dereference) a locator

Note

this y_locator is xy_locator::y_locator, not MaskedImage::y_locator

template<>
cached_location_t cache_location(int x, int y) const

Create a cached_location_t offset by (x, y) from locator.

template<typename N>
Ref<typename boost::mpl::at<PixelTVec, N>::type>::type apply_IMV(cached_location_t const &cached_loc)
template<typename N>
Ref<typename boost::mpl::at<PixelTVec, N>::type>::type apply_IMV()
template<typename N>
Ref<typename boost::mpl::at<PixelTVec, N>::type>::type apply_IMV(int x, int y)
template<>
Ref<ImagePixelT>::type image(cached_location_t const &cached_loc)

Return a reference to the image at the offset set when we created the cached_location_t

template<>
Ref<ImagePixelT>::type image()

Return a reference to the image at the current position of the locator.

template<>
Ref<ImagePixelT>::type image(int x, int y)

Return a reference to the image offset by (x, y) from the current position of the locator.

template<>
Ref<MaskPixelT>::type mask(cached_location_t const &cached_loc)

Return a reference to the mask at the offset set when we created the cached_location_t

template<>
Ref<MaskPixelT>::type mask()

Return a reference to the mask at the current position of the locator.

template<>
Ref<MaskPixelT>::type mask(int x, int y)

Return a reference to the mask offset by (x, y) from the current position of the locator.

template<>
Ref<VariancePixelT>::type variance(cached_location_t const &cached_loc)

Return a reference to the variance at the offset set when we created the cached_location_t

template<>
Ref<VariancePixelT>::type variance()

Return a reference to the variance at the current position of the locator.

template<>
Ref<VariancePixelT>::type variance(int x, int y)

Return a reference to the variance offset by (x, y) from the current position of the locator.

template<>
bool operator==(MaskedImageLocatorBase const &rhs)

Return true iff two locators are equal.

template<>
bool operator!=(MaskedImageLocatorBase const &rhs)

Return true iff two locators are not equal.

template<>
bool operator<(MaskedImageLocatorBase const &rhs)

Return true iff lhs is less than rhs.

template<>
MaskedImageLocatorBase &operator+=(pair2I const &p)

Increment the locator’s x and y positions by p

template<>
MaskedImageLocatorBase &operator+=(detail::difference_type p)

Increment the locator’s x and y positions by p

template<>
IMVLocator const &getLoc() const

Protected Attributes

template<>
IMVLocator _loc

Private Types

template<>
typedef boost::tuple<ImageLocator, MaskLocator, VarianceLocator> IMVLocator
template<template<typename> class X_OR_Y>
class _x_or_y_iterator

Public Functions

template<>
template<>
_x_or_y_iterator(MaskedImageLocatorBase *mil)
template<>
template<>
_x_or_y_iterator &operator+=(const int di)
template<>
template<>
_x_or_y_iterator &operator++()
template<>
template<>
bool operator==(_x_or_y_iterator const &rhs)
template<>
template<>
bool operator!=(_x_or_y_iterator const &rhs)
template<>
template<>
bool operator<(_x_or_y_iterator const &rhs)
template<>
template<>
Pixel operator*()
template<>
template<>
Ref<ImagePixelT>::type image()
template<>
template<>
Ref<MaskPixelT>::type mask()
template<>
template<>
Ref<VariancePixelT>::type variance()

Protected Attributes

template<>
template<>
MaskedImageLocatorBase *_mil
template<typename LocT>
class apply_x

Public Functions

template<>
template<>
apply_x(LocT &loc)
template<>
template<>
IterT &operator()()

Private Types

template<>
template<>
typedef LocT::x_iterator IterT

Private Members

template<>
template<>
LocT &_loc
template<typename LocT>
class apply_y

Public Functions

template<>
template<>
apply_y(LocT &loc)
template<>
template<>
IterT &operator()()

Private Types

template<>
template<>
typedef LocT::y_iterator IterT

Private Members

template<>
template<>
LocT &_loc
class cached_location_t
#include <MaskedImage.h>

A saved relative position, providing efficient access to neighbouring pixels.

Public Functions

template<>
template<>
cached_location_t(IMVLocator const &loc, int x, int y)

Create a cached_location_t that can be used to access pixels (x, y) away from loc

Public Members

template<>
template<>
IMVCachedLocation _imv

Friends

friend lsst::afw::image::const_MaskedImageLocator
namespace detail

Variables

std::string const fitsFile_RE = "\.fits(\.[fg]z)?$"

regexp to identify when MaskedImages should be written as MEFs

std::string const compressedFileNoMEF_RE = "(\.gz)$"

regexp to identify compressed files that we can’t write MEFs to

struct MaskedImage_tag : public lsst::afw::image::detail::basic_tag
#include <MaskedImage.h>

A traits class for MaskedImage.

struct MaskedImagePixel_tag
#include <MaskedImage.h>

A class used to identify classes that represent MaskedImage pixels.

Subclassed by lsst::afw::image::pixel::Pixel< _ImagePixelT, _MaskPixelT, _VariancePixelT >, lsst::afw::image::pixel::SinglePixel< _ImagePixelT, _MaskPixelT, _VariancePixelT >