LSSTApplications  19.0.0-14-gb0260a2+c4152221ba,20.0.0+428775a0ef,20.0.0+7c6b12c2f9,20.0.0+ae956f52c5,20.0.0+c388114e2c,20.0.0+e2e26847c2,20.0.0+e5529315c6,20.0.0-1-g04bee24+7c6b12c2f9,20.0.0-1-g10df615+cc9679e3e4,20.0.0-1-g253301a+7c6b12c2f9,20.0.0-1-g2b7511a+46a6078777,20.0.0-1-g4d801e7+9b3155b620,20.0.0-1-g5b95a8c+3d35cd64b7,20.0.0-1-gb058bd0+46a6078777,20.0.0-1-gb88604f+acecce4127,20.0.0-1-gc96f8cb+f5ea1f6730,20.0.0-1-gedffbd8+57e6df9186,20.0.0-10-g0891cd99+21712b8dc8,20.0.0-10-g9a20bd332+576ca7b471,20.0.0-17-gcdbda88+f8ebf1b2ab,20.0.0-2-g4dae9ad+f5ea1f6730,20.0.0-2-g61b8584+85c46248f3,20.0.0-2-gb780d76+f45b7d88f4,20.0.0-20-g7966b28+f5ea1f6730,20.0.0-21-g1f5da01+74cacf985d,20.0.0-23-g8900aa8+dfd6ff4ddf,20.0.0-3-g1653f94+85c46248f3,20.0.0-3-g4cc78c6+63636aeed8,20.0.0-3-g750bffe+3a91ba9410,20.0.0-3-gbd60e8c+ff10c6d78d,20.0.0-32-g15a0e07c+fb20712e7c,20.0.0-4-g97dc21a+dfd6ff4ddf,20.0.0-4-gfea843c+f45b7d88f4,20.0.0-5-g357b56b+f45b7d88f4,20.0.0-59-gb502cbb+701042a847,20.0.0-6-g9a5b7a1+3980549e0d,20.0.0-7-gcda7bf1+ddb9d7f898,w.2020.43
LSSTDataManagementBasePackage
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 404 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 56 of file DecoratedImage.cc.

57  : _image(new Image<PixelT>(dimensions)) {
58  init();
59 }

◆ 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 61 of file DecoratedImage.cc.

61  : _image(new Image<PixelT>(bbox)) {
62  init();
63 }

◆ 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 65 of file DecoratedImage.cc.

65  : _image(rhs) {
66  init();
67 }

◆ 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 69 of file DecoratedImage.cc.

70  : _image(new Image<PixelT>(*src._image, deep)), _gain(src._gain) {
71  setMetadata(src.getMetadata());
72 }

◆ 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 98 of file DecoratedImage.cc.

100  {
101  init();
103  new Image<PixelT>(fileName, hdu, getMetadata(), bbox, origin, allowUnsafe));
104 }

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 473 of file Image.h.

473 { 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 512 of file Image.h.

512 { 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 465 of file Image.h.

465 { 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 503 of file Image.h.

503 { 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 505 of file Image.h.

505 { return _image; }

◆ getMetadata()

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

Definition at line 459 of file Image.h.

459 { 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 463 of file Image.h.

463 { 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 468 of file Image.h.

468 { 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 470 of file Image.h.

470 { 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 74 of file DecoratedImage.cc.

74  {
75  DecoratedImage tmp(src);
76  swap(tmp); // See Meyers, Effective C++, Item 11
77 
78  return *this;
79 }

◆ setGain()

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

Set the DecoratedImage's gain.

Definition at line 514 of file Image.h.

514 { _gain = gain; }

◆ setMetadata()

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

Definition at line 460 of file Image.h.

460 { _metadata = metadata; }

◆ swap()

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

Definition at line 82 of file DecoratedImage.cc.

82  {
83  using std::swap; // See Meyers, Effective C++, Item 25
84 
85  swap(_image, rhs._image); // just swapping the pointers
86  swap(_gain, rhs._gain);
87 }

◆ 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 115 of file DecoratedImage.cc.

117  {
119 
120  if (metadata_i) {
121  metadata = getMetadata()->deepCopy();
122  metadata->combine(metadata_i);
123  } else {
124  metadata = getMetadata();
125  }
126 
127  getImage()->writeFits(fileName, options, mode, metadata);
128 }

◆ 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 107 of file DecoratedImage.cc.

109  {
110  fits::ImageWriteOptions const options;
111  writeFits(fileName, options, metadata, mode);
112 }

The documentation for this class was generated from the following files:
std::shared_ptr
STL class.
lsst::afw::image::DecoratedImage::setMetadata
void setMetadata(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Definition: Image.h:460
src
std::shared_ptr< RecordT > src
Definition: Match.cc:48
lsst::afw::image::DecoratedImage::swap
void swap(DecoratedImage &rhs)
Definition: DecoratedImage.cc:82
dimensions
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:49
lsst::afw::image::DecoratedImage::DecoratedImage
DecoratedImage(const lsst::geom::Extent2I &dimensions=lsst::geom::Extent2I())
Create an image of the specified size.
Definition: DecoratedImage.cc:56
std::swap
T swap(T... args)
gain
table::Key< double > gain
Definition: Amplifier.cc:118
lsst::afw::image::DecoratedImage::getImage
std::shared_ptr< Image< PixelT > > getImage()
Return a shared_ptr to the DecoratedImage's Image.
Definition: Image.h:503
lsst::afw::image::DecoratedImage::getMetadata
std::shared_ptr< lsst::daf::base::PropertySet > getMetadata() const
Definition: Image.h:459
lsst::utils.tests.init
def init()
Definition: tests.py:59
bbox
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
lsst::daf::base::PropertySet::deepCopy
virtual Ptr deepCopy() const
Make a deep copy of the PropertySet and all of its contents.
lsst::afw::image::DecoratedImage::writeFits
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.
Definition: DecoratedImage.cc:107