30#ifndef LSST_AFW_IMAGE_IMAGEBASE_H
31#define LSST_AFW_IMAGE_IMAGEBASE_H
52struct ImageWriteOptions;
65template <
typename ImageT>
77 operator bool()
const {
return _check; }
84template <
typename PixelT>
86 using type =
typename boost::gil::channel_traits<PixelT>::reference;
89template <
typename PixelT>
91 using type =
typename boost::gil::channel_traits<PixelT>::const_reference;
101template <
typename PixelT>
104 using _view_t =
typename lsst::afw::image::detail::types_traits<PixelT>::view_t;
105 using _const_view_t =
typename lsst::afw::image::detail::types_traits<PixelT>::const_view_t;
107 using Manager = ndarray::Manager;
149 using Array =
typename ndarray::Array<PixelT, 2, 1>;
151 using ConstArray =
typename ndarray::Array<const PixelT, 2, 1>;
153 template <
typename OtherPixelT>
157 template <
typename SinglePixelT>
167 template <
typename,
typename,
typename>
209 const bool deep =
false);
216 template <
typename OtherPixelT>
220 "Only deep copies are permitted for ImageBases with different pixel types");
224 copy_and_convert_pixels(rhs._gilView, tmp._gilView);
306 int getX0()
const {
return _origin.getX(); }
314 int getY0()
const {
return _origin.getY(); }
335 int const roundedIndex =
static_cast<int>(fullIndex + 0.5);
336 double const residual = fullIndex - roundedIndex;
454 Manager::Ptr _manager;
463 const _view_t& view);
470template <
typename PixelT>
471void swap(ImageBase<PixelT>&
a, ImageBase<PixelT>&
b);
475template <
typename PixelT>
478 PixelT *
data =
nullptr;
480 data =
reinterpret_cast<PixelT*
>(row_begin(0));
482 if (getHeight() > 1) {
483 rowStride =
reinterpret_cast<PixelT*
>(row_begin(1)) -
reinterpret_cast<PixelT*
>(row_begin(0));
485 return ndarray::external(
data,
486 ndarray::makeVector(getHeight(), getWidth()), ndarray::makeVector(rowStride, 1),
490template <
typename PixelT>
493 PixelT *
data =
nullptr;
495 data =
reinterpret_cast<PixelT*
>(row_begin(0));
497 if (getHeight() > 1) {
498 rowStride =
reinterpret_cast<PixelT*
>(row_begin(1)) -
reinterpret_cast<PixelT*
>(row_begin(0));
500 return ndarray::external(
data,
501 ndarray::makeVector(getHeight(), getWidth()), ndarray::makeVector(rowStride, 1),
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
afw::table::PointKey< int > dimensions
std::shared_ptr< RecordT > src
A class used to request that array accesses be checked.
CheckIndices(bool check=true)
A container for an Image and its associated metadata.
The base class for all image classed (Image, Mask, MaskedImage, ...)
y_iterator col_begin(int x) const
Return an y_iterator to the start of the y'th row.
iterator end() const
Return an STL compliant iterator to the end of the image.
void setXY0(lsst::geom::Point2I const origin)
Set the ImageBase's origin.
y_iterator y_at(int x, int y) const
Return an y_iterator to the point (x, y) in the image.
int getX0() const
Return the image's column-origin.
PixelT Pixel
A pixel in this ImageBase.
xy_locator xy_at(int x, int y) const
Return an xy_locator at the point (x, y) in the image.
iterator begin() const
Return an STL compliant iterator to the start of the image.
typename _view_t::xy_locator xy_locator
An xy_locator.
void setXY0(int const x0, int const y0)
Set the ImageBase's origin.
typename _const_view_t::x_iterator const_x_iterator
A const iterator for traversing the pixels in a row.
static _view_t _allocateView(lsst::geom::Extent2I const &dimensions, Manager::Ptr &manager)
typename _const_view_t::iterator const_iterator
An STL compliant const iterator.
typename Reference< PixelT >::type PixelReference
A Reference to a PixelT.
typename _view_t::iterator iterator
An STL compliant iterator.
PixelReference operator()(int x, int y)
Return a reference to the pixel (x, y) in LOCAL coordinates.
static _view_t _makeSubView(lsst::geom::Extent2I const &dimensions, lsst::geom::Extent2I const &offset, const _view_t &view)
int getWidth() const
Return the number of columns in the image.
typename _view_t::xy_locator::const_t const_xy_locator
A const_xy_locator.
typename _const_view_t::y_iterator const_y_iterator
A const iterator for traversing the pixels in a column.
lsst::geom::Box2I getBBox(ImageOrigin origin=PARENT) const
typename ndarray::Array< const PixelT, 2, 1 > ConstArray
An immutable ndarray representation of the image.
typename _const_view_t::reverse_iterator const_reverse_iterator
An STL compliant const reverse iterator.
PixelReference operator[](lsst::geom::Point2I const &index)
Return a reference to a single pixel in PARENT coordinates (with no bounds check).
int getY0() const
Return the image's row-origin.
int getArea() const
Return the area of the image.
x_iterator x_at(int x, int y) const
Return an x_iterator to the point (x, y) in the image.
lsst::geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
typename ndarray::Array< PixelT, 2, 1 > Array
A mutable ndarray representation of the image.
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.
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)
x_iterator fast_iterator
A fast STL compliant iterator for contiguous images N.b.
typename _view_t::reverse_iterator reverse_iterator
An STL compliant reverse iterator.
int getHeight() const
Return the number of rows in the image.
y_iterator col_end(int x) const
Return an y_iterator to the start of the y'th row.
ImageBase & operator=(const ImageBase &rhs)
Shallow assignment operator.
bool isContiguous() const
typename _view_t::y_iterator xy_y_iterator
An iterator for traversing the pixels in a row, created from an xy_locator.
PixelT SinglePixel
A single Pixel of the same type as those in the ImageBase.
ImageBase(const ImageBase< OtherPixelT > &rhs, const bool deep)
generalised copy constructor
double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const
Convert image index to image position.
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.
typename _view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
reverse_iterator rbegin() const
Return an STL compliant reverse iterator to the start of the image.
virtual ~ImageBase()=default
_view_t _getRawView() const
ConstArray getArray() const
PixelReference get(lsst::geom::Point2I const &index, ImageOrigin origin)
Return a reference to a single pixel (with no bounds check).
typename _view_t::y_iterator y_iterator
An iterator for traversing the pixels in a column.
lsst::geom::Point2I getXY0() const
Return the image's origin.
void swap(ImageBase &rhs)
typename ConstReference< PixelT >::type PixelConstReference
A ConstReference to a PixelT.
static SinglePixel PixelCast(SinglePixelT rhs)
Convert a type to our SinglePixel type.
typename _view_t::x_iterator xy_x_iterator
An iterator for traversing the pixels in a row, created from an xy_locator.
PixelConstReference operator[](lsst::geom::Point2I const &index) const
Return a reference to a single pixel in PARENT coordinates (with no bounds check).
reverse_iterator rend() const
Return an STL compliant reverse iterator to the end of the image.
A class to manipulate images, masks, and variance as a single object.
An integer coordinate rectangle.
Reports invalid arguments.
std::string const wcsNameForXY0
const double PixelZeroPos
position of center of pixel 0
Extent< int, 2 > Extent2I
metafunction to extract const reference type from PixelT
typename boost::gil::channel_traits< PixelT >::const_reference type
const reference type
metafunction to extract reference type from PixelT
typename boost::gil::channel_traits< PixelT >::reference type
reference type
traits class for image categories
typename ImageT::image_category image_category