Template Class ImageBase

Inheritance Relationships

Derived Types

Class Documentation

template<typename PixelT>
class ImageBase

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

Subclassed by lsst::afw::image::Image< lsst::afw::math::Kernel::Pixel >, lsst::afw::image::Image< Pixel >, lsst::afw::image::Image< PixelT >

Unnamed Group

PixelReference operator()(int x, int y)

Return a reference to the pixel (x, y)

PixelReference operator()(int x, int y, CheckIndices const&)

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

PixelConstReference operator()(int x, int y) const

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

PixelConstReference operator()(int x, int y, CheckIndices const&) const

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

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)

Public Types

typedef detail::basic_tag image_category

trait class to identify type of image

typedef PixelT SinglePixel

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

typedef PixelT Pixel

A pixel in this ImageBase.

typedef Reference<PixelT>::type PixelReference

A Reference to a PixelT.

typedef ConstReference<PixelT>::type PixelConstReference

A ConstReference to a PixelT.

typedef _view_t::xy_locator xy_locator

An xy_locator.

typedef _view_t::xy_locator::const_t const_xy_locator

A const_xy_locator.

typedef _view_t::iterator iterator

An STL compliant iterator.

typedef _const_view_t::iterator const_iterator

An STL compliant const iterator.

typedef _view_t::reverse_iterator reverse_iterator

An STL compliant reverse iterator.

typedef _const_view_t::reverse_iterator const_reverse_iterator

An STL compliant const reverse iterator.

typedef _view_t::x_iterator x_iterator

An iterator for traversing the pixels in a row.

typedef x_iterator fast_iterator

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

typedef _view_t::x_iterator xy_x_iterator

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

typedef _const_view_t::x_iterator const_x_iterator

A const iterator for traversing the pixels in a row.

typedef _view_t::y_iterator y_iterator

An iterator for traversing the pixels in a column.

typedef _view_t::y_iterator xy_y_iterator

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

typedef _const_view_t::y_iterator const_y_iterator

A const iterator for traversing the pixels in a column.

typedef ndarray::Array<PixelT, 2, 1> Array

A mutable ndarray representation of the image.

typedef ndarray::Array<PixelT const, 2, 1> ConstArray

An immutable ndarray representation of the image.

Public Functions

ImageBase(const lsst::geom::Extent2I &dimensions = lsst::geom::Extent2I())

Allocator Constructor

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

ImageBase(const lsst::geom::Box2I &bbox)

Allocator Constructor

allocate a new image with the specified dimensions and origin

ImageBase(const ImageBase &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 assign(rhs) to copy pixels between Images

Parameters
  • src: Right-hand-side image

  • deep: If false, new ImageBase shares storage with src; if true make a new, standalone, ImageBase

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.

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
  • src: Right-hand-side image

  • bbox: Specify desired region

  • origin: Specify the coordinate system of the bbox

  • deep: If false, new ImageBase shares storage with src; if true make a new, standalone, ImageBase

template<typename OtherPixelT>
ImageBase(const ImageBase<OtherPixelT> &rhs, const bool deep)

generalised copy constructor

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

ImageBase(Array const &array, bool deep = false, lsst::geom::Point2I const &xy0 = lsst::geom::Point2I())

Construction from ndarray::Array and NumPy.

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

Note

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

virtual ~ImageBase()
ImageBase &operator=(const ImageBase &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)

Note

this behaviour is required to make the swig interface work, otherwise I’d declare this function private

ImageBase &operator=(ImageBase &&rhs)
ImageBase &operator=(const PixelT rhs)

Set the image’s pixels to rhs.

ImageBase &operator<<=(const ImageBase &rhs)

Set the lhs’s pixel values to equal the rhs’s

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.

Parameters
  • [in] rhs: source image whose pixels are to be copied into this image (the destination)

  • [in] bbox: subregion of this image to set; if empty (the default) then all pixels are set

  • [in] origin: origin 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::LengthError: if the dimensions of rhs and the specified subregion of this image do not match.

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 getX0() const

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

int getY0() const

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

lsst::geom::Point2I getXY0() const

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

std::pair<int, double> positionToIndex(double const pos, lsst::afw::image::xOrY const xy) const

Parameters
  • pos: image position

  • xy: Is this a column or row coordinate?

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

Return

std::pair(nearest integer index, fractional part)

double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const

Parameters
  • ind: image index

  • xy: Is this a column or row coordinate?

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

Return

image position

lsst::geom::Extent2I getDimensions() const

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

void swap(ImageBase &rhs)
ImageBase<PixelT>::Array getArray()
ImageBase<PixelT>::ConstArray getArray() const
iterator begin() const

Return an STL compliant iterator to the start of the image

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

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

Parameters
  • contiguous: Pixels are contiguous (must be true)

Exceptions
  • lsst::pex::exceptions::RuntimeError: Argument contiguous is false, or the pixels are not in fact contiguous

fast_iterator end(bool contiguous) const

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

Parameters
  • contiguous: Pixels are contiguous (must be true)

Exceptions
  • lsst::pex::exceptions::RuntimeError: Argument contiguous is false, or the pixels are not in fact contiguous

x_iterator row_begin(int y) const

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

Incrementing an x_iterator moves it across the 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

Incrementing an y_iterator moves it up the column

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

Locators may be used to access a patch in an image

void setXY0(lsst::geom::Point2I const origin)

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.

void setXY0(int const x0, int const y0)

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.

lsst::geom::Box2I getBBox(ImageOrigin origin = PARENT) const

Public Static Functions

template<typename SinglePixelT>
static SinglePixel PixelCast(SinglePixelT rhs)

Convert a type to our SinglePixel type.

Protected Functions

_view_t _getRawView() const
bool isContiguous() const

Protected Static 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

friend lsst::afw::image::ImageBase::ImageBase
friend lsst::afw::image::ImageBase::DecoratedImage
friend lsst::afw::image::ImageBase::MaskedImage