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,
199 Image& operator=(
const PixelT rhs);
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,
349 void scaledMultiplies(
double const c,
Image<PixelT> const& rhs);
359 void scaledDivides(
double const c,
Image<PixelT> const& rhs);
372 template <
typename LhsPixelT,
typename RhsPixelT>
375 template <
typename LhsPixelT,
typename RhsPixelT>
378 template <
typename LhsPixelT,
typename RhsPixelT>
381 template <
typename LhsPixelT,
typename RhsPixelT>
384 template <
typename PixelT>
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.
std::shared_ptr< Image< PixelT > const > getImage() const
Return a shared_ptr to the DecoratedImage's Image as const.
A templated class to return this classes' type (present in Image/Mask/MaskedImage) ...
void scaledPlus(OutImageT &outImage, double c1, InImageT const &inImage1, double c2, InImageT const &inImage2)
Compute the scaled sum of two images.
std::shared_ptr< lsst::daf::base::PropertySet > getMetadata() const
int getWidth() const
Return the number of columns in the image.
int getHeight() const
Return the number of rows in the image.
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.
const geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
Options for writing an image to FITS.
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.
An integer coordinate rectangle.
lsst::daf::base::PropertySet PropertySet
afw::table::PointKey< int > dimensions
A base class for image defects.
Represent a 2-dimensional array of bitmask pixels.
Lifetime-management for memory that goes into FITS memory files.
A class to manipulate images, masks, and variance as a single object.
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.
Image(ndarray::Array< PixelT, 2, 1 > const &array, bool deep=false, geom::Point2I const &xy0=geom::Point2I())
void swap(DecoratedImage< PixelT > &a, DecoratedImage< 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.
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.
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. ...
Image(Image< OtherPixelT > const &rhs, const bool deep)
int getY0() const
Return the image's row-origin.
A class to represent a 2-dimensional array of pixels.
detail::Image_tag image_category
double getGain() const
Return the DecoratedImage's gain.
Image< ImagePT > type
Return the desired type.
A container for an Image and its associated metadata.