29#ifndef LSST_IMAGE_MASKEDIMAGE_H
30#define LSST_IMAGE_MASKEDIMAGE_H
38#include "boost/mpl/at.hpp"
39#include "boost/mpl/vector.hpp"
40#include "boost/iterator/zip_iterator.hpp"
41#include "boost/tuple/tuple.hpp"
92 template <
typename ImagePT = ImagePixelT,
typename MaskPT = MaskPixelT,
typename VarPT = VariancePixelT>
99 template <
typename,
typename,
typename>
102 template <
typename,
typename,
typename>
105 template <
typename,
typename,
typename>
108 template <
typename,
typename,
typename>
117 template <
typename ImageIterator,
typename MaskIterator,
typename VarianceIterator,
118 template <
typename>
class Ref =
Reference>
120 using IMV_iterator_tuple = boost::tuple<ImageIterator, MaskIterator, VarianceIterator>;
126 using IMV_tuple =
typename boost::zip_iterator<IMV_iterator_tuple>::reference;
130 template <
typename,
typename,
typename>
137 VarianceIterator
const& var)
140 typename Ref<ImagePixelT>::type
image() {
return _iter->template get<0>()[0]; }
143 typename Ref<MaskPixelT>::type
mask() {
return _iter->template get<1>()[0]; }
146 typename Ref<VariancePixelT>::type
variance() {
return _iter->template get<2>()[0]; }
178 return &this->
_iter->template get<0>() - &rhs.
_iter->template get<0>();
182 return &this->
_iter->template get<0>() == &rhs.
_iter->template get<0>();
186 return &this->
_iter->template get<0>() != &rhs.
_iter->template get<0>();
190 return &this->
_iter->template get<0>() < &rhs.
_iter->template get<0>();
195 _iter->template get<2>()[0]);
204 typename boost::zip_iterator<IMV_iterator_tuple>
_iter;
208 template <
typename ImageIterator,
typename MaskIterator,
typename VarianceIterator>
215 : MaskedImageIteratorBase_t(img, msk, var) {}
226 template <
typename ImageIterator,
typename MaskIterator,
typename VarianceIterator>
229 typename detail::const_iterator_type<MaskIterator>::type,
230 typename detail::const_iterator_type<VarianceIterator>::type,
232 using const_ImageIterator =
typename detail::const_iterator_type<ImageIterator>::type;
233 using const_MaskIterator =
typename detail::const_iterator_type<MaskIterator>::type;
234 using const_VarianceIterator =
typename detail::const_iterator_type<VarianceIterator>::type;
241 : MaskedImageIteratorBase_t(
257 template <
typename ImageLocator,
typename MaskLocator,
typename VarianceLocator,
258 template <
typename>
class Ref =
Reference>
260 using IMVLocator =
typename boost::tuple<ImageLocator, MaskLocator, VarianceLocator>;
266 template <
template <
typename>
class X_OR_Y>
267 class _x_or_y_iterator {
273 X_OR_Y<ImageLocator>(_mil->
_loc.template get<0>())() += di;
274 X_OR_Y<MaskLocator>(_mil->
_loc.template get<1>())() += di;
275 X_OR_Y<VarianceLocator>(_mil->
_loc.template get<2>())() += di;
279 _x_or_y_iterator& operator++() {
281 ++X_OR_Y<ImageLocator>(_mil->
_loc.template get<0>())();
282 ++X_OR_Y<MaskLocator>(_mil->
_loc.template get<1>())();
283 ++X_OR_Y<VarianceLocator>(_mil->
_loc.template get<2>())();
287 bool operator==(_x_or_y_iterator
const& rhs) {
288 return X_OR_Y<ImageLocator>(_mil->
_loc.template get<0>())() ==
289 X_OR_Y<ImageLocator>(rhs._mil->
_loc.template get<0>())();
291 bool operator!=(_x_or_y_iterator
const& rhs) {
292 return X_OR_Y<ImageLocator>(_mil->
_loc.template get<0>())() !=
293 X_OR_Y<ImageLocator>(rhs._mil->
_loc.template get<0>())();
295 bool operator<(_x_or_y_iterator
const& rhs) {
296 return X_OR_Y<ImageLocator>(_mil->
_loc.template get<0>())() <
297 X_OR_Y<ImageLocator>(rhs._mil->
_loc.template get<0>())();
301 return Pixel((*(X_OR_Y<ImageLocator>(_mil->
_loc.template get<0>())()))[0],
302 (*(X_OR_Y<MaskLocator>(_mil->
_loc.template get<1>())()))[0],
303 (*(X_OR_Y<VarianceLocator>(_mil->
_loc.template get<2>())()))[0]);
306 typename Ref<ImagePixelT>::type
image() {
309 return (*(X_OR_Y<ImageLocator>(_mil->
_loc.template get<0>())()))[0];
311 typename Ref<MaskPixelT>::type
mask() {
312 return (*(X_OR_Y<MaskLocator>(_mil->
_loc.template get<1>())()))[0];
314 typename Ref<VariancePixelT>::type
variance() {
315 return (*(X_OR_Y<VarianceLocator>(_mil->
_loc.template get<2>())()))[0];
323 template <
typename LocT>
325 using IterT =
typename LocT::x_iterator;
328 apply_x(LocT& loc) :
_loc(loc) {}
335 template <
typename LocT>
337 using IterT =
typename LocT::y_iterator;
340 apply_y(LocT& loc) :
_loc(loc) {}
348 using IMVCachedLocation =
typename boost::tuple<typename ImageLocator::cached_location_t, typename MaskLocator::cached_location_t, typename VarianceLocator::cached_location_t>;
358 template <
typename,
typename,
typename>
373 :
_loc(img, msk, var) {
379 return Pixel(
_loc.template get<0>().x()[0][0],
_loc.template get<1>().x()[0][0],
380 _loc.template get<2>().x()[0][0]);
386 _loc.template get<2>()(
x,
y)[0]);
392 return Pixel(
_loc.template get<0>()[cached_loc._imv.template get<0>()][0],
393 _loc.template get<1>()[cached_loc._imv.template get<1>()][0],
394 _loc.template get<2>()[cached_loc._imv.template get<2>()][0]);
415 using PixelTVec =
typename boost::mpl::vector<ImagePixelT, MaskPixelT, VariancePixelT>;
417 template <
typename N>
418 typename Ref<typename boost::mpl::at<PixelTVec, N>::type>::type
apply_IMV(
419 cached_location_t
const& cached_loc) {
420 return _loc.template get<N::value>()[cached_loc._imv.template get<N::value>()][0];
418 typename Ref<typename boost::mpl::at<PixelTVec, N>::type>::type
apply_IMV( {
…}
423 template <
typename N>
424 typename Ref<typename boost::mpl::at<PixelTVec, N>::type>::type
apply_IMV() {
425 return _loc.template get<N::value>()[0][0];
424 typename Ref<typename boost::mpl::at<PixelTVec, N>::type>::type
apply_IMV() {
…}
428 template <
typename N>
429 typename Ref<typename boost::mpl::at<PixelTVec, N>::type>::type
apply_IMV(
int x,
int y) {
430 return _loc.template get<N::value>()(
x,
y)[0];
429 typename Ref<typename boost::mpl::at<PixelTVec, N>::type>::type
apply_IMV(
int x,
int y) {
…}
436 typename Ref<ImagePixelT>::type
image(cached_location_t
const& cached_loc) {
436 typename Ref<ImagePixelT>::type
image(cached_location_t
const& cached_loc) {
…}
445 typename Ref<MaskPixelT>::type
mask(cached_location_t
const& cached_loc) {
445 typename Ref<MaskPixelT>::type
mask(cached_location_t
const& cached_loc) {
…}
454 typename Ref<VariancePixelT>::type
variance(cached_location_t
const& cached_loc) {
454 typename Ref<VariancePixelT>::type
variance(cached_location_t
const& cached_loc) {
…}
466 return _loc.template get<0>() == rhs.
_loc.template get<0>();
472 return _loc.template get<0>() < rhs.
_loc.template get<0>();
477 return operator+=(detail::difference_type(p.first, p.second));
482 _loc.template get<0>() += p;
483 _loc.template get<1>() += p;
484 _loc.template get<2>() += p;
498 template <
typename ImageLocator,
typename MaskLocator,
typename VarianceLocator>
504 : MaskedImageLocatorBase_t(img, msk, var) {}
508 template <
typename ImageLocator,
typename MaskLocator,
typename VarianceLocator>
511 typename detail::const_locator_type<MaskLocator>::type,
512 typename detail::const_locator_type<VarianceLocator>::type,
514 using const_ImageLocator =
typename detail::const_locator_type<ImageLocator>::type;
515 using const_MaskLocator =
typename detail::const_locator_type<MaskLocator>::type;
516 using const_VarianceLocator =
typename detail::const_locator_type<VarianceLocator>::type;
522 : MaskedImageLocatorBase_t(const_ImageLocator(iter.
getLoc().template get<0>()),
523 const_MaskLocator(iter.
getLoc().template get<1>()),
524 const_VarianceLocator(iter.
getLoc().template get<2>())) {
530 using iterator = MaskedImageIterator<typename Image::iterator, typename Mask::iterator, typename Variance::iterator>;
532 using const_iterator = const_MaskedImageIterator<typename Image::iterator, typename Mask::iterator, typename Variance::iterator>;
534 using reverse_iterator = MaskedImageIterator<typename Image::reverse_iterator, typename Mask::reverse_iterator, typename Variance::reverse_iterator>;
537 typedef const_MaskedImageIterator<typename Image::reverse_iterator,
541 using x_iterator = MaskedImageIterator<typename Image::x_iterator, typename Mask::x_iterator, typename Variance::x_iterator>;
543 using const_x_iterator = const_MaskedImageIterator<typename Image::x_iterator, typename Mask::x_iterator, typename Variance::x_iterator>;
549 using y_iterator = MaskedImageIterator<typename Image::y_iterator, typename Mask::y_iterator, typename Variance::y_iterator>;
551 using const_y_iterator = const_MaskedImageIterator<typename Image::y_iterator, typename Mask::y_iterator, typename Variance::y_iterator>;
554 using xy_locator = MaskedImageLocator<typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator>;
556 using const_xy_locator = const_MaskedImageLocator<typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator>;
559 using xy_x_iterator =
typename MaskedImageLocator<typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator>::x_iterator;
561 using xy_y_iterator =
typename MaskedImageLocator<typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator>::y_iterator;
624 bool conformMasks =
false,
bool needAllHdus =
false,
629 bool allowUnsafe =
false);
652 bool conformMasks =
false,
bool needAllHdus =
false,
657 bool allowUnsafe =
false);
680 bool conformMasks =
false,
bool needAllHdus =
false,
685 bool allowUnsafe =
false);
706 bool const deep =
false);
712 template <
typename OtherPixelT>
717 : _image(), _mask(), _variance() {
720 "Only deep copies are permitted for MaskedImages with different pixel types");
1067 int getX0()
const {
return _image->getX0(); }
1075 int getY0()
const {
return _image->getY0(); }
1105 _image->setXY0(origin);
1109 _mask->setXY0(origin);
1113 _variance->setXY0(origin);
1192 return x_iterator(imageEnd, maskEnd, varianceEnd);
1211 return y_iterator(imageEnd, maskEnd, varianceEnd);
1226 return xy_locator(imageEnd, maskEnd, varianceEnd);
1230 void conformSizes();
1240template <
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
1252template <
typename ImagePixelT1,
typename ImagePixelT2>
1253bool imagesOverlap(MaskedImage<ImagePixelT1, MaskPixel, VariancePixel>
const& image1,
1254 MaskedImage<ImagePixelT2, MaskPixel, VariancePixel>
const& image2);
1274template <
typename ImageT,
typename TagT>
1276 using type = ImageT;
1280template <
typename ImageT>
1281struct GetImage_<ImageT, typename
image::detail::MaskedImage_tag> {
1282 using type =
typename ImageT::Image;
1287template <
typename ImageT>
1288struct GetImage :
public GetImage_<ImageT, typename ImageT::image_category> {};
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
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.
y_iterator y_at(int x, int y) const
Return an y_iterator to the point (x, y) in the image.
xy_locator xy_at(int x, int y) const
Return an xy_locator at the point (x, y) in the image.
typename _view_t::xy_locator xy_locator
x_iterator x_at(int x, int y) const
Return an x_iterator to the point (x, y) in the image.
std::pair< int, double > positionToIndex(double const pos, lsst::afw::image::xOrY const xy) const
Convert image position to index (nearest integer and fractional parts)
typename _view_t::reverse_iterator reverse_iterator
double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const
Convert image index to image position.
typename _view_t::x_iterator x_iterator
typename _view_t::y_iterator y_iterator
A class to represent a 2-dimensional array of pixels.
Represent a 2-dimensional array of bitmask pixels.
detail::MaskPlaneDict MaskPlaneDict
bool operator==(MaskedImageIteratorBase const &rhs)
Return true if the lhs equals the rhs.
MaskedImageIteratorBase operator++(int)
Increment the iterator (postfix)
const Pixel operator*() const
Dereference the iterator, returning a const Pixel.
std::ptrdiff_t operator-(MaskedImageIteratorBase const &rhs)
Return the distance between two iterators.
MaskedImageIteratorBase & operator++()
Increment the iterator (prefix)
bool operator!=(MaskedImageIteratorBase const &rhs)
Return true if the lhs doesn't equal the rhs.
boost::zip_iterator< IMV_iterator_tuple > _iter
Ref< ImagePixelT >::type image()
Return (a reference to) the image part of the Pixel pointed at by the iterator.
Ref< MaskPixelT >::type mask()
Return (a reference to) the mask part of the Pixel pointed at by the iterator.
Ref< VariancePixelT >::type variance()
Return (a reference to) the variance part of the Pixel pointed at by the iterator.
Pixel operator*()
Dereference the iterator, returning a Pixel.
Pixel type
Type pointed to by the iterator.
MaskedImageIteratorBase & operator-=(std::ptrdiff_t delta)
Decrement the iterator by delta
friend class const_MaskedImageIterator
typename boost::zip_iterator< IMV_iterator_tuple >::reference IMV_tuple
The underlying iterator tuple.
MaskedImageIteratorBase(ImageIterator const &img, MaskIterator const &msk, VarianceIterator const &var)
Construct a MaskedImageIteratorBase from the image/mask/variance iterators.
bool operator<(MaskedImageIteratorBase const &rhs)
Return true if the lhs is less than the rhs.
MaskedImageIteratorBase & operator+=(std::ptrdiff_t delta)
Increment the iterator by delta
const IMV_iterator_tuple get_iterator_tuple() const
Return the underlying iterator tuple.
An iterator to the MaskedImage.
MaskedImageIterator(ImageIterator &img, MaskIterator &msk, VarianceIterator &var)
MaskedImageIterator operator+(std::ptrdiff_t delta)
Return a MaskedImageIterator that's delta beyond this.
friend class const_MaskedImageLocator
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
typename boost::tuple< typename ImageLocator::cached_location_t, typename MaskLocator::cached_location_t, typename VarianceLocator::cached_location_t > IMVCachedLocation
Ref< typenameboost::mpl::at< PixelTVec, N >::type >::type apply_IMV(cached_location_t const &cached_loc)
IMVLocator const & getLoc() const
Pixel operator*()
Dereference a locator, returning a Pixel.
_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)
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...
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.
cached_location_t cache_location(int x, int y) const
Create a cached_location_t offset by (x, y) from locator.
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.
Ref< VariancePixelT >::type variance()
Return a reference to the variance at the current position of the locator.
MaskedImageLocatorBase & operator+=(pair2I const &p)
Increment the locator's x and y positions by p
Ref< ImagePixelT >::type image()
Return a reference to the image at the current position of the locator.
_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)
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
MaskedImageLocatorBase & operator+=(detail::difference_type p)
Increment the locator's x and y positions by p
Pixel operator()(int x, int y)
Dereference a locator, returning a Pixel offset by (x, y) from the locator.
y_iterator y()
Return an iterator that can be used to move (or dereference) a locator.
bool operator==(MaskedImageLocatorBase const &rhs)
Return true iff two locators are equal.
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
Ref< typenameboost::mpl::at< PixelTVec, N >::type >::type apply_IMV()
Ref< typenameboost::mpl::at< PixelTVec, N >::type >::type apply_IMV(int x, int y)
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.
Ref< MaskPixelT >::type mask()
Return a reference to the mask at the current position of the locator.
bool operator!=(MaskedImageLocatorBase const &rhs)
Return true iff two locators are not equal.
typename boost::mpl::vector< ImagePixelT, MaskPixelT, VariancePixelT > PixelTVec
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
bool operator<(MaskedImageLocatorBase const &rhs)
Return true iff lhs is less than rhs.
MaskedImageLocatorBase(ImageLocator const &img, MaskLocator const &msk, VarianceLocator const &var)
Construct a MaskedImageLocator from image/mask/variance locators.
x_iterator x()
Return an iterator that can be used to move (or dereference) a locator.
A locator for the MaskedImage.
MaskedImageLocator(ImageLocator &img, MaskLocator &msk, VarianceLocator &var)
An const iterator to the MaskedImage.
const_MaskedImageIterator & operator+(std::ptrdiff_t delta)
Return a const_MaskedImageIterator that's delta beyond this.
const_MaskedImageIterator(MaskedImageIterator< ImageIterator, MaskIterator, VarianceIterator > const &iter)
A const locator for the MaskedImage.
const_MaskedImageLocator(MaskedImageLocator< ImageLocator, MaskLocator, VarianceLocator > const &iter)
A class to manipulate images, masks, and variance as a single object.
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...
void scaledPlus(double const c, MaskedImage const &rhs)
Add a scaled MaskedImage c*rhs to a MaskedImage.
lsst::afw::image::Image< VarianceT > Variance
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)
Add a MaskedImage rhs to a MaskedImage.
MaskedImage & operator-=(lsst::afw::math::Function2< double > const &function)
fast_iterator begin(bool contiguous) const
Fast iterators to contiguous images.
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.
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.
MaskedImage & operator*=(MaskedImage const &rhs)
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.
int getX0() const
Return the image's column-origin.
std::pair< int, double > positionToIndex(double const pos, lsst::afw::image::xOrY const xy) const
Convert image position to index (see Image::positionToIndex)
MaskedImage(unsigned int width, unsigned int height, MaskPlaneDict const &planeDict=MaskPlaneDict())
Construct from a supplied dimensions.
void setXY0(lsst::geom::Point2I const origin)
Set the MaskedImage's origin.
lsst::geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
MaskedImage & operator*=(lsst::afw::image::Image< ImagePixelT > const &rhs)
void setVariance(Variance const &other)
Set the variance plane's pixel values to those of another Image.
void setXY0(int const x0, int const y0)
Set the MaskedImage's origin.
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.
const_MaskedImageLocator< typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator > const_xy_locator
static MaskedImage readFits(fits::MemFileManager &manager)
Read a MaskedImage from a FITS RAM file.
void scaledDivides(double const c, MaskedImage const &rhs)
const_MaskedImageIterator< typename Image::x_iterator, typename Mask::x_iterator, typename Variance::x_iterator > const_x_iterator
typename MaskedImageLocator< typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator >::y_iterator xy_y_iterator
MaskedImage(MaskedImage< OtherPixelT, MaskPixelT, VariancePixelT > const &rhs, const bool deep)
generalised copy constructor; defined here in the header so that the compiler can instantiate N(N-1)/...
MaskedImageIterator< typename Image::y_iterator, typename Mask::y_iterator, typename Variance::y_iterator > y_iterator
int getHeight() const
Return the number of rows in the image.
typename Mask< MaskT >::MaskPlaneDict MaskPlaneDict
int getY0() const
Return the image's row-origin.
virtual ~MaskedImage()=default
MaskedImage & operator=(MaskedImage &&rhs)
lsst::afw::image::pixel::Pixel< ImageT, MaskT, VarianceT > Pixel
iterator begin() const
Return an iterator to the start of the image.
lsst::afw::image::pixel::SinglePixel< ImageT, MaskT, VarianceT > SinglePixel
reverse_iterator rbegin() const
Return a reverse_iterator to the start of the image.
std::shared_ptr< image::Mask< MaskT > > MaskPtr
MaskedImageIterator< typename Image::x_iterator, typename Mask::x_iterator, typename Variance::x_iterator > x_iterator
void setMask(Mask const &other)
Set the mask plane's pixel values to those of another Mask.
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.
MaskedImage(MaskedImage const &rhs, bool const deep=false)
Copy constructor; shallow, unless deep is true.
lsst::afw::image::Mask< MaskT > Mask
y_iterator col_end(int x) const
Return an y_iterator to the end of the image.
void scaledMinus(double const c, MaskedImage const &rhs)
Subtract a scaled MaskedImage c*rhs from a MaskedImage.
MaskedImage & operator=(SinglePixel const &rhs)
Set the pixels in the MaskedImage to the rhs.
std::shared_ptr< image::Image< ImageT > > ImagePtr
MaskedImageLocator< typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator > xy_locator
lsst::geom::Extent2I getDimensions() const
MaskedImage(lsst::geom::Extent2I const &dimensions=lsst::geom::Extent2I(), MaskPlaneDict const &planeDict=MaskPlaneDict())
Construct from a supplied dimensions.
lsst::geom::Point2I getXY0() const
Return the image's origin.
MaskedImageIterator< typename Image::reverse_iterator, typename Mask::reverse_iterator, typename Variance::reverse_iterator > reverse_iterator
MaskedImageIterator< typename Image::iterator, typename Mask::iterator, typename Variance::iterator > iterator
xy_locator xy_at(int x, int y) const
Return an xy_locator at the point (x, y)
MaskedImage & operator-=(ImagePixelT const rhs)
Subtract a scalar rhs from a MaskedImage.
int getWidth() const
Return the number of columns in the image.
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.
const_MaskedImageIterator< typename Image::iterator, typename Mask::iterator, typename Variance::iterator > const_iterator
x_iterator row_end(int y) const
Return an x_iterator to the end of the image.
MaskedImage subset(lsst::geom::Box2I const &bbox, ImageOrigin origin=PARENT) const
Return a subimage corresponding to the given box.
void scaledMultiplies(double const c, MaskedImage const &rhs)
MaskedImage & operator/=(MaskedImage const &rhs)
iterator end() const
Return an iterator to the end of the image.
MaskedImage & operator/=(lsst::afw::image::Image< ImagePixelT > const &rhs)
typename MaskedImageLocator< typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator >::x_iterator xy_x_iterator
MaskedImage & operator-=(lsst::afw::image::Image< ImagePixelT > const &rhs)
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.
VariancePtr getVariance() const
Return a (shared_ptr to) the MaskedImage's variance.
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.
MaskedImage & operator+=(lsst::afw::image::Image< ImagePixelT > const &rhs)
MaskedImage & operator=(MaskedImage const &rhs)
Make the lhs use the rhs's pixels.
MaskedImage(MaskedImage &&rhs)
lsst::afw::image::Image< ImageT > Image
x_iterator row_begin(int y) const
Return an x_iterator to the start of the image.
void swap(MaskedImage &rhs)
MaskedImage & operator=(Pixel const &rhs)
Set the pixels in the MaskedImage to the rhs.
double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const
Convert image index to image position (see Image::indexToPosition)
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.
void setImage(Image const &other)
Set the image plane's pixel values to those of another Image.
y_iterator col_begin(int x) const
Return an y_iterator to the start of the image.
std::shared_ptr< image::Image< VarianceT > > VariancePtr
reverse_iterator rend() const
Return a reverse_iterator to the end of the image.
static MaskedImage readFits(std::string const &filename)
Read a MaskedImage from a regular FITS file.
MaskedImage & operator+=(ImagePixelT const rhs)
Add a scalar rhs to a MaskedImage.
x_iterator x_at(int x, int y) const
Return an x_iterator at the point (x, y)
MaskedImage & operator*=(ImagePixelT const rhs)
iterator at(int const x, int const y) const
Return an iterator at the point (x, y)
MaskedImage & operator/=(ImagePixelT const rhs)
MaskedImage & operator-=(MaskedImage const &rhs)
Subtract a MaskedImage rhs from a MaskedImage.
y_iterator y_at(int x, int y) const
Return an y_iterator at the point (x, y)
MaskedImage(ImagePtr image, MaskPtr mask=MaskPtr(), VariancePtr variance=VariancePtr())
Construct from a supplied Image and optional Mask and Variance.
MaskedImage(lsst::geom::Box2I const &bbox, MaskPlaneDict const &planeDict=MaskPlaneDict())
Create an MaskedImage of the specified size.
MaskPtr getMask() const
Return a (shared_ptr to) the MaskedImage's mask.
detail::MaskedImage_tag image_category
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.
const_MaskedImageIterator< typename Image::y_iterator, typename Mask::y_iterator, typename Variance::y_iterator > const_y_iterator
MaskedImage & operator+=(lsst::afw::math::Function2< double > const &function)
ImagePtr getImage() const
Return a (shared_ptr to) the MaskedImage's image.
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.
A pixel of a MaskedImage.
A single pixel of the same type as a MaskedImage.
A Function taking two arguments.
An integer coordinate rectangle.
Reports invalid arguments.
std::string const fitsFile_RE
regexp to identify when MaskedImages should be written as MEFs
std::string const compressedFileNoMEF_RE
regexp to identify compressed files that we can't write MEFs to
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks
float VariancePixel
default type for MaskedImage variance images
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 >())
A function to return a MaskedImage of the correct type (cf.
bool imagesOverlap(ImageBase< T1 > const &image1, ImageBase< T2 > const &image2)
Return true if the pixels for two images or masks overlap in memory.
Extent< int, 2 > Extent2I
Options for writing an image to FITS.
A templated class to return this classes' type (present in Image/Mask/MaskedImage)
MaskedImage< ImagePT, MaskPT, VarPT > type
Return the desired type.
metafunction to extract reference type from PixelT
A traits class for MaskedImage.
A class used to identify classes that represent MaskedImage pixels.