29 #ifndef LSST_IMAGE_MASKEDIMAGE_H
30 #define LSST_IMAGE_MASKEDIMAGE_H
38 #include "boost/mpl/at.hpp"
39 #include "boost/iterator/zip_iterator.hpp"
40 #include "boost/tuple/tuple.hpp"
42 #include "lsst/daf/base/Citizen.h"
43 #include "lsst/daf/base/Persistable.h"
71 namespace formatters {
72 template <
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
73 class MaskedImageFormatter;
81 class MaskedImage :
public lsst::daf::base::Persistable,
public lsst::daf::base::Citizen {
84 typedef std::shared_ptr<image::Image<ImagePixelT>>
ImagePtr;
86 typedef std::shared_ptr<image::Mask<MaskPixelT>>
MaskPtr;
88 typedef std::shared_ptr<image::Image<VariancePixelT>>
VariancePtr;
99 template <
typename ImagePT = ImagePixelT,
typename MaskPT = MaskPixelT,
typename VarPT = VariancePixelT>
106 template <
typename,
typename,
typename>
109 template <
typename,
typename,
typename>
112 template <
typename,
typename,
typename>
115 template <
typename,
typename,
typename>
116 class const_MaskedImageLocator;
124 template <
typename ImageIterator,
typename MaskIterator,
typename VarianceIterator,
125 template <
typename>
class Ref =
Reference>
127 typedef boost::tuple<ImageIterator, MaskIterator, VarianceIterator> IMV_iterator_tuple;
133 typedef typename boost::zip_iterator<IMV_iterator_tuple>::reference
IMV_tuple;
137 template <
typename,
typename,
typename>
144 VarianceIterator
const& var)
145 :
_iter(boost::make_zip_iterator(boost::make_tuple(img, msk, var))) {}
147 typename Ref<ImagePixelT>::type
image() {
return _iter->template get<0>()[0]; }
150 typename Ref<MaskPixelT>::type
mask() {
return _iter->template get<1>()[0]; }
153 typename Ref<VariancePixelT>::type
variance() {
return _iter->template get<2>()[0]; }
185 return &this->
_iter->template get<0>() - &rhs.
_iter->template get<0>();
189 return &this->
_iter->template get<0>() == &rhs.
_iter->template get<0>();
193 return &this->
_iter->template get<0>() != &rhs.
_iter->template get<0>();
197 return &this->
_iter->template get<0>() < &rhs.
_iter->template get<0>();
202 _iter->template get<2>()[0]);
211 typename boost::zip_iterator<IMV_iterator_tuple>
_iter;
215 template <
typename ImageIterator,
typename MaskIterator,
typename VarianceIterator>
219 MaskedImageIteratorBase_t;
234 template <
typename ImageIterator,
typename MaskIterator,
typename VarianceIterator>
235 class const_MaskedImageIterator
236 :
public MaskedImageIteratorBase<typename detail::const_iterator_type<ImageIterator>::type,
237 typename detail::const_iterator_type<MaskIterator>::type,
238 typename detail::const_iterator_type<VarianceIterator>::type,
240 typedef typename detail::const_iterator_type<ImageIterator>::type const_ImageIterator;
241 typedef typename detail::const_iterator_type<MaskIterator>::type const_MaskIterator;
242 typedef typename detail::const_iterator_type<VarianceIterator>::type const_VarianceIterator;
246 MaskedImageIteratorBase_t;
267 template <
typename ImageLocator,
typename MaskLocator,
typename VarianceLocator,
268 template <
typename>
class Ref =
Reference>
270 typedef typename boost::tuple<ImageLocator, MaskLocator, VarianceLocator> IMVLocator;
276 template <
template <
typename>
class X_OR_Y>
277 class _x_or_y_iterator {
283 X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())() += di;
284 X_OR_Y<MaskLocator>(_mil->_loc.template get<1>())() += di;
285 X_OR_Y<VarianceLocator>(_mil->_loc.template get<2>())() += di;
289 _x_or_y_iterator& operator++() {
291 ++X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())();
292 ++X_OR_Y<MaskLocator>(_mil->_loc.template get<1>())();
293 ++X_OR_Y<VarianceLocator>(_mil->_loc.template get<2>())();
297 bool operator==(_x_or_y_iterator
const& rhs) {
298 return X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())() ==
299 X_OR_Y<ImageLocator>(rhs._mil->_loc.template get<0>())();
301 bool operator!=(_x_or_y_iterator
const& rhs) {
302 return X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())() !=
303 X_OR_Y<ImageLocator>(rhs._mil->_loc.template get<0>())();
305 bool operator<(_x_or_y_iterator
const& rhs) {
306 return X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())() <
307 X_OR_Y<ImageLocator>(rhs._mil->_loc.template get<0>())();
311 return Pixel((*(X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())()))[0],
312 (*(X_OR_Y<MaskLocator>(_mil->_loc.template get<1>())()))[0],
313 (*(X_OR_Y<VarianceLocator>(_mil->_loc.template get<2>())()))[0]);
316 typename Ref<ImagePixelT>::type
image() {
319 return (*(X_OR_Y<ImageLocator>(_mil->_loc.template get<0>())()))[0];
321 typename Ref<MaskPixelT>::type
mask() {
322 return (*(X_OR_Y<MaskLocator>(_mil->_loc.template get<1>())()))[0];
324 typename Ref<VariancePixelT>::type
variance() {
325 return (*(X_OR_Y<VarianceLocator>(_mil->_loc.template get<2>())()))[0];
333 template <
typename LocT>
335 typedef typename LocT::x_iterator IterT;
338 apply_x(LocT& loc) :
_loc(loc) {}
345 template <
typename LocT>
347 typedef typename LocT::y_iterator IterT;
350 apply_y(LocT& loc) :
_loc(loc) {}
358 typedef typename boost::tuple<
typename ImageLocator::cached_location_t,
359 typename MaskLocator::cached_location_t,
360 typename VarianceLocator::cached_location_t>
371 template <
typename,
typename,
typename>
386 :
_loc(img, msk, var) {
392 return Pixel(
_loc.template get<0>().x()[0][0],
_loc.template get<1>().
x()[0][0],
393 _loc.template get<2>().
x()[0][0]);
398 return Pixel(
_loc.template get<0>()(x, y)[0],
_loc.template get<1>()(x, y)[0],
399 _loc.template get<2>()(x, y)[0]);
405 return Pixel(
_loc.template get<0>()[cached_loc._imv.template get<0>()][0],
406 _loc.template get<1>()[cached_loc._imv.template get<1>()][0],
407 _loc.template get<2>()[cached_loc._imv.template get<2>()][0]);
428 typedef typename boost::mpl::vector<ImagePixelT, MaskPixelT, VariancePixelT>
PixelTVec;
430 template <
typename N>
431 typename Ref<typename boost::mpl::at<PixelTVec, N>::type>::type
apply_IMV(
432 cached_location_t
const& cached_loc) {
433 return _loc.template get<N::value>()[cached_loc._imv.template get<N::value>()][0];
436 template <
typename N>
437 typename Ref<typename boost::mpl::at<PixelTVec, N>::type>::type
apply_IMV() {
438 return _loc.template get<N::value>()[0][0];
441 template <
typename N>
442 typename Ref<typename boost::mpl::at<PixelTVec, N>::type>::type
apply_IMV(
int x,
int y) {
443 return _loc.template get<N::value>()(x, y)[0];
449 typename Ref<ImagePixelT>::type
image(cached_location_t
const& cached_loc) {
450 return apply_IMV<boost::mpl::int_<0>>(cached_loc);
453 typename Ref<ImagePixelT>::type
image() {
return apply_IMV<boost::mpl::int_<0>>(); }
455 typename Ref<ImagePixelT>::type
image(
int x,
int y) {
return apply_IMV<boost::mpl::int_<0>>(
x,
y); }
458 typename Ref<MaskPixelT>::type
mask(cached_location_t
const& cached_loc) {
459 return apply_IMV<boost::mpl::int_<1>>(cached_loc);
462 typename Ref<MaskPixelT>::type
mask() {
return apply_IMV<boost::mpl::int_<1>>(); }
464 typename Ref<MaskPixelT>::type
mask(
int x,
int y) {
return apply_IMV<boost::mpl::int_<1>>(
x,
y); }
467 typename Ref<VariancePixelT>::type
variance(cached_location_t
const& cached_loc) {
468 return apply_IMV<boost::mpl::int_<2>>(cached_loc);
471 typename Ref<VariancePixelT>::type
variance() {
return apply_IMV<boost::mpl::int_<2>>(); }
474 return apply_IMV<boost::mpl::int_<2>>(
x,
y);
479 return _loc.template get<0>() == rhs.
_loc.template get<0>();
485 return _loc.template get<0>() < rhs.
_loc.template get<0>();
490 return operator+=(detail::difference_type(p.first, p.second));
495 _loc.template get<0>() += p;
496 _loc.template get<1>() += p;
497 _loc.template get<2>() += p;
511 template <
typename ImageLocator,
typename MaskLocator,
typename VarianceLocator>
521 template <
typename ImageLocator,
typename MaskLocator,
typename VarianceLocator>
522 class const_MaskedImageLocator
523 :
public MaskedImageLocatorBase<typename detail::const_locator_type<ImageLocator>::type,
524 typename detail::const_locator_type<MaskLocator>::type,
525 typename detail::const_locator_type<VarianceLocator>::type,
527 typedef typename detail::const_locator_type<ImageLocator>::type const_ImageLocator;
528 typedef typename detail::const_locator_type<MaskLocator>::type const_MaskLocator;
529 typedef typename detail::const_locator_type<VarianceLocator>::type const_VarianceLocator;
533 MaskedImageLocatorBase_t;
538 const_MaskLocator(iter.
getLoc().template get<1>()),
539 const_VarianceLocator(iter.
getLoc().template get<2>())) {
556 #if 0 // doesn't compile. I should fix this, but it's low priority. RHL
606 explicit MaskedImage(
unsigned int width,
unsigned int height,
654 std::string
const& fileName,
655 std::shared_ptr<daf::base::PropertySet> metadata = std::shared_ptr<daf::base::PropertySet>(),
657 bool needAllHdus =
false,
658 std::shared_ptr<daf::base::PropertySet> imageMetadata = std::shared_ptr<daf::base::PropertySet>(),
659 std::shared_ptr<daf::base::PropertySet> maskMetadata = std::shared_ptr<daf::base::PropertySet>(),
660 std::shared_ptr<daf::base::PropertySet> varianceMetadata =
661 std::shared_ptr<daf::base::PropertySet>());
680 std::shared_ptr<daf::base::PropertySet> metadata = std::shared_ptr<daf::base::PropertySet>(),
682 bool needAllHdus =
false,
683 std::shared_ptr<daf::base::PropertySet> imageMetadata = std::shared_ptr<daf::base::PropertySet>(),
684 std::shared_ptr<daf::base::PropertySet> maskMetadata = std::shared_ptr<daf::base::PropertySet>(),
685 std::shared_ptr<daf::base::PropertySet> varianceMetadata =
686 std::shared_ptr<daf::base::PropertySet>());
705 std::shared_ptr<daf::base::PropertySet> metadata = std::shared_ptr<daf::base::PropertySet>(),
707 bool needAllHdus =
false,
708 std::shared_ptr<daf::base::PropertySet> imageMetadata = std::shared_ptr<daf::base::PropertySet>(),
709 std::shared_ptr<daf::base::PropertySet> maskMetadata = std::shared_ptr<daf::base::PropertySet>(),
710 std::shared_ptr<daf::base::PropertySet> varianceMetadata =
711 std::shared_ptr<daf::base::PropertySet>());
730 bool const deep =
false);
736 template <
typename OtherPixelT>
741 : lsst::daf::base::Citizen(typeid(this)), _image(), _mask(), _variance() {
743 throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
744 "Only deep copies are permitted for MaskedImages with different pixel types");
886 void writeFits(std::string
const& fileName, std::shared_ptr<daf::base::PropertySet const> metadata =
887 std::shared_ptr<daf::base::PropertySet const>(),
888 std::shared_ptr<daf::base::PropertySet const> imageMetadata =
889 std::shared_ptr<daf::base::PropertySet const>(),
890 std::shared_ptr<daf::base::PropertySet const> maskMetadata =
891 std::shared_ptr<daf::base::PropertySet const>(),
892 std::shared_ptr<daf::base::PropertySet const> varianceMetadata =
893 std::shared_ptr<daf::base::PropertySet const>())
const;
909 std::shared_ptr<daf::base::PropertySet const>(),
910 std::shared_ptr<daf::base::PropertySet const> imageMetadata =
911 std::shared_ptr<daf::base::PropertySet const>(),
912 std::shared_ptr<daf::base::PropertySet const> maskMetadata =
913 std::shared_ptr<daf::base::PropertySet const>(),
914 std::shared_ptr<daf::base::PropertySet const> varianceMetadata =
915 std::shared_ptr<daf::base::PropertySet const>())
const;
930 void writeFits(
fits::Fits& fitsfile, std::shared_ptr<daf::base::PropertySet const> metadata =
931 std::shared_ptr<daf::base::PropertySet const>(),
932 std::shared_ptr<daf::base::PropertySet const> imageMetadata =
933 std::shared_ptr<daf::base::PropertySet const>(),
934 std::shared_ptr<daf::base::PropertySet const> maskMetadata =
935 std::shared_ptr<daf::base::PropertySet const>(),
936 std::shared_ptr<daf::base::PropertySet const> varianceMetadata =
937 std::shared_ptr<daf::base::PropertySet const>())
const;
956 std::string
const& fileName,
960 std::shared_ptr<daf::base::PropertySet const> metadata =
nullptr,
961 std::shared_ptr<daf::base::PropertySet const> imageMetadata =
nullptr,
962 std::shared_ptr<daf::base::PropertySet const> maskMetadata =
nullptr,
963 std::shared_ptr<daf::base::PropertySet const> varianceMetadata =
nullptr
987 std::shared_ptr<daf::base::PropertySet const> metadata =
nullptr,
988 std::shared_ptr<daf::base::PropertySet const> imageMetadata =
nullptr,
989 std::shared_ptr<daf::base::PropertySet const> maskMetadata =
nullptr,
990 std::shared_ptr<daf::base::PropertySet const> varianceMetadata =
nullptr
1014 std::shared_ptr<daf::base::PropertySet const> metadata =
nullptr,
1015 std::shared_ptr<daf::base::PropertySet const> imageMetadata =
nullptr,
1016 std::shared_ptr<daf::base::PropertySet const> maskMetadata =
nullptr,
1017 std::shared_ptr<daf::base::PropertySet const> varianceMetadata =
nullptr
1089 int getX0()
const {
return _image->getX0(); }
1097 int getY0()
const {
return _image->getY0(); }
1127 _image->setXY0(origin);
1131 _mask->setXY0(origin);
1135 _variance->setXY0(origin);
1147 return getImage()->indexToPosition(ind, xy);
1159 return getImage()->positionToIndex(pos, xy);
1208 #else // bypass checks for non-NULL pointers
1214 return x_iterator(imageEnd, maskEnd, varianceEnd);
1228 #else // bypass checks for non-NULL pointers
1233 return y_iterator(imageEnd, maskEnd, varianceEnd);
1242 #else // bypass checks for non-NULL pointers
1248 return xy_locator(imageEnd, maskEnd, varianceEnd);
1253 LSST_PERSIST_FORMATTER(
1256 void conformSizes();
1266 template <
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
1293 template <
typename ImageT,
typename TagT>
1295 typedef ImageT type;
1296 static std::shared_ptr<type> getImage(std::shared_ptr<ImageT> image) {
return image; }
1299 template <
typename ImageT>
1300 struct GetImage_<ImageT, typename image::detail::MaskedImage_tag> {
1301 typedef typename ImageT::Image type;
1302 static std::shared_ptr<type> getImage(std::shared_ptr<ImageT> image) {
return image->getImage(); }
1306 template <
typename ImageT>
1307 struct GetImage :
public GetImage_<ImageT, typename ImageT::image_category> {};
1312 #endif // LSST_IMAGE_MASKEDIMAGE_H
MaskedImageLocatorBase & operator+=(detail::difference_type p)
Increment the locator's x and y positions by p
afw::table::PointKey< int > dimensions
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< 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 ...
x_iterator row_begin(int y) const
Return an x_iterator to the start of the image.
void scaledDivides(double const c, MaskedImage const &rhs)
y_iterator col_begin(int x) const
Return an y_iterator to the start of the image.
Ref< MaskPixelT >::type mask()
Return (a reference to) the mask part of the Pixel pointed at by the iterator.
MaskedImageIterator(ImageIterator &img, MaskIterator &msk, VarianceIterator &var)
Ref< MaskPixelT >::type mask()
Return a reference to the mask at the current position of the locator.
MaskedImage & operator=(MaskedImage const &rhs)
Make the lhs use the rhs's pixels.
const_MaskedImageLocator< typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator > const_xy_locator
A const_locator for a MaskedImage.
y_iterator y()
Return an iterator that can be used to move (or dereference) a locator.
MaskedImageIteratorBase(ImageIterator const &img, MaskIterator const &msk, VarianceIterator const &var)
Construct a MaskedImageIteratorBase from the image/mask/variance iterators.
The base class for MaskedImageLocators (const and non-const)
MaskedImage & operator-=(lsst::afw::math::Function2< double > const &function)
Ref< typename boost::mpl::at< PixelTVec, N >::type >::type apply_IMV(int x, int y)
boost::mpl::vector< ImagePixelT, MaskPixelT, VariancePixelT > PixelTVec
_view_t::reverse_iterator reverse_iterator
An STL compliant reverse iterator.
std::shared_ptr< image::Mask< MaskPixelT > > MaskPtr
shared pointer to the Mask
const_MaskedImageIterator< typename Image::iterator, typename Mask::iterator, typename Variance::iterator > const_iterator
boost::zip_iterator< IMV_iterator_tuple > _iter
Pixel type
Type pointed to by the iterator.
A templated class to return this classes' type (present in Image/Mask/MaskedImage) ...
Pixel operator()(int x, int y)
Dereference a locator, returning a Pixel offset by (x, y) from the locator.
lsst::afw::image::pixel::Pixel< ImagePixelT, MaskPixelT, VariancePixelT > Pixel
A Pixel in the MaskedImage.
VariancePtr getVariance() const
Return a (shared_ptr to) the MaskedImage's variance.
x_iterator fast_iterator
A fast STL compliant iterator for contiguous images N.b.
boost::tuple< typename ImageLocator::cached_location_t, typename MaskLocator::cached_location_t, typename VarianceLocator::cached_location_t > IMVCachedLocation
int getHeight() const
Return the number of rows in the image.
int getX0() const
Return the image's column-origin.
void scaledPlus(double const c, MaskedImage const &rhs)
Add a scaled MaskedImage c*rhs to a MaskedImage.
Pixel operator*()
Dereference a locator, returning a Pixel.
Options for writing an image to FITS.
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...
bool operator==(MaskedImageIteratorBase const &rhs)
Return true if the lhs equals the rhs.
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
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< typename boost::mpl::at< PixelTVec, N >::type >::type apply_IMV(cached_location_t const &cached_loc)
The base class for MaskedImageIterators (const and non-const)
geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
detail::MaskPlaneDict MaskPlaneDict
MaskedImageIterator< typename Image::x_iterator, typename Mask::x_iterator, typename Variance::x_iterator > x_iterator
An iterator to a row of a MaskedImage.
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 ...
reverse_iterator rend() const
Return a reverse_iterator to the end of the image.
lsst::afw::image::pixel::SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > SinglePixel
A single Pixel of the same type as those in the MaskedImage.
ImagePtr getImage() const
Return a (shared_ptr to) the MaskedImage's image.
A single pixel of the same type as a MaskedImage.
std::shared_ptr< image::Image< VariancePixelT > > VariancePtr
shared pointer to the variance Image
void setXY0(geom::Point2I const origin)
Set the MaskedImage's origin.
MaskedImageIteratorBase operator++(int)
Increment the iterator (postfix)
MaskedImage & operator-=(lsst::afw::image::Image< ImagePixelT > const &rhs)
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 ...
void assign(MaskedImage const &rhs, geom::Box2I const &bbox=geom::Box2I(), ImageOrigin origin=PARENT)
Copy pixels from another masked image to a specified subregion of this masked image.
void swap(MaskedImage &rhs)
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
lsst::afw::image::Mask< MaskPixelT > Mask
MaskedImageIteratorBase & operator+=(std::ptrdiff_t delta)
Increment the iterator by delta
A Function taking two arguments.
geom::Extent2I getDimensions() const
MaskedImage(unsigned int width, unsigned int height, MaskPlaneDict const &planeDict=MaskPlaneDict())
Construct from a supplied dimensions.
MaskedImage & operator+=(ImagePixelT const rhs)
Add a scalar rhs to a MaskedImage.
MaskPtr getMask() const
Return a (shared_ptr to) the MaskedImage's mask.
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.
MaskedImageIterator< typename Image::iterator, typename Mask::iterator, typename Variance::iterator > iterator
An integer coordinate rectangle.
Ref< VariancePixelT >::type variance()
Return (a reference to) the variance part of the Pixel pointed at by the iterator.
bool operator==(MaskedImageLocatorBase const &rhs)
Return true iff two locators are equal.
Mask< MaskPixelT >::MaskPlaneDict MaskPlaneDict
The Mask's MaskPlaneDict.
xy_locator xy_at(int x, int y) const
Return an xy_locator at the point (x, y)
An iterator to the MaskedImage.
MaskedImage & operator/=(lsst::afw::image::Image< ImagePixelT > const &rhs)
bool operator!=(MaskedImageIteratorBase const &rhs)
Return true if the lhs doesn't equal the rhs.
MaskedImage & operator+=(lsst::afw::math::Function2< double > const &function)
_view_t::iterator iterator
An STL compliant iterator.
const_MaskedImageIterator & operator+(std::ptrdiff_t delta)
Return a const_MaskedImageIterator that's delta beyond this.
A locator for the MaskedImage.
_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) ...
double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const
Convert image index to image position (see Image::indexToPosition)
x_iterator x_at(int x, int y) const
Return an x_iterator at the point (x, y)
MaskedImageLocator(ImageLocator &img, MaskLocator &msk, VarianceLocator &var)
MaskedImage & operator<<=(MaskedImage const &rhs)
Copy the pixels from the rhs to the lhs.
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)/...
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.
static MaskedImage readFits(fits::MemFileManager &manager)
Read a MaskedImage from a FITS RAM file.
Represent a 2-dimensional array of bitmask pixels.
MaskedImageIterator< typename Image::y_iterator, typename Mask::y_iterator, typename Variance::y_iterator > y_iterator
An iterator to a column of a MaskedImage.
Lifetime-management for memory that goes into FITS memory files.
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.
A traits class for MaskedImage.
_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) ...
const_MaskedImageIterator(MaskedImageIterator< ImageIterator, MaskIterator, VarianceIterator > const &iter)
A class to manipulate images, masks, and variance as a single object.
_view_t::y_iterator y_iterator
An iterator for traversing the pixels in a column.
IMVLocator const & getLoc() const
MaskedImageIterator< typename Image::reverse_iterator, typename Mask::reverse_iterator, typename Variance::reverse_iterator > reverse_iterator
std::shared_ptr< image::Image< ImagePixelT > > ImagePtr
shared pointer to the Image
detail::MaskedImage_tag image_category
boost::zip_iterator< IMV_iterator_tuple >::reference IMV_tuple
The underlying iterator tuple.
Ref< ImagePixelT >::type image()
Return (a reference to) the image part of the Pixel pointed at by the iterator.
A saved relative position, providing efficient access to neighbouring pixels.
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks
Pixel operator*()
Dereference the iterator, returning a Pixel.
void scaledMultiplies(double const c, MaskedImage const &rhs)
void setMask(Mask const &other)
Set the mask plane's pixel values to those of another Mask.
const Pixel operator*() const
Dereference the iterator, returning a const Pixel.
bool operator!=(MaskedImageLocatorBase const &rhs)
Return true iff two locators are not equal.
lsst::afw::image::Image< VariancePixelT > Variance
iterator begin() const
Return an iterator to the start of the image.
std::string const compressedFileNoMEF_RE
regexp to identify compressed files that we can't write MEFs to
MaskedImageIterator operator+(std::ptrdiff_t delta)
Return a MaskedImageIterator that's delta beyond this.
std::ptrdiff_t operator-(MaskedImageIteratorBase const &rhs)
Return the distance between two iterators.
reverse_iterator rbegin() const
Return a reverse_iterator to the start of the image.
Ref< ImagePixelT >::type image()
Return a reference to the image at the current position of the locator.
x_iterator x()
Return an iterator that can be used to move (or dereference) a locator.
A pixel of a MaskedImage.
MaskedImageIteratorBase & operator++()
Increment the iterator (prefix)
An const iterator to the MaskedImage.
MaskedImage & operator+=(lsst::afw::image::Image< ImagePixelT > const &rhs)
std::string const fitsFile_RE
regexp to identify when MaskedImages should be written as MEFs
cached_location_t cache_location(int x, int y) const
Create a cached_location_t offset by (x, y) from locator.
MaskedImageIteratorBase & operator-=(std::ptrdiff_t delta)
Decrement the iterator by delta
x_iterator row_end(int y) const
Return an x_iterator to the end of the image.
void setXY0(int const x0, int const y0)
Set the MaskedImage's origin.
geom::Point2I getXY0() const
Return the image's origin.
bool operator<(MaskedImageLocatorBase const &rhs)
Return true iff lhs is less than rhs.
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.
void setImage(Image const &other)
Set the image plane's pixel values to those of another Image.
Ref< VariancePixelT >::type variance()
Return a reference to the variance at the current position of the locator.
int getWidth() const
Return the number of columns in the image.
int getY0() const
Return the image's row-origin.
const IMV_iterator_tuple get_iterator_tuple() const
Return the underlying iterator tuple.
MaskedImage & operator/=(ImagePixelT const rhs)
void setVariance(Variance const &other)
Set the variance plane's pixel values to those of another Image.
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
static MaskedImage readFits(std::string const &filename)
Read a MaskedImage from a regular FITS file.
MaskedImage & operator*=(ImagePixelT const rhs)
MaskedImage & operator*=(lsst::afw::image::Image< ImagePixelT > const &rhs)
MaskedImage< ImagePT, MaskPT, VarPT > type
Return the desired type.
iterator end() const
Return an iterator to the end of the image.
MaskedImage & operator-=(ImagePixelT const rhs)
Subtract a scalar rhs from a MaskedImage.
lsst::afw::image::Image< ImagePixelT > Image
MaskedImageLocator< typename Image::xy_locator, typename Mask::xy_locator, typename Variance::xy_locator > xy_locator
A locator for a MaskedImage.
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
bool operator<(MaskedImageIteratorBase const &rhs)
Return true if the lhs is less than the rhs.
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 ...
float VariancePixel
default type for MaskedImage variance images
A class used to identify classes that represent MaskedImage pixels.
iterator at(int const x, int const y) const
Return an iterator at the point (x, y)
MaskedImageLocatorBase(ImageLocator const &img, MaskLocator const &msk, VarianceLocator const &var)
Construct a MaskedImageLocator from image/mask/variance locators.
_view_t::xy_locator xy_locator
An xy_locator.
y_iterator y_at(int x, int y) const
Return an y_iterator at the point (x, y)
A class to represent a 2-dimensional array of pixels.
MaskedImageLocatorBase & operator+=(pair2I const &p)
Increment the locator's x and y positions by p
const_MaskedImageLocator(MaskedImageLocator< ImageLocator, MaskLocator, VarianceLocator > const &iter)
void scaledMinus(double const c, MaskedImage const &rhs)
Subtract a scaled MaskedImage c*rhs from a MaskedImage.
y_iterator col_end(int x) const
Return an y_iterator to the end of the image.
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.
std::pair< int, double > positionToIndex(double const pos, lsst::afw::image::xOrY const xy) const
Convert image position to index (see Image::positionToIndex)
A const locator for the MaskedImage.
metafunction to extract reference type from PixelT
Ref< typename boost::mpl::at< PixelTVec, N >::type >::type apply_IMV()
metafunction to extract const reference type from PixelT