31 #ifndef LSST_AFW_IMAGE_IMAGE_H
32 #define LSST_AFW_IMAGE_IMAGE_H
40 #include "boost/mpl/bool.hpp"
41 #include "boost/shared_ptr.hpp"
55 namespace lsst {
namespace afw {
57 namespace formatters {
58 template <
typename PixelT>
class ImageFormatter;
59 template <
typename PixelT>
class DecoratedImageFormatter;
77 template<
typename ImageT>
90 operator bool()
const {
return _check; }
97 template<
typename PixelT>
99 typedef typename boost::gil::channel_traits<PixelT>::reference
type;
102 template<
typename PixelT>
104 typedef typename boost::gil::channel_traits<PixelT>::const_reference
type;
114 template<
typename PixelT>
118 typedef typename lsst::afw::image::detail::types_traits<PixelT>::view_t
_view_t;
119 typedef typename lsst::afw::image::detail::types_traits<PixelT>::const_view_t
_const_view_t;
125 typedef boost::shared_ptr<ImageBase<PixelT> >
Ptr;
126 typedef boost::shared_ptr<const ImageBase<PixelT> >
ConstPtr;
174 template<
typename SinglePixelT>
192 template<
typename OtherPixelT>
194 lsst::daf::base::
Citizen(typeid(this)) {
196 throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
197 "Only deep copies are permitted for ImageBases with different pixel types");
201 copy_and_convert_pixels(rhs.
_gilView, tmp._gilView);
276 int const roundedIndex =
static_cast<int>(fullIndex + 0.5);
277 double const residual = fullIndex - roundedIndex;
278 return std::pair<int, double>(roundedIndex, residual);
409 template<
typename PixelT>
410 void swap(ImageBase<PixelT>& a, ImageBase<PixelT>&
b);
414 template<
typename PixelT>
418 typedef boost::shared_ptr<Image<PixelT> >
Ptr;
419 typedef boost::shared_ptr<const Image<PixelT> >
ConstPtr;
424 template<
typename ImagePT=PixelT>
431 template<
typename OtherPixelT>
friend class Image;
438 const bool deep=
false);
439 Image(
const Image& rhs,
const bool deep=
false);
454 std::string
const & fileName,
int hdu=0,
496 template<
typename OtherPixelT>
519 std::string
const& fileName,
521 std::string
const& mode=
"w"
534 std::string
const& mode=
"w"
597 template<
typename LhsPixelT,
typename RhsPixelT>
598 void operator+=(Image<LhsPixelT> &lhs, Image<RhsPixelT>
const& rhs);
599 template<
typename LhsPixelT,
typename RhsPixelT>
600 void operator-=(Image<LhsPixelT> &lhs, Image<RhsPixelT>
const& rhs);
601 template<
typename LhsPixelT,
typename RhsPixelT>
602 void operator*=(Image<LhsPixelT> &lhs, Image<RhsPixelT>
const& rhs);
603 template<
typename LhsPixelT,
typename RhsPixelT>
604 void operator/=(Image<LhsPixelT> &lhs, Image<RhsPixelT>
const& rhs);
606 template<
typename PixelT>
607 void swap(Image<PixelT>& a, Image<PixelT>&
b);
613 template<
typename PixelT>
618 typedef boost::shared_ptr<DecoratedImage>
Ptr;
620 typedef boost::shared_ptr<const DecoratedImage>
ConstPtr;
631 std::
string const& fileName,
633 geom::Box2I const& bbox=geom::Box2I(),
658 std::string
const& fileName,
660 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)
A templated class to return this classes' type (present in Image/Mask/MaskedImage) ...
View< boost::fusion::vector1< index::Full > > view()
Start a view definition that includes the entire first dimension.
_const_view_t::reverse_iterator const_reverse_iterator
An STL compliant const reverse iterator.
A coordinate class intended to represent absolute positions.
reverse_iterator rend() const
Return an STL compliant reverse iterator to the end of the image.
ConstReference< PixelT >::type PixelConstReference
A ConstReference to a PixelT.
_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.
void swap(ImageBase< PixelT > &a, ImageBase< PixelT > &b)
detail::basic_tag image_category
trait class to identify type of image
A set of classes of general utility in connection with images.
Include files required for standard LSST Exception handling.
boost::shared_ptr< Image< PixelT > > _image
_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)
double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const
Convert image index to image position.
boost::shared_ptr< Image< PixelT > > ImagePtr
shared_ptr to the Image
void operator/=(PixelT const 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)
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, ...)
Extent< int, 2 > Extent2I
void operator*=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
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.
boost::shared_ptr< const DecoratedImage > ConstPtr
shared_ptr to a const DecoratedImage
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
afw::table::PointKey< int > dimensions
boost::intrusive_ptr< Manager > Ptr
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.
Types and classes to interface lsst::afw::image to boost::gil.
_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.
boost::shared_ptr< Image< PixelT > > Ptr
void setGain(double gain)
Set the DecoratedImage's gain.
void operator+=(PixelT const rhs)
Add scalar rhs to lhs.
#define LSST_PERSIST_FORMATTER(formatter...)
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)
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
_view_t::xy_locator::const_t const_xy_locator
A const_xy_locator.
#define LSST_EXCEPT(type,...)
boost::shared_ptr< ImageBase< PixelT > > Ptr
A shared_ptr to an ImageBase.
A multidimensional strided array.
y_iterator col_begin(int x) const
boost::shared_ptr< lsst::daf::base::PropertySet > _metadata
Citizen(const std::type_info &)
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)
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
void operator-=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Base class for all persistable classes.
void setMetadata(boost::shared_ptr< lsst::daf::base::PropertySet > metadata)
x_iterator row_begin(int y) const
const geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
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.
const double PixelZeroPos
FITS uses 1.0, SDSS uses 0.5, LSST uses 0.0 (http://dev.lsstcorp.org/trac/wiki/BottomLeftPixelProposa...
_view_t::xy_locator xy_locator
An xy_locator.
ImageBase(const ImageBase< OtherPixelT > &rhs, const bool deep)
Image(Image< OtherPixelT > const &rhs, const bool deep)
A coordinate class intended to represent offsets and dimensions.
boost::shared_ptr< const Image< PixelT > > ConstPtr
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)
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)
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)
metafunction to extract reference type from PixelT
boost::shared_ptr< DecoratedImage > Ptr
shared_ptr to a DecoratedImage
boost::shared_ptr< const ImageBase< PixelT > > ConstPtr
A shared_ptr to a const ImageBase.
_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