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>
415 class Image :
public ImageBase<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;
433 explicit Image(
unsigned int width,
unsigned int height,
PixelT initialValue=0);
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"
boost::shared_ptr< ImageBase< PixelT > > Ptr
A shared_ptr to an ImageBase.
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.
void operator<<=(const ImageBase &rhs)
Set the lhs's pixel values to equal the rhs's.
A coordinate class intended to represent absolute positions.
void scaledMinus(double const c, Image< PixelT >const &rhs)
Subtract Image c*rhs from lhs.
x_iterator row_begin(int y) const
boost::shared_ptr< lsst::daf::base::PropertySet > _metadata
const geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
void swap(ImageBase< PixelT > &a, ImageBase< PixelT > &b)
x_iterator row_end(int y) const
Return an x_iterator to the end of the y'th row.
double indexToPosition(double ind, lsst::afw::image::xOrY const xy) const
Convert image index to image position.
reverse_iterator rend() const
Return an STL compliant reverse iterator to the end of the image.
void scaledMultiplies(double const c, Image< PixelT >const &rhs)
Multiply lhs by Image c*rhs (i.e. pixel-by-pixel multiplication)
boost::shared_ptr< const ImageBase< PixelT > > ConstPtr
A shared_ptr to a const ImageBase.
ndarray::Array< PixelT const, 2, 1 > ConstArray
An immutable ndarray representation of the image.
void setXY0(int const x0, int const y0)
_view_t::y_iterator y_iterator
An iterator for traversing the pixels in a column.
PixelReference operator()(int x, int y)
Return a reference to the pixel (x, y)
static Image readFits(std::string const &filename, int hdu=0)
Read an Image from a regular FITS file.
ImageConstPtr getImage() const
Return a shared_ptr to the DecoratedImage's Image as const.
y_iterator y_at(int x, int y) const
Return an y_iterator to the point (x, y) in the image.
static SinglePixel PixelCast(SinglePixelT rhs)
Convert a type to our SinglePixel type.
static Image readFits(fits::MemFileManager &manager, int hdu=0)
Read an Image from a FITS RAM file.
int getX0() const
Return the image's column-origin.
void operator+=(PixelT const rhs)
Add scalar rhs to lhs.
void operator/=(PixelT const rhs)
ImageBase & operator=(const ImageBase &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, ...)
static _view_t _allocateView(geom::Extent2I const &dimensions, Manager::Ptr &manager)
void operator*=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
boost::shared_ptr< Image< PixelT > > Ptr
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.
iterator end() const
Return an STL compliant iterator to the end of the image.
CheckIndices(bool check=true)
void set0(int x, int y, const PixelT v)
PixelConstReference get0(int x, int y) const
PixelT Pixel
A pixel in this ImageBase.
An integer coordinate rectangle.
table::Key< table::Array< Kernel::Pixel > > image
y_iterator col_begin(int x) const
_view_t::iterator iterator
An STL compliant iterator.
bool isContiguous() const
int getY0() const
Return the image's row-origin.
PixelT SinglePixel
A single Pixel of the same type as those in the ImageBase.
ndarray::Array< PixelT, 2, 1 > Array
A mutable ndarray representation of the image.
_view_t::x_iterator xy_x_iterator
An iterator for traversing the pixels in a row, created from an xy_locator.
afw::table::PointKey< int > dimensions
int getWidth() const
Return the number of columns in the image.
boost::intrusive_ptr< Manager > Ptr
void swap(ImageBase &rhs)
A set of classes of general utility in connection with images.
ImageT::image_category image_category
_const_view_t::x_iterator const_x_iterator
A const iterator for traversing the pixels in a row.
_view_t::xy_locator xy_locator
An xy_locator.
static _view_t _makeSubView(geom::Extent2I const &dimensions, geom::Extent2I const &offset, const _view_t &view)
Lifetime-management for memory that goes into FITS memory files.
Types and classes to interface lsst::afw::image to boost::gil.
boost::shared_ptr< lsst::daf::base::PropertySet > getMetadata() const
x_iterator x_at(int x, int y) const
Return an x_iterator to the point (x, y) in the image.
detail::Image_tag image_category
detail::basic_tag image_category
trait class to identify type of image
Image(ndarray::Array< PixelT, 2, 1 > const &array, bool deep=false, geom::Point2I const &xy0=geom::Point2I())
A class to manipulate images, masks, and variance as a single object.
reverse_iterator rbegin() const
Return an STL compliant reverse iterator to the start of the image.
_view_t::reverse_iterator reverse_iterator
An STL compliant reverse iterator.
void operator-=(PixelT const rhs)
Subtract scalar rhs from lhs.
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 end of the y'th row.
int getWidth() const
Return the number of columns in the image.
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
ImagePtr getImage()
Return a shared_ptr to the DecoratedImage's Image.
Reference< PixelT >::type PixelReference
A Reference to a PixelT.
Image(Image< OtherPixelT > const &rhs, const bool deep)
boost::shared_ptr< Image< PixelT > const > ImageConstPtr
shared_ptr to the Image as const
_view_t::y_iterator xy_y_iterator
An iterator for traversing the pixels in a row, created from an xy_locator.
boost::shared_ptr< const Image< PixelT > > ConstPtr
void operator*=(PixelT const rhs)
Multiply lhs by scalar rhs.
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)
void setMetadata(boost::shared_ptr< lsst::daf::base::PropertySet > metadata)
#define LSST_PERSIST_FORMATTER(formatter...)
void setXY0(geom::Point2I const origin)
#define LSST_EXCEPT(type,...)
boost::shared_ptr< Image< PixelT > > ImagePtr
shared_ptr to the Image
A multidimensional strided array.
Citizen(const std::type_info &)
ConstReference< PixelT >::type PixelConstReference
A ConstReference to a PixelT.
geom::Box2I getBBox(ImageOrigin origin=PARENT) const
boost::gil::channel_traits< PixelT >::reference type
reference type
lsst::afw::image::detail::types_traits< PixelT >::const_view_t _const_view_t
ImageBase(const ImageBase< OtherPixelT > &rhs, const bool deep)
const double PixelZeroPos
FITS uses 1.0, SDSS uses 0.5, LSST uses 0.0 (http://dev.lsstcorp.org/trac/wiki/BottomLeftPixelProposa...
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
Class for storing generic metadata.
void swap(DecoratedImage &rhs)
boost::shared_ptr< Image< PixelT > > _image
void operator/=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Image & operator=(const PixelT rhs)
Set the image's pixels to rhs.
Define the basic Function classes.
afw::table::Key< double > b
iterator at(int x, int y) const
Return an STL compliant iterator at the point (x, y)
xy_locator xy_at(int x, int y) const
void operator-=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
boost::shared_ptr< const DecoratedImage > ConstPtr
shared_ptr to a const DecoratedImage
geom::Point2I getXY0() const
Base class for all persistable classes.
int getHeight() const
Return the number of rows in the image.
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
boost::shared_ptr< DecoratedImage > Ptr
shared_ptr to a DecoratedImage
void scaledDivides(double const c, Image< PixelT >const &rhs)
Divide lhs by Image c*rhs (i.e. pixel-by-pixel division)
void set0(int x, int y, const PixelT v, CheckIndices const &check)
lsst::afw::image::detail::types_traits< PixelT >::view_t _view_t
boost::gil::channel_traits< PixelT >::const_reference type
const reference type
A coordinate class intended to represent offsets and dimensions.
_const_view_t::iterator const_iterator
An STL compliant const iterator.
_view_t::xy_locator::const_t const_xy_locator
A const_xy_locator.
geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
A class to represent a 2-dimensional array of pixels.
_const_view_t::y_iterator const_y_iterator
A const iterator for traversing the pixels in a column.
Extent< int, 2 > Extent2I
void setGain(double gain)
Set the DecoratedImage's gain.
std::string const wcsNameForXY0
_view_t _getRawView() const
PixelConstReference get0(int x, int y, CheckIndices const &check) const
Image< ImagePT > type
Return the desired type.
int getHeight() const
Return the number of rows in the image.
Include files required for standard LSST Exception handling.
_const_view_t::reverse_iterator const_reverse_iterator
An STL compliant const reverse iterator.
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
void scaledPlus(double const c, Image< PixelT >const &rhs)
Add Image c*rhs to lhs.
metafunction to extract const reference type from PixelT