31 #ifndef LSST_AFW_IMAGE_IMAGE_H
32 #define LSST_AFW_IMAGE_IMAGE_H
40 #include "boost/mpl/bool.hpp"
54 namespace lsst {
namespace afw {
56 namespace formatters {
57 template <
typename PixelT>
class ImageFormatter;
58 template <
typename PixelT>
class DecoratedImageFormatter;
76 template<
typename ImageT>
89 operator bool()
const {
return _check; }
96 template<
typename PixelT>
98 typedef typename boost::gil::channel_traits<PixelT>::reference
type;
101 template<
typename PixelT>
103 typedef typename boost::gil::channel_traits<PixelT>::const_reference
type;
113 template<
typename PixelT>
117 typedef typename lsst::afw::image::detail::types_traits<PixelT>::view_t
_view_t;
118 typedef typename lsst::afw::image::detail::types_traits<PixelT>::const_view_t
_const_view_t;
124 typedef std::shared_ptr<ImageBase<PixelT> >
Ptr;
125 typedef std::shared_ptr<const ImageBase<PixelT> >
ConstPtr;
165 typedef typename ndarray::Array<PixelT, 2, 1>
Array;
167 typedef typename ndarray::Array<PixelT const, 2, 1>
ConstArray;
173 template<
typename SinglePixelT>
191 template<
typename OtherPixelT>
193 lsst::daf::base::
Citizen(typeid(this)) {
195 throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
196 "Only deep copies are permitted for ImageBases with different pixel types");
200 copy_and_convert_pixels(rhs.
_gilView, tmp._gilView);
277 int const roundedIndex =
static_cast<int>(fullIndex + 0.5);
278 double const residual = fullIndex - roundedIndex;
279 return std::pair<int, double>(roundedIndex, residual);
410 template<
typename PixelT>
411 void swap(ImageBase<PixelT>& a, ImageBase<PixelT>&
b);
415 template<
typename PixelT>
419 typedef std::shared_ptr<Image<PixelT> >
Ptr;
420 typedef std::shared_ptr<const Image<PixelT> >
ConstPtr;
425 template<
typename ImagePT=PixelT>
432 template<
typename OtherPixelT>
friend class Image;
439 const bool deep=
false);
440 Image(
const Image& rhs,
const bool deep=
false);
455 std::string
const & fileName,
int hdu=0,
497 template<
typename OtherPixelT>
501 explicit Image(ndarray::Array<PixelT,2,1>
const & array,
bool deep =
false,
520 std::string
const& fileName,
522 std::string
const& mode=
"w"
535 std::string
const& mode=
"w"
598 template<
typename LhsPixelT,
typename RhsPixelT>
599 void operator+=(Image<LhsPixelT> &lhs, Image<RhsPixelT>
const& rhs);
600 template<
typename LhsPixelT,
typename RhsPixelT>
601 void operator-=(Image<LhsPixelT> &lhs, Image<RhsPixelT>
const& rhs);
602 template<
typename LhsPixelT,
typename RhsPixelT>
603 void operator*=(Image<LhsPixelT> &lhs, Image<RhsPixelT>
const& rhs);
604 template<
typename LhsPixelT,
typename RhsPixelT>
605 void operator/=(Image<LhsPixelT> &lhs, Image<RhsPixelT>
const& rhs);
607 template<
typename PixelT>
608 void swap(Image<PixelT>& a, Image<PixelT>&
b);
614 template<
typename PixelT>
619 typedef std::shared_ptr<DecoratedImage>
Ptr;
621 typedef std::shared_ptr<const DecoratedImage>
ConstPtr;
632 std::
string const& fileName,
634 geom::Box2I const& bbox=geom::Box2I(),
659 std::string
const& fileName,
661 std::string
const& mode=
"w"
iterator at(int x, int y) const
Return an STL compliant iterator at the point (x, y)
void scaledDivides(double const c, Image< PixelT >const &rhs)
Divide lhs by Image c*rhs (i.e. pixel-by-pixel division)
static Image readFits(std::string const &filename, int hdu=0)
Read an Image from a regular FITS file.
boost::gil::channel_traits< PixelT >::reference type
reference type
PixelConstReference get0(int x, int y, CheckIndices const &check) const
iterator end() const
Return an STL compliant iterator to the end of the image.
void setXY0(geom::Point2I const origin)
Set the ImageBase's origin.
A templated class to return this classes' type (present in Image/Mask/MaskedImage) ...
_const_view_t::reverse_iterator const_reverse_iterator
An STL compliant const reverse iterator.
A coordinate class intended to represent absolute positions.
x_iterator fast_iterator
A fast STL compliant iterator for contiguous images N.b.
reverse_iterator rend() const
Return an STL compliant reverse iterator to the end of the image.
#define LSST_PERSIST_FORMATTER(formatter...)
Macro used to connect the persistable class with the Formatter and boost::serialization.
ConstReference< PixelT >::type PixelConstReference
A ConstReference to a PixelT.
Citizen(const std::type_info &)
_view_t::reverse_iterator reverse_iterator
An STL compliant reverse iterator.
_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)
x_iterator x_at(int x, int y) const
Return an x_iterator to the point (x, y) in the image.
detail::basic_tag image_category
trait class to identify type of image
Include files required for standard LSST Exception handling.
boost::shared_ptr< Image< PixelT > > _image
std::shared_ptr< const Image< PixelT > > ConstPtr
_const_view_t::x_iterator const_x_iterator
A const iterator for traversing the pixels in a row.
bool isContiguous() const
PixelT Pixel
A pixel in this ImageBase.
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
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)
std::shared_ptr< const ImageBase< PixelT > > ConstPtr
A shared_ptr to a const ImageBase.
double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const
Convert image index to image position.
double getGain() const
Return the DecoratedImage's gain.
std::shared_ptr< DecoratedImage > Ptr
shared_ptr to a DecoratedImage
boost::shared_ptr< Image< PixelT > > ImagePtr
shared_ptr to the Image
void operator/=(PixelT const rhs)
Divide lhs by scalar rhs.
geom::Box2I getBBox(ImageOrigin origin=PARENT) const
static _view_t _makeSubView(geom::Extent2I const &dimensions, geom::Extent2I const &offset, const _view_t &view)
void swap(DecoratedImage &rhs)
void swap(Mask< PixelT > &a, Mask< PixelT > &b)
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
The base class for all image classed (Image, Mask, MaskedImage, ...)
void operator*=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Multiply lhs by Image rhs (i.e.
A Function taking two arguments.
int getX0() const
Return the image's column-origin.
std::shared_ptr< const DecoratedImage > ConstPtr
shared_ptr to a const DecoratedImage
void writeFits(std::string const &fileName, boost::shared_ptr< lsst::daf::base::PropertySet const > metadata=boost::shared_ptr< lsst::daf::base::PropertySet const >(), std::string const &mode="w") const
Write an image to a regular FITS file.
static Image readFits(fits::MemFileManager &manager, int hdu=0)
Read an Image from a FITS RAM file.
int getWidth() const
Return the number of columns in the image.
_const_view_t::iterator const_iterator
An STL compliant const iterator.
An integer coordinate rectangle.
void operator<<=(const ImageBase &rhs)
Set the lhs's pixel values to equal the rhs's.
table::Key< table::Array< Kernel::Pixel > > image
void scaledPlus(double const c, Image< PixelT >const &rhs)
Add Image c*rhs to lhs.
boost::shared_ptr< lsst::daf::base::PropertySet > getMetadata() const
_view_t::iterator iterator
An STL compliant iterator.
lsst::afw::image::detail::types_traits< PixelT >::const_view_t _const_view_t
geom::Point2I getXY0() const
Return the image's origin.
afw::table::PointKey< int > dimensions
Image & operator=(const PixelT rhs)
Set the image's pixels to rhs.
void operator*=(PixelT const rhs)
Multiply lhs by scalar rhs.
void ImageT ImageT int float saturatedPixelValue int const width
lsst::afw::image::detail::types_traits< PixelT >::view_t _view_t
geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
void set0(int x, int y, const PixelT v)
x_iterator row_end(int y) const
Return an x_iterator to the end of the y'th row.
Lifetime-management for memory that goes into FITS memory files.
std::shared_ptr< ImageBase< PixelT > > Ptr
A shared_ptr to an ImageBase.
Types and classes to interface lsst::afw::image to boost::gil.
void assign(ImageBase const &rsh, geom::Box2I const &bbox=geom::Box2I(), ImageOrigin origin=PARENT)
Copy pixels from another image to a specified subregion of this image.
_view_t _getRawView() const
ImagePtr getImage()
Return a shared_ptr to the DecoratedImage's Image.
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.
int getHeight() const
Return the number of rows in the image.
traits class for image categories
A class used to request that array accesses be checked.
int getHeight() const
Return the number of rows in the image.
std::shared_ptr< Image< PixelT > > Ptr
void setGain(double gain)
Set the DecoratedImage's gain.
void operator+=(PixelT const rhs)
Add scalar rhs to lhs.
Image(ndarray::Array< PixelT, 2, 1 > const &array, bool deep=false, geom::Point2I const &xy0=geom::Point2I())
void swap(ImageBase &rhs)
y_iterator col_end(int x) const
Return an y_iterator to the end of the y'th row.
void operator-=(PixelT const rhs)
Subtract scalar rhs from lhs.
void ImageT ImageT int float saturatedPixelValue int const height
y_iterator y_at(int x, int y) const
Return an y_iterator to the point (x, y) in the image.
ndarray::Array< PixelT const, 2, 1 > ConstArray
An immutable ndarray representation of the image.
PixelConstReference get0(int x, int y) const
void setXY0(int const x0, int const y0)
Set the ImageBase's origin.
void writeFits(std::string const &fileName, boost::shared_ptr< lsst::daf::base::PropertySet const > metadata=boost::shared_ptr< lsst::daf::base::PropertySet const >(), std::string const &mode="w") const
Write a FITS file.
_view_t::xy_locator::const_t const_xy_locator
A const_xy_locator.
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
y_iterator col_begin(int x) const
Return an y_iterator to the start of the y'th row.
boost::shared_ptr< lsst::daf::base::PropertySet > _metadata
static _view_t _allocateView(geom::Extent2I const &dimensions, Manager::Ptr &manager)
ImageConstPtr getImage() const
Return a shared_ptr to the DecoratedImage's Image as const.
_const_view_t::y_iterator const_y_iterator
A const iterator for traversing the pixels in a column.
void scaledMinus(double const c, Image< PixelT >const &rhs)
Subtract Image c*rhs from lhs.
Class for storing generic metadata.
void operator/=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Divide lhs by Image rhs (i.e.
Reference< PixelT >::type PixelReference
A Reference to a PixelT.
int getX0() const
Return the image's column-origin.
boost::shared_ptr< Image< PixelT > const > ImageConstPtr
shared_ptr to the Image as const
Define the basic Function classes.
static SinglePixel PixelCast(SinglePixelT rhs)
Convert a type to our SinglePixel type.
afw::table::Key< double > b
void scaledMultiplies(double const c, Image< PixelT >const &rhs)
Multiply lhs by Image c*rhs (i.e. pixel-by-pixel multiplication)
ImageT::image_category image_category
xy_locator xy_at(int x, int y) const
Return an xy_locator at the point (x, y) in the image.
void operator-=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Subtract lhs from Image rhs (i.e.
Base class for all persistable classes.
void setMetadata(boost::shared_ptr< lsst::daf::base::PropertySet > metadata)
x_iterator row_begin(int y) const
Return an x_iterator to the start of the y'th row.
const geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
iterator begin() const
Return an STL compliant iterator to the start of the image.
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
reverse_iterator rbegin() const
Return an STL compliant reverse iterator to the start of the image.
#define CONST_PTR(...)
A shared pointer to a const object.
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
Image(Image< OtherPixelT > const &rhs, const bool deep)
A coordinate class intended to represent offsets and dimensions.
int getWidth() const
Return the number of columns in the image.
ndarray::Array< PixelT, 2, 1 > Array
A mutable ndarray representation of the image.
PixelT SinglePixel
A single Pixel of the same type as those in the ImageBase.
A class to represent a 2-dimensional array of pixels.
CheckIndices(bool check=true)
Extent< int, 2 > Extent2I
detail::Image_tag image_category
std::string const wcsNameForXY0
boost::gil::channel_traits< PixelT >::const_reference type
const reference type
ImageBase & operator=(const ImageBase &rhs)
Shallow assignment operator.
PixelReference operator()(int x, int y)
Return a reference to the pixel (x, y)
Image< ImagePT > type
Return the desired type.
A container for an Image and its associated metadata.
void operator+=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Add lhs to Image rhs (i.e.
metafunction to extract reference type from PixelT
int getY0() const
Return the image's row-origin.
_view_t::y_iterator xy_y_iterator
An iterator for traversing the pixels in a row, created from an xy_locator.
int getY0() const
Return the image's row-origin.
metafunction to extract const reference type from PixelT