30 #ifndef LSST_AFW_IMAGE_IMAGEBASE_H 31 #define LSST_AFW_IMAGE_IMAGEBASE_H 53 struct ImageWriteOptions;
66 template <
typename ImageT>
78 operator bool()
const {
return _check; }
85 template <
typename PixelT>
87 typedef typename boost::gil::channel_traits<PixelT>::reference
type;
90 template <
typename PixelT>
92 typedef typename boost::gil::channel_traits<PixelT>::const_reference
type;
102 template <
typename PixelT>
105 typedef typename lsst::afw::image::detail::types_traits<PixelT>::view_t _view_t;
106 typedef typename lsst::afw::image::detail::types_traits<PixelT>::const_view_t _const_view_t;
108 typedef ndarray::Manager Manager;
150 typedef typename ndarray::Array<PixelT, 2, 1>
Array;
152 typedef typename ndarray::Array<PixelT const, 2, 1>
ConstArray;
154 template <
typename OtherPixelT>
158 template <
typename SinglePixelT>
160 return SinglePixel(rhs);
168 template <
typename,
typename,
typename>
210 const bool deep =
false);
217 template <
typename OtherPixelT>
221 "Only deep copies are permitted for ImageBases with different pixel types");
225 copy_and_convert_pixels(rhs._gilView, tmp._gilView);
240 explicit ImageBase(Array
const& array,
bool deep =
false,
282 PixelReference operator()(
int x,
int y);
285 PixelReference operator()(
int x,
int y,
CheckIndices const&);
287 PixelConstReference operator()(
int x,
int y)
const;
289 PixelConstReference operator()(
int x,
int y,
CheckIndices const&)
const;
291 PixelConstReference
get0(
int x,
int y)
const {
return operator()(x - getX0(), y - getY0()); }
293 return operator()(x - getX0(), y - getY0(), check);
295 void set0(
int x,
int y,
const PixelT v) { operator()(x - getX0(), y - getY0()) = v; }
297 operator()(x - getX0(), y - getY0(), check) = v;
324 int getX0()
const {
return _origin.getX(); }
332 int getY0()
const {
return _origin.getY(); }
352 double const fullIndex = pos -
PixelZeroPos - (xy ==
X ? getX0() : getY0());
353 int const roundedIndex =
static_cast<int>(fullIndex + 0.5);
354 double const residual = fullIndex - roundedIndex;
379 ConstArray getArray()
const;
388 iterator begin()
const;
390 iterator
end()
const;
392 reverse_iterator rbegin()
const;
394 reverse_iterator rend()
const;
396 iterator at(
int x,
int y)
const;
405 fast_iterator begin(
bool contiguous)
const;
413 fast_iterator
end(
bool contiguous)
const;
419 x_iterator
row_begin(
int y)
const {
return _gilView.row_begin(y); }
422 x_iterator
row_end(
int y)
const {
return _gilView.row_end(y); }
425 x_iterator
x_at(
int x,
int y)
const {
return _gilView.x_at(x, y); }
431 y_iterator
col_begin(
int x)
const {
return _gilView.col_begin(x); }
434 y_iterator
col_end(
int x)
const {
return _gilView.col_end(x); }
437 y_iterator
y_at(
int x,
int y)
const {
return _gilView.y_at(x, y); }
443 xy_locator
xy_at(
int x,
int y)
const {
return xy_locator(_gilView.xy_at(x, y)); }
472 Manager::Ptr _manager;
481 const _view_t& view);
485 inline bool isContiguous()
const {
return begin() + getWidth() * getHeight() ==
end(); }
488 template <
typename PixelT>
493 template <
typename PixelT>
495 int rowStride =
reinterpret_cast<PixelT*
>(row_begin(1)) - reinterpret_cast<PixelT*>(row_begin(0));
496 return ndarray::external(reinterpret_cast<PixelT*>(row_begin(0)),
497 ndarray::makeVector(getHeight(), getWidth()), ndarray::makeVector(rowStride, 1),
501 template <
typename PixelT>
503 int rowStride =
reinterpret_cast<PixelT*
>(row_begin(1)) - reinterpret_cast<PixelT*>(row_begin(0));
504 return ndarray::external(reinterpret_cast<PixelT*>(row_begin(0)),
505 ndarray::makeVector(getHeight(), getWidth()), ndarray::makeVector(rowStride, 1),
bool isContiguous() const
boost::gil::channel_traits< PixelT >::reference type
reference type
afw::table::PointKey< int > dimensions
_const_view_t::reverse_iterator const_reverse_iterator
An STL compliant const reverse iterator.
x_iterator fast_iterator
A fast STL compliant iterator for contiguous images N.b.
ConstReference< PixelT >::type PixelConstReference
A ConstReference to a PixelT.
_view_t::reverse_iterator reverse_iterator
An STL compliant reverse iterator.
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)
_view_t::x_iterator xy_x_iterator
An iterator for traversing the pixels in a row, created from an xy_locator.
void set0(int x, int y, const PixelT v, CheckIndices const &check)
void swap(ImageBase< PixelT > &a, ImageBase< PixelT > &b)
detail::basic_tag image_category
trait class to identify type of image
int getHeight() const
Return the number of rows in the image.
_const_view_t::x_iterator const_x_iterator
A const iterator for traversing the pixels in a row.
PixelT Pixel
A pixel in this ImageBase.
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
void setXY0(lsst::geom::Point2I const origin)
Set the ImageBase's origin.
int getX0() const
Return the image's column-origin.
The base class for all image classed (Image, Mask, MaskedImage, ...)
x_iterator row_begin(int y) const
Return an x_iterator to the start of the y'th row.
_const_view_t::iterator const_iterator
An STL compliant const iterator.
_view_t::iterator iterator
An STL compliant iterator.
y_iterator y_at(int x, int y) const
Return an y_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.
A base class for image defects.
lsst::geom::Box2I getBBox(ImageOrigin origin=PARENT) const
void set0(int x, int y, const PixelT v)
PixelReference operator[](lsst::geom::Point2I const &index)
Return a reference to a single pixel in PARENT coordinates (with no bounds check).
A class to manipulate images, masks, and variance as a single object.
_view_t::y_iterator y_iterator
An iterator for traversing the pixels in a column.
traits class for image categories
A class used to request that array accesses be checked.
y_iterator col_end(int x) const
Return an y_iterator to the start of the y'th row.
PixelConstReference operator[](lsst::geom::Point2I const &index) const
Return a reference to a single pixel in PARENT coordinates (with no bounds check).
ndarray::Array< PixelT const, 2, 1 > ConstArray
An immutable ndarray representation of the image.
std::shared_ptr< RecordT > src
void setXY0(int const x0, int const y0)
Set the ImageBase's origin.
_view_t::xy_locator::const_t const_xy_locator
A const_xy_locator.
lsst::geom::Point2I getXY0() const
Return the image's origin.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Extent< int, 2 > Extent2I
int getY0() const
Return the image's row-origin.
_const_view_t::y_iterator const_y_iterator
A const iterator for traversing the pixels in a column.
int getWidth() const
Return the number of columns in the image.
Reference< PixelT >::type PixelReference
A Reference to a PixelT.
static SinglePixel PixelCast(SinglePixelT rhs)
Convert a type to our SinglePixel type.
Reports invalid arguments.
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.
ImageT::image_category image_category
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
lsst::geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...
PixelConstReference get0(int x, int y, CheckIndices const &check) const
_view_t _getRawView() const
const double PixelZeroPos
position of center of pixel 0
_view_t::xy_locator xy_locator
An xy_locator.
ImageBase(const ImageBase< OtherPixelT > &rhs, const bool deep)
generalised copy constructor
ndarray::Array< PixelT, 2, 1 > Array
A mutable ndarray representation of the image.
xy_locator xy_at(int x, int y) const
Return an xy_locator at the point (x, y) in the image.
An integer coordinate rectangle.
PixelConstReference get0(int x, int y) const
PixelT SinglePixel
A single Pixel of the same type as those in the ImageBase.
CheckIndices(bool check=true)
double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const
Convert image index to image position.
std::string const wcsNameForXY0
boost::gil::channel_traits< PixelT >::const_reference type
const reference type
A container for an Image and its associated metadata.
metafunction to extract reference type from PixelT
_view_t::y_iterator xy_y_iterator
An iterator for traversing the pixels in a row, created from an xy_locator.
metafunction to extract const reference type from PixelT