LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Member Functions | List of all members
lsst::afw::image::DecoratedImage< PixelT > Class Template Reference

A container for an Image and its associated metadata. More...

#include <Image.h>

Public Member Functions

 DecoratedImage (const lsst::geom::Extent2I &dimensions=lsst::geom::Extent2I())
 Create an image of the specified size. More...
 
 DecoratedImage (const lsst::geom::Box2I &bbox)
 Create an image of the specified size. More...
 
 DecoratedImage (std::shared_ptr< Image< PixelT >> rhs)
 Create a DecoratedImage wrapping rhs More...
 
 DecoratedImage (DecoratedImage const &rhs, const bool deep=false)
 Copy constructor. More...
 
 DecoratedImage (std::string const &fileName, const int hdu=fits::DEFAULT_HDU, lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin const origin=PARENT, bool allowUnsafe=false)
 Create a DecoratedImage from a FITS file. More...
 
DecoratedImageoperator= (const DecoratedImage &image)
 Assignment operator. More...
 
std::shared_ptr< lsst::daf::base::PropertySetgetMetadata () const
 
void setMetadata (std::shared_ptr< lsst::daf::base::PropertySet > metadata)
 
int getWidth () const
 Return the number of columns in the image. More...
 
int getHeight () const
 Return the number of rows in the image. More...
 
int getX0 () const
 Return the image's column-origin. More...
 
int getY0 () const
 Return the image's row-origin. More...
 
const lsst::geom::Extent2I getDimensions () const
 Return the image's size; useful for passing to constructors. More...
 
void swap (DecoratedImage &rhs)
 
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. More...
 
void writeFits (std::string const &fileName, fits::ImageWriteOptions const &options, 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. More...
 
std::shared_ptr< Image< PixelT > > getImage ()
 Return a shared_ptr to the DecoratedImage's Image. More...
 
std::shared_ptr< Image< PixelT > const > getImage () const
 Return a shared_ptr to the DecoratedImage's Image as const. More...
 
double getGain () const
 Return the DecoratedImage's gain. More...
 
void setGain (double gain)
 Set the DecoratedImage's gain. More...
 

Detailed Description

template<typename PixelT>
class lsst::afw::image::DecoratedImage< PixelT >

A container for an Image and its associated metadata.

Definition at line 397 of file Image.h.

Constructor & Destructor Documentation

◆ DecoratedImage() [1/5]

template<typename PixelT >
lsst::afw::image::DecoratedImage< PixelT >::DecoratedImage ( const lsst::geom::Extent2I dimensions = lsst::geom::Extent2I())
explicit

Create an image of the specified size.

Parameters
dimensionsdesired number of columns. rows

Definition at line 44 of file DecoratedImage.cc.

45  : _image(new Image<PixelT>(dimensions)) {
46  init();
47 }
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:48

◆ DecoratedImage() [2/5]

template<typename PixelT >
lsst::afw::image::DecoratedImage< PixelT >::DecoratedImage ( const lsst::geom::Box2I bbox)
explicit

Create an image of the specified size.

Parameters
bbox(width, height) and origin of the desired Image
Note
Many lsst::afw::image and lsst::afw::math objects define a dimensions member which may be conveniently used to make objects of an appropriate size

Definition at line 49 of file DecoratedImage.cc.

49  : _image(new Image<PixelT>(bbox)) {
50  init();
51 }
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117

◆ DecoratedImage() [3/5]

template<typename PixelT >
lsst::afw::image::DecoratedImage< PixelT >::DecoratedImage ( std::shared_ptr< Image< PixelT >>  rhs)
explicit

Create a DecoratedImage wrapping rhs

Note that this ctor shares pixels with the rhs; it isn't a deep copy

Parameters
rhsImage to go into DecoratedImage

Definition at line 53 of file DecoratedImage.cc.

53  : _image(rhs) {
54  init();
55 }

◆ DecoratedImage() [4/5]

template<typename PixelT >
lsst::afw::image::DecoratedImage< PixelT >::DecoratedImage ( DecoratedImage< PixelT > const &  rhs,
const bool  deep = false 
)

Copy constructor.

Note that the lhs will share memory with the rhs unless deep is true

Parameters
rhsright hand side
deepMake deep copy?

Definition at line 57 of file DecoratedImage.cc.

58  : _image(new Image<PixelT>(*src._image, deep)), _gain(src._gain) {
59  setMetadata(src.getMetadata());
60 }
std::shared_ptr< RecordT > src
Definition: Match.cc:48
void setMetadata(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Definition: Image.h:453

◆ DecoratedImage() [5/5]

template<typename PixelT >
lsst::afw::image::DecoratedImage< PixelT >::DecoratedImage ( std::string const &  fileName,
const int  hdu = fits::DEFAULT_HDU,
lsst::geom::Box2I const &  bbox = lsst::geom::Box2I(),
ImageOrigin const  origin = PARENT,
bool  allowUnsafe = false 
)
explicit

Create a DecoratedImage from a FITS file.

Parameters
fileNameFile to read
hduThe HDU to read
bboxOnly read these pixels
originCoordinate system of the bbox
allowUnsafePermit reading into the requested pixel type even when on-disk values may overflow or truncate.

Definition at line 86 of file DecoratedImage.cc.

88  {
89  init();
91  new Image<PixelT>(fileName, hdu, getMetadata(), bbox, origin, allowUnsafe));
92 }
std::shared_ptr< lsst::daf::base::PropertySet > getMetadata() const
Definition: Image.h:452

Member Function Documentation

◆ getDimensions()

template<typename PixelT >
const lsst::geom::Extent2I lsst::afw::image::DecoratedImage< PixelT >::getDimensions ( ) const
inline

Return the image's size; useful for passing to constructors.

Definition at line 466 of file Image.h.

466 { return _image->getDimensions(); }

◆ getGain()

template<typename PixelT >
double lsst::afw::image::DecoratedImage< PixelT >::getGain ( ) const
inline

Return the DecoratedImage's gain.

Note
This is mostly just a place holder for other properties that we might want to associate with a DecoratedImage

Definition at line 505 of file Image.h.

505 { return _gain; }

◆ getHeight()

template<typename PixelT >
int lsst::afw::image::DecoratedImage< PixelT >::getHeight ( ) const
inline

Return the number of rows in the image.

Definition at line 458 of file Image.h.

458 { return _image->getHeight(); }

◆ getImage() [1/2]

template<typename PixelT >
std::shared_ptr<Image<PixelT> > lsst::afw::image::DecoratedImage< PixelT >::getImage ( )
inline

Return a shared_ptr to the DecoratedImage's Image.

Definition at line 496 of file Image.h.

496 { return _image; }

◆ getImage() [2/2]

template<typename PixelT >
std::shared_ptr<Image<PixelT> const> lsst::afw::image::DecoratedImage< PixelT >::getImage ( ) const
inline

Return a shared_ptr to the DecoratedImage's Image as const.

Definition at line 498 of file Image.h.

498 { return _image; }

◆ getMetadata()

template<typename PixelT >
std::shared_ptr<lsst::daf::base::PropertySet> lsst::afw::image::DecoratedImage< PixelT >::getMetadata ( ) const
inline

Definition at line 452 of file Image.h.

452 { return _metadata; }

◆ getWidth()

template<typename PixelT >
int lsst::afw::image::DecoratedImage< PixelT >::getWidth ( ) const
inline

Return the number of columns in the image.

Definition at line 456 of file Image.h.

456 { return _image->getWidth(); }

◆ getX0()

template<typename PixelT >
int lsst::afw::image::DecoratedImage< PixelT >::getX0 ( ) const
inline

Return the image's column-origin.

Definition at line 461 of file Image.h.

461 { return _image->getX0(); }

◆ getY0()

template<typename PixelT >
int lsst::afw::image::DecoratedImage< PixelT >::getY0 ( ) const
inline

Return the image's row-origin.

Definition at line 463 of file Image.h.

463 { return _image->getY0(); }

◆ operator=()

template<typename PixelT >
DecoratedImage< PixelT > & lsst::afw::image::DecoratedImage< PixelT >::operator= ( const DecoratedImage< PixelT > &  image)

Assignment operator.

N.b. this is a shallow assignment; use set(src) if you want to copy the pixels

Definition at line 62 of file DecoratedImage.cc.

62  {
63  DecoratedImage tmp(src);
64  swap(tmp); // See Meyers, Effective C++, Item 11
65 
66  return *this;
67 }
DecoratedImage(const lsst::geom::Extent2I &dimensions=lsst::geom::Extent2I())
Create an image of the specified size.
void swap(DecoratedImage &rhs)

◆ setGain()

template<typename PixelT >
void lsst::afw::image::DecoratedImage< PixelT >::setGain ( double  gain)
inline

Set the DecoratedImage's gain.

Definition at line 507 of file Image.h.

507 { _gain = gain; }
table::Key< double > gain
Definition: Amplifier.cc:118

◆ setMetadata()

template<typename PixelT >
void lsst::afw::image::DecoratedImage< PixelT >::setMetadata ( std::shared_ptr< lsst::daf::base::PropertySet metadata)
inline

Definition at line 453 of file Image.h.

453 { _metadata = metadata; }

◆ swap()

template<typename PixelT >
void lsst::afw::image::DecoratedImage< PixelT >::swap ( DecoratedImage< PixelT > &  rhs)

Definition at line 70 of file DecoratedImage.cc.

70  {
71  using std::swap; // See Meyers, Effective C++, Item 25
72 
73  swap(_image, rhs._image); // just swapping the pointers
74  swap(_gain, rhs._gain);
75 }
T swap(T... args)

◆ writeFits() [1/2]

template<typename PixelT >
void lsst::afw::image::DecoratedImage< PixelT >::writeFits ( std::string const &  fileName,
fits::ImageWriteOptions const &  options,
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.

Parameters
[in]fileNamethe file to write
[in]optionsOptions controlling writing of FITS image.
[in]metadatametadata to write to header; or NULL
[in]mode"w" to write a new file; "a" to append

Definition at line 103 of file DecoratedImage.cc.

105  {
107 
108  if (metadata_i) {
109  metadata = getMetadata()->deepCopy();
110  metadata->combine(metadata_i);
111  } else {
112  metadata = getMetadata();
113  }
114 
115  getImage()->writeFits(fileName, options, mode, metadata);
116 }
std::shared_ptr< Image< PixelT > > getImage()
Return a shared_ptr to the DecoratedImage's Image.
Definition: Image.h:496
virtual Ptr deepCopy() const
Make a deep copy of the PropertySet and all of its contents.

◆ writeFits() [2/2]

template<typename PixelT >
void lsst::afw::image::DecoratedImage< PixelT >::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.

Parameters
fileNamethe file to write
metadatametadata to write to header; or NULL
mode"w" to write a new file; "a" to append

Definition at line 95 of file DecoratedImage.cc.

97  {
98  fits::ImageWriteOptions const options;
99  writeFits(fileName, options, metadata, mode);
100 }
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.

The documentation for this class was generated from the following files: