LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
LSSTDataManagementBasePackage
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | Related Functions | List of all members
lsst::afw::image::Image< PixelT > Class Template Reference

A class to represent a 2-dimensional array of pixels. More...

#include <Image.h>

Inheritance diagram for lsst::afw::image::Image< PixelT >:
lsst::afw::image::ImageBase< PixelT > lsst::daf::base::Persistable lsst::daf::base::Citizen lsst::afw::image::ImageSlice< PixelT >

Classes

struct  ImageTypeFactory
 A templated class to return this classes' type (present in Image/Mask/MaskedImage) More...
 

Public Types

typedef boost::shared_ptr
< Image< PixelT > > 
Ptr
 
typedef boost::shared_ptr
< const Image< PixelT > > 
ConstPtr
 
typedef detail::Image_tag image_category
 
- Public Types inherited from lsst::afw::image::ImageBase< PixelT >
typedef boost::shared_ptr
< ImageBase< PixelT > > 
Ptr
 A shared_ptr to an ImageBase. More...
 
typedef boost::shared_ptr
< const ImageBase< PixelT > > 
ConstPtr
 A shared_ptr to a const ImageBase. More...
 
typedef detail::basic_tag image_category
 trait class to identify type of image More...
 
typedef PixelT SinglePixel
 A single Pixel of the same type as those in the ImageBase. More...
 
typedef PixelT Pixel
 A pixel in this ImageBase. More...
 
typedef Reference< PixelT >::type PixelReference
 A Reference to a PixelT. More...
 
typedef ConstReference< PixelT >
::type 
PixelConstReference
 A ConstReference to a PixelT. More...
 
typedef _view_t::xy_locator xy_locator
 An xy_locator. More...
 
typedef
_view_t::xy_locator::const_t 
const_xy_locator
 A const_xy_locator. More...
 
typedef _view_t::iterator iterator
 An STL compliant iterator. More...
 
typedef _const_view_t::iterator const_iterator
 An STL compliant const iterator. More...
 
typedef _view_t::reverse_iterator reverse_iterator
 An STL compliant reverse iterator. More...
 
typedef
_const_view_t::reverse_iterator 
const_reverse_iterator
 An STL compliant const reverse iterator. More...
 
typedef _view_t::x_iterator x_iterator
 An iterator for traversing the pixels in a row. More...
 
typedef x_iterator fast_iterator
 
typedef _view_t::x_iterator xy_x_iterator
 An iterator for traversing the pixels in a row, created from an xy_locator. More...
 
typedef _const_view_t::x_iterator const_x_iterator
 A const iterator for traversing the pixels in a row. More...
 
typedef _view_t::y_iterator y_iterator
 An iterator for traversing the pixels in a column. More...
 
typedef _view_t::y_iterator xy_y_iterator
 An iterator for traversing the pixels in a row, created from an xy_locator. More...
 
typedef _const_view_t::y_iterator const_y_iterator
 A const iterator for traversing the pixels in a column. More...
 
typedef ndarray::Array< PixelT, 2, 1 > Array
 A mutable ndarray representation of the image. More...
 
typedef ndarray::Array< PixelT
const, 2, 1 > 
ConstArray
 An immutable ndarray representation of the image. More...
 
- Public Types inherited from lsst::daf::base::Persistable
typedef boost::shared_ptr
< Persistable
Ptr
 
- Public Types inherited from lsst::daf::base::Citizen
enum  { magicSentinel = 0xdeadbeef }
 
typedef unsigned long memId
 Type of the block's ID. More...
 
typedef memId(* memNewCallback )(const memId cid)
 A function used to register a callback. More...
 
typedef memId(* memCallback )(const Citizen *ptr)
 

Public Member Functions

 Image (unsigned int width, unsigned int height, PixelT initialValue=0)
 
 Image (geom::Extent2I const &dimensions=geom::Extent2I(), PixelT initialValue=0)
 
 Image (geom::Box2I const &bbox, PixelT initialValue=0)
 
 Image (Image const &rhs, geom::Box2I const &bbox, ImageOrigin const origin=PARENT, const bool deep=false)
 
 Image (const Image &rhs, const bool deep=false)
 
 Image (std::string const &fileName, int hdu=0, boost::shared_ptr< lsst::daf::base::PropertySet > metadata=boost::shared_ptr< lsst::daf::base::PropertySet >(), geom::Box2I const &bbox=geom::Box2I(), ImageOrigin origin=PARENT)
 Construct an Image by reading a regular FITS file. More...
 
 Image (fits::MemFileManager &manager, int hdu=0, boost::shared_ptr< lsst::daf::base::PropertySet > metadata=boost::shared_ptr< lsst::daf::base::PropertySet >(), geom::Box2I const &bbox=geom::Box2I(), ImageOrigin origin=PARENT)
 Construct an Image by reading a FITS image in memory. More...
 
 Image (fits::Fits &fitsfile, boost::shared_ptr< lsst::daf::base::PropertySet > metadata=boost::shared_ptr< lsst::daf::base::PropertySet >(), geom::Box2I const &bbox=geom::Box2I(), ImageOrigin origin=PARENT)
 Construct an Image from an already-open FITS object. More...
 
template<typename OtherPixelT >
 Image (Image< OtherPixelT > const &rhs, const bool deep)
 
 Image (ndarray::Array< PixelT, 2, 1 > const &array, bool deep=false, geom::Point2I const &xy0=geom::Point2I())
 
virtual ~Image ()
 
Imageoperator= (const PixelT rhs)
 Set the image's pixels to rhs. More...
 
Imageoperator= (const Image &rhs)
 
void writeFits (std::string const &fileName, boost::shared_ptr< lsst::daf::base::PropertySet const > metadata=boost::shared_ptr< lsst::daf::base::PropertySet const >(), std::string const &mode="w") const
 Write an image to a regular FITS file. More...
 
void writeFits (fits::MemFileManager &manager, boost::shared_ptr< lsst::daf::base::PropertySet const > metadata=boost::shared_ptr< lsst::daf::base::PropertySet const >(), std::string const &mode="w") const
 Write an image to a FITS RAM file. More...
 
void writeFits (fits::Fits &fitsfile, boost::shared_ptr< lsst::daf::base::PropertySet const > metadata=boost::shared_ptr< lsst::daf::base::PropertySet const >()) const
 Write an image to an open FITS file object. More...
 
void swap (Image &rhs)
 
void operator+= (PixelT const rhs)
 Add scalar rhs to lhs. More...
 
virtual void operator+= (Image< PixelT >const &rhs)
 Add Image rhs to lhs. More...
 
void operator+= (lsst::afw::math::Function2< double > const &function)
 Add a Function2(x, y) to an Image. More...
 
void scaledPlus (double const c, Image< PixelT >const &rhs)
 Add Image c*rhs to lhs. More...
 
void operator-= (PixelT const rhs)
 Subtract scalar rhs from lhs. More...
 
void operator-= (Image< PixelT > const &rhs)
 Subtract Image rhs from lhs. More...
 
void operator-= (lsst::afw::math::Function2< double > const &function)
 Subtract a Function2(x, y) from an Image. More...
 
void scaledMinus (double const c, Image< PixelT >const &rhs)
 Subtract Image c*rhs from lhs. More...
 
void operator*= (PixelT const rhs)
 Multiply lhs by scalar rhs. More...
 
void operator*= (Image< PixelT > const &rhs)
 Multiply lhs by Image rhs (i.e. pixel-by-pixel multiplication) More...
 
void scaledMultiplies (double const c, Image< PixelT >const &rhs)
 Multiply lhs by Image c*rhs (i.e. pixel-by-pixel multiplication) More...
 
void operator/= (PixelT const rhs)
 
void operator/= (Image< PixelT > const &rhs)
 Divide lhs by Image rhs (i.e. pixel-by-pixel division) More...
 
void scaledDivides (double const c, Image< PixelT >const &rhs)
 Divide lhs by Image c*rhs (i.e. pixel-by-pixel division) More...
 
void sqrt ()
 
template<>
void operator/= (double const rhs)
 
template<>
void operator/= (float const rhs)
 
- Public Member Functions inherited from lsst::afw::image::ImageBase< PixelT >
 ImageBase (const geom::Extent2I &dimensions=geom::Extent2I())
 
 ImageBase (const geom::Box2I &bbox)
 
 ImageBase (const ImageBase &src, const bool deep=false)
 
 ImageBase (const ImageBase &src, const geom::Box2I &bbox, const ImageOrigin origin=PARENT, const bool deep=false)
 
template<typename OtherPixelT >
 ImageBase (const ImageBase< OtherPixelT > &rhs, const bool deep)
 
 ImageBase (Array const &array, bool deep=false, geom::Point2I const &xy0=geom::Point2I())
 
virtual ~ImageBase ()
 
ImageBaseoperator= (const ImageBase &rhs)
 
ImageBaseoperator= (const PixelT rhs)
 Set the image's pixels to rhs. More...
 
void operator<<= (const ImageBase &rhs)
 Set the lhs's pixel values to equal the rhs's. More...
 
PixelReference operator() (int x, int y)
 Return a reference to the pixel (x, y) More...
 
PixelReference operator() (int x, int y, CheckIndices const &)
 Return a reference to the pixel (x, y) with bounds checking. More...
 
PixelConstReference operator() (int x, int y) const
 Return a const reference to the pixel (x, y) More...
 
PixelConstReference operator() (int x, int y, CheckIndices const &) const
 Return a const reference to the pixel (x, y) with bounds checking. More...
 
PixelConstReference get0 (int x, int y) const
 
PixelConstReference get0 (int x, int y, CheckIndices const &check) const
 
void set0 (int x, int y, const PixelT v)
 
void set0 (int x, int y, const PixelT v, CheckIndices const &check)
 
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
 
int getY0 () const
 
geom::Point2I getXY0 () const
 
std::pair< int, double > positionToIndex (double const pos, lsst::afw::image::xOrY const xy) const
 Convert image position to index (nearest integer and fractional parts) More...
 
double indexToPosition (double ind, lsst::afw::image::xOrY const xy) const
 Convert image index to image position. More...
 
geom::Extent2I getDimensions () const
 Return the image's size; useful for passing to constructors. More...
 
void swap (ImageBase &rhs)
 
Array getArray ()
 
ConstArray getArray () const
 
iterator begin () const
 
iterator end () const
 Return an STL compliant iterator to the end of the image. More...
 
reverse_iterator rbegin () const
 Return an STL compliant reverse iterator to the start of the image. More...
 
reverse_iterator rend () const
 Return an STL compliant reverse iterator to the end of the image. More...
 
iterator at (int x, int y) const
 Return an STL compliant iterator at the point (x, y) More...
 
fast_iterator begin (bool) const
 
fast_iterator end (bool) const
 
x_iterator row_begin (int y) const
 
x_iterator row_end (int y) const
 Return an x_iterator to the end of the y'th row. More...
 
x_iterator x_at (int x, int y) const
 Return an x_iterator to the point (x, y) in the image. More...
 
y_iterator col_begin (int x) const
 
y_iterator col_end (int x) const
 Return an y_iterator to the end of the y'th row. More...
 
y_iterator y_at (int x, int y) const
 Return an y_iterator to the point (x, y) in the image. More...
 
xy_locator xy_at (int x, int y) const
 
void setXY0 (geom::Point2I const origin)
 
void setXY0 (int const x0, int const y0)
 
geom::Box2I getBBox (ImageOrigin origin=PARENT) const
 
- Public Member Functions inherited from lsst::daf::base::Persistable
 Persistable (void)
 
virtual ~Persistable (void)
 
template<class Archive >
void serialize (Archive &, unsigned int const)
 
- Public Member Functions inherited from lsst::daf::base::Citizen
 Citizen (const std::type_info &)
 
 Citizen (Citizen const &)
 
 ~Citizen ()
 
Citizenoperator= (Citizen const &)
 
std::string repr () const
 Return a string representation of a Citizen. More...
 
void markPersistent (void)
 Mark a Citizen as persistent and not destroyed until process end. More...
 
memId getId () const
 Return the Citizen's ID. More...
 

Static Public Member Functions

static Image readFits (std::string const &filename, int hdu=0)
 Read an Image from a regular FITS file. More...
 
static Image readFits (fits::MemFileManager &manager, int hdu=0)
 Read an Image from a FITS RAM file. More...
 
- Static Public Member Functions inherited from lsst::afw::image::ImageBase< PixelT >
template<typename SinglePixelT >
static SinglePixel PixelCast (SinglePixelT rhs)
 Convert a type to our SinglePixel type. More...
 
- Static Public Member Functions inherited from lsst::daf::base::Citizen
static bool hasBeenCorrupted ()
 Check all allocated blocks for corruption. More...
 
static memId getNextMemId ()
 Return the memId of the next object to be allocated. More...
 
static int init ()
 Called once when the memory system is being initialised. More...
 
static int census (int, memId startingMemId=0)
 How many active Citizens are there? More...
 
static void census (std::ostream &stream, memId startingMemId=0)
 Print a list of all active Citizens to stream, sorted by ID. More...
 
static const std::vector
< const Citizen * > * 
census ()
 Return a (newly allocated) std::vector of active Citizens sorted by ID. More...
 
static memId setNewCallbackId (memId id)
 Call the NewCallback when block is allocated. More...
 
static memId setDeleteCallbackId (memId id)
 Call the current DeleteCallback when block is deleted. More...
 
static memNewCallback setNewCallback (memNewCallback func)
 Set the NewCallback function. More...
 
static memCallback setDeleteCallback (memCallback func)
 Set the DeleteCallback function. More...
 
static memCallback setCorruptionCallback (memCallback func)
 Set the CorruptionCallback function. More...
 

Friends

template<typename , typename , typename >
class MaskedImage
 
template<typename OtherPixelT >
class Image
 

Related Functions

(Note that these are not member functions.)

template<typename ImageT >
ImageT::SinglePixel badPixel (typename ImageT::Pixel bad=0)
 

Additional Inherited Members

- Protected Member Functions inherited from lsst::afw::image::ImageBase< PixelT >
_view_t _getRawView () const
 
bool isContiguous () const
 
- Static Protected Member Functions inherited from lsst::afw::image::ImageBase< PixelT >
static _view_t _allocateView (geom::Extent2I const &dimensions, Manager::Ptr &manager)
 
static _view_t _makeSubView (geom::Extent2I const &dimensions, geom::Extent2I const &offset, const _view_t &view)
 

Detailed Description

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

A class to represent a 2-dimensional array of pixels.

Examples:
forEachPixel.cc, image1.cc, image2.cc, imageStatistics.cc, spatialCellExample.cc, and statistics.cc.

Definition at line 415 of file Image.h.

Member Typedef Documentation

template<typename PixelT>
typedef boost::shared_ptr<const Image<PixelT> > lsst::afw::image::Image< PixelT >::ConstPtr

Definition at line 419 of file Image.h.

template<typename PixelT>
typedef detail::Image_tag lsst::afw::image::Image< PixelT >::image_category

Definition at line 421 of file Image.h.

template<typename PixelT>
typedef boost::shared_ptr<Image<PixelT> > lsst::afw::image::Image< PixelT >::Ptr

Definition at line 418 of file Image.h.

Constructor & Destructor Documentation

template<typename PixelT>
lsst::afw::image::Image< PixelT >::Image ( unsigned int  width,
unsigned int  height,
PixelT  initialValue = 0 
)
explicit

Create an initialised Image of the specified size

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
Parameters
widthnumber of columns
heightnumber of rows
initialValueInitial value

Definition at line 409 of file Image.cc.

412  :
414 {
415  *this = initialValue;
416 }
The base class for all image classed (Image, Mask, MaskedImage, ...)
Definition: Image.h:115
Extent< int, 2 > ExtentI
Definition: Extent.h:347
template<typename PixelT>
lsst::afw::image::Image< PixelT >::Image ( geom::Extent2I const &  dimensions = geom::Extent2I(),
PixelT  initialValue = 0 
)
explicit

Create an initialised Image of the specified size

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
Parameters
dimensionsNumber of columns, rows
initialValueInitial value

Definition at line 425 of file Image.cc.

427  :
429 {
430  *this = initialValue;
431 }
afw::table::Key< afw::table::Point< int > > dimensions
The base class for all image classed (Image, Mask, MaskedImage, ...)
Definition: Image.h:115
template<typename PixelT>
lsst::afw::image::Image< PixelT >::Image ( geom::Box2I const &  bbox,
PixelT  initialValue = 0 
)
explicit

Create an initialized Image of the specified size

Parameters
bboxdimensions and origin of desired Image
initialValueInitial value

Definition at line 437 of file Image.cc.

439  :
441  *this = initialValue;
442 }
The base class for all image classed (Image, Mask, MaskedImage, ...)
Definition: Image.h:115
template<typename PixelT>
lsst::afw::image::Image< PixelT >::Image ( Image< PixelT > const &  rhs,
geom::Box2I const &  bbox,
ImageOrigin const  origin = PARENT,
const bool  deep = false 
)
explicit

Copy constructor to make a copy of part of an Image.

The bbox ignores X0/Y0 if origin == LOCAL, and uses it if origin == PARENT.

Note
Unless deep is true, the new image will share the old image's pixels; this is probably what you want
Parameters
rhsRight-hand-side Image
bboxSpecify desired region
originCoordinate system of the bbox
deepIf false, new ImageBase shares storage with rhs; if true make a new, standalone, ImageBase

Definition at line 466 of file Image.cc.

471  :
472  image::ImageBase<PixelT>(rhs, bbox, origin, deep) {}
The base class for all image classed (Image, Mask, MaskedImage, ...)
Definition: Image.h:115
template<typename PixelT>
lsst::afw::image::Image< PixelT >::Image ( const Image< PixelT > &  rhs,
const bool  deep = false 
)

Copy constructor.

Note
Unless deep is true, the new image will share the old image's pixels; this may not be what you want. See also operator<<=() to copy pixels between Images
Parameters
rhsRight-hand-side Image
deepIf false, new Image shares storage with rhs; if true make a new, standalone, ImageBase

Definition at line 451 of file Image.cc.

454  :
455  image::ImageBase<PixelT>(rhs, deep) {}
The base class for all image classed (Image, Mask, MaskedImage, ...)
Definition: Image.h:115
template<typename PixelT>
lsst::afw::image::Image< PixelT >::Image ( std::string const &  fileName,
int  hdu = 0,
boost::shared_ptr< lsst::daf::base::PropertySet metadata = boost::shared_ptr< lsst::daf::base::PropertySet >(),
geom::Box2I const &  bbox = geom::Box2I(),
ImageOrigin  origin = PARENT 
)
explicit

Construct an Image by reading a regular FITS file.

Parameters
[in]fileNameFile to read.
[in]hduHDU to read, 1-indexed (i.e. 1=Primary HDU). The special value of 0 reads the Primary HDU unless it is empty, in which case it reads the first extension HDU.
[in,out]metadataMetadata read from the header (may be null).
[in]bboxIf non-empty, read only the pixels within the bounding box.
[in]originCoordinate system of the bounding box; if PARENT, the bounding box should take into account the xy0 saved with the image.
template<typename PixelT>
lsst::afw::image::Image< PixelT >::Image ( fits::MemFileManager manager,
int  hdu = 0,
boost::shared_ptr< lsst::daf::base::PropertySet metadata = boost::shared_ptr< lsst::daf::base::PropertySet >(),
geom::Box2I const &  bbox = geom::Box2I(),
ImageOrigin  origin = PARENT 
)
explicit

Construct an Image by reading a FITS image in memory.

Parameters
[in]managerAn object that manages the memory buffer to read.
[in]hduHDU to read, 1-indexed (i.e. 1=Primary HDU). The special value of 0 reads the Primary HDU unless it is empty, in which case it reads the first extension HDU.
[in,out]metadataMetadata read from the header (may be null).
[in]bboxIf non-empty, read only the pixels within the bounding box.
[in]originCoordinate system of the bounding box; if PARENT, the bounding box should take into account the xy0 saved with the image.
template<typename PixelT>
lsst::afw::image::Image< PixelT >::Image ( fits::Fits fitsfile,
boost::shared_ptr< lsst::daf::base::PropertySet metadata = boost::shared_ptr< lsst::daf::base::PropertySet >(),
geom::Box2I const &  bbox = geom::Box2I(),
ImageOrigin  origin = PARENT 
)
explicit

Construct an Image from an already-open FITS object.

Parameters
[in]fitsfileA FITS object to read from, already at the desired HDU.
[in,out]metadataMetadata read from the header (may be null).
[in]bboxIf non-empty, read only the pixels within the bounding box.
[in]originCoordinate system of the bounding box; if PARENT, the bounding box should take into account the xy0 saved with the image.
template<typename PixelT>
template<typename OtherPixelT >
lsst::afw::image::Image< PixelT >::Image ( Image< OtherPixelT > const &  rhs,
const bool  deep 
)
inline

Definition at line 497 of file Image.h.

497  :
498  image::ImageBase<PixelT>(rhs, deep) {}
The base class for all image classed (Image, Mask, MaskedImage, ...)
Definition: Image.h:115
template<typename PixelT>
lsst::afw::image::Image< PixelT >::Image ( ndarray::Array< PixelT, 2, 1 > const &  array,
bool  deep = false,
geom::Point2I const &  xy0 = geom::Point2I() 
)
inlineexplicit

Definition at line 500 of file Image.h.

501  :
502  image::ImageBase<PixelT>(array, deep, xy0) {}
The base class for all image classed (Image, Mask, MaskedImage, ...)
Definition: Image.h:115
template<typename PixelT>
virtual lsst::afw::image::Image< PixelT >::~Image ( )
inlinevirtual

Definition at line 504 of file Image.h.

504 { }

Member Function Documentation

template<typename PixelT>
void lsst::afw::image::Image< PixelT >::operator*= ( PixelT const  rhs)

Multiply lhs by scalar rhs.

Definition at line 731 of file Image.cc.

731  {
732  transform_pixels(_getRawView(), _getRawView(), bl::ret<PixelT>(bl::_1 * rhs));
733 }
_view_t _getRawView() const
Definition: Image.h:401
template<typename PixelT>
void lsst::afw::image::Image< PixelT >::operator*= ( Image< PixelT > const &  rhs)

Multiply lhs by Image rhs (i.e. pixel-by-pixel multiplication)

Definition at line 737 of file Image.cc.

737  {
738  if (this->getDimensions() != rhs.getDimensions()) {
739  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
740  (boost::format("Images are of different size, %dx%d v %dx%d") %
741  this->getWidth() % this->getHeight() % rhs.getWidth() % rhs.getHeight()).str());
742  }
743  transform_pixels(_getRawView(), rhs._getRawView(), _getRawView(), bl::ret<PixelT>(bl::_1 * bl::_2));
744 }
geom::Extent2I getDimensions() const
Return the image&#39;s size; useful for passing to constructors.
Definition: Image.h:298
_view_t _getRawView() const
Definition: Image.h:401
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:239
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:237
template<typename PixelT>
void lsst::afw::image::Image< PixelT >::operator+= ( PixelT const  rhs)

Add scalar rhs to lhs.

Definition at line 639 of file Image.cc.

639  {
640  transform_pixels(_getRawView(), _getRawView(), bl::ret<PixelT>(bl::_1 + rhs));
641 }
_view_t _getRawView() const
Definition: Image.h:401
template<typename PixelT>
void lsst::afw::image::Image< PixelT >::operator+= ( Image< PixelT >const &  rhs)
virtual

Add Image rhs to lhs.

Definition at line 645 of file Image.cc.

645  {
646  if (this->getDimensions() != rhs.getDimensions()) {
647  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
648  (boost::format("Images are of different size, %dx%d v %dx%d") %
649  this->getWidth() % this->getHeight() % rhs.getWidth() % rhs.getHeight()).str());
650  }
651  transform_pixels(_getRawView(), rhs._getRawView(), _getRawView(), bl::ret<PixelT>(bl::_1 + bl::_2));
652 }
geom::Extent2I getDimensions() const
Return the image&#39;s size; useful for passing to constructors.
Definition: Image.h:298
_view_t _getRawView() const
Definition: Image.h:401
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:239
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:237
template<typename PixelT>
void lsst::afw::image::Image< PixelT >::operator+= ( lsst::afw::math::Function2< double > const &  function)

Add a Function2(x, y) to an Image.

Parameters
functionfunction to add

Definition at line 658 of file Image.cc.

660  {
661  for (int y = 0; y != this->getHeight(); ++y) {
662  double const yPos = this->indexToPosition(y, image::Y);
663  double xPos = this->indexToPosition(0, image::X);
664  for (typename Image<PixelT>::x_iterator ptr = this->row_begin(y), end = this->row_end(y);
665  ptr != end; ++ptr, ++xPos) {
666  *ptr += function(xPos, yPos);
667  }
668  }
669 }
iterator end() const
Return an STL compliant iterator to the end of the image.
Definition: Image.cc:327
int y
double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const
Convert image index to image position.
Definition: Image.h:290
x_iterator row_end(int y) const
Return an x_iterator to the end of the y&#39;th row.
Definition: Image.h:324
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:239
x_iterator row_begin(int y) const
Definition: Image.h:319
template<typename PixelT>
void lsst::afw::image::Image< PixelT >::operator-= ( PixelT const  rhs)

Subtract scalar rhs from lhs.

Definition at line 685 of file Image.cc.

685  {
686  transform_pixels(_getRawView(), _getRawView(), bl::ret<PixelT>(bl::_1 - rhs));
687 }
_view_t _getRawView() const
Definition: Image.h:401
template<typename PixelT>
void lsst::afw::image::Image< PixelT >::operator-= ( Image< PixelT > const &  rhs)

Subtract Image rhs from lhs.

Definition at line 691 of file Image.cc.

691  {
692  if (this->getDimensions() != rhs.getDimensions()) {
693  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
694  (boost::format("Images are of different size, %dx%d v %dx%d") %
695  this->getWidth() % this->getHeight() % rhs.getWidth() % rhs.getHeight()).str());
696  }
697  transform_pixels(_getRawView(), rhs._getRawView(), _getRawView(), bl::ret<PixelT>(bl::_1 - bl::_2));
698 }
geom::Extent2I getDimensions() const
Return the image&#39;s size; useful for passing to constructors.
Definition: Image.h:298
_view_t _getRawView() const
Definition: Image.h:401
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:239
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:237
template<typename PixelT>
void lsst::afw::image::Image< PixelT >::operator-= ( lsst::afw::math::Function2< double > const &  function)

Subtract a Function2(x, y) from an Image.

Parameters
functionfunction to add

Definition at line 716 of file Image.cc.

718  {
719  for (int y = 0; y != this->getHeight(); ++y) {
720  double const yPos = this->indexToPosition(y, image::Y);
721  double xPos = this->indexToPosition(0, image::X);
722  for (typename Image<PixelT>::x_iterator ptr = this->row_begin(y), end = this->row_end(y);
723  ptr != end; ++ptr, ++xPos) {
724  *ptr -= function(xPos, yPos);
725  }
726  }
727 }
iterator end() const
Return an STL compliant iterator to the end of the image.
Definition: Image.cc:327
int y
double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const
Convert image index to image position.
Definition: Image.h:290
x_iterator row_end(int y) const
Return an x_iterator to the end of the y&#39;th row.
Definition: Image.h:324
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:239
x_iterator row_begin(int y) const
Definition: Image.h:319
template<typename PixelT>
void lsst::afw::image::Image< PixelT >::operator/= ( PixelT const  rhs)

Divide lhs by scalar rhs

Note
Floating point types implement this by multiplying by the 1/rhs

Definition at line 762 of file Image.cc.

762  {
763  transform_pixels(_getRawView(), _getRawView(), bl::ret<PixelT>(bl::_1 / rhs));
764 }
_view_t _getRawView() const
Definition: Image.h:401
template<typename PixelT>
void lsst::afw::image::Image< PixelT >::operator/= ( Image< PixelT > const &  rhs)

Divide lhs by Image rhs (i.e. pixel-by-pixel division)

Definition at line 784 of file Image.cc.

784  {
785  if (this->getDimensions() != rhs.getDimensions()) {
786  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
787  (boost::format("Images are of different size, %dx%d v %dx%d") %
788  this->getWidth() % this->getHeight() % rhs.getWidth() % rhs.getHeight()).str());
789  }
790  transform_pixels(_getRawView(), rhs._getRawView(), _getRawView(), bl::ret<PixelT>(bl::_1 / bl::_2));
791 }
geom::Extent2I getDimensions() const
Return the image&#39;s size; useful for passing to constructors.
Definition: Image.h:298
_view_t _getRawView() const
Definition: Image.h:401
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:239
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:237
template<>
void lsst::afw::image::Image< double >::operator/= ( double const  rhs)

Definition at line 770 of file Image.cc.

770  {
771  double const irhs = 1/rhs;
772  *this *= irhs;
773 }
template<>
void lsst::afw::image::Image< float >::operator/= ( float const  rhs)

Definition at line 776 of file Image.cc.

776  {
777  float const irhs = 1/rhs;
778  *this *= irhs;
779 }
template<typename PixelT>
image::Image< PixelT > & lsst::afw::image::Image< PixelT >::operator= ( const PixelT  rhs)

Set the image's pixels to rhs.

Definition at line 476 of file Image.cc.

476  {
477  this->ImageBase<PixelT>::operator=(rhs);
478 
479  return *this;
480 }
ImageBase & operator=(const ImageBase &rhs)
Definition: Image.cc:212
template<typename PixelT>
image::Image< PixelT > & lsst::afw::image::Image< PixelT >::operator= ( const Image< PixelT > &  rhs)

Assignment operator.

Note
that this has the effect of making the lhs share pixels with the rhs which may not be what you intended; to copy the pixels, use operator<<=()
this behaviour is required to make the swig interface work, otherwise I'd declare this function private

Definition at line 490 of file Image.cc.

490  {
491  this->ImageBase<PixelT>::operator=(rhs);
492 
493  return *this;
494 }
ImageBase & operator=(const ImageBase &rhs)
Definition: Image.cc:212
template<typename PixelT>
static Image lsst::afw::image::Image< PixelT >::readFits ( std::string const &  filename,
int  hdu = 0 
)
inlinestatic

Read an Image from a regular FITS file.

Parameters
[in]filenameName of the file to read.
[in]hduNumber of the "header-data unit" to read (where 1 is the Primary HDU). The default value of 0 is interpreted as "the first HDU with NAXIS != 0".

Definition at line 555 of file Image.h.

555  {
556  return Image<PixelT>(filename, hdu);
557  }
template<typename PixelT>
static Image lsst::afw::image::Image< PixelT >::readFits ( fits::MemFileManager manager,
int  hdu = 0 
)
inlinestatic

Read an Image from a FITS RAM file.

Parameters
[in]managerObject that manages the memory to be read.
[in]hduNumber of the "header-data unit" to read (where 1 is the Primary HDU). The default value of 0 is interpreted as "the first HDU with NAXIS != 0".

Definition at line 566 of file Image.h.

566  {
567  return Image<PixelT>(manager, hdu);
568  }
template<typename PixelT>
void lsst::afw::image::Image< PixelT >::scaledDivides ( double const  c,
Image< PixelT >const &  rhs 
)

Divide lhs by Image c*rhs (i.e. pixel-by-pixel division)

Definition at line 795 of file Image.cc.

795  {
796  if (this->getDimensions() != rhs.getDimensions()) {
797  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
798  (boost::format("Images are of different size, %dx%d v %dx%d") %
799  this->getWidth() % this->getHeight() % rhs.getWidth() % rhs.getHeight()).str());
800  }
801  transform_pixels(_getRawView(), rhs._getRawView(), _getRawView(),
802  bl::ret<PixelT>(bl::_1 / bl::ret<PixelT>(c*bl::_2)));
803 }
geom::Extent2I getDimensions() const
Return the image&#39;s size; useful for passing to constructors.
Definition: Image.h:298
_view_t _getRawView() const
Definition: Image.h:401
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:239
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:237
template<typename PixelT>
void lsst::afw::image::Image< PixelT >::scaledMinus ( double const  c,
Image< PixelT >const &  rhs 
)

Subtract Image c*rhs from lhs.

Definition at line 702 of file Image.cc.

702  {
703  if (this->getDimensions() != rhs.getDimensions()) {
704  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
705  (boost::format("Images are of different size, %dx%d v %dx%d") %
706  this->getWidth() % this->getHeight() % rhs.getWidth() % rhs.getHeight()).str());
707  }
708  transform_pixels(_getRawView(), rhs._getRawView(), _getRawView(),
709  bl::ret<PixelT>(bl::_1 - bl::ret<PixelT>(c*bl::_2)));
710 }
geom::Extent2I getDimensions() const
Return the image&#39;s size; useful for passing to constructors.
Definition: Image.h:298
_view_t _getRawView() const
Definition: Image.h:401
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:239
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:237
template<typename PixelT>
void lsst::afw::image::Image< PixelT >::scaledMultiplies ( double const  c,
Image< PixelT >const &  rhs 
)

Multiply lhs by Image c*rhs (i.e. pixel-by-pixel multiplication)

Definition at line 748 of file Image.cc.

748  {
749  if (this->getDimensions() != rhs.getDimensions()) {
750  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
751  (boost::format("Images are of different size, %dx%d v %dx%d") %
752  this->getWidth() % this->getHeight() % rhs.getWidth() % rhs.getHeight()).str());
753  }
754  transform_pixels(_getRawView(), rhs._getRawView(), _getRawView(),
755  bl::ret<PixelT>(bl::_1 * bl::ret<PixelT>(c*bl::_2)));
756 }
geom::Extent2I getDimensions() const
Return the image&#39;s size; useful for passing to constructors.
Definition: Image.h:298
_view_t _getRawView() const
Definition: Image.h:401
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:239
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:237
template<typename PixelT>
void lsst::afw::image::Image< PixelT >::scaledPlus ( double const  c,
Image< PixelT >const &  rhs 
)

Add Image c*rhs to lhs.

Definition at line 673 of file Image.cc.

673  {
674  if (this->getDimensions() != rhs.getDimensions()) {
675  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
676  (boost::format("Images are of different size, %dx%d v %dx%d") %
677  this->getWidth() % this->getHeight() % rhs.getWidth() % rhs.getHeight()).str());
678  }
679  transform_pixels(_getRawView(), rhs._getRawView(), _getRawView(),
680  bl::ret<PixelT>(bl::_1 + bl::ret<PixelT>(c*bl::_2)));
681 }
geom::Extent2I getDimensions() const
Return the image&#39;s size; useful for passing to constructors.
Definition: Image.h:298
_view_t _getRawView() const
Definition: Image.h:401
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:239
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:237
template<typename PixelT >
void lsst::afw::image::Image< PixelT >::sqrt ( )

Definition at line 632 of file Image.cc.

632  {
633  transform_pixels(_getRawView(), _getRawView(),
634  boost::bind(mysqrt<PixelT>, bl::_1));
635 }
_view_t _getRawView() const
Definition: Image.h:401
template<typename PixelT >
void lsst::afw::image::Image< PixelT >::swap ( Image< PixelT > &  rhs)

Definition at line 602 of file Image.cc.

602  {
603  using std::swap; // See Meyers, Effective C++, Item 25
605  ; // no private variables to swap
606 }
void swap(ImageBase< PixelT > &a, ImageBase< PixelT > &b)
Definition: Image.cc:287
void swap(ImageBase &rhs)
Definition: Image.cc:278
template<typename PixelT>
void lsst::afw::image::Image< PixelT >::writeFits ( std::string const &  fileName,
boost::shared_ptr< lsst::daf::base::PropertySet const >  metadata = boost::shared_ptr< lsst::daf::base::PropertySet const  >(),
std::string const &  mode = "w" 
) const

Write an image to a regular FITS file.

Parameters
[in]fileNameName of the file to write.
[in]metadataAdditional values to write to the header (may be null).
[in]mode"w"=Create a new file; "a"=Append a new HDU.
template<typename PixelT>
void lsst::afw::image::Image< PixelT >::writeFits ( fits::MemFileManager manager,
boost::shared_ptr< lsst::daf::base::PropertySet const >  metadata = boost::shared_ptr< lsst::daf::base::PropertySet const  >(),
std::string const &  mode = "w" 
) const

Write an image to a FITS RAM file.

Parameters
[in]managerManager object for the memory block to write to.
[in]metadataAdditional values to write to the header (may be null).
[in]mode"w"=Create a new file; "a"=Append a new HDU.
template<typename PixelT>
void lsst::afw::image::Image< PixelT >::writeFits ( fits::Fits fitsfile,
boost::shared_ptr< lsst::daf::base::PropertySet const >  metadata = boost::shared_ptr< lsst::daf::base::PropertySet const  >() 
) const

Write an image to an open FITS file object.

Parameters
[in]fitsfileA FITS file already open to the desired HDU.
[in]metadataAdditional values to write to the header (may be null).

Friends And Related Function Documentation

template<typename PixelT>
template<typename OtherPixelT >
friend class Image
friend

Definition at line 431 of file Image.h.

template<typename ImageT >
ImageT::SinglePixel badPixel ( typename ImageT::Pixel  bad = 0)
related

Return a value indicating a bad pixel for the given Image type

A quiet NaN is returned for types that support it otherwise bad

Parameters
badThe bad value if NaN isn't supported

Definition at line 70 of file Utils.h.

71  {
72  typedef typename ImageT::SinglePixel SinglePixelT;
73  return SinglePixelT(std::numeric_limits<SinglePixelT>::has_quiet_NaN ?
74  std::numeric_limits<SinglePixelT>::quiet_NaN() : bad);
75 }
template<typename PixelT>
template<typename , typename , typename >
friend class MaskedImage
friend

Definition at line 417 of file Image.h.


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