29#ifndef LSST_AFW_IMAGE_MASK_H
30#define LSST_AFW_IMAGE_MASK_H
81template <
typename MaskPixelT = lsst::afw::image::MaskPixel>
89 template <
typename MaskPT = MaskPixelT>
112 explicit Mask(
unsigned int width,
unsigned int height, MaskPixelT initialValue,
172 bool conformMasks =
false,
bool allowUnsafe =
false);
198 bool conformMasks =
false,
bool allowUnsafe =
false);
221 bool conformMasks =
false,
bool allowUnsafe =
false);
224 template <
typename OtherPixelT>
226 :
image::
ImageBase<MaskPixelT>(rhs, deep), _maskDict(rhs._maskDict) {}
246 const bool deep =
false);
248 explicit Mask(ndarray::Array<MaskPixelT, 2, 1>
const& array,
bool deep =
false,
282 return Mask(*
this, bbox, origin,
false);
550 static int getMaskPlaneNoThrow(
const std::string& name);
552 static MaskPixelT getBitMaskNoThrow(
int plane);
558 static MaskPixelT getBitMask(
int plane);
576 void checkMaskDictionaries(
Mask const& other);
579template <
typename PixelT>
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Lifetime-management for memory that goes into FITS memory files.
A class used to request that array accesses be checked.
The base class for all image classed (Image, Mask, MaskedImage, ...)
typename Reference< PixelT >::type PixelReference
A Reference to a PixelT.
_view_t _getRawView() const
typename ConstReference< PixelT >::type PixelConstReference
A ConstReference to a PixelT.
Represent a 2-dimensional array of bitmask pixels.
void writeFits(fits::MemFileManager &manager, fits::ImageWriteOptions const &options, std::string const &mode="w", daf::base::PropertySet const *header=nullptr) const
Write a mask to a FITS RAM file.
Mask & operator=(MaskPixelT const rhs)
friend class MaskFitsReader
void printMaskPlanes() const
print the mask plane dictionary to std::cout
static Mask readFits(std::string const &filename, int hdu=fits::DEFAULT_HDU)
Read a Mask from a regular FITS file.
ImageBase< MaskPixelT >::PixelConstReference operator()(int x, int y) const
get the specified pixel (const version)
Mask & operator|=(MaskPixelT const rhs)
OR a bitmask into a Mask.
static int getMaskPlane(const std::string &name)
Return the mask plane number corresponding to a plane name.
static MaskPixelT getPlaneBitMask(const std::string &name)
Return the bitmask corresponding to a plane name.
detail::MaskPlaneDict MaskPlaneDict
Mask(lsst::geom::Box2I const &bbox, MaskPlaneDict const &planeDefs=MaskPlaneDict())
Construct a Mask initialized to 0x0.
static std::string interpret(MaskPixelT value)
Interpret a mask value as a comma-separated list of mask plane names.
Mask(const Mask &src, const bool deep=false)
Construct a Mask from another Mask.
static void removeMaskPlane(const std::string &name)
Mask & operator^=(MaskPixelT const rhs)
XOR a bitmask into a Mask.
void removeAndClearMaskPlane(const std::string &name, bool const removeFromDefault=false)
Clear all pixels of the specified mask and remove the plane from the mask plane dictionary; optionall...
Mask(Mask< OtherPixelT > const &rhs, const bool deep)
static Mask readFits(fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU)
Read a Mask from a FITS RAM file.
static void clearMaskPlaneDict()
Reset the maskPlane dictionary.
void setMaskPlaneValues(const int plane, const int x0, const int x1, const int y)
Set the bit specified by "planeId" for pixels (x0, y) ... (x1, y)
static void addMaskPlanesToMetadata(std::shared_ptr< lsst::daf::base::PropertySet >)
Given a PropertySet, replace any existing MaskPlane assignments with the current ones.
Mask subset(lsst::geom::Box2I const &bbox, ImageOrigin origin=PARENT) const
Return a subimage corresponding to the given box.
Mask & operator&=(MaskPixelT const rhs)
AND a bitmask into a Mask.
ImageBase< MaskPixelT >::PixelReference operator()(int x, int y)
get a reference to the specified pixel
Mask & operator^=(Mask const &rhs)
XOR a Mask into a Mask.
bool operator()(int x, int y, int plane, CheckIndices const &check) const
is the specified mask plane set in the specified pixel, checking array bounds?
Mask(lsst::geom::Extent2I const &dimensions=lsst::geom::Extent2I(), MaskPlaneDict const &planeDefs=MaskPlaneDict())
Construct a Mask initialized to 0x0.
Mask(const Mask &src, const lsst::geom::Box2I &bbox, ImageOrigin const origin=PARENT, const bool deep=false)
Construct a Mask from a subregion of another Mask.
static int addMaskPlane(const std::string &name)
Mask(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 conformMasks=false, bool allowUnsafe=false)
Construct a Mask by reading a regular FITS file.
Mask & operator=(Mask &&rhs)
void writeFits(std::string const &filename, fits::ImageWriteOptions const &options, std::string const &mode="w", daf::base::PropertySet const *header=nullptr) const
Write a mask to a regular FITS file.
Mask(unsigned int width, unsigned int height, MaskPixelT initialValue, MaskPlaneDict const &planeDefs=MaskPlaneDict())
Construct a Mask initialized to a specified value.
static MaskPixelT getPlaneBitMask(const std::vector< std::string > &names)
Return the bitmask corresponding to a vector of plane names OR'd together.
Mask(lsst::geom::Extent2I const &dimensions, MaskPixelT initialValue, MaskPlaneDict const &planeDefs=MaskPlaneDict())
Construct a Mask initialized to a specified value.
Mask(ndarray::Array< MaskPixelT, 2, 1 > const &array, bool deep=false, lsst::geom::Point2I const &xy0=lsst::geom::Point2I())
Mask(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 conformMasks=false, bool allowUnsafe=false)
Construct a Mask by reading a FITS image in memory.
Mask(unsigned int width, unsigned int height, MaskPlaneDict const &planeDefs=MaskPlaneDict())
Construct a Mask initialized to 0x0.
std::string getAsString(int x, int y)
Mask(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 conformMasks=false, bool allowUnsafe=false)
Construct a Mask from an already-open FITS object.
void writeFits(fits::MemFileManager &manager, daf::base::PropertySet const *metadata=nullptr, std::string const &mode="w") const
Write a mask to a FITS RAM file.
MaskPlaneDict const & getMaskPlaneDict() const
Return the Mask's maskPlaneDict.
Mask(lsst::geom::Box2I const &bbox, MaskPixelT initialValue, MaskPlaneDict const &planeDefs=MaskPlaneDict())
Construct a Mask initialized to a specified value.
void conformMaskPlanes(const MaskPlaneDict &masterPlaneDict)
Adjust this mask to conform to the standard Mask class's mask plane dictionary, adding any new mask p...
Mask & operator|=(Mask const &rhs)
OR a Mask into a Mask.
Mask operator[](lsst::geom::Box2I const &bbox) const
Return a subimage corresponding to the given box (interpreted as PARENT coordinates).
ImageBase< MaskPixelT >::PixelReference operator()(int x, int y, CheckIndices const &check)
get a reference to the specified pixel checking array bounds
bool operator()(int x, int y, int plane) const
is the specified mask plane set in the specified pixel?
detail::Mask_tag image_category
ImageBase< MaskPixelT >::PixelConstReference operator()(int x, int y, CheckIndices const &check) const
get the specified pixel with array checking (const version)
static MaskPlaneDict parseMaskPlaneMetadata(std::shared_ptr< lsst::daf::base::PropertySet const > metadata)
Given a PropertySet that contains the MaskPlane assignments, setup the MaskPlanes.
void clearAllMaskPlanes()
Clear all the pixels.
static int getNumPlanesUsed()
void writeFits(fits::Fits &fitsfile, daf::base::PropertySet const *metadata=nullptr) const
Write a mask to an open FITS file object.
Mask & operator=(const Mask &rhs)
void clearMaskPlane(int plane)
Clear the specified bit in all pixels.
static int getNumPlanesMax()
void writeFits(std::string const &fileName, daf::base::PropertySet const *metadata=nullptr, std::string const &mode="w") const
Write a mask to a regular FITS file.
void writeFits(fits::Fits &fitsfile, fits::ImageWriteOptions const &options, daf::base::PropertySet const *header=nullptr) const
Write a mask to an open FITS file object.
Mask & operator&=(Mask const &rhs)
AND a Mask into a Mask.
Class for storing generic metadata.
An integer coordinate rectangle.
const int DEFAULT_HDU
Specify that the default HDU should be read.
std::map< std::string, int > MaskPlaneDict
void swap(Image< PixelT > &a, Image< PixelT > &b)
Extent< int, 2 > Extent2I
Options for writing an image to FITS.
A templated class to return this classes' type (present in Image/Mask/MaskedImage)
Mask< MaskPT > type
Return the desired type.
g2d::python::Image< bool > Mask