LSST Applications 27.0.0,g0265f82a02+469cd937ee,g02d81e74bb+21ad69e7e1,g1470d8bcf6+cbe83ee85a,g2079a07aa2+e67c6346a6,g212a7c68fe+04a9158687,g2305ad1205+94392ce272,g295015adf3+81dd352a9d,g2bbee38e9b+469cd937ee,g337abbeb29+469cd937ee,g3939d97d7f+72a9f7b576,g487adcacf7+71499e7cba,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+df404f777f,g5a732f18d5+be83d3ecdb,g64a986408d+21ad69e7e1,g858d7b2824+21ad69e7e1,g8a8a8dda67+a6fc98d2e7,g99cad8db69+f62e5b0af5,g9ddcbc5298+d4bad12328,ga1e77700b3+9c366c4306,ga8c6da7877+71e4819109,gb0e22166c9+25ba2f69a1,gb6a65358fc+469cd937ee,gbb8dafda3b+69d3c0e320,gc07e1c2157+a98bf949bb,gc120e1dc64+615ec43309,gc28159a63d+469cd937ee,gcf0d15dbbd+72a9f7b576,gdaeeff99f8+a38ce5ea23,ge6526c86ff+3a7c1ac5f1,ge79ae78c31+469cd937ee,gee10cc3b42+a6fc98d2e7,gf1cff7945b+21ad69e7e1,gfbcc870c63+9a11dc8c8f
LSST Data Management Base Package
Loading...
Searching...
No Matches
Mask.cc
Go to the documentation of this file.
1// -*- lsst-c++ -*-
2
3/*
4 * LSST Data Management System
5 * Copyright 2008-2016 AURA/LSST.
6 *
7 * This product includes software developed by the
8 * LSST Project (http://www.lsst.org/).
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the LSST License Statement and
21 * the GNU General Public License along with this program. If not,
22 * see <http://www.lsstcorp.org/LegalNotices/>.
23 */
24
25/*
26 * The fundamental type defined here is Mask; a 2-d array of pixels. Each of
27 * these pixels should be thought of as a set of bits, and the names of these
28 * bits are given by MaskPlaneDict (which is implemented as a std::map)
29 */
30
31#include <functional>
32#include <list>
33#include <string>
34#include "boost/format.hpp"
35
36#include "lsst/daf/base.h"
37#include "lsst/geom.h"
38#include "lsst/pex/exceptions.h"
39#include "lsst/log/Log.h"
40#include "lsst/afw/image/Mask.h"
44
45namespace dafBase = lsst::daf::base;
47
48namespace lsst {
49namespace afw {
50namespace image {
51
52namespace {} // namespace
53
54template <typename MaskPixelT>
55void Mask<MaskPixelT>::_initializePlanes(MaskPlaneDict const& planeDefs) {
56 LOGL_DEBUG("lsst.afw.image.Mask", "Number of mask planes: %d", getNumPlanesMax());
57
58 _maskDict = detail::MaskDict::copyOrGetDefault(planeDefs);
59}
60
61template <typename MaskPixelT>
62Mask<MaskPixelT>::Mask(unsigned int width, unsigned int height, MaskPlaneDict const& planeDefs)
63 : ImageBase<MaskPixelT>(lsst::geom::ExtentI(width, height)) {
64 _initializePlanes(planeDefs);
65 *this = 0x0;
66}
67
68template <typename MaskPixelT>
69Mask<MaskPixelT>::Mask(unsigned int width, unsigned int height, MaskPixelT initialValue,
71 : ImageBase<MaskPixelT>(lsst::geom::ExtentI(width, height)) {
72 _initializePlanes(planeDefs);
73 *this = initialValue;
74}
75
76template <typename MaskPixelT>
78 : ImageBase<MaskPixelT>(dimensions) {
79 _initializePlanes(planeDefs);
80 *this = 0x0;
81}
82
83template <typename MaskPixelT>
86 : ImageBase<MaskPixelT>(dimensions) {
87 _initializePlanes(planeDefs);
88 *this = initialValue;
89}
90
91template <typename MaskPixelT>
93 : ImageBase<MaskPixelT>(bbox) {
94 _initializePlanes(planeDefs);
95 *this = 0x0;
96}
97
98template <typename MaskPixelT>
100 : ImageBase<MaskPixelT>(bbox) {
101 _initializePlanes(planeDefs);
102 *this = initialValue;
103}
104
105template <typename MaskPixelT>
107 bool const deep)
108 : ImageBase<MaskPixelT>(rhs, bbox, origin, deep), _maskDict(rhs._maskDict) {}
109
110template <typename MaskPixelT>
112 : ImageBase<MaskPixelT>(rhs, deep), _maskDict(rhs._maskDict) {}
113// Delegate to copy-constructor for backwards compatibility
114template <typename MaskPixelT>
116
117template <typename MaskPixelT>
118Mask<MaskPixelT>::~Mask() = default;
119
120template <typename MaskPixelT>
121Mask<MaskPixelT>::Mask(ndarray::Array<MaskPixelT, 2, 1> const& array, bool deep,
123 : image::ImageBase<MaskPixelT>(array, deep, xy0), _maskDict(detail::MaskDict::getDefault()) {}
125template <typename PixelT>
127 using std::swap; // See Meyers, Effective C++, Item 25
128
130 swap(_maskDict, rhs._maskDict);
131}
133template <typename PixelT>
135 a.swap(b);
136}
137
138template <typename MaskPixelT>
140 Mask tmp(rhs);
141 swap(tmp); // See Meyers, Effective C++, Item 11
142
143 return *this;
144}
145// Delegate to copy-assignment for backwards compatibility
146template <typename MaskPixelT>
148 return *this = rhs;
149}
150
151template <typename MaskPixelT>
153 fill_pixels(_getRawView(), rhs);
154
155 return *this;
156}
157
158#ifndef DOXYGEN // doc for this section is already in header
159
160template <typename MaskPixelT>
162 lsst::geom::Box2I const& bbox, ImageOrigin origin, bool conformMasks, bool allowUnsafe)
163 : ImageBase<MaskPixelT>(), _maskDict(detail::MaskDict::getDefault()) {
165 *this = reader.read<MaskPixelT>(bbox, origin, conformMasks, allowUnsafe);
166 if (metadata) {
167 metadata->combine(*reader.readMetadata());
168 }
169}
170
171template <typename MaskPixelT>
172Mask<MaskPixelT>::Mask(fits::MemFileManager& manager, int hdu,
174 ImageOrigin origin, bool conformMasks, bool allowUnsafe)
175 : ImageBase<MaskPixelT>(), _maskDict(detail::MaskDict::getDefault()) {
176 MaskFitsReader reader(manager, hdu);
177 *this = reader.read<MaskPixelT>(bbox, origin, conformMasks, allowUnsafe);
178 if (metadata) {
179 metadata->combine(*reader.readMetadata());
180 }
181}
182
183template <typename MaskPixelT>
185 lsst::geom::Box2I const& bbox, ImageOrigin const origin, bool const conformMasks,
186 bool allowUnsafe)
187 : ImageBase<MaskPixelT>(), _maskDict(detail::MaskDict::getDefault()) {
189 *this = reader.read<MaskPixelT>(bbox, origin, conformMasks, allowUnsafe);
190 if (metadata) {
191 metadata->combine(*reader.readMetadata());
192 }
193}
194
195template <typename MaskPixelT>
196void Mask<MaskPixelT>::writeFits(std::string const& fileName,
197 daf::base::PropertySet const * metadata_i,
198 std::string const& mode) const {
199 fits::Fits fitsfile(fileName, mode, fits::Fits::AUTO_CLOSE | fits::Fits::AUTO_CHECK);
200 writeFits(fitsfile, metadata_i);
201}
202
203
204template <typename MaskPixelT>
205void Mask<MaskPixelT>::writeFits(fits::MemFileManager& manager,
206 daf::base::PropertySet const * metadata_i,
207 std::string const& mode) const {
208 fits::Fits fitsfile(manager, mode, fits::Fits::AUTO_CLOSE | fits::Fits::AUTO_CHECK);
209 writeFits(fitsfile, metadata_i);
210}
211
212
213template <typename MaskPixelT>
214void Mask<MaskPixelT>::writeFits(fits::Fits& fitsfile,
215 daf::base::PropertySet const * metadata) const {
216 writeFits(fitsfile, fits::ImageWriteOptions(*this), metadata);
217}
218
219template <typename MaskPixelT>
220void Mask<MaskPixelT>::writeFits(std::string const& filename, fits::ImageWriteOptions const& options,
221 std::string const& mode,
222 daf::base::PropertySet const * header) const {
223 fits::Fits fitsfile(filename, mode, fits::Fits::AUTO_CLOSE | fits::Fits::AUTO_CHECK);
224 writeFits(fitsfile, options, header);
225}
226
227
228template <typename MaskPixelT>
230 std::string const& mode,
231 daf::base::PropertySet const * header) const {
233 writeFits(fitsfile, options, header);
234}
235
236
237template <typename MaskPixelT>
239 daf::base::PropertySet const * header) const {
241 header ? header->deepCopy() : std::make_shared<dafBase::PropertySet>();
242 addMaskPlanesToMetadata(useHeader);
243 fitsfile.writeImage(*this, options, useHeader.get());
244}
245
246#endif // !DOXYGEN
247
248template <typename MaskPixelT>
251 MaskPlaneDict const& mpd = _maskPlaneDict()->getMaskPlaneDict();
252 for (auto const &iter : mpd) {
253 if (value & getBitMask(iter.second)) {
254 if (result.size() > 0) {
255 result += ",";
257 result += iter.first;
258 }
260 return result;
262
263template <typename MaskPixelT>
265 int id = getMaskPlaneNoThrow(name); // see if the plane is already available
266
267 if (id < 0) { // doesn't exist
268 id = _maskPlaneDict()->getUnusedPlane();
269 }
270
271 // build new entry, adding the plane to all Masks where this is no contradiction
272
273 if (id >= getNumPlanesMax()) { // Max number of planes is already allocated
275 str(boost::format("Max number of planes (%1%) already used") % getNumPlanesMax()));
276 }
277
279
280 return id;
281}
282
283template <typename MaskPixelT>
284int Mask<MaskPixelT>::addMaskPlane(std::string name, int planeId) {
285 if (planeId < 0 || planeId >= getNumPlanesMax()) {
286 throw LSST_EXCEPT(
288 str(boost::format("mask plane ID must be between 0 and %1%") % (getNumPlanesMax() - 1)));
289 }
291 _maskPlaneDict()->add(name, planeId);
292
293 return planeId;
294}
296template <typename MaskPixelT>
298 return _maskDict->getMaskPlaneDict();
299}
300
301template <typename MaskPixelT>
303 if (detail::MaskDict::getDefault()->getMaskPlane(name) < 0) {
305 str(boost::format("Plane %s doesn't exist in the default Mask") % name));
306 }
307
308 detail::MaskDict::detachDefault(); // leave current Masks alone
309 _maskPlaneDict()->erase(name);
311
312template <typename MaskPixelT>
314
315) {
316 clearMaskPlane(getMaskPlane(name)); // clear this bits in this Mask
317
318 if (_maskDict == detail::MaskDict::getDefault() && removeFromDefault) { // we are the default
319 ;
320 } else {
321 _maskDict = _maskDict->clone();
322 }
323
324 _maskDict->erase(name);
325
326 if (removeFromDefault && detail::MaskDict::getDefault()->getMaskPlane(name) >= 0) {
327 removeMaskPlane(name);
328 }
329}
330
331template <typename MaskPixelT>
332MaskPixelT Mask<MaskPixelT>::getBitMaskNoThrow(int planeId) {
333 return (planeId >= 0 && planeId < getNumPlanesMax()) ? (1 << planeId) : 0;
335
336template <typename MaskPixelT>
337MaskPixelT Mask<MaskPixelT>::getBitMask(int planeId) {
338 MaskPlaneDict const& mpd = _maskPlaneDict()->getMaskPlaneDict();
339
340 for (auto const &i : mpd) {
341 if (planeId == i.second) {
342 MaskPixelT const bitmask = getBitMaskNoThrow(planeId);
343 if (bitmask == 0) { // failed
344 break;
345 }
346 return bitmask;
347 }
348 }
350 str(boost::format("Invalid mask plane ID: %d") % planeId));
351}
352
353template <typename MaskPixelT>
355 int const plane = getMaskPlaneNoThrow(name);
356
357 if (plane < 0) {
359 str(boost::format("Invalid mask plane name: %s") % name));
360 } else {
361 return plane;
362 }
363}
364
365template <typename MaskPixelT>
367 return _maskPlaneDict()->getMaskPlane(name);
368}
369
370template <typename MaskPixelT>
372 return getBitMask(getMaskPlane(name));
373}
374
375template <typename MaskPixelT>
377 MaskPixelT mpix = 0x0;
378 for (auto const &it : name) {
379 mpix |= getBitMask(getMaskPlane(it));
380 }
381 return mpix;
382}
383
384template <typename MaskPixelT>
386 return _maskPlaneDict()->size();
387}
388
389template <typename MaskPixelT>
391 _maskPlaneDict()->clear();
392}
393
394template <typename MaskPixelT>
396 *this = 0;
397}
398
399template <typename MaskPixelT>
401 *this &= ~getBitMask(planeId);
402}
403
404template <typename MaskPixelT>
407
408 if (*_maskDict == *currentMD) {
409 if (*detail::MaskDict::getDefault() == *_maskDict) {
410 return; // nothing to do
411 }
412 } else {
413 //
414 // Find out which planes need to be permuted
415 //
416 MaskPixelT keepBitmask = 0; // mask of bits to keep
417 MaskPixelT canonicalMask[sizeof(MaskPixelT) * 8]; // bits in lsst::afw::image::Mask that should be
418 MaskPixelT currentMask[sizeof(MaskPixelT) * 8]; // mapped to these bits
419 int numReMap = 0;
420
421 for (auto const &i : currentPlaneDict) {
422 std::string const name = i.first; // name of mask plane
423 int const currentPlaneNumber = i.second; // plane number currently in use
424 int canonicalPlaneNumber = getMaskPlaneNoThrow(name); // plane number in lsst::afw::image::Mask
425
426 if (canonicalPlaneNumber < 0) { // no such plane; add it
427 canonicalPlaneNumber = addMaskPlane(name);
428 }
429
431 keepBitmask |= getBitMask(canonicalPlaneNumber); // bit is unchanged, so preserve it
432 } else {
434 currentMask[numReMap] = getBitMaskNoThrow(currentPlaneNumber);
435 numReMap++;
436 }
437 }
438
439 // Now loop over all pixels in Mask
440 if (numReMap > 0) {
441 for (int r = 0; r != this->getHeight(); ++r) { // "this->": Meyers, Effective C++, Item 43
442 for (typename Mask::x_iterator ptr = this->row_begin(r), end = this->row_end(r); ptr != end;
443 ++ptr) {
444 MaskPixelT const pixel = *ptr;
445
446 MaskPixelT newPixel = pixel & keepBitmask; // value of invariant mask bits
447 for (int i = 0; i < numReMap; i++) {
448 if (pixel & currentMask[i]) newPixel |= canonicalMask[i];
449 }
450
451 *ptr = newPixel;
452 }
454 }
456 // We've made the planes match the current mask dictionary
457 _maskDict = detail::MaskDict::getDefault();
458}
460template <typename MaskPixelT>
464
465template <typename MaskPixelT>
467 CheckIndices const& check) {
468 return this->ImageBase<MaskPixelT>::operator()(x, y, check);
469}
470
471template <typename MaskPixelT>
474}
475
476template <typename MaskPixelT>
478 int x, int y, CheckIndices const& check) const {
479 return this->ImageBase<MaskPixelT>::operator()(x, y, check);
480}
481
482template <typename MaskPixelT>
483bool Mask<MaskPixelT>::operator()(int x, int y, int planeId) const {
484 // !! converts an int to a bool
485 return !!(this->ImageBase<MaskPixelT>::operator()(x, y) & getBitMask(planeId));
486}
487
488template <typename MaskPixelT>
489bool Mask<MaskPixelT>::operator()(int x, int y, int planeId, CheckIndices const& check) const {
490 // !! converts an int to a bool
491 return !!(this->ImageBase<MaskPixelT>::operator()(x, y, check) & getBitMask(planeId));
492}
493
494template <typename MaskPixelT>
496 if (*_maskDict != *other._maskDict) {
497 throw LSST_EXCEPT(pexExcept::RuntimeError, "Mask dictionaries do not match");
498 }
500
501template <typename MaskPixelT>
503 transform_pixels(_getRawView(), _getRawView(),
504 [&val](MaskPixelT const& l) -> MaskPixelT { return l | val; });
505 return *this;
506}
507
508template <typename MaskPixelT>
510 checkMaskDictionaries(rhs);
511
512 if (this->getDimensions() != rhs.getDimensions()) {
514 str(boost::format("Images are of different size, %dx%d v %dx%d") %
515 this->getWidth() % this->getHeight() % rhs.getWidth() % rhs.getHeight()));
516 }
517 transform_pixels(_getRawView(), rhs._getRawView(), _getRawView(),
518 [](MaskPixelT const& l, MaskPixelT const& r) -> MaskPixelT { return l | r; });
519 return *this;
520}
521
522template <typename MaskPixelT>
524 transform_pixels(_getRawView(), _getRawView(), [&val](MaskPixelT const& l) { return l & val; });
525 return *this;
526}
528template <typename MaskPixelT>
530 checkMaskDictionaries(rhs);
531
532 if (this->getDimensions() != rhs.getDimensions()) {
534 str(boost::format("Images are of different size, %dx%d v %dx%d") %
535 this->getWidth() % this->getHeight() % rhs.getWidth() % rhs.getHeight()));
536 }
537 transform_pixels(_getRawView(), rhs._getRawView(), _getRawView(),
538 [](MaskPixelT const& l, MaskPixelT const& r) -> MaskPixelT { return l & r; });
539 return *this;
540}
541
542template <typename MaskPixelT>
544 transform_pixels(_getRawView(), _getRawView(),
545 [&val](MaskPixelT const& l) -> MaskPixelT { return l ^ val; });
546 return *this;
547}
548
549template <typename MaskPixelT>
551 checkMaskDictionaries(rhs);
552
553 if (this->getDimensions() != rhs.getDimensions()) {
555 str(boost::format("Images are of different size, %dx%d v %dx%d") %
556 this->getWidth() % this->getHeight() % rhs.getWidth() % rhs.getHeight()));
557 }
558 transform_pixels(_getRawView(), rhs._getRawView(), _getRawView(),
559 [](MaskPixelT const& l, MaskPixelT const& r) -> MaskPixelT { return l ^ r; });
560 return *this;
561}
562
563template <typename MaskPixelT>
564void Mask<MaskPixelT>::setMaskPlaneValues(int const planeId, int const x0, int const x1, int const y) {
565 MaskPixelT const bitMask = getBitMask(planeId);
566
567 for (int x = x0; x <= x1; x++) {
568 operator()(x, y) = operator()(x, y) | bitMask;
569 }
570}
571
572template <typename MaskPixelT>
574 if (!metadata) {
575 throw LSST_EXCEPT(pexExcept::InvalidParameterError, "Null std::shared_ptr<PropertySet>");
576 }
577
578 // First, clear existing MaskPlane metadata
580 NameList paramNames = metadata->paramNames(false);
581 for (auto const &paramName : paramNames) {
582 if (paramName.compare(0, maskPlanePrefix.size(), maskPlanePrefix) == 0) {
583 metadata->remove(paramName);
584 }
585 }
586
587 MaskPlaneDict const& mpd = _maskPlaneDict()->getMaskPlaneDict();
588
589 // Add new MaskPlane metadata
590 for (auto const &i : mpd) {
591 std::string const& planeName = i.first;
592 int const planeNumber = i.second;
593
594 if (planeName != "") {
595 metadata->add(maskPlanePrefix + planeName, planeNumber);
596 }
597 }
598}
599
600template <typename MaskPixelT>
604
605 // First, clear existing MaskPlane metadata
607 NameList paramNames = metadata->paramNames(false);
608 int numPlanesUsed = 0; // number of planes used
609
610 // Iterate over childless properties with names starting with maskPlanePrefix
611 for (auto const &paramName : paramNames) {
612 if (paramName.compare(0, maskPlanePrefix.size(), maskPlanePrefix) == 0) {
613 // split off maskPlanePrefix to obtain plane name
614 std::string planeName = paramName.substr(maskPlanePrefix.size());
615 int const planeId = metadata->getAsInt(paramName);
616
617 MaskPlaneDict::const_iterator plane = newDict.find(planeName);
618 if (plane != newDict.end() && planeId != plane->second) {
619 throw LSST_EXCEPT(pexExcept::RuntimeError, "File specifies plane " + planeName + " twice");
620 }
621 for (MaskPlaneDict::const_iterator j = newDict.begin(); j != newDict.end(); ++j) {
622 if (planeId == j->second) {
624 str(boost::format("File specifies plane %s has same value (%d) as %s") %
625 planeName % planeId % j->first));
626 }
627 }
628 // build new entry
629 if (numPlanesUsed >= getNumPlanesMax()) {
630 // Max number of planes already allocated
631 throw LSST_EXCEPT(
633 str(boost::format("Max number of planes (%1%) already used") % getNumPlanesMax()));
634 }
636 }
637 }
638 return newDict;
639}
640
641template <typename MaskPixelT>
643 _maskDict->print();
644}
645
646/*
647 * Static members of Mask
648 */
649template <typename MaskPixelT>
651
652template <typename MaskPixelT>
655}
656
657//
658// Explicit instantiations
659//
660template class Mask<MaskPixel>;
661} // namespace image
662} // namespace afw
663} // namespace lsst
py::object result
Definition _schema.cc:429
table::Key< std::string > name
Definition Amplifier.cc:116
AmpInfoBoxKey bbox
Definition Amplifier.cc:117
int end
table::Key< int > id
Definition Detector.cc:162
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition Exception.h:48
LSST DM logging module built on log4cxx.
#define LOGL_DEBUG(logger, message...)
Log a debug-level message using a varargs/printf style interface.
Definition Log.h:515
uint64_t * ptr
Definition RangeSet.cc:95
int y
Definition SpanSet.cc:48
table::Key< int > b
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition fits.h:308
Lifetime-management for memory that goes into FITS memory files.
Definition fits.h:125
A class used to request that array accesses be checked.
Definition ImageBase.h:74
The base class for all image classed (Image, Mask, MaskedImage, ...)
Definition ImageBase.h:102
typename Reference< PixelT >::type PixelReference
A Reference to a PixelT.
Definition ImageBase.h:117
PixelReference operator()(int x, int y)
Return a reference to the pixel (x, y) in LOCAL coordinates.
Definition Image.cc:171
int getWidth() const
Return the number of columns in the image.
Definition ImageBase.h:294
lsst::geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
Definition ImageBase.h:356
typename ndarray::Array< PixelT, 2, 1 > Array
A mutable ndarray representation of the image.
Definition ImageBase.h:149
int getHeight() const
Return the number of rows in the image.
Definition ImageBase.h:296
typename _view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
Definition ImageBase.h:133
_view_t _getRawView() const
Definition ImageBase.h:465
void swap(ImageBase &rhs)
Definition Image.cc:233
typename ConstReference< PixelT >::type PixelConstReference
A ConstReference to a PixelT.
Definition ImageBase.h:119
A FITS reader class for Masks.
Represent a 2-dimensional array of bitmask pixels.
Definition Mask.h:77
void swap(Mask &rhs)
Definition Mask.cc:126
Mask & operator=(MaskPixelT const rhs)
Definition Mask.cc:152
friend class MaskFitsReader
Definition Mask.h:530
void printMaskPlanes() const
print the mask plane dictionary to std::cout
Definition Mask.cc:642
static int getMaskPlane(const std::string &name)
Return the mask plane number corresponding to a plane name.
Definition Mask.cc:354
static std::string interpret(MaskPixelT value)
Interpret a mask value as a comma-separated list of mask plane names.
Definition Mask.cc:249
static void removeMaskPlane(const std::string &name)
Definition Mask.cc:302
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...
Definition Mask.cc:313
static void clearMaskPlaneDict()
Reset the maskPlane dictionary.
Definition Mask.cc:390
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)
Definition Mask.cc:564
static void addMaskPlanesToMetadata(std::shared_ptr< lsst::daf::base::PropertySet >)
Given a PropertySet, replace any existing MaskPlane assignments with the current ones.
Definition Mask.cc:573
ImageBase< MaskPixelT >::PixelReference operator()(int x, int y)
get a reference to the specified pixel
Definition Mask.cc:461
Mask & operator^=(Mask const &rhs)
XOR a Mask into a Mask.
Definition Mask.cc:550
static int addMaskPlane(const std::string &name)
Definition Mask.cc:264
static MaskPixelT getPlaneBitMask(const std::vector< std::string > &names)
Return the bitmask corresponding to a vector of plane names OR'd together.
Definition Mask.cc:376
Mask(unsigned int width, unsigned int height, MaskPlaneDict const &planeDefs=MaskPlaneDict())
Construct a Mask initialized to 0x0.
Definition Mask.cc:62
MaskPlaneDict const & getMaskPlaneDict() const
Return the Mask's maskPlaneDict.
Definition Mask.cc:297
void conformMaskPlanes(const MaskPlaneDict &masterPlaneDict)
Adjust this mask to conform to the standard Mask class's mask plane dictionary, adding any new mask p...
Definition Mask.cc:405
Mask & operator|=(Mask const &rhs)
OR a Mask into a Mask.
Definition Mask.cc:509
static MaskPlaneDict parseMaskPlaneMetadata(std::shared_ptr< lsst::daf::base::PropertySet const > metadata)
Given a PropertySet that contains the MaskPlane assignments, setup the MaskPlanes.
Definition Mask.cc:601
void clearAllMaskPlanes()
Clear all the pixels.
Definition Mask.cc:395
static int getNumPlanesUsed()
Definition Mask.cc:385
void clearMaskPlane(int plane)
Clear the specified bit in all pixels.
Definition Mask.cc:400
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.
Mask & operator&=(Mask const &rhs)
AND a Mask into a Mask.
Definition Mask.cc:529
static void addAllMasksPlane(std::string const &name, int bitId)
Definition MaskDict.cc:127
static std::shared_ptr< MaskDict > detachDefault()
Definition MaskDict.cc:123
static std::shared_ptr< MaskDict > getDefault()
Definition MaskDict.cc:115
static std::shared_ptr< MaskDict > copyOrGetDefault(MaskPlaneDict const &dict)
Definition MaskDict.cc:111
Class for storing generic metadata.
Definition PropertySet.h:66
An integer coordinate rectangle.
Definition Box.h:55
Reports invalid arguments.
Definition Runtime.h:66
Reports attempts to exceed implementation-defined length limits for some classes.
Definition Runtime.h:76
Reports when the result of an operation cannot be represented by the destination type.
Definition Runtime.h:115
Reports errors that are due to events beyond the control of the program.
Definition Runtime.h:104
void swap(Image< PixelT > &a, Image< PixelT > &b)
Definition Image.cc:443
writeFits(filename, stamps, metadata, type_name, write_mask, write_variance, write_archive=False)
Definition stamps.py:40
ImageT val
Definition CR.cc:146
Options for writing an image to FITS.
Definition fits.h:223
T substr(T... args)
T swap(T... args)