LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Types | Private Attributes | Friends | List of all members
lsst.afw.image::ImageBase< PixelT > Class Template Reference

The base class for all image classed (Image, Mask, MaskedImage, ...) More...

#include <Image.h>

Inheritance diagram for lsst.afw.image::ImageBase< PixelT >:
lsst::daf::base::Persistable lsst::daf::base::Citizen lsst.afw.image::Image< EntryT > lsst.afw.image::Image< float > lsst.afw.image::Image< ImagePixelT > lsst.afw.image::Image< ImageT > lsst.afw.image::Image< InternalPixelT > lsst.afw.image::Image< lsst::afw::image::VariancePixel > lsst.afw.image::Image< lsst::afw::math::Kernel::Pixel > lsst.afw.image::Image< Pixel > lsst.afw.image::Image< PixelT > lsst.afw.image::Image< VariancePixelT > lsst.afw.image::Image< VarianceT > lsst.afw.image::Image< T >

Public Types

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

 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

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...
 

Protected Member Functions

_view_t _getRawView () const
 
bool isContiguous () const
 

Static Protected Member Functions

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)
 

Private Types

typedef
lsst::afw::image::detail::types_traits
< PixelT >::view_t 
_view_t
 
typedef
lsst::afw::image::detail::types_traits
< PixelT >::const_view_t 
_const_view_t
 
typedef ndarray::Manager Manager
 

Private Attributes

geom::Point2I _origin
 
Manager::Ptr _manager
 
_view_t _gilView
 

Friends

template<typename OtherPixelT >
class ImageBase
 
template<typename >
class DecoratedImage
 
template<typename , typename , typename >
class MaskedImage
 

Detailed Description

template<typename PixelT>
class lsst.afw.image::ImageBase< PixelT >

The base class for all image classed (Image, Mask, MaskedImage, ...)

Definition at line 115 of file Image.h.

Member Typedef Documentation

template<typename PixelT>
typedef lsst::afw::image::detail::types_traits<PixelT>::const_view_t lsst.afw.image::ImageBase< PixelT >::_const_view_t
private

Definition at line 119 of file Image.h.

template<typename PixelT>
typedef lsst::afw::image::detail::types_traits<PixelT>::view_t lsst.afw.image::ImageBase< PixelT >::_view_t
private

Definition at line 118 of file Image.h.

template<typename PixelT>
typedef ndarray::Array<PixelT, 2, 1> lsst.afw.image::ImageBase< PixelT >::Array

A mutable ndarray representation of the image.

Definition at line 166 of file Image.h.

template<typename PixelT>
typedef _const_view_t::iterator lsst.afw.image::ImageBase< PixelT >::const_iterator

An STL compliant const iterator.

Definition at line 145 of file Image.h.

template<typename PixelT>
typedef _const_view_t::reverse_iterator lsst.afw.image::ImageBase< PixelT >::const_reverse_iterator

An STL compliant const reverse iterator.

Definition at line 149 of file Image.h.

template<typename PixelT>
typedef _const_view_t::x_iterator lsst.afw.image::ImageBase< PixelT >::const_x_iterator

A const iterator for traversing the pixels in a row.

Definition at line 158 of file Image.h.

template<typename PixelT>
typedef _view_t::xy_locator::const_t lsst.afw.image::ImageBase< PixelT >::const_xy_locator

A const_xy_locator.

Definition at line 141 of file Image.h.

template<typename PixelT>
typedef _const_view_t::y_iterator lsst.afw.image::ImageBase< PixelT >::const_y_iterator

A const iterator for traversing the pixels in a column.

Definition at line 164 of file Image.h.

template<typename PixelT>
typedef ndarray::Array<PixelT const, 2, 1> lsst.afw.image::ImageBase< PixelT >::ConstArray

An immutable ndarray representation of the image.

Definition at line 168 of file Image.h.

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

A shared_ptr to a const ImageBase.

Definition at line 126 of file Image.h.

template<typename PixelT>
typedef x_iterator lsst.afw.image::ImageBase< PixelT >::fast_iterator

A fast STL compliant iterator for contiguous images N.b. The order of pixel access is undefined

Definition at line 154 of file Image.h.

template<typename PixelT>
typedef detail::basic_tag lsst.afw.image::ImageBase< PixelT >::image_category

trait class to identify type of image

Definition at line 128 of file Image.h.

template<typename PixelT>
typedef _view_t::iterator lsst.afw.image::ImageBase< PixelT >::iterator

An STL compliant iterator.

Definition at line 143 of file Image.h.

template<typename PixelT>
typedef ndarray::Manager lsst.afw.image::ImageBase< PixelT >::Manager
private

Definition at line 122 of file Image.h.

template<typename PixelT>
typedef PixelT lsst.afw.image::ImageBase< PixelT >::Pixel

A pixel in this ImageBase.

Definition at line 133 of file Image.h.

template<typename PixelT>
typedef ConstReference<PixelT>::type lsst.afw.image::ImageBase< PixelT >::PixelConstReference

A ConstReference to a PixelT.

Definition at line 137 of file Image.h.

template<typename PixelT>
typedef Reference<PixelT>::type lsst.afw.image::ImageBase< PixelT >::PixelReference

A Reference to a PixelT.

Definition at line 135 of file Image.h.

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

A shared_ptr to an ImageBase.

Definition at line 125 of file Image.h.

template<typename PixelT>
typedef _view_t::reverse_iterator lsst.afw.image::ImageBase< PixelT >::reverse_iterator

An STL compliant reverse iterator.

Definition at line 147 of file Image.h.

template<typename PixelT>
typedef PixelT lsst.afw.image::ImageBase< PixelT >::SinglePixel

A single Pixel of the same type as those in the ImageBase.

Definition at line 131 of file Image.h.

template<typename PixelT>
typedef _view_t::x_iterator lsst.afw.image::ImageBase< PixelT >::x_iterator

An iterator for traversing the pixels in a row.

Definition at line 151 of file Image.h.

template<typename PixelT>
typedef _view_t::xy_locator lsst.afw.image::ImageBase< PixelT >::xy_locator

An xy_locator.

Definition at line 139 of file Image.h.

template<typename PixelT>
typedef _view_t::x_iterator lsst.afw.image::ImageBase< PixelT >::xy_x_iterator

An iterator for traversing the pixels in a row, created from an xy_locator.

Definition at line 156 of file Image.h.

template<typename PixelT>
typedef _view_t::y_iterator lsst.afw.image::ImageBase< PixelT >::xy_y_iterator

An iterator for traversing the pixels in a row, created from an xy_locator.

Definition at line 162 of file Image.h.

template<typename PixelT>
typedef _view_t::y_iterator lsst.afw.image::ImageBase< PixelT >::y_iterator

An iterator for traversing the pixels in a column.

Definition at line 160 of file Image.h.

Constructor & Destructor Documentation

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

Allocator Constructor

allocate a new image with the specified dimensions. Sets origin at (0,0)

Definition at line 108 of file Image.cc.

110  : lsst::daf::base::Citizen(typeid(this)),
111  _origin(0,0), _manager(),
112  _gilView(_allocateView(dimensions, _manager))
113 {}
Manager::Ptr _manager
Definition: Image.h:385
geom::Point2I _origin
Definition: Image.h:384
static _view_t _allocateView(geom::Extent2I const &dimensions, Manager::Ptr &manager)
Definition: Image.cc:53
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Definition: Citizen.h:56
template<typename PixelT >
lsst.afw.image::ImageBase< PixelT >::ImageBase ( const geom::Box2I bbox)
explicit

Allocator Constructor

allocate a new image with the specified dimensions and origin

Definition at line 121 of file Image.cc.

123  : lsst::daf::base::Citizen(typeid(this)),
124  _origin(bbox.getMin()), _manager(),
126 {}
Manager::Ptr _manager
Definition: Image.h:385
geom::Point2I _origin
Definition: Image.h:384
static _view_t _allocateView(geom::Extent2I const &dimensions, Manager::Ptr &manager)
Definition: Image.cc:53
Extent2I const getDimensions() const
Definition: Box.h:153
Point2I const getMin() const
Definition: Box.h:123
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Definition: Citizen.h:56
template<typename PixelT >
lsst.afw.image::ImageBase< PixelT >::ImageBase ( const ImageBase< PixelT > &  src,
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
srcRight-hand-side image
deepIf false, new ImageBase shares storage with rhs; if true make a new, standalone, ImageBase

Definition at line 135 of file Image.cc.

139  :
140  lsst::daf::base::Citizen(typeid(this)),
141  _origin(rhs._origin),
142  _manager(rhs._manager),
143  _gilView(rhs._gilView)
144 {
145  if (deep) {
146  ImageBase tmp(getBBox());
147  tmp <<= *this; // now copy the pixels
148  swap(tmp);
149  }
150 }
Manager::Ptr _manager
Definition: Image.h:385
geom::Point2I _origin
Definition: Image.h:384
void swap(ImageBase &rhs)
Definition: Image.cc:282
friend class ImageBase
Definition: Image.h:170
geom::Box2I getBBox(ImageOrigin origin=PARENT) const
Definition: Image.h:377
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Definition: Citizen.h:56
template<typename PixelT >
lsst.afw.image::ImageBase< PixelT >::ImageBase ( const ImageBase< PixelT > &  src,
const geom::Box2I bbox,
const ImageOrigin  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
srcRight-hand-side image
bboxSpecify desired region
originSpecify the coordinate system of the bbox
deepIf false, new ImageBase shares storage with rhs; if true make a new, standalone, ImageBase

Definition at line 161 of file Image.cc.

167  :
168  lsst::daf::base::Citizen(typeid(this)),
169  _origin((origin==PARENT) ? bbox.getMin(): rhs._origin + geom::Extent2I(bbox.getMin())),
170  _manager(rhs._manager), // reference counted pointer, don't copy pixels
171  _gilView(_makeSubView(bbox.getDimensions(), _origin - rhs._origin, rhs._gilView))
172 {
173  if (deep) {
174  ImageBase tmp(getBBox());
175  tmp <<= *this; // now copy the pixels
176  swap(tmp);
177  }
178 }
Manager::Ptr _manager
Definition: Image.h:385
geom::Point2I _origin
Definition: Image.h:384
void swap(ImageBase &rhs)
Definition: Image.cc:282
Extent2I const getDimensions() const
Definition: Box.h:153
static _view_t _makeSubView(geom::Extent2I const &dimensions, geom::Extent2I const &offset, const _view_t &view)
Definition: Image.cc:78
friend class ImageBase
Definition: Image.h:170
geom::Box2I getBBox(ImageOrigin origin=PARENT) const
Definition: Image.h:377
Point2I const getMin() const
Definition: Box.h:123
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Definition: Citizen.h:56
Extent< int, 2 > Extent2I
Definition: Extent.h:355
template<typename PixelT>
template<typename OtherPixelT >
lsst.afw.image::ImageBase< PixelT >::ImageBase ( const ImageBase< OtherPixelT > &  rhs,
const bool  deep 
)
inline

generalised copy constructor

defined here in the header so that the compiler can instantiate N(N-1) conversions between N ImageBase types.

Definition at line 193 of file Image.h.

193  :
194  lsst::daf::base::Citizen(typeid(this)) {
195  if (!deep) {
196  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
197  "Only deep copies are permitted for ImageBases with different pixel types");
198  }
199 
200  ImageBase<PixelT> tmp(rhs.getBBox());
201  copy_and_convert_pixels(rhs._gilView, tmp._gilView); // from boost::gil
202 
203  using std::swap; // See Meyers, Effective C++, Item 25
204  ImageBase<PixelT>::swap(tmp); // See Meyers, Effective C++, Items 11 and 43
205  }
void swap(ImageBase< PixelT > &a, ImageBase< PixelT > &b)
Definition: Image.cc:291
void swap(ImageBase &rhs)
Definition: Image.cc:282
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Definition: Citizen.h:56
template<typename PixelT >
lsst.afw.image::ImageBase< PixelT >::ImageBase ( Array const &  array,
bool  deep = false,
geom::Point2I const &  xy0 = geom::Point2I() 
)
explicit

Construction from ndarray::Array and NumPy.

Note
ndarray and NumPy indexes are ordered (y,x), but Image indices are ordered (x,y).

Unless deep is true, the new image will share memory with the array if the the dimension is contiguous in memory. If the last dimension is not contiguous, the array will be deep-copied in Python, but the constructor will fail to compile in pure C++.

Definition at line 190 of file Image.cc.

190  :
191  lsst::daf::base::Citizen(typeid(this)),
192  _origin(xy0),
193  _manager(array.getManager()),
194  _gilView(
195  boost::gil::interleaved_view(
196  array.template getSize<1>(), array.template getSize<0>(),
197  (typename _view_t::value_type* )array.getData(),
198  array.template getStride<0>() * sizeof(PixelT)
199  )
200  )
201 {
202  if (deep) {
203  ImageBase tmp(*this, true);
204  swap(tmp);
205  }
206 }
Manager::Ptr _manager
Definition: Image.h:385
geom::Point2I _origin
Definition: Image.h:384
void swap(ImageBase &rhs)
Definition: Image.cc:282
friend class ImageBase
Definition: Image.h:170
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Definition: Citizen.h:56
template<typename PixelT>
virtual lsst.afw.image::ImageBase< PixelT >::~ImageBase ( )
inlinevirtual

Definition at line 211 of file Image.h.

211 { }

Member Function Documentation

template<typename PixelT >
image::ImageBase< PixelT >::_view_t lsst.afw.image::ImageBase< PixelT >::_allocateView ( geom::Extent2I const &  dimensions,
Manager::Ptr manager 
)
staticprotected

Definition at line 53 of file Image.cc.

56  {
57  if (dimensions.getX() < 0 || dimensions.getY() < 0) {
58  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
59  str(boost::format("Both width and height must be non-negative: %d, %d")
60  % dimensions.getX() % dimensions.getY()));
61  }
62  if (dimensions.getX() != 0 && dimensions.getY() > std::numeric_limits<int>::max()/dimensions.getX()) {
63  throw LSST_EXCEPT(pex::exceptions::LengthError,
64  str(boost::format("Image dimensions (%d x %d) too large; int overflow detected.")
65  % dimensions.getX() % dimensions.getY()));
66  }
67  std::pair<Manager::Ptr,PixelT*> r = ndarray::SimpleManager<PixelT>::allocate(
68  dimensions.getX() * dimensions.getY()
69  );
70  manager = r.first;
71  return boost::gil::interleaved_view(
72  dimensions.getX(), dimensions.getY(),
73  (typename _view_t::value_type* )r.second,
74  dimensions.getX()*sizeof(PixelT)
75  );
76 }
afw::table::PointKey< int > dimensions
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
static std::pair< Manager::Ptr, T * > allocate(int size)
Definition: Manager.h:71
template<typename PixelT>
_view_t lsst.afw.image::ImageBase< PixelT >::_getRawView ( ) const
inlineprotected

Definition at line 401 of file Image.h.

401 { return _gilView; }
template<typename PixelT >
image::ImageBase< PixelT >::_view_t lsst.afw.image::ImageBase< PixelT >::_makeSubView ( geom::Extent2I const &  dimensions,
geom::Extent2I const &  offset,
const _view_t view 
)
staticprotected

Definition at line 78 of file Image.cc.

80  {
81  if (offset.getX() < 0 || offset.getY() < 0 ||
82  offset.getX() + dimensions.getX() > view.width() ||
83  offset.getY() + dimensions.getY() > view.height()
84  ) {
85  throw LSST_EXCEPT(
86  lsst::pex::exceptions::LengthError,
87  (boost::format("Box2I(Point2I(%d,%d),Extent2I(%d,%d)) doesn't fit in image %dx%d") %
88  offset.getX() % offset.getY() %
89  dimensions.getX() % dimensions.getY() %
90  view.width() % view.height()
91  ).str()
92  );
93  }
94  return boost::gil::subimage_view(
95  view,
96  offset.getX(), offset.getY(),
97  dimensions.getX(), dimensions.getY()
98  );
99 }
View< boost::fusion::vector1< index::Full > > view()
Start a view definition that includes the entire first dimension.
Definition: views.h:131
afw::table::PointKey< int > dimensions
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<typename PixelT >
image::ImageBase< PixelT >::iterator lsst.afw.image::ImageBase< PixelT >::at ( int  x,
int  y 
) const

Return an STL compliant iterator at the point (x, y)

Definition at line 349 of file Image.cc.

349  {
350  return _gilView.at(x, y);
351 }
int y
int x
template<typename PixelT >
image::ImageBase< PixelT >::iterator lsst.afw.image::ImageBase< PixelT >::begin ( void  ) const

Return an STL compliant iterator to the start of the image

Note that this isn't especially efficient; see imageIterators for a discussion

Definition at line 325 of file Image.cc.

325  {
326  return _gilView.begin();
327 }
template<typename PixelT >
image::ImageBase< PixelT >::fast_iterator lsst.afw.image::ImageBase< PixelT >::begin ( bool  contiguous) const

Return a fast STL compliant iterator to the start of the image which must be contiguous

Exceptions
lsst::pex::exceptions::RuntimeArgument contiguous is false, or the pixels are not in fact contiguous
Parameters
contiguousPixels are contiguous (must be true)

Definition at line 358 of file Image.cc.

360  {
361  if (!contiguous) {
362  throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
363  "Only contiguous == true makes sense");
364  }
365  if (!this->isContiguous()) {
366  throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
367  "Image's pixels are not contiguous");
368  }
369 
370  return row_begin(0);
371 }
x_iterator row_begin(int y) const
Definition: Image.h:319
bool isContiguous() const
Definition: Image.h:404
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<typename PixelT>
y_iterator lsst.afw.image::ImageBase< PixelT >::col_begin ( int  x) const
inline

Return an y_iterator to the start of the y'th row

Incrementing an y_iterator moves it up the column

Definition at line 334 of file Image.h.

334  {
335  return _gilView.col_begin(x);
336  }
int x
template<typename PixelT>
y_iterator lsst.afw.image::ImageBase< PixelT >::col_end ( int  x) const
inline

Return an y_iterator to the end of the y'th row.

Definition at line 339 of file Image.h.

339  {
340  return _gilView.col_end(x);
341  }
int x
template<typename PixelT >
image::ImageBase< PixelT >::iterator lsst.afw.image::ImageBase< PixelT >::end ( void  ) const

Return an STL compliant iterator to the end of the image.

Definition at line 331 of file Image.cc.

331  {
332  return _gilView.end();
333 }
template<typename PixelT >
image::ImageBase< PixelT >::fast_iterator lsst.afw.image::ImageBase< PixelT >::end ( bool  contiguous) const

Return a fast STL compliant iterator to the end of the image which must be contiguous

Exceptions
lsst::pex::exceptions::RuntimeArgument contiguous is false, or the pixels are not in fact contiguous
Parameters
contiguousPixels are contiguous (must be true)

Definition at line 378 of file Image.cc.

380  {
381  if (!contiguous) {
382  throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
383  "Only contiguous == true makes sense");
384  }
385  if (!this->isContiguous()) {
386  throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
387  "Image's pixels are not contiguous");
388  }
389 
390  return row_end(getHeight()-1);
391 }
x_iterator row_end(int y) const
Return an x_iterator to the end of the y&#39;th row.
Definition: Image.h:324
bool isContiguous() const
Definition: Image.h:404
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:239
template<typename PixelT>
PixelConstReference lsst.afw.image::ImageBase< PixelT >::get0 ( int  x,
int  y 
) const
inline

Definition at line 223 of file Image.h.

223  {
224  return operator()(x-getX0(), y-getY0());
225  }
int y
PixelReference operator()(int x, int y)
Return a reference to the pixel (x, y)
Definition: Image.cc:236
int getY0() const
Definition: Image.h:255
int x
int getX0() const
Definition: Image.h:247
template<typename PixelT>
PixelConstReference lsst.afw.image::ImageBase< PixelT >::get0 ( int  x,
int  y,
CheckIndices const &  check 
) const
inline

Definition at line 226 of file Image.h.

226  {
227  return operator()(x-getX0(), y-getY0(), check);
228  }
int y
PixelReference operator()(int x, int y)
Return a reference to the pixel (x, y)
Definition: Image.cc:236
int getY0() const
Definition: Image.h:255
int x
int getX0() const
Definition: Image.h:247
template<typename PixelT >
image::ImageBase< PixelT >::Array lsst.afw.image::ImageBase< PixelT >::getArray ( )

Definition at line 296 of file Image.cc.

296  {
297  int rowStride = reinterpret_cast<PixelT*>(row_begin(1)) - reinterpret_cast<PixelT*>(row_begin(0));
298  return ndarray::external(
299  reinterpret_cast<PixelT*>(row_begin(0)),
301  ndarray::makeVector(rowStride, 1),
302  this->_manager
303  );
304 }
Manager::Ptr _manager
Definition: Image.h:385
x_iterator row_begin(int y) const
Definition: Image.h:319
detail::ExternalInitializer< T, N, Owner > external(T *data, Vector< int, N > const &shape, Vector< int, N > const &strides, Owner const &owner)
Create an expression that initializes an Array with externally allocated memory.
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:237
Vector< T, N > makeVector(T v1, T v2,..., T vN)
Variadic constructor for Vector.
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:239
template<typename PixelT >
image::ImageBase< PixelT >::ConstArray lsst.afw.image::ImageBase< PixelT >::getArray ( ) const

Definition at line 308 of file Image.cc.

308  {
309  int rowStride = reinterpret_cast<PixelT*>(row_begin(1)) - reinterpret_cast<PixelT*>(row_begin(0));
310  return ndarray::external(
311  reinterpret_cast<PixelT*>(row_begin(0)),
313  ndarray::makeVector(rowStride, 1),
314  this->_manager
315  );
316 }
Manager::Ptr _manager
Definition: Image.h:385
x_iterator row_begin(int y) const
Definition: Image.h:319
detail::ExternalInitializer< T, N, Owner > external(T *data, Vector< int, N > const &shape, Vector< int, N > const &strides, Owner const &owner)
Create an expression that initializes an Array with externally allocated memory.
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:237
Vector< T, N > makeVector(T v1, T v2,..., T vN)
Variadic constructor for Vector.
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:239
template<typename PixelT>
geom::Box2I lsst.afw.image::ImageBase< PixelT >::getBBox ( ImageOrigin  origin = PARENT) const
inline

Definition at line 377 of file Image.h.

377  {
378  if (origin == PARENT) {
379  return geom::Box2I(_origin, getDimensions());
380  }
381  else return geom::Box2I(geom::Point2I(0,0), getDimensions());
382  }
geom::Point2I _origin
Definition: Image.h:384
An integer coordinate rectangle.
Definition: Box.h:53
geom::Extent2I getDimensions() const
Return the image&#39;s size; useful for passing to constructors.
Definition: Image.h:298
template<typename PixelT>
geom::Extent2I lsst.afw.image::ImageBase< PixelT >::getDimensions ( ) const
inline

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

Definition at line 298 of file Image.h.

298 { return geom::Extent2I(getWidth(), getHeight()); }
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:237
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:239
Extent< int, 2 > Extent2I
Definition: Extent.h:355
template<typename PixelT>
int lsst.afw.image::ImageBase< PixelT >::getHeight ( ) const
inline

Return the number of rows in the image.

Definition at line 239 of file Image.h.

239 { return _gilView.height(); }
template<typename PixelT>
int lsst.afw.image::ImageBase< PixelT >::getWidth ( ) const
inline

Return the number of columns in the image.

Definition at line 237 of file Image.h.

237 { return _gilView.width(); }
template<typename PixelT>
int lsst.afw.image::ImageBase< PixelT >::getX0 ( ) const
inline

Return the image's column-origin

This will usually be 0 except for images created using the ImageBase(fileName, hdu, BBox, mode) ctor or ImageBase(ImageBase, BBox) cctor The origin can be reset with setXY0

Definition at line 247 of file Image.h.

247 { return _origin.getX(); }
geom::Point2I _origin
Definition: Image.h:384
template<typename PixelT>
geom::Point2I lsst.afw.image::ImageBase< PixelT >::getXY0 ( ) const
inline

Return the image's origin

This will usually be (0, 0) except for images created using the ImageBase(fileName, hdu, BBox, mode) ctor or ImageBase(ImageBase, BBox) cctor The origin can be reset with setXY0

Definition at line 264 of file Image.h.

264 { return _origin; }
geom::Point2I _origin
Definition: Image.h:384
template<typename PixelT>
int lsst.afw.image::ImageBase< PixelT >::getY0 ( ) const
inline

Return the image's row-origin

This will usually be 0 except for images created using the ImageBase(fileName, hdu, BBox, mode) ctor or ImageBase(ImageBase, BBox) cctor The origin can be reset with setXY0

Definition at line 255 of file Image.h.

255 { return _origin.getY(); }
geom::Point2I _origin
Definition: Image.h:384
template<typename PixelT>
double lsst.afw.image::ImageBase< PixelT >::indexToPosition ( double  ind,
lsst::afw::image::xOrY const  xy 
) const
inline

Convert image index to image position.

The LSST indexing convention is:

  • the index of the bottom left pixel is 0,0
  • the position of the center of the bottom left pixel is PixelZeroPos, PixelZeroPos
Returns
image position
Parameters
indimage index
xyIs this a column or row coordinate?

Definition at line 290 of file Image.h.

293  {
294  return ind + PixelZeroPos + (xy == X ? getX0() : getY0());
295  }
int getY0() const
Definition: Image.h:255
const double PixelZeroPos
FITS uses 1.0, SDSS uses 0.5, LSST uses 0.0 (http://dev.lsstcorp.org/trac/wiki/BottomLeftPixelProposa...
Definition: ImageUtils.h:42
int getX0() const
Definition: Image.h:247
template<typename PixelT>
bool lsst.afw.image::ImageBase< PixelT >::isContiguous ( ) const
inlineprotected

Definition at line 404 of file Image.h.

404  {
405  return begin()+getWidth()*getHeight() == end();
406  }
iterator begin() const
Definition: Image.cc:325
iterator end() const
Return an STL compliant iterator to the end of the image.
Definition: Image.cc:331
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:237
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:239
template<typename PixelT >
image::ImageBase< PixelT >::PixelReference lsst.afw.image::ImageBase< PixelT >::operator() ( int  x,
int  y 
)

Return a reference to the pixel (x, y)

Definition at line 236 of file Image.cc.

236  {
237  return const_cast<typename image::ImageBase<PixelT>::PixelReference>(
238  static_cast<typename image::ImageBase<PixelT>::PixelConstReference>(_gilView(x, y)[0])
239  );
240 }
int y
The base class for all image classed (Image, Mask, MaskedImage, ...)
Definition: Image.h:115
int x
template<typename PixelT >
image::ImageBase< PixelT >::PixelReference lsst.afw.image::ImageBase< PixelT >::operator() ( int  x,
int  y,
image::CheckIndices const &  check 
)

Return a reference to the pixel (x, y) with bounds checking.

Definition at line 244 of file Image.cc.

249 {
250  if (check && (x < 0 || x >= getWidth() || y < 0 || y >= getHeight())) {
251  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
252  (boost::format("Index (%d, %d) is out of range [0--%d], [0--%d]") %
253  x % y % (getWidth() - 1) % (getHeight() - 1)).str());
254  }
255 
256  return const_cast<typename image::ImageBase<PixelT>::PixelReference>(
257  static_cast<typename image::ImageBase<PixelT>::PixelConstReference>(_gilView(x, y)[0])
258  );
259 }
int y
The base class for all image classed (Image, Mask, MaskedImage, ...)
Definition: Image.h:115
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:237
int x
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:239
template<typename PixelT >
image::ImageBase< PixelT >::PixelConstReference lsst.afw.image::ImageBase< PixelT >::operator() ( int  x,
int  y 
) const

Return a const reference to the pixel (x, y)

Definition at line 264 of file Image.cc.

264  {
265  return _gilView(x, y)[0];
266 }
int y
int x
template<typename PixelT >
image::ImageBase< PixelT >::PixelConstReference lsst.afw.image::ImageBase< PixelT >::operator() ( int  x,
int  y,
image::CheckIndices const &  check 
) const

Return a const reference to the pixel (x, y) with bounds checking.

Definition at line 271 of file Image.cc.

271  {
272  if (check && (x < 0 || x >= getWidth() || y < 0 || y >= getHeight())) {
273  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
274  (boost::format("Index (%d, %d) is out of range [0--%d], [0--%d]") %
275  x % y % (this->getWidth() - 1) % (this->getHeight() - 1)).str());
276  }
277 
278  return _gilView(x, y)[0];
279 }
int y
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:237
int x
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:239
template<typename PixelT >
void lsst.afw.image::ImageBase< PixelT >::operator<<= ( const ImageBase< PixelT > &  rhs)

Set the lhs's pixel values to equal the rhs's.

Definition at line 225 of file Image.cc.

225  {
226  if (getDimensions() != rhs.getDimensions()) {
227  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
228  (boost::format("Dimension mismatch: %dx%d v. %dx%d") %
229  getWidth() % getHeight() % rhs.getWidth() % rhs.getHeight()).str());
230  }
231  copy_pixels(rhs._gilView, _gilView);
232 }
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:237
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:239
geom::Extent2I getDimensions() const
Return the image&#39;s size; useful for passing to constructors.
Definition: Image.h:298
template<typename PixelT >
image::ImageBase< PixelT > & lsst.afw.image::ImageBase< PixelT >::operator= ( const ImageBase< PixelT > &  rhs)

Shallow 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 216 of file Image.cc.

216  {
217  ImageBase tmp(rhs);
218  swap(tmp); // See Meyers, Effective C++, Item 11
219 
220  return *this;
221 }
void swap(ImageBase &rhs)
Definition: Image.cc:282
friend class ImageBase
Definition: Image.h:170
template<typename PixelT>
image::ImageBase< PixelT > & lsst.afw.image::ImageBase< PixelT >::operator= ( const PixelT  rhs)

Set the image's pixels to rhs.

Definition at line 396 of file Image.cc.

396  {
397  fill_pixels(_gilView, rhs);
398 
399  return *this;
400 }
template<typename PixelT>
template<typename SinglePixelT >
static SinglePixel lsst.afw.image::ImageBase< PixelT >::PixelCast ( SinglePixelT  rhs)
inlinestatic

Convert a type to our SinglePixel type.

Definition at line 175 of file Image.h.

175  {
176  return SinglePixel(rhs);
177  }
PixelT SinglePixel
A single Pixel of the same type as those in the ImageBase.
Definition: Image.h:131
template<typename PixelT>
std::pair<int, double> lsst.afw.image::ImageBase< PixelT >::positionToIndex ( double const  pos,
lsst::afw::image::xOrY const  xy 
) const
inline

Convert image position to index (nearest integer and fractional parts)

Returns
std::pair(nearest integer index, fractional part)
Parameters
posimage position
xyIs this a column or row coordinate?

Definition at line 271 of file Image.h.

274  {
275  double const fullIndex = pos - PixelZeroPos - (xy == X ? getX0() : getY0());
276  int const roundedIndex = static_cast<int>(fullIndex + 0.5);
277  double const residual = fullIndex - roundedIndex;
278  return std::pair<int, double>(roundedIndex, residual);
279  }
int getY0() const
Definition: Image.h:255
const double PixelZeroPos
FITS uses 1.0, SDSS uses 0.5, LSST uses 0.0 (http://dev.lsstcorp.org/trac/wiki/BottomLeftPixelProposa...
Definition: ImageUtils.h:42
int getX0() const
Definition: Image.h:247
template<typename PixelT >
image::ImageBase< PixelT >::reverse_iterator lsst.afw.image::ImageBase< PixelT >::rbegin ( ) const

Return an STL compliant reverse iterator to the start of the image.

Definition at line 337 of file Image.cc.

337  {
338  return _gilView.rbegin();
339 }
template<typename PixelT >
image::ImageBase< PixelT >::reverse_iterator lsst.afw.image::ImageBase< PixelT >::rend ( ) const

Return an STL compliant reverse iterator to the end of the image.

Definition at line 343 of file Image.cc.

343  {
344  return _gilView.rend();
345 }
template<typename PixelT>
x_iterator lsst.afw.image::ImageBase< PixelT >::row_begin ( int  y) const
inline

Return an x_iterator to the start of the y'th row

Incrementing an x_iterator moves it across the row

Definition at line 319 of file Image.h.

319  {
320  return _gilView.row_begin(y);
321  }
int y
template<typename PixelT>
x_iterator lsst.afw.image::ImageBase< PixelT >::row_end ( int  y) const
inline

Return an x_iterator to the end of the y'th row.

Definition at line 324 of file Image.h.

324  {
325  return _gilView.row_end(y);
326  }
int y
template<typename PixelT>
void lsst.afw.image::ImageBase< PixelT >::set0 ( int  x,
int  y,
const PixelT  v 
)
inline

Definition at line 229 of file Image.h.

229  {
230  operator()(x-getX0(), y-getY0()) = v;
231  }
int y
PixelReference operator()(int x, int y)
Return a reference to the pixel (x, y)
Definition: Image.cc:236
int getY0() const
Definition: Image.h:255
int x
int getX0() const
Definition: Image.h:247
template<typename PixelT>
void lsst.afw.image::ImageBase< PixelT >::set0 ( int  x,
int  y,
const PixelT  v,
CheckIndices const &  check 
)
inline

Definition at line 232 of file Image.h.

232  {
233  operator()(x-getX0(), y-getY0(), check) = v;
234  }
int y
PixelReference operator()(int x, int y)
Return a reference to the pixel (x, y)
Definition: Image.cc:236
int getY0() const
Definition: Image.h:255
int x
int getX0() const
Definition: Image.h:247
template<typename PixelT>
void lsst.afw.image::ImageBase< PixelT >::setXY0 ( geom::Point2I const  origin)
inline

Set the ImageBase's origin

The origin is usually set by the constructor, so you shouldn't need this function

Note
There are use cases (e.g. memory overlays) that may want to set these values, but don't do so unless you are an Expert.

Definition at line 362 of file Image.h.

362  {
363  _origin=origin;
364  }
geom::Point2I _origin
Definition: Image.h:384
template<typename PixelT>
void lsst.afw.image::ImageBase< PixelT >::setXY0 ( int const  x0,
int const  y0 
)
inline

Set the ImageBase's origin

The origin is usually set by the constructor, so you shouldn't need this function

Note
There are use cases (e.g. memory overlays) that may want to set these values, but don't do so unless you are an Expert.

Definition at line 373 of file Image.h.

373  {
375  }
int const x0
Definition: saturated.cc:45
void setXY0(geom::Point2I const origin)
Definition: Image.h:362
int const y0
Definition: saturated.cc:45
template<typename PixelT >
void lsst.afw.image::ImageBase< PixelT >::swap ( ImageBase< PixelT > &  rhs)

Definition at line 282 of file Image.cc.

282  {
283  using std::swap; // See Meyers, Effective C++, Item 25
284 
285  swap(_manager, rhs._manager); // just swapping the pointers
286  swap(_gilView, rhs._gilView);
287  swap(_origin, rhs._origin);
288 }
Manager::Ptr _manager
Definition: Image.h:385
void swap(ImageBase< PixelT > &a, ImageBase< PixelT > &b)
Definition: Image.cc:291
geom::Point2I _origin
Definition: Image.h:384
void swap(ImageBase &rhs)
Definition: Image.cc:282
template<typename PixelT>
x_iterator lsst.afw.image::ImageBase< PixelT >::x_at ( int  x,
int  y 
) const
inline

Return an x_iterator to the point (x, y) in the image.

Definition at line 329 of file Image.h.

329 { return _gilView.x_at(x, y); }
int y
int x
template<typename PixelT>
xy_locator lsst.afw.image::ImageBase< PixelT >::xy_at ( int  x,
int  y 
) const
inline

Return an xy_locator at the point (x, y) in the image

Locators may be used to access a patch in an image

Definition at line 351 of file Image.h.

351  {
352  return xy_locator(_gilView.xy_at(x, y));
353  }
int y
_view_t::xy_locator xy_locator
An xy_locator.
Definition: Image.h:139
int x
template<typename PixelT>
y_iterator lsst.afw.image::ImageBase< PixelT >::y_at ( int  x,
int  y 
) const
inline

Return an y_iterator to the point (x, y) in the image.

Definition at line 344 of file Image.h.

344  {
345  return _gilView.y_at(x, y);
346  }
int y
int x

Friends And Related Function Documentation

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

Definition at line 170 of file Image.h.

template<typename PixelT>
template<typename >
friend class DecoratedImage
friend

Definition at line 181 of file Image.h.

template<typename PixelT>
template<typename , typename , typename >
friend class MaskedImage
friend

Definition at line 182 of file Image.h.

Member Data Documentation

template<typename PixelT>
_view_t lsst.afw.image::ImageBase< PixelT >::_gilView
private

Definition at line 386 of file Image.h.

template<typename PixelT>
Manager::Ptr lsst.afw.image::ImageBase< PixelT >::_manager
private

Definition at line 385 of file Image.h.

template<typename PixelT>
geom::Point2I lsst.afw.image::ImageBase< PixelT >::_origin
private

Definition at line 384 of file Image.h.


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