LSST Applications g063fba187b+cac8b7c890,g0f08755f38+6aee506743,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g1a2382251a+b4475c5878,g1dcb35cd9c+8f9bc1652e,g20f6ffc8e0+6aee506743,g217e2c1bcf+73dee94bd0,g28da252d5a+1f19c529b9,g2bbee38e9b+3f2625acfc,g2bc492864f+3f2625acfc,g3156d2b45e+6e55a43351,g32e5bea42b+1bb94961c2,g347aa1857d+3f2625acfc,g35bb328faa+a8ce1bb630,g3a166c0a6a+3f2625acfc,g3e281a1b8c+c5dd892a6c,g3e8969e208+a8ce1bb630,g414038480c+5927e1bc1e,g41af890bb2+8a9e676b2a,g7af13505b9+809c143d88,g80478fca09+6ef8b1810f,g82479be7b0+f568feb641,g858d7b2824+6aee506743,g89c8672015+f4add4ffd5,g9125e01d80+a8ce1bb630,ga5288a1d22+2903d499ea,gb58c049af0+d64f4d3760,gc28159a63d+3f2625acfc,gcab2d0539d+b12535109e,gcf0d15dbbd+46a3f46ba9,gda6a2b7d83+46a3f46ba9,gdaeeff99f8+1711a396fd,ge79ae78c31+3f2625acfc,gef2f8181fd+0a71e47438,gf0baf85859+c1f95f4921,gfa517265be+6aee506743,gfa999e8aa5+17cd334064,w.2024.51
LSST Data Management Base Package
Loading...
Searching...
No Matches
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< EntryT > lsst::afw::image::Image< lsst::afw::image::VariancePixel > lsst::afw::image::Image< ImageT > lsst::afw::image::Image< ImagePixelT > lsst::afw::image::Image< InternalPixelT > lsst::afw::image::Image< Pixel > lsst::afw::image::Image< lsst::afw::math::Kernel::Pixel > lsst::afw::image::Image< afw::image::VariancePixel > lsst::afw::image::Image< float > lsst::afw::image::Mask< lsst::afw::image::MaskPixel > lsst::afw::image::Image< PixelT > lsst::afw::image::Mask< MaskPixelT >

Public Types

using image_category = detail::basic_tag
 trait class to identify type of image
 
using SinglePixel = PixelT
 A single Pixel of the same type as those in the ImageBase.
 
using Pixel = PixelT
 A pixel in this ImageBase.
 
using PixelReference = typename Reference<PixelT>::type
 A Reference to a PixelT.
 
using PixelConstReference = typename ConstReference<PixelT>::type
 A ConstReference to a PixelT.
 
using xy_locator = typename _view_t::xy_locator
 An xy_locator.
 
using const_xy_locator = typename _view_t::xy_locator::const_t
 A const_xy_locator.
 
using iterator = typename _view_t::iterator
 An STL compliant iterator.
 
using const_iterator = typename _const_view_t::iterator
 An STL compliant const iterator.
 
using reverse_iterator = typename _view_t::reverse_iterator
 An STL compliant reverse iterator.
 
using const_reverse_iterator = typename _const_view_t::reverse_iterator
 An STL compliant const reverse iterator.
 
using x_iterator = typename _view_t::x_iterator
 An iterator for traversing the pixels in a row.
 
using fast_iterator = x_iterator
 A fast STL compliant iterator for contiguous images N.b.
 
using xy_x_iterator = typename _view_t::x_iterator
 An iterator for traversing the pixels in a row, created from an xy_locator.
 
using const_x_iterator = typename _const_view_t::x_iterator
 A const iterator for traversing the pixels in a row.
 
using y_iterator = typename _view_t::y_iterator
 An iterator for traversing the pixels in a column.
 
using xy_y_iterator = typename _view_t::y_iterator
 An iterator for traversing the pixels in a row, created from an xy_locator.
 
using const_y_iterator = typename _const_view_t::y_iterator
 A const iterator for traversing the pixels in a column.
 
using Array = typename ndarray::Array<PixelT, 2, 1>
 A mutable ndarray representation of the image.
 
using ConstArray = typename ndarray::Array<const PixelT, 2, 1>
 An immutable ndarray representation of the image.
 

Public Member Functions

 ImageBase (const lsst::geom::Extent2I &dimensions=lsst::geom::Extent2I())
 Allocator Constructor.
 
 ImageBase (const lsst::geom::Box2I &bbox)
 Allocator Constructor.
 
 ImageBase (const ImageBase &src, const bool deep=false)
 Copy constructor.
 
 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.
 
template<typename OtherPixelT >
 ImageBase (const ImageBase< OtherPixelT > &rhs, const bool deep)
 generalised copy constructor
 
 ImageBase (Array const &array, bool deep=false, lsst::geom::Point2I const &xy0=lsst::geom::Point2I())
 Construction from ndarray::Array and NumPy.
 
virtual ~ImageBase ()=default
 
ImageBaseoperator= (const ImageBase &rhs)
 Shallow assignment operator.
 
ImageBaseoperator= (ImageBase &&rhs)
 
ImageBaseoperator= (const PixelT rhs)
 Set the image's pixels to rhs.
 
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.
 
PixelReference operator() (int x, int y)
 Return a reference to the pixel (x, y) in LOCAL coordinates.
 
PixelReference operator() (int x, int y, CheckIndices const &)
 Return a reference to the pixel (x, y) in LOCAL coordinates with bounds checking.
 
PixelConstReference operator() (int x, int y) const
 Return a const reference to the pixel (x, y) in LOCAL coordinates.
 
PixelConstReference operator() (int x, int y, CheckIndices const &) const
 Return a const reference to the pixel (x, y) in LOCAL coordinates with bounds checking.
 
PixelReference get (lsst::geom::Point2I const &index, ImageOrigin origin)
 Return a reference to a single pixel (with no bounds check).
 
PixelConstReference get (lsst::geom::Point2I const &index, ImageOrigin origin) const
 Return a const reference to a single pixel (with no bounds check).
 
PixelReference operator[] (lsst::geom::Point2I const &index)
 Return a reference to a single pixel in PARENT coordinates (with no bounds check).
 
PixelConstReference operator[] (lsst::geom::Point2I const &index) const
 Return a reference to a single pixel in PARENT coordinates (with no bounds check).
 
int getWidth () const
 Return the number of columns in the image.
 
int getHeight () const
 Return the number of rows in the image.
 
int getArea () const
 Return the area of the image.
 
int getX0 () const
 Return the image's column-origin.
 
int getY0 () const
 Return the image's row-origin.
 
lsst::geom::Point2I getXY0 () const
 Return the image's origin.
 
std::pair< int, doublepositionToIndex (double const pos, lsst::afw::image::xOrY const xy) const
 Convert image position to index (nearest integer and fractional parts)
 
double indexToPosition (double ind, lsst::afw::image::xOrY const xy) const
 Convert image index to image position.
 
lsst::geom::Extent2I getDimensions () const
 Return the image's size; useful for passing to constructors.
 
void swap (ImageBase &rhs)
 
Array getArray ()
 
ConstArray getArray () const
 
iterator begin () const
 Return an STL compliant iterator to the start of the image.
 
iterator end () const
 Return an STL compliant iterator to the end of the image.
 
reverse_iterator rbegin () const
 Return an STL compliant reverse iterator to the start of the image.
 
reverse_iterator rend () const
 Return an STL compliant reverse iterator to the end of the image.
 
iterator at (int x, int y) const
 Return an STL compliant iterator at the point (x, y)
 
fast_iterator begin (bool contiguous) const
 Return a fast STL compliant iterator to the start of the image which must be contiguous.
 
fast_iterator end (bool contiguous) const
 Return a fast STL compliant iterator to the end of the image which must be contiguous.
 
x_iterator row_begin (int y) const
 Return an x_iterator to the start of the y'th row.
 
x_iterator row_end (int y) const
 Return an x_iterator to the end of the y'th row.
 
x_iterator x_at (int x, int y) const
 Return an x_iterator to the point (x, y) in the image.
 
y_iterator col_begin (int x) const
 Return an y_iterator to the start of the y'th row.
 
y_iterator col_end (int x) const
 Return an y_iterator to the start of the y'th row.
 
y_iterator y_at (int x, int y) const
 Return an y_iterator to the point (x, y) in the image.
 
xy_locator xy_at (int x, int y) const
 Return an xy_locator at the point (x, y) in the image.
 
void setXY0 (lsst::geom::Point2I const origin)
 Set the ImageBase's origin.
 
void setXY0 (int const x0, int const y0)
 Set the ImageBase's origin.
 
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.
 

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 >
using lsst::afw::image::ImageBase< PixelT >::Array = typename ndarray::Array<PixelT, 2, 1>

A mutable ndarray representation of the image.

Definition at line 149 of file ImageBase.h.

◆ const_iterator

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

An STL compliant const iterator.

Definition at line 127 of file ImageBase.h.

◆ const_reverse_iterator

template<typename PixelT >
using lsst::afw::image::ImageBase< PixelT >::const_reverse_iterator = typename _const_view_t::reverse_iterator

An STL compliant const reverse iterator.

Definition at line 131 of file ImageBase.h.

◆ const_x_iterator

template<typename PixelT >
using lsst::afw::image::ImageBase< PixelT >::const_x_iterator = typename _const_view_t::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 >
using lsst::afw::image::ImageBase< PixelT >::const_xy_locator = typename _view_t::xy_locator::const_t

A const_xy_locator.

Definition at line 123 of file ImageBase.h.

◆ const_y_iterator

template<typename PixelT >
using lsst::afw::image::ImageBase< PixelT >::const_y_iterator = typename _const_view_t::y_iterator

A const iterator for traversing the pixels in a column.

Definition at line 147 of file ImageBase.h.

◆ ConstArray

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

An immutable ndarray representation of the image.

Definition at line 151 of file ImageBase.h.

◆ fast_iterator

template<typename PixelT >
using lsst::afw::image::ImageBase< PixelT >::fast_iterator = x_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 >
using lsst::afw::image::ImageBase< PixelT >::image_category = detail::basic_tag

trait class to identify type of image

Definition at line 110 of file ImageBase.h.

◆ iterator

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

An STL compliant iterator.

Definition at line 125 of file ImageBase.h.

◆ Pixel

template<typename PixelT >
using lsst::afw::image::ImageBase< PixelT >::Pixel = PixelT

A pixel in this ImageBase.

Definition at line 115 of file ImageBase.h.

◆ PixelConstReference

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

A ConstReference to a PixelT.

Definition at line 119 of file ImageBase.h.

◆ PixelReference

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

A Reference to a PixelT.

Definition at line 117 of file ImageBase.h.

◆ reverse_iterator

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

An STL compliant reverse iterator.

Definition at line 129 of file ImageBase.h.

◆ SinglePixel

template<typename PixelT >
using lsst::afw::image::ImageBase< PixelT >::SinglePixel = PixelT

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 >
using lsst::afw::image::ImageBase< PixelT >::x_iterator = typename _view_t::x_iterator

An iterator for traversing the pixels in a row.

Definition at line 133 of file ImageBase.h.

◆ xy_locator

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

An xy_locator.

Definition at line 121 of file ImageBase.h.

◆ xy_x_iterator

template<typename PixelT >
using lsst::afw::image::ImageBase< PixelT >::xy_x_iterator = typename _view_t::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 >
using lsst::afw::image::ImageBase< PixelT >::xy_y_iterator = typename _view_t::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 >
using lsst::afw::image::ImageBase< PixelT >::y_iterator = typename _view_t::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 89 of file Image.cc.

90 : _origin(0, 0), _manager(), _gilView(_allocateView(dimensions, _manager)) {}
static _view_t _allocateView(lsst::geom::Extent2I const &dimensions, Manager::Ptr &manager)
Definition Image.cc:45

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

94 : _origin(bbox.getMin()), _manager(), _gilView(_allocateView(bbox.getDimensions(), _manager)) {}
AmpInfoBoxKey bbox
Definition Amplifier.cc:117

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

100 : _origin(rhs._origin), _manager(rhs._manager), _gilView(rhs._gilView) {
101 if (deep) {
102 ImageBase tmp(getBBox());
103 tmp.assign(*this); // now copy the pixels
104 swap(tmp);
105 }
106}
lsst::geom::Box2I getBBox(ImageOrigin origin=PARENT) const
Definition ImageBase.h:445
typename ndarray::Array< PixelT, 2, 1 > Array
A mutable ndarray representation of the image.
Definition ImageBase.h:149
void swap(ImageBase &rhs)
Definition Image.cc:233

◆ ImageBase() [4/7]

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

Definition at line 109 of file Image.cc.

109: 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 112 of file Image.cc.

116 : _origin((origin == PARENT) ? bbox.getMin() : rhs._origin + lsst::geom::Extent2I(bbox.getMin())),
117 _manager(rhs._manager), // reference counted pointer, don't copy pixels
118 _gilView(_makeSubView(bbox.getDimensions(), _origin - rhs._origin, rhs._gilView)) {
119 if (deep) {
120 ImageBase tmp(getBBox());
121 tmp.assign(*this); // now copy the pixels
122 swap(tmp);
123 }
124}
static _view_t _makeSubView(lsst::geom::Extent2I const &dimensions, lsst::geom::Extent2I const &offset, const _view_t &view)
Definition Image.cc:65
lsst::geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
Definition ImageBase.h:356
Extent< int, 2 > Extent2I
Definition Extent.h:397

◆ 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 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition Exception.h:48
Reports invalid arguments.
Definition Runtime.h:66
T swap(T... args)

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

128 : _origin(xy0),
129 _manager(array.getManager()),
130 _gilView(boost::gil::interleaved_view(array.template getSize<1>(), array.template getSize<0>(),
131 (typename _view_t::value_type*)array.getData(),
132 array.template getStride<0>() * sizeof(PixelT))) {
133 if (deep) {
134 ImageBase tmp(*this, true);
135 swap(tmp);
136 }
137}

◆ ~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 45 of file Image.cc.

46 {
47 if (dimensions.getX() < 0 || dimensions.getY() < 0) {
48 throw LSST_EXCEPT(pex::exceptions::LengthError,
49 str(boost::format("Both width and height must be non-negative: %d, %d") %
50 dimensions.getX() % dimensions.getY()));
51 }
52 if (dimensions.getX() != 0 && dimensions.getY() > std::numeric_limits<int>::max() / dimensions.getX()) {
53 throw LSST_EXCEPT(pex::exceptions::LengthError,
54 str(boost::format("Image dimensions (%d x %d) too large; int overflow detected.") %
55 dimensions.getX() % dimensions.getY()));
56 }
58 ndarray::SimpleManager<PixelT>::allocate(dimensions.getX() * dimensions.getY());
59 manager = r.first;
60 return boost::gil::interleaved_view(dimensions.getX(), dimensions.getY(),
61 (typename _view_t::value_type*)r.second,
62 dimensions.getX() * sizeof(PixelT));
63}

◆ _getRawView()

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

Definition at line 465 of file ImageBase.h.

465{ 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 65 of file Image.cc.

67 {
68 if (offset.getX() < 0 || offset.getY() < 0 || offset.getX() + dimensions.getX() > view.width() ||
69 offset.getY() + dimensions.getY() > view.height()) {
70 throw LSST_EXCEPT(
71 pex::exceptions::LengthError,
72 (boost::format(
73 "Box2I(Point2I(%d,%d),lsst::geom::Extent2I(%d,%d)) doesn't fit in image %dx%d") %
74 offset.getX() % offset.getY() % dimensions.getX() % dimensions.getY() % view.width() %
75 view.height())
76 .str());
77 }
78 if (dimensions.getX() == 0 && dimensions.getY() == 0
79 && view.width() == 0 && view.height() == 0) {
80 // Getting a zero-extent subview of a zero-extent view returns itself
81 return view;
82 } else {
83 return boost::gil::subimage_view(view, offset.getX(), offset.getY(), dimensions.getX(),
84 dimensions.getY());
85 }
86}

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

153 {
154 auto lhsDim = bbox.isEmpty() ? getDimensions() : bbox.getDimensions();
155 if (lhsDim != rhs.getDimensions()) {
156 throw LSST_EXCEPT(pex::exceptions::LengthError,
157 (boost::format("Dimension mismatch: %dx%d v. %dx%d") % lhsDim.getX() %
158 lhsDim.getY() % rhs.getWidth() % rhs.getHeight())
159 .str());
160 }
161 if (bbox.isEmpty()) {
162 copy_pixels(rhs._gilView, _gilView);
163 } else {
164 auto lhsOff = (origin == PARENT) ? bbox.getMin() - _origin : lsst::geom::Extent2I(bbox.getMin());
165 auto lhsGilView = _makeSubView(lhsDim, lhsOff, _gilView);
166 copy_pixels(rhs._gilView, lhsGilView);
167 }
168}

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

270 {
271 return _gilView.at(x, y);
272}
int y
Definition SpanSet.cc:48

◆ begin() [1/2]

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

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

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

Definition at line 250 of file Image.cc.

250 {
251 return _gilView.begin();
252}

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

275 {
276 if (!contiguous) {
277 throw LSST_EXCEPT(pex::exceptions::RuntimeError, "Only contiguous == true makes sense");
278 }
279 if (!this->isContiguous()) {
280 throw LSST_EXCEPT(pex::exceptions::RuntimeError, "Image's pixels are not contiguous");
281 }
282
283 return row_begin(0);
284}
x_iterator row_begin(int y) const
Return an x_iterator to the start of the y'th row.
Definition ImageBase.h:401

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

413{ 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 416 of file ImageBase.h.

416{ return _gilView.col_end(x); }

◆ end() [1/2]

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

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

Definition at line 255 of file Image.cc.

255 {
256 return _gilView.end();
257}

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

287 {
288 if (!contiguous) {
289 throw LSST_EXCEPT(pex::exceptions::RuntimeError, "Only contiguous == true makes sense");
290 }
291 if (!this->isContiguous()) {
292 throw LSST_EXCEPT(pex::exceptions::RuntimeError, "Image's pixels are not contiguous");
293 }
294
295 return row_end(getHeight() - 1);
296}
int getHeight() const
Return the number of rows in the image.
Definition ImageBase.h:296
x_iterator row_end(int y) const
Return an x_iterator to the end of the y'th row.
Definition ImageBase.h:404

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

210 {
211 int x = index.getX();
212 int y = index.getY();
213 if (origin == PARENT) {
214 x -= getX0();
215 y -= getY0();
216 }
217 return _gilView(x, y)[0];
218}
int getX0() const
Return the image's column-origin.
Definition ImageBase.h:306
int getY0() const
Return the image's row-origin.
Definition ImageBase.h:314

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

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

◆ getArea()

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

Return the area of the image.

Definition at line 298 of file ImageBase.h.

298{ return getWidth()*getHeight(); }
int getWidth() const
Return the number of columns in the image.
Definition ImageBase.h:294

◆ getArray() [1/2]

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

Definition at line 476 of file ImageBase.h.

476 {
477 int rowStride = 1;
478 PixelT * data = nullptr;
479 if (getArea() > 0) {
480 data = reinterpret_cast<PixelT*>(row_begin(0));
481 }
482 if (getHeight() > 1) {
483 rowStride = reinterpret_cast<PixelT*>(row_begin(1)) - reinterpret_cast<PixelT*>(row_begin(0));
484 }
485 return ndarray::external(data,
486 ndarray::makeVector(getHeight(), getWidth()), ndarray::makeVector(rowStride, 1),
487 this->_manager);
488}
char * data
Definition BaseRecord.cc:61
int getArea() const
Return the area of the image.
Definition ImageBase.h:298

◆ getArray() [2/2]

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

Definition at line 491 of file ImageBase.h.

491 {
492 int rowStride = 1;
493 PixelT * data = nullptr;
494 if (getArea() > 0) {
495 data = reinterpret_cast<PixelT*>(row_begin(0));
496 }
497 if (getHeight() > 1) {
498 rowStride = reinterpret_cast<PixelT*>(row_begin(1)) - reinterpret_cast<PixelT*>(row_begin(0));
499 }
500 return ndarray::external(data,
501 ndarray::makeVector(getHeight(), getWidth()), ndarray::makeVector(rowStride, 1),
502 this->_manager);
503}

◆ getBBox()

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

Definition at line 445 of file ImageBase.h.

445 {
446 if (origin == PARENT) {
447 return lsst::geom::Box2I(_origin, getDimensions());
448 } else
450 }
An integer coordinate rectangle.
Definition Box.h:55

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

◆ getHeight()

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

Return the number of rows in the image.

Definition at line 296 of file ImageBase.h.

296{ 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 294 of file ImageBase.h.

294{ 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 306 of file ImageBase.h.

306{ 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 323 of file ImageBase.h.

323{ 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 314 of file ImageBase.h.

314{ 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 349 of file ImageBase.h.

351 {
352 return ind + PixelZeroPos + (xy == X ? getX0() : getY0());
353 }
const double PixelZeroPos
position of center of pixel 0
Definition ImageUtils.h:44

◆ isContiguous()

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

Definition at line 467 of file ImageBase.h.

467{ return begin() + getWidth() * getHeight() == end(); }
iterator end() const
Return an STL compliant iterator to the end of the image.
Definition Image.cc:255
iterator begin() const
Return an STL compliant iterator to the start of the image.
Definition Image.cc:250

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

171 {
172 return const_cast<typename ImageBase<PixelT>::PixelReference>(
173 static_cast<typename ImageBase<PixelT>::PixelConstReference>(_gilView(x, y)[0]));
174}
typename Reference< PixelT >::type PixelReference
A Reference to a PixelT.
Definition ImageBase.h:117
typename ConstReference< PixelT >::type PixelConstReference
A ConstReference to a PixelT.
Definition ImageBase.h:119

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

191 {
192 return _gilView(x, y)[0];
193}

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

178 {
179 if (check && (x < 0 || x >= getWidth() || y < 0 || y >= getHeight())) {
180 throw LSST_EXCEPT(pex::exceptions::LengthError,
181 (boost::format("Index (%d, %d) is out of range [0--%d], [0--%d]") % x % y %
182 (getWidth() - 1) % (getHeight() - 1))
183 .str());
184 }
185
186 return const_cast<typename ImageBase<PixelT>::PixelReference>(
187 static_cast<typename ImageBase<PixelT>::PixelConstReference>(_gilView(x, y)[0]));
188}

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

197 {
198 if (check && (x < 0 || x >= getWidth() || y < 0 || y >= getHeight())) {
199 throw LSST_EXCEPT(pex::exceptions::LengthError,
200 (boost::format("Index (%d, %d) is out of range [0--%d], [0--%d]") % x % y %
201 (this->getWidth() - 1) % (this->getHeight() - 1))
202 .str());
203 }
204
205 return _gilView(x, y)[0];
206}

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

140 {
141 ImageBase tmp(rhs);
142 swap(tmp); // See Meyers, Effective C++, Item 11
143
144 return *this;
145}

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

299 {
300 fill_pixels(_gilView, rhs);
301
302 return *this;
303}

◆ operator=() [3/3]

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

Definition at line 148 of file Image.cc.

148 {
149 return *this = rhs;
150}

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

288{ return get(index, PARENT); }
PixelReference get(lsst::geom::Point2I const &index, ImageOrigin origin)
Return a reference to a single pixel (with no bounds check).
Definition Image.cc:209

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

291{ 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 }
PixelT SinglePixel
A single Pixel of the same type as those in the ImageBase.
Definition ImageBase.h:113

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

333 {
334 double const fullIndex = pos - PixelZeroPos - (xy == X ? getX0() : getY0());
335 int const roundedIndex = static_cast<int>(fullIndex + 0.5);
336 double const residual = fullIndex - roundedIndex;
338 }

◆ rbegin()

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

260 {
261 return _gilView.rbegin();
262}

◆ rend()

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

265 {
266 return _gilView.rend();
267}

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

401{ 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 404 of file ImageBase.h.

404{ return _gilView.row_end(y); }

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

443{ setXY0(lsst::geom::Point2I(x0, y0)); }
void setXY0(lsst::geom::Point2I const origin)
Set the ImageBase's origin.
Definition ImageBase.h:434

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

434{ _origin = origin; }

◆ swap()

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

Definition at line 233 of file Image.cc.

233 {
234 using std::swap; // See Meyers, Effective C++, Item 25
235
236 swap(_manager, rhs._manager); // just swapping the pointers
237 swap(_gilView, rhs._gilView);
238 swap(_origin, rhs._origin);
239}

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

407{ 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 425 of file ImageBase.h.

425{ return xy_locator(_gilView.xy_at(x, y)); }
typename _view_t::xy_locator xy_locator
An xy_locator.
Definition ImageBase.h:121

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

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

Friends And Related Symbol 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: