LSSTApplications  19.0.0-10-g4a5fae6+3,19.0.0-10-g920eed2,19.0.0-11-g48a0200+2,19.0.0-18-gfc4e62b+16,19.0.0-2-g3b2f90d+2,19.0.0-2-gd671419+6,19.0.0-20-g5a5a17ab+14,19.0.0-21-g2644856+17,19.0.0-24-g0913cb1,19.0.0-24-g878c510+4,19.0.0-25-g6c8df7140+1,19.0.0-25-gb330496+4,19.0.0-3-g2b32d65+6,19.0.0-3-g8227491+15,19.0.0-3-g9c54d0d+15,19.0.0-3-gca68e65+11,19.0.0-3-gcfc5f51+6,19.0.0-3-ge110943+14,19.0.0-3-ge74d124,19.0.0-30-g9c3fd16+5,19.0.0-4-g06f5963+6,19.0.0-4-g10df615,19.0.0-4-g3d16501+17,19.0.0-4-g4a9c019+6,19.0.0-4-g5a8b323,19.0.0-4-g66397f0+1,19.0.0-4-g8557e14,19.0.0-4-g8964aba+16,19.0.0-4-ge404a01+15,19.0.0-5-g40f3a5a,19.0.0-5-g4db63b3,19.0.0-5-gb9eeb60,19.0.0-5-gfb03ce7+16,19.0.0-6-gbaebbfb+15,19.0.0-61-gec4c6e08+5,19.0.0-7-g039c0b5+15,19.0.0-7-gbea9075+4,19.0.0-7-gc567de5+16,19.0.0-72-g37abf38+2,19.0.0-9-g463f923+15,v20.0.0.rc1
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | 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 <ImageBase.h>

Inheritance diagram for lsst::afw::image::ImageBase< PixelT >:
lsst::afw::image::Image< PixelT > lsst::afw::image::ImageSlice< PixelT >

Public Types

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
 A fast STL compliant iterator for contiguous images N.b. More...
 
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 Member Functions

 ImageBase (const lsst::geom::Extent2I &dimensions=lsst::geom::Extent2I())
 Allocator Constructor. More...
 
 ImageBase (const lsst::geom::Box2I &bbox)
 Allocator Constructor. More...
 
 ImageBase (const ImageBase &src, const bool deep=false)
 Copy constructor. More...
 
 ImageBase (ImageBase &&src)
 
 ImageBase (const ImageBase &src, const lsst::geom::Box2I &bbox, const ImageOrigin origin=PARENT, const bool deep=false)
 Copy constructor to make a copy of part of an image. More...
 
template<typename OtherPixelT >
 ImageBase (const ImageBase< OtherPixelT > &rhs, const bool deep)
 generalised copy constructor More...
 
 ImageBase (Array const &array, bool deep=false, lsst::geom::Point2I const &xy0=lsst::geom::Point2I())
 Construction from ndarray::Array and NumPy. More...
 
virtual ~ImageBase ()=default
 
ImageBaseoperator= (const ImageBase &rhs)
 Shallow assignment operator. More...
 
ImageBaseoperator= (ImageBase &&rhs)
 
ImageBaseoperator= (const PixelT rhs)
 Set the image's pixels to rhs. More...
 
ImageBaseoperator<<= (const ImageBase &rhs)
 Set the lhs's pixel values to equal the rhs's. More...
 
void assign (ImageBase const &rhs, lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT)
 Copy pixels from another image to a specified subregion of this image. More...
 
PixelReference operator() (int x, int y)
 Return a reference to the pixel (x, y) in LOCAL coordinates. More...
 
PixelReference operator() (int x, int y, CheckIndices const &)
 Return a reference to the pixel (x, y) in LOCAL coordinates with bounds checking. More...
 
PixelConstReference operator() (int x, int y) const
 Return a const reference to the pixel (x, y) in LOCAL coordinates. More...
 
PixelConstReference operator() (int x, int y, CheckIndices const &) const
 Return a const reference to the pixel (x, y) in LOCAL coordinates with bounds checking. More...
 
PixelConstReference get0 (int x, int y) const
 
provides unchecked lookup To be removed after PixelConstReference get0 (int x, int y, CheckIndices const &check) const
 
void set0 (int x, int y, const PixelT v)
 
provides unchecked lookup To be removed after void set0 (int x, int y, const PixelT v, CheckIndices const &check)
 
PixelReference get (lsst::geom::Point2I const &index, ImageOrigin origin)
 Return a reference to a single pixel (with no bounds check). More...
 
PixelConstReference get (lsst::geom::Point2I const &index, ImageOrigin origin) const
 Return a const reference to a single pixel (with no bounds check). More...
 
PixelReference operator[] (lsst::geom::Point2I const &index)
 Return a reference to a single pixel in PARENT coordinates (with no bounds check). More...
 
PixelConstReference operator[] (lsst::geom::Point2I const &index) const
 Return a reference to a single pixel in PARENT coordinates (with no bounds check). More...
 
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...
 
lsst::geom::Point2I getXY0 () const
 Return the image's origin. More...
 
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...
 
lsst::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
 Return an STL compliant iterator to the start of the image. More...
 
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 contiguous) const
 Return a fast STL compliant iterator to the start of the image which must be contiguous. More...
 
fast_iterator end (bool contiguous) const
 Return a fast STL compliant iterator to the end of the image which must be contiguous. More...
 
x_iterator row_begin (int y) const
 Return an x_iterator to the start of the y'th row. More...
 
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
 Return an y_iterator to the start of the y'th row. More...
 
y_iterator col_end (int x) const
 Return an y_iterator to the start 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
 Return an xy_locator at the point (x, y) in the image. More...
 
void setXY0 (lsst::geom::Point2I const origin)
 Set the ImageBase's origin. More...
 
void setXY0 (int const x0, int const y0)
 Set the ImageBase's origin. More...
 
lsst::geom::Box2I getBBox (ImageOrigin origin=PARENT) const
 

Static Public Member Functions

template<typename SinglePixelT >
static SinglePixel PixelCast (SinglePixelT rhs)
 Convert a type to our SinglePixel type. More...
 

Protected Member Functions

_view_t _getRawView () const
 
bool isContiguous () const
 

Static Protected Member Functions

static _view_t _allocateView (lsst::geom::Extent2I const &dimensions, Manager::Ptr &manager)
 
static _view_t _makeSubView (lsst::geom::Extent2I const &dimensions, lsst::geom::Extent2I const &offset, const _view_t &view)
 

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 102 of file ImageBase.h.

Member Typedef Documentation

◆ Array

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 149 of file ImageBase.h.

◆ const_iterator

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

An STL compliant const iterator.

Definition at line 127 of file ImageBase.h.

◆ const_reverse_iterator

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 131 of file ImageBase.h.

◆ const_x_iterator

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 141 of file ImageBase.h.

◆ const_xy_locator

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 123 of file ImageBase.h.

◆ const_y_iterator

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 147 of file ImageBase.h.

◆ ConstArray

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 151 of file ImageBase.h.

◆ fast_iterator

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 137 of file ImageBase.h.

◆ image_category

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

trait class to identify type of image

Definition at line 110 of file ImageBase.h.

◆ iterator

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

An STL compliant iterator.

Definition at line 125 of file ImageBase.h.

◆ Pixel

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

A pixel in this ImageBase.

Definition at line 115 of file ImageBase.h.

◆ PixelConstReference

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

A ConstReference to a PixelT.

Definition at line 119 of file ImageBase.h.

◆ PixelReference

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

A Reference to a PixelT.

Definition at line 117 of file ImageBase.h.

◆ reverse_iterator

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

An STL compliant reverse iterator.

Definition at line 129 of file ImageBase.h.

◆ SinglePixel

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 113 of file ImageBase.h.

◆ x_iterator

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 133 of file ImageBase.h.

◆ xy_locator

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

An xy_locator.

Definition at line 121 of file ImageBase.h.

◆ xy_x_iterator

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 139 of file ImageBase.h.

◆ xy_y_iterator

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 145 of file ImageBase.h.

◆ y_iterator

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 143 of file ImageBase.h.

Constructor & Destructor Documentation

◆ ImageBase() [1/7]

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

Allocator Constructor.

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

Definition at line 96 of file Image.cc.

97  : _origin(0, 0), _manager(), _gilView(_allocateView(dimensions, _manager)) {}

◆ ImageBase() [2/7]

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

Allocator Constructor.

allocate a new image with the specified dimensions and origin

Definition at line 100 of file Image.cc.

101  : _origin(bbox.getMin()), _manager(), _gilView(_allocateView(bbox.getDimensions(), _manager)) {}

◆ ImageBase() [3/7]

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

Copy constructor.

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

Definition at line 104 of file Image.cc.

107  : _origin(rhs._origin), _manager(rhs._manager), _gilView(rhs._gilView) {
108  if (deep) {
109  ImageBase tmp(getBBox());
110  tmp.assign(*this); // now copy the pixels
111  swap(tmp);
112  }
113 }

◆ ImageBase() [4/7]

template<typename PixelT >
lsst::afw::image::ImageBase< PixelT >::ImageBase ( ImageBase< PixelT > &&  src)

Definition at line 116 of file Image.cc.

116 : ImageBase(rhs, false) {}

◆ ImageBase() [5/7]

template<typename PixelT >
lsst::afw::image::ImageBase< PixelT >::ImageBase ( const ImageBase< PixelT > &  src,
const lsst::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.

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

Definition at line 119 of file Image.cc.

123  : _origin((origin == PARENT) ? bbox.getMin() : rhs._origin + lsst::geom::Extent2I(bbox.getMin())),
124  _manager(rhs._manager), // reference counted pointer, don't copy pixels
125  _gilView(_makeSubView(bbox.getDimensions(), _origin - rhs._origin, rhs._gilView)) {
126  if (deep) {
127  ImageBase tmp(getBBox());
128  tmp.assign(*this); // now copy the pixels
129  swap(tmp);
130  }
131 }

◆ ImageBase() [6/7]

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 217 of file ImageBase.h.

217  {
218  if (!deep) {
220  "Only deep copies are permitted for ImageBases with different pixel types");
221  }
222 
223  ImageBase<PixelT> tmp(rhs.getBBox());
224  copy_and_convert_pixels(rhs._gilView, tmp._gilView); // from boost::gil
225 
226  using std::swap; // See Meyers, Effective C++, Item 25
227  ImageBase<PixelT>::swap(tmp); // See Meyers, Effective C++, Items 11 and 43
228  }

◆ ImageBase() [7/7]

template<typename PixelT >
lsst::afw::image::ImageBase< PixelT >::ImageBase ( Array const &  array,
bool  deep = false,
lsst::geom::Point2I const &  xy0 = lsst::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 134 of file Image.cc.

135  : _origin(xy0),
136  _manager(array.getManager()),
137  _gilView(boost::gil::interleaved_view(array.template getSize<1>(), array.template getSize<0>(),
138  (typename _view_t::value_type*)array.getData(),
139  array.template getStride<0>() * sizeof(PixelT))) {
140  if (deep) {
141  ImageBase tmp(*this, true);
142  swap(tmp);
143  }
144 }

◆ ~ImageBase()

template<typename PixelT >
virtual lsst::afw::image::ImageBase< PixelT >::~ImageBase ( )
virtualdefault

Member Function Documentation

◆ _allocateView()

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

Definition at line 58 of file Image.cc.

59  {
60  if (dimensions.getX() < 0 || dimensions.getY() < 0) {
61  throw LSST_EXCEPT(pex::exceptions::LengthError,
62  str(boost::format("Both width and height must be non-negative: %d, %d") %
63  dimensions.getX() % dimensions.getY()));
64  }
65  if (dimensions.getX() != 0 && dimensions.getY() > std::numeric_limits<int>::max() / dimensions.getX()) {
66  throw LSST_EXCEPT(pex::exceptions::LengthError,
67  str(boost::format("Image dimensions (%d x %d) too large; int overflow detected.") %
68  dimensions.getX() % dimensions.getY()));
69  }
71  ndarray::SimpleManager<PixelT>::allocate(dimensions.getX() * dimensions.getY());
72  manager = r.first;
73  return boost::gil::interleaved_view(dimensions.getX(), dimensions.getY(),
74  (typename _view_t::value_type*)r.second,
75  dimensions.getX() * sizeof(PixelT));
76 }

◆ _getRawView()

template<typename PixelT >
_view_t lsst::afw::image::ImageBase< PixelT >::_getRawView ( ) const
inlineprotected

Definition at line 502 of file ImageBase.h.

502 { return _gilView; }

◆ _makeSubView()

template<typename PixelT >
ImageBase< PixelT >::_view_t lsst::afw::image::ImageBase< PixelT >::_makeSubView ( lsst::geom::Extent2I const &  dimensions,
lsst::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 || offset.getX() + dimensions.getX() > view.width() ||
82  offset.getY() + dimensions.getY() > view.height()) {
83  throw LSST_EXCEPT(
84  pex::exceptions::LengthError,
86  "Box2I(Point2I(%d,%d),lsst::geom::Extent2I(%d,%d)) doesn't fit in image %dx%d") %
87  offset.getX() % offset.getY() % dimensions.getX() % dimensions.getY() % view.width() %
88  view.height())
89  .str());
90  }
91  return boost::gil::subimage_view(view, offset.getX(), offset.getY(), dimensions.getX(),
92  dimensions.getY());
93 }

◆ assign()

template<typename PixelT >
void lsst::afw::image::ImageBase< PixelT >::assign ( ImageBase< PixelT > const &  rhs,
lsst::geom::Box2I const &  bbox = lsst::geom::Box2I(),
ImageOrigin  origin = PARENT 
)

Copy pixels from another image to a specified subregion of this image.

Parameters
[in]rhssource image whose pixels are to be copied into this image (the destination)
[in]bboxsubregion of this image to set; if empty (the default) then all pixels are set
[in]originorigin of bbox: if PARENT then the lower left pixel of this image is at xy0 if LOCAL then the lower left pixel of this image is at 0,0
Exceptions
lsst::pex::exceptions::LengthErrorif the dimensions of rhs and the specified subregion of this image do not match.

Definition at line 166 of file Image.cc.

166  {
167  auto lhsDim = bbox.isEmpty() ? getDimensions() : bbox.getDimensions();
168  if (lhsDim != rhs.getDimensions()) {
169  throw LSST_EXCEPT(pex::exceptions::LengthError,
170  (boost::format("Dimension mismatch: %dx%d v. %dx%d") % lhsDim.getX() %
171  lhsDim.getY() % rhs.getWidth() % rhs.getHeight())
172  .str());
173  }
174  if (bbox.isEmpty()) {
175  copy_pixels(rhs._gilView, _gilView);
176  } else {
177  auto lhsOff = (origin == PARENT) ? bbox.getMin() - _origin : lsst::geom::Extent2I(bbox.getMin());
178  auto lhsGilView = _makeSubView(lhsDim, lhsOff, _gilView);
179  copy_pixels(rhs._gilView, lhsGilView);
180  }
181 }

◆ at()

template<typename PixelT >
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 283 of file Image.cc.

283  {
284  return _gilView.at(x, y);
285 }

◆ begin() [1/2]

template<typename PixelT >
ImageBase< PixelT >::iterator lsst::afw::image::ImageBase< PixelT >::begin

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

263  {
264  return _gilView.begin();
265 }

◆ begin() [2/2]

template<typename PixelT >
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.

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

Definition at line 288 of file Image.cc.

288  {
289  if (!contiguous) {
290  throw LSST_EXCEPT(pex::exceptions::RuntimeError, "Only contiguous == true makes sense");
291  }
292  if (!this->isContiguous()) {
293  throw LSST_EXCEPT(pex::exceptions::RuntimeError, "Image's pixels are not contiguous");
294  }
295 
296  return row_begin(0);
297 }

◆ col_begin()

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 450 of file ImageBase.h.

450 { return _gilView.col_begin(x); }

◆ col_end()

template<typename PixelT >
y_iterator lsst::afw::image::ImageBase< PixelT >::col_end ( int  x) const
inline

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

Definition at line 453 of file ImageBase.h.

453 { return _gilView.col_end(x); }

◆ end() [1/2]

template<typename PixelT >
ImageBase< PixelT >::iterator lsst::afw::image::ImageBase< PixelT >::end

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

Definition at line 268 of file Image.cc.

268  {
269  return _gilView.end();
270 }

◆ end() [2/2]

template<typename PixelT >
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.

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

Definition at line 300 of file Image.cc.

300  {
301  if (!contiguous) {
302  throw LSST_EXCEPT(pex::exceptions::RuntimeError, "Only contiguous == true makes sense");
303  }
304  if (!this->isContiguous()) {
305  throw LSST_EXCEPT(pex::exceptions::RuntimeError, "Image's pixels are not contiguous");
306  }
307 
308  return row_end(getHeight() - 1);
309 }

◆ get() [1/2]

template<typename PixelT >
ImageBase< PixelT >::PixelReference lsst::afw::image::ImageBase< PixelT >::get ( lsst::geom::Point2I const &  index,
ImageOrigin  origin 
)

Return a reference to a single pixel (with no bounds check).

Definition at line 222 of file Image.cc.

223  {
224  int x = index.getX();
225  int y = index.getY();
226  if (origin == PARENT) {
227  x -= getX0();
228  y -= getY0();
229  }
230  return _gilView(x, y)[0];
231 }

◆ get() [2/2]

template<typename PixelT >
ImageBase< PixelT >::PixelConstReference lsst::afw::image::ImageBase< PixelT >::get ( lsst::geom::Point2I const &  index,
ImageOrigin  origin 
) const

Return a const reference to a single pixel (with no bounds check).

Definition at line 234 of file Image.cc.

235  {
236  int x = index.getX();
237  int y = index.getY();
238  if (origin == PARENT) {
239  x -= getX0();
240  y -= getY0();
241  }
242  return _gilView(x, y)[0];
243 }

◆ get0() [1/2]

template<typename PixelT >
PixelConstReference lsst::afw::image::ImageBase< PixelT >::get0 ( int  x,
int  y 
) const
inline
Deprecated:
Deprecated in 16.0.

To be removed after 20.0.0. Replaced by get(Point2I, ImageOrigin).

Definition at line 296 of file ImageBase.h.

296  {
297  return operator()(x - getX0(), y - getY0());
298  }

◆ get0() [2/2]

template<typename PixelT >
provides unchecked lookup To be removed after PixelConstReference lsst::afw::image::ImageBase< PixelT >::get0 ( int  x,
int  y,
CheckIndices const &  check 
) const
inline

Definition at line 303 of file ImageBase.h.

303  {
304  return operator()(x - getX0(), y - getY0(), check);
305  }

◆ getArray() [1/2]

template<typename PixelT >
ImageBase< PixelT >::Array lsst::afw::image::ImageBase< PixelT >::getArray

Definition at line 513 of file ImageBase.h.

513  {
514  int rowStride = reinterpret_cast<PixelT*>(row_begin(1)) - reinterpret_cast<PixelT*>(row_begin(0));
515  return ndarray::external(reinterpret_cast<PixelT*>(row_begin(0)),
516  ndarray::makeVector(getHeight(), getWidth()), ndarray::makeVector(rowStride, 1),
517  this->_manager);
518 }

◆ getArray() [2/2]

template<typename PixelT >
ImageBase< PixelT >::ConstArray lsst::afw::image::ImageBase< PixelT >::getArray

Definition at line 521 of file ImageBase.h.

521  {
522  int rowStride = reinterpret_cast<PixelT*>(row_begin(1)) - reinterpret_cast<PixelT*>(row_begin(0));
523  return ndarray::external(reinterpret_cast<PixelT*>(row_begin(0)),
524  ndarray::makeVector(getHeight(), getWidth()), ndarray::makeVector(rowStride, 1),
525  this->_manager);
526 }

◆ getBBox()

template<typename PixelT >
lsst::geom::Box2I lsst::afw::image::ImageBase< PixelT >::getBBox ( ImageOrigin  origin = PARENT) const
inline

Definition at line 482 of file ImageBase.h.

482  {
483  if (origin == PARENT) {
484  return lsst::geom::Box2I(_origin, getDimensions());
485  } else
487  }

◆ getDimensions()

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

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

Definition at line 393 of file ImageBase.h.

393 { return lsst::geom::Extent2I(getWidth(), getHeight()); }

◆ getHeight()

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

Return the number of rows in the image.

Definition at line 335 of file ImageBase.h.

335 { return _gilView.height(); }

◆ getWidth()

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

Return the number of columns in the image.

Definition at line 333 of file ImageBase.h.

333 { return _gilView.width(); }

◆ getX0()

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 343 of file ImageBase.h.

343 { return _origin.getX(); }

◆ getXY0()

template<typename PixelT >
lsst::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 360 of file ImageBase.h.

360 { return _origin; }

◆ getY0()

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 351 of file ImageBase.h.

351 { return _origin.getY(); }

◆ indexToPosition()

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 386 of file ImageBase.h.

388  {
389  return ind + PixelZeroPos + (xy == X ? getX0() : getY0());
390  }

◆ isContiguous()

template<typename PixelT >
bool lsst::afw::image::ImageBase< PixelT >::isContiguous ( ) const
inlineprotected

Definition at line 504 of file ImageBase.h.

504 { return begin() + getWidth() * getHeight() == end(); }

◆ operator()() [1/4]

template<typename PixelT >
ImageBase< PixelT >::PixelReference lsst::afw::image::ImageBase< PixelT >::operator() ( int  x,
int  y 
)

Return a reference to the pixel (x, y) in LOCAL coordinates.

Definition at line 184 of file Image.cc.

184  {
185  return const_cast<typename ImageBase<PixelT>::PixelReference>(
186  static_cast<typename ImageBase<PixelT>::PixelConstReference>(_gilView(x, y)[0]));
187 }

◆ operator()() [2/4]

template<typename PixelT >
ImageBase< PixelT >::PixelConstReference lsst::afw::image::ImageBase< PixelT >::operator() ( int  x,
int  y 
) const

Return a const reference to the pixel (x, y) in LOCAL coordinates.

Definition at line 204 of file Image.cc.

204  {
205  return _gilView(x, y)[0];
206 }

◆ operator()() [3/4]

template<typename PixelT >
ImageBase< PixelT >::PixelReference lsst::afw::image::ImageBase< PixelT >::operator() ( int  x,
int  y,
CheckIndices const &  check 
)

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

Definition at line 190 of file Image.cc.

191  {
192  if (check && (x < 0 || x >= getWidth() || y < 0 || y >= getHeight())) {
193  throw LSST_EXCEPT(pex::exceptions::LengthError,
194  (boost::format("Index (%d, %d) is out of range [0--%d], [0--%d]") % x % y %
195  (getWidth() - 1) % (getHeight() - 1))
196  .str());
197  }
198 
199  return const_cast<typename ImageBase<PixelT>::PixelReference>(
200  static_cast<typename ImageBase<PixelT>::PixelConstReference>(_gilView(x, y)[0]));
201 }

◆ operator()() [4/4]

template<typename PixelT >
ImageBase< PixelT >::PixelConstReference lsst::afw::image::ImageBase< PixelT >::operator() ( int  x,
int  y,
CheckIndices const &  check 
) const

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

Definition at line 209 of file Image.cc.

210  {
211  if (check && (x < 0 || x >= getWidth() || y < 0 || y >= getHeight())) {
212  throw LSST_EXCEPT(pex::exceptions::LengthError,
213  (boost::format("Index (%d, %d) is out of range [0--%d], [0--%d]") % x % y %
214  (this->getWidth() - 1) % (this->getHeight() - 1))
215  .str());
216  }
217 
218  return _gilView(x, y)[0];
219 }

◆ operator<<=()

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

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

Deprecated:
use assign(rhs) instead

Definition at line 155 of file Image.cc.

160  {
161  assign(rhs);
162  return *this;
163 }

◆ operator=() [1/3]

template<typename PixelT >
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 assign(rhs)
this behaviour is required to make the swig interface work, otherwise I'd declare this function private

Definition at line 147 of file Image.cc.

147  {
148  ImageBase tmp(rhs);
149  swap(tmp); // See Meyers, Effective C++, Item 11
150 
151  return *this;
152 }

◆ operator=() [2/3]

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

Set the image's pixels to rhs.

Definition at line 312 of file Image.cc.

312  {
313  fill_pixels(_gilView, rhs);
314 
315  return *this;
316 }

◆ operator=() [3/3]

template<typename PixelT >
ImageBase< PixelT > & lsst::afw::image::ImageBase< PixelT >::operator= ( ImageBase< PixelT > &&  rhs)

Definition at line 155 of file Image.cc.

155  {
156  return *this = rhs;
157 }

◆ operator[]() [1/2]

template<typename PixelT >
PixelReference lsst::afw::image::ImageBase< PixelT >::operator[] ( lsst::geom::Point2I const &  index)
inline

Return a reference to a single pixel in PARENT coordinates (with no bounds check).

Definition at line 327 of file ImageBase.h.

327 { return get(index, PARENT); }

◆ operator[]() [2/2]

template<typename PixelT >
PixelConstReference lsst::afw::image::ImageBase< PixelT >::operator[] ( lsst::geom::Point2I const &  index) const
inline

Return a reference to a single pixel in PARENT coordinates (with no bounds check).

Definition at line 330 of file ImageBase.h.

330 { return get(index, PARENT); }

◆ PixelCast()

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 158 of file ImageBase.h.

158  {
159  return SinglePixel(rhs);
160  }

◆ positionToIndex()

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 367 of file ImageBase.h.

370  {
371  double const fullIndex = pos - PixelZeroPos - (xy == X ? getX0() : getY0());
372  int const roundedIndex = static_cast<int>(fullIndex + 0.5);
373  double const residual = fullIndex - roundedIndex;
374  return std::pair<int, double>(roundedIndex, residual);
375  }

◆ rbegin()

template<typename PixelT >
ImageBase< PixelT >::reverse_iterator lsst::afw::image::ImageBase< PixelT >::rbegin

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

Definition at line 273 of file Image.cc.

273  {
274  return _gilView.rbegin();
275 }

◆ rend()

template<typename PixelT >
ImageBase< PixelT >::reverse_iterator lsst::afw::image::ImageBase< PixelT >::rend

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

Definition at line 278 of file Image.cc.

278  {
279  return _gilView.rend();
280 }

◆ row_begin()

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 438 of file ImageBase.h.

438 { return _gilView.row_begin(y); }

◆ row_end()

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 441 of file ImageBase.h.

441 { return _gilView.row_end(y); }

◆ set0() [1/2]

template<typename PixelT >
void lsst::afw::image::ImageBase< PixelT >::set0 ( int  x,
int  y,
const PixelT  v 
)
inline

Definition at line 308 of file ImageBase.h.

308  {
309  operator()(x - getX0(), y - getY0()) = v;
310  }

◆ set0() [2/2]

template<typename PixelT >
provides unchecked lookup To be removed after void lsst::afw::image::ImageBase< PixelT >::set0 ( int  x,
int  y,
const PixelT  v,
CheckIndices const &  check 
)
inline

Definition at line 315 of file ImageBase.h.

315  {
316  operator()(x - getX0(), y - getY0(), check) = v;
317  }

◆ setXY0() [1/2]

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 480 of file ImageBase.h.

480 { setXY0(lsst::geom::Point2I(x0, y0)); }

◆ setXY0() [2/2]

template<typename PixelT >
void lsst::afw::image::ImageBase< PixelT >::setXY0 ( lsst::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 471 of file ImageBase.h.

471 { _origin = origin; }

◆ swap()

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

Definition at line 246 of file Image.cc.

246  {
247  using std::swap; // See Meyers, Effective C++, Item 25
248 
249  swap(_manager, rhs._manager); // just swapping the pointers
250  swap(_gilView, rhs._gilView);
251  swap(_origin, rhs._origin);
252 }

◆ x_at()

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 444 of file ImageBase.h.

444 { return _gilView.x_at(x, y); }

◆ xy_at()

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 462 of file ImageBase.h.

462 { return xy_locator(_gilView.xy_at(x, y)); }

◆ y_at()

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 456 of file ImageBase.h.

456 { return _gilView.y_at(x, y); }

Friends And Related Function Documentation

◆ ImageBase

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

Definition at line 154 of file ImageBase.h.

◆ DecoratedImage

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

Definition at line 166 of file ImageBase.h.

◆ MaskedImage

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

Definition at line 168 of file ImageBase.h.


The documentation for this class was generated from the following files:
y
int y
Definition: SpanSet.cc:49
lsst::afw::image::ImageBase::_allocateView
static _view_t _allocateView(lsst::geom::Extent2I const &dimensions, Manager::Ptr &manager)
Definition: Image.cc:58
lsst::afw::image::ImageBase::assign
void assign(ImageBase const &rhs, lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT)
Copy pixels from another image to a specified subregion of this image.
Definition: Image.cc:166
std::pair
lsst::afw::image::ImageBase::isContiguous
bool isContiguous() const
Definition: ImageBase.h:504
lsst::afw::image::PixelZeroPos
const double PixelZeroPos
position of center of pixel 0
Definition: ImageUtils.h:44
lsst::afw::image::ImageBase::end
iterator end() const
Return an STL compliant iterator to the end of the image.
Definition: Image.cc:268
pex.config.history.format
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174
lsst::afw::image::ImageBase::row_begin
x_iterator row_begin(int y) const
Return an x_iterator to the start of the y'th row.
Definition: ImageBase.h:438
lsst::ip::diffim::detail::PixelT
float PixelT
Definition: AssessSpatialKernelVisitor.cc:208
lsst::afw::image::ImageBase::xy_locator
_view_t::xy_locator xy_locator
An xy_locator.
Definition: ImageBase.h:121
lsst::afw::image::X
@ X
Definition: ImageUtils.h:36
lsst::afw::image::ImageBase::getHeight
int getHeight() const
Return the number of rows in the image.
Definition: ImageBase.h:335
lsst::afw::image::ImageBase::operator()
PixelReference operator()(int x, int y)
Return a reference to the pixel (x, y) in LOCAL coordinates.
Definition: Image.cc:184
lsst::afw::image::ImageBase::begin
iterator begin() const
Return an STL compliant iterator to the start of the image.
Definition: Image.cc:263
lsst::afw::image::ImageBase::PixelReference
Reference< PixelT >::type PixelReference
A Reference to a PixelT.
Definition: ImageBase.h:117
lsst::afw::image::ImageBase::row_end
x_iterator row_end(int y) const
Return an x_iterator to the end of the y'th row.
Definition: ImageBase.h:441
x
double x
Definition: ChebyshevBoundedField.cc:277
lsst::afw::image::ImageBase::_makeSubView
static _view_t _makeSubView(lsst::geom::Extent2I const &dimensions, lsst::geom::Extent2I const &offset, const _view_t &view)
Definition: Image.cc:78
dimensions
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:49
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
std::swap
T swap(T... args)
lsst::afw::image::ImageBase::getX0
int getX0() const
Return the image's column-origin.
Definition: ImageBase.h:343
lsst::afw::image::ImageBase::SinglePixel
PixelT SinglePixel
A single Pixel of the same type as those in the ImageBase.
Definition: ImageBase.h:113
lsst::afw::image::ImageBase::getDimensions
lsst::geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
Definition: ImageBase.h:393
lsst::pex::exceptions::InvalidParameterError
Reports invalid arguments.
Definition: Runtime.h:66
lsst::geom::Extent2I
Extent< int, 2 > Extent2I
Definition: Extent.h:397
lsst::geom::Point< int, 2 >
lsst::geom::Box2I
An integer coordinate rectangle.
Definition: Box.h:55
lsst::afw::image::PARENT
@ PARENT
Definition: ImageBase.h:94
lsst::afw::image::ImageBase::setXY0
void setXY0(lsst::geom::Point2I const origin)
Set the ImageBase's origin.
Definition: ImageBase.h:471
lsst::afw::image::ImageBase::getY0
int getY0() const
Return the image's row-origin.
Definition: ImageBase.h:351
lsst::afw::image::ImageBase::getBBox
lsst::geom::Box2I getBBox(ImageOrigin origin=PARENT) const
Definition: ImageBase.h:482
lsst::afw::image::ImageBase::swap
void swap(ImageBase &rhs)
Definition: Image.cc:246
lsst::afw::image::ImageBase::PixelConstReference
ConstReference< PixelT >::type PixelConstReference
A ConstReference to a PixelT.
Definition: ImageBase.h:119
lsst::geom::Extent< int, 2 >
std::numeric_limits
lsst::afw::image::ImageBase::get
PixelReference get(lsst::geom::Point2I const &index, ImageOrigin origin)
Return a reference to a single pixel (with no bounds check).
Definition: Image.cc:222
lsst::afw::image::ImageBase::ImageBase
friend class ImageBase
Definition: ImageBase.h:154
lsst::afw::image::ImageBase::getWidth
int getWidth() const
Return the number of columns in the image.
Definition: ImageBase.h:333
bbox
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117