30 #ifndef LSST_AFW_IMAGE_IMAGE_H
31 #define LSST_AFW_IMAGE_IMAGE_H
37 #include "boost/mpl/bool.hpp"
49 #include "lsst/daf/base.h"
50 #include "lsst/daf/base/Citizen.h"
51 #include "lsst/pex/exceptions.h"
57 namespace formatters {
58 template <
typename PixelT>
60 template <
typename PixelT>
61 class DecoratedImageFormatter;
67 template <
typename PixelT>
70 template <
typename,
typename,
typename>
76 template <
typename ImagePT = PixelT>
81 template <
typename OtherPixelT>
94 explicit Image(
unsigned int width,
unsigned int height, PixelT initialValue = 0);
127 const bool deep =
false);
137 Image(
const Image& rhs,
const bool deep =
false);
151 explicit Image(std::string
const& fileName,
int hdu = INT_MIN,
152 std::shared_ptr<lsst::daf::base::PropertySet> metadata =
153 std::shared_ptr<lsst::daf::base::PropertySet>(),
169 std::shared_ptr<lsst::daf::base::PropertySet> metadata =
170 std::shared_ptr<lsst::daf::base::PropertySet>(),
182 explicit Image(
fits::Fits& fitsfile, std::shared_ptr<lsst::daf::base::PropertySet> metadata =
183 std::shared_ptr<lsst::daf::base::PropertySet>(),
187 template <
typename OtherPixelT>
190 explicit Image(ndarray::Array<PixelT, 2, 1>
const& array,
bool deep =
false,
218 void writeFits(std::string
const& fileName, std::shared_ptr<lsst::daf::base::PropertySet const> metadata =
219 std::shared_ptr<lsst::daf::base::PropertySet const>(),
220 std::string
const& mode =
"w")
const;
230 std::shared_ptr<lsst::daf::base::PropertySet const> metadata =
231 std::shared_ptr<lsst::daf::base::PropertySet const>(),
232 std::string
const& mode =
"w")
const;
240 void writeFits(
fits::Fits& fitsfile, std::shared_ptr<lsst::daf::base::PropertySet const> metadata =
241 std::shared_ptr<lsst::daf::base::PropertySet const>())
const;
253 std::string
const& filename,
255 std::string
const& mode =
"w",
256 std::shared_ptr<daf::base::PropertySet const> header=
nullptr,
272 std::string
const& mode =
"w",
273 std::shared_ptr<daf::base::PropertySet const> header=
nullptr,
288 std::shared_ptr<daf::base::PropertySet const> header=
nullptr,
372 template <
typename LhsPixelT,
typename RhsPixelT>
373 Image<LhsPixelT>&
operator+=(Image<LhsPixelT>& lhs, Image<RhsPixelT>
const& rhs);
375 template <
typename LhsPixelT,
typename RhsPixelT>
376 Image<LhsPixelT>&
operator-=(Image<LhsPixelT>& lhs, Image<RhsPixelT>
const& rhs);
378 template <
typename LhsPixelT,
typename RhsPixelT>
379 Image<LhsPixelT>&
operator*=(Image<LhsPixelT>& lhs, Image<RhsPixelT>
const& rhs);
381 template <
typename LhsPixelT,
typename RhsPixelT>
382 Image<LhsPixelT>&
operator/=(Image<LhsPixelT>& lhs, Image<RhsPixelT>
const& rhs);
384 template <
typename PixelT>
385 void swap(Image<PixelT>& a, Image<PixelT>& b);
390 template <
typename PixelT>
391 class DecoratedImage :
public lsst::daf::base::Persistable,
public lsst::daf::base::Citizen {
433 explicit DecoratedImage(std::string
const& fileName,
const int hdu = INT_MIN,
443 std::shared_ptr<lsst::daf::base::PropertySet>
getMetadata()
const {
return _metadata; }
444 void setMetadata(std::shared_ptr<lsst::daf::base::PropertySet> metadata) { _metadata = metadata; }
447 int getWidth()
const {
return _image->getWidth(); }
452 int getX0()
const {
return _image->getX0(); }
454 int getY0()
const {
return _image->getY0(); }
468 void writeFits(std::string
const& fileName, std::shared_ptr<lsst::daf::base::PropertySet const> metadata =
469 std::shared_ptr<lsst::daf::base::PropertySet const>(),
470 std::string
const& mode =
"w")
const;
473 std::shared_ptr<Image<PixelT>>
getImage() {
return _image; }
475 std::shared_ptr<Image<PixelT>
const>
getImage()
const {
return _image; }
488 std::shared_ptr<
Image<PixelT>> _image;
489 std::shared_ptr<lsst::daf::base::
PropertySet> _metadata;
496 template <typename PixelT>
std::shared_ptr< Image< PixelT > > getImage()
Return a shared_ptr to the DecoratedImage's Image.
A templated class to return this classes' type (present in Image/Mask/MaskedImage) ...
Image & operator=(const PixelT rhs)
Set the image's pixels to rhs.
afw::table::PointKey< int > dimensions
Image & operator*=(PixelT const rhs)
Multiply lhs by scalar rhs.
DecoratedImage(const geom::Extent2I &dimensions=geom::Extent2I())
Create an image of the specified size.
Image< LhsPixelT > & operator+=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Add lhs to Image rhs (i.e. pixel-by-pixel addition) where types are different.
static Image readFits(std::string const &filename, int hdu=INT_MIN)
Read an Image from a regular FITS file.
Options for writing an image to FITS.
Image & operator/=(PixelT const rhs)
Divide lhs by scalar rhs.
double getGain() const
Return the DecoratedImage's gain.
void scaledDivides(double const c, Image< PixelT > const &rhs)
Divide lhs by Image c*rhs (i.e. pixel-by-pixel division)
void swap(DecoratedImage &rhs)
void setMetadata(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
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, ...)
A Function taking two arguments.
int getWidth() const
Return the number of columns in the image.
An integer coordinate rectangle.
Image & operator-=(PixelT const rhs)
Subtract scalar rhs from lhs.
DecoratedImage & operator=(const DecoratedImage &image)
Assignment operator.
Represent a 2-dimensional array of bitmask pixels.
Lifetime-management for memory that goes into FITS memory files.
void writeFits(std::string const &fileName, std::shared_ptr< lsst::daf::base::PropertySet const > metadata=std::shared_ptr< lsst::daf::base::PropertySet const >(), std::string const &mode="w") const
Write an image to a regular FITS file.
A class to manipulate images, masks, and variance as a single object.
std::shared_ptr< lsst::daf::base::PropertySet > getMetadata() const
int getHeight() const
Return the number of rows in the image.
Image & operator+=(PixelT const rhs)
Add scalar rhs to lhs.
geom::Box2I bboxFromMetadata(daf::base::PropertySet &metadata)
Determine the image bounding box from its metadata (FITS header)
void setGain(double gain)
Set the DecoratedImage's gain.
void scaledPlus(double const c, Image< PixelT > const &rhs)
Add Image c*rhs to lhs.
Image(ndarray::Array< PixelT, 2, 1 > const &array, bool deep=false, geom::Point2I const &xy0=geom::Point2I())
std::shared_ptr< Image< PixelT > const > getImage() const
Return a shared_ptr to the DecoratedImage's Image as const.
void swap(Image< PixelT > &a, Image< PixelT > &b)
Image< LhsPixelT > & operator*=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Multiply lhs by Image rhs (i.e. pixel-by-pixel multiplication) where types are different.
void scaledMultiplies(double const c, Image< PixelT > const &rhs)
Multiply lhs by Image c*rhs (i.e. pixel-by-pixel multiplication)
Image< LhsPixelT > & operator-=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Subtract lhs from Image rhs (i.e. pixel-by-pixel subtraction) where types are different.
lsst::daf::base::PropertySet PropertySet
int getX0() const
Return the image's column-origin.
static Image readFits(fits::MemFileManager &manager, int hdu=INT_MIN)
Read an Image from a FITS RAM file.
Image< LhsPixelT > & operator/=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Divide lhs by Image rhs (i.e. pixel-by-pixel division) where types are different. ...
const geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
Image(Image< OtherPixelT > const &rhs, const bool deep)
A class to represent a 2-dimensional array of pixels.
detail::Image_tag image_category
void writeFits(std::string const &fileName, std::shared_ptr< lsst::daf::base::PropertySet const > metadata=std::shared_ptr< lsst::daf::base::PropertySet const >(), std::string const &mode="w") const
Write a FITS file.
Image< ImagePT > type
Return the desired type.
A container for an Image and its associated metadata.
void scaledMinus(double const c, Image< PixelT > const &rhs)
Subtract Image c*rhs from lhs.
int getY0() const
Return the image's row-origin.