29 #ifndef LSST_AFW_IMAGE_MASK_H
30 #define LSST_AFW_IMAGE_MASK_H
38 #include "lsst/base.h"
39 #include "lsst/daf/base/Citizen.h"
40 #include "lsst/daf/base/Persistable.h"
41 #include "lsst/daf/base/PropertySet.h"
42 #include "lsst/pex/exceptions.h"
49 namespace formatters {
82 template <
typename MaskPixelT = lsst::afw::image::MaskPixel>
90 template <
typename MaskPT = MaskPixelT>
113 explicit Mask(
unsigned int width,
unsigned int height, MaskPixelT initialValue,
167 explicit Mask(std::string
const& fileName,
int hdu = INT_MIN,
168 std::shared_ptr<lsst::daf::base::PropertySet> metadata =
169 std::shared_ptr<lsst::daf::base::PropertySet>(),
171 bool conformMasks =
false);
192 std::shared_ptr<lsst::daf::base::PropertySet> metadata =
193 std::shared_ptr<lsst::daf::base::PropertySet>(),
195 bool conformMasks =
false);
212 explicit Mask(
fits::Fits& fitsfile, std::shared_ptr<lsst::daf::base::PropertySet> metadata =
213 std::shared_ptr<lsst::daf::base::PropertySet>(),
215 bool conformMasks =
false);
218 template <
typename OtherPixelT>
220 :
image::
ImageBase<MaskPixelT>(rhs, deep), _maskDict(rhs._maskDict) {}
228 Mask(
const Mask& src,
const bool deep =
false);
238 const bool deep =
false);
240 explicit Mask(ndarray::Array<MaskPixelT, 2, 1>
const& array,
bool deep =
false,
263 static MaskPixelT
getPlaneBitMask(
const std::vector<std::string>& names);
326 void writeFits(std::string
const& fileName, std::shared_ptr<lsst::daf::base::PropertySet const> metadata =
327 std::shared_ptr<lsst::daf::base::PropertySet>(),
328 std::string
const& mode =
"w")
const;
338 std::shared_ptr<lsst::daf::base::PropertySet const> metadata =
339 std::shared_ptr<lsst::daf::base::PropertySet>(),
340 std::string
const& mode =
"w")
const;
348 void writeFits(
fits::Fits& fitsfile, std::shared_ptr<lsst::daf::base::PropertySet const> metadata =
349 std::shared_ptr<lsst::daf::base::PropertySet const>())
const;
360 std::string
const& filename,
362 std::string
const& mode =
"w",
363 std::shared_ptr<daf::base::PropertySet const> header=
nullptr
377 std::string
const& mode =
"w",
378 std::shared_ptr<daf::base::PropertySet const> header=
nullptr
391 std::shared_ptr<daf::base::PropertySet const> header=
nullptr
418 static std::string
interpret(MaskPixelT value);
502 std::shared_ptr<detail::MaskDict> _maskDict;
504 static std::shared_ptr<detail::MaskDict> _maskPlaneDict();
506 static const std::string maskPlanePrefix;
519 static int getMaskPlaneNoThrow(
const std::string&
name);
521 static MaskPixelT getBitMaskNoThrow(
int plane);
527 static MaskPixelT getBitMask(
int plane);
545 void checkMaskDictionaries(
Mask const& other);
548 template <
typename PixelT>
549 void swap(Mask<PixelT>& a, Mask<PixelT>& b);
554 #endif // LSST_AFW_IMAGE_MASK_H
static std::string interpret(MaskPixelT value)
Interpret a mask value as a comma-separated list of mask plane names.
afw::table::PointKey< int > dimensions
static void clearMaskPlaneDict()
Reset the maskPlane dictionary.
static int getMaskPlane(const std::string &name)
Return the mask plane number corresponding to a plane name.
Mask(Mask< OtherPixelT > const &rhs, const bool deep)
std::map< std::string, int > MaskPlaneDict
Options for writing an image to FITS.
Mask & operator=(MaskPixelT const rhs)
std::string getAsString(int x, int y)
detail::MaskPlaneDict MaskPlaneDict
static void addMaskPlanesToMetadata(std::shared_ptr< lsst::daf::base::PropertySet >)
Given a PropertySet, replace any existing MaskPlane assignments with the current ones.
static int getNumPlanesUsed()
static MaskPlaneDict parseMaskPlaneMetadata(std::shared_ptr< lsst::daf::base::PropertySet const > metadata)
Given a PropertySet that contains the MaskPlane assignments, setup the MaskPlanes.
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
The base class for all image classed (Image, Mask, MaskedImage, ...)
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< MaskPT > type
Return the desired type.
ImageBase< MaskPixelT >::PixelReference operator()(int x, int y)
get a reference to the specified pixel
An integer coordinate rectangle.
Mask & operator&=(Mask const &rhs)
AND a Mask into a Mask.
Mask(unsigned int width, unsigned int height, MaskPlaneDict const &planeDefs=MaskPlaneDict())
Construct a Mask initialized to 0x0.
Represent a 2-dimensional array of bitmask pixels.
detail::Mask_tag image_category
Lifetime-management for memory that goes into FITS memory files.
void setMaskPlaneValues(const int plane, const int x0, const int x1, const int y)
Set the bit specified by "planeId" for pixels (x0, y) ...
static Mask readFits(fits::MemFileManager &manager, int hdu=INT_MIN)
Read a Mask from a FITS RAM file.
table::Key< std::string > name
A class used to request that array accesses be checked.
static MaskPixelT getPlaneBitMask(const std::vector< std::string > &names)
Return the bitmask corresponding to a vector of plane names OR'd together.
static Mask readFits(std::string const &filename, int hdu=INT_MIN)
Read a Mask from a regular FITS file.
void swap(Image< PixelT > &a, Image< PixelT > &b)
static void removeMaskPlane(const std::string &name)
static int getNumPlanesMax()
MaskPlaneDict const & getMaskPlaneDict() const
Return the Mask's maskPlaneDict.
void writeFits(std::string const &fileName, std::shared_ptr< lsst::daf::base::PropertySet const > metadata=std::shared_ptr< lsst::daf::base::PropertySet >(), std::string const &mode="w") const
Write a mask to a regular FITS file.
Mask & operator|=(Mask const &rhs)
OR a Mask into a Mask.
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)
XOR a Mask into a Mask.
A templated class to return this classes' type (present in Image/Mask/MaskedImage) ...
void clearMaskPlane(int plane)
Clear the specified bit in all pixels.
void printMaskPlanes() const
print the mask plane dictionary to std::cout
void clearAllMaskPlanes()
Clear all the pixels.
static int addMaskPlane(const std::string &name)