LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
lsst::afw::math Namespace Reference

Namespaces

 detail
 
 details
 
 warper
 

Classes

class  Approximate
 Approximate values for a MaskedImage. More...
 
class  ApproximateControl
 Control how to make an approximation. More...
 
class  BackgroundControl
 Pass parameters to a Background object. More...
 
class  Background
 A virtual base class to evaluate image background levels. More...
 
class  BackgroundMI
 A class to evaluate image background levels. More...
 
class  BoundedField
 An abstract base class for 2-d functions defined on an integer bounding boxes. More...
 
class  ChebyshevBoundedFieldControl
 A control object used when fitting ChebyshevBoundedField to data (see ChebyshevBoundedField::fit) More...
 
class  ChebyshevBoundedField
 A BoundedField based on 2-d Chebyshev polynomials of the first kind. More...
 
class  ConvolutionControl
 Parameters to control convolution. More...
 
class  Function
 Basic Function class. More...
 
class  Function1
 A Function taking one argument. More...
 
class  Function2
 A Function taking two arguments. More...
 
class  BasePolynomialFunction2
 Base class for 2-dimensional polynomials of the form: More...
 
class  NullFunction1
 a class used in function calls to indicate that no Function1 is being provided More...
 
class  NullFunction2
 a class used in function calls to indicate that no Function2 is being provided More...
 
class  IntegerDeltaFunction1
 1-dimensional integer delta function. More...
 
class  IntegerDeltaFunction2
 2-dimensional integer delta function. More...
 
class  GaussianFunction1
 1-dimensional Gaussian More...
 
class  GaussianFunction2
 2-dimensional Gaussian More...
 
class  DoubleGaussianFunction2
 double Guassian (sum of two Gaussians) More...
 
class  PolynomialFunction1
 1-dimensional polynomial function. More...
 
class  PolynomialFunction2
 2-dimensional polynomial function with cross terms More...
 
class  Chebyshev1Function1
 1-dimensional weighted sum of Chebyshev polynomials of the first kind. More...
 
class  Chebyshev1Function2
 2-dimensional weighted sum of Chebyshev polynomials of the first kind. More...
 
class  LanczosFunction1
 1-dimensional Lanczos function More...
 
class  LanczosFunction2
 2-dimensional separable Lanczos function More...
 
class  GaussianProcessTimer
 This is a structure for keeping track of how long the interpolation methods spend on different parts of the interpolation. More...
 
class  Covariogram
 The parent class of covariogram functions for use in Gaussian Process interpolation. More...
 
class  SquaredExpCovariogram
 a Covariogram that falls off as the negative exponent of the square of the distance between the points More...
 
class  NeuralNetCovariogram
 a Covariogram that recreates a neural network with one hidden layer and infinite units in that layer More...
 
class  KdTree
 The data for GaussianProcess is stored in a KD tree to facilitate nearest-neighbor searches. More...
 
class  GaussianProcess
 Stores values of a function sampled on an image and allows you to interpolate the function to unsampled points. More...
 
struct  IntRegion
 
class  Interpolate
 Interpolate values for a set of x,y vector<>s. More...
 
class  Kernel
 Kernels are used for convolution with MaskedImages and (eventually) Images. More...
 
class  FixedKernel
 A kernel created from an Image. More...
 
class  AnalyticKernel
 A kernel described by a function. More...
 
class  DeltaFunctionKernel
 A kernel that has only one non-zero pixel (of value 1) More...
 
class  LinearCombinationKernel
 A kernel that is a linear combination of fixed basis kernels. More...
 
class  SeparableKernel
 A kernel described by a pair of functions: func(x, y) = colFunc(x) * rowFunc(y) More...
 
class  LeastSquares
 Solver for linear least-squares problems. More...
 
class  MaskedVector
 
struct  FitResults
 Results from minimizing a function. More...
 
class  Random
 
class  CandidateVisitor
 
class  SpatialCellCandidate
 
class  SpatialCellImageCandidate
 
class  SpatialCellMaskedImageCandidate
 
class  SpatialCellCandidateIterator
 An iterator that only returns usable members of the SpatialCell. More...
 
class  SpatialCell
 Class to ensure constraints for spatial modeling. More...
 
class  SpatialCellSet
 A collection of SpatialCells covering an entire image. More...
 
class  StatisticsControl
 Pass parameters to a Statistics objectA class to pass parameters which control how the stats are calculated. More...
 
class  Statistics
 
class  infinite_iterator
 This iterator will never increment. It is returned by row_begin() in the MaskImposter class (below) to allow phony mask pixels to be iterated over for non-mask images within Statistics. More...
 
class  MaskImposter
 A Mask wrapper to provide an infinite_iterator for Mask::row_begin(). This allows a fake Mask to be passed in to Statistics with a regular (non-masked) Image. More...
 
class  ImageImposter
 A vector wrapper to provide a vector with the necessary methods and typedefs to be processed by Statistics as though it were an Image. More...
 
struct  is_analyticKernel
 traits class to determine if a Kernel is represented as an analytic function More...
 
struct  is_analyticKernel< KernelT * >
 
struct  is_analyticKernel< boost::shared_ptr< KernelT > >
 
struct  is_analyticKernel< AnalyticKernel >
 
struct  generic_kernel_tag
 Tags carrying information about Kernels Kernel with no special properties. More...
 
struct  deltafunction_kernel_tag
 Kernel has only one non-zero pixel. More...
 
struct  kernel_traits
 template trait class with information about Kernels More...
 
class  LanczosWarpingKernel
 Lanczos warping: accurate but slow and can introduce ringing artifacts. More...
 
class  BilinearWarpingKernel
 Bilinear warping: fast; good for undersampled data. More...
 
class  NearestWarpingKernel
 Nearest neighbor warping: fast; good for undersampled data. More...
 
class  WarpingControl
 Parameters to control convolution. More...
 
class  InterpolateConstant
 
class  InterpolateGsl
 
class  KernelFormatter
 Formatter for persistence of Kernel instances. More...
 

Typedefs

typedef std::vector
< boost::shared_ptr< Kernel > > 
KernelList
 
typedef
lsst::afw::image::VariancePixel 
WeightPixel
 

Enumerations

enum  UndersampleStyle { THROW_EXCEPTION, REDUCE_INTERP_ORDER, INCREASE_NXNYSAMPLE }
 
enum  Property {
  NOTHING = 0x0, ERRORS = 0x1, NPOINT = 0x2, MEAN = 0x4,
  STDEV = 0x8, VARIANCE = 0x10, MEDIAN = 0x20, IQRANGE = 0x40,
  MEANCLIP = 0x80, STDEVCLIP = 0x100, VARIANCECLIP = 0x200, MIN = 0x400,
  MAX = 0x800, SUM = 0x1000, MEANSQUARE = 0x2000, ORMASK = 0x4000
}
 control what is calculated More...
 

Functions

template<typename PixelT >
boost::shared_ptr< Approximate
< PixelT > > 
makeApproximate (std::vector< double > const &x, std::vector< double > const &y, image::MaskedImage< PixelT > const &im, geom::Box2I const &bbox, ApproximateControl const &ctrl)
 Construct a new Approximate object, inferring the type from the type of the given MaskedImage. More...
 
UndersampleStyle stringToUndersampleStyle (std::string const &style)
 Conversion function to switch a string to an UndersampleStyle. More...
 
template<typename ImageT >
boost::shared_ptr< BackgroundmakeBackground (ImageT const &img, BackgroundControl const &bgCtrl)
 A convenience function that uses function overloading to make the correct type of Background. More...
 
boost::shared_ptr< BoundedFieldoperator* (double const scale, boost::shared_ptr< BoundedField const > bf)
 
template<typename OutImageT , typename InImageT >
void scaledPlus (OutImageT &outImage, double c1, InImageT const &inImage1, double c2, InImageT const &inImage2)
 
template<typename OutImageT , typename InImageT >
OutImageT::SinglePixel convolveAtAPoint (typename InImageT::const_xy_locator inImageLocator, typename lsst::afw::image::Image< lsst::afw::math::Kernel::Pixel >::const_xy_locator kernelLocator, int kWidth, int kHeight)
 Apply convolution kernel to an image at one point. More...
 
template<typename OutImageT , typename InImageT >
OutImageT::SinglePixel convolveAtAPoint (typename InImageT::const_xy_locator inImageLocator, std::vector< lsst::afw::math::Kernel::Pixel > const &kernelColList, std::vector< lsst::afw::math::Kernel::Pixel > const &kernelRowList)
 Apply separable convolution kernel to an image at one point. More...
 
template<typename OutImageT , typename InImageT , typename KernelT >
void convolve (OutImageT &convolvedImage, InImageT const &inImage, KernelT const &kernel, ConvolutionControl const &convolutionControl=ConvolutionControl())
 Convolve an Image or MaskedImage with a Kernel, setting pixels of an existing output image. More...
 
template<typename OutImageT , typename InImageT , typename KernelT >
void convolve (OutImageT &convolvedImage, InImageT const &inImage, KernelT const &kernel, bool doNormalize, bool doCopyEdge=false)
 Old, deprecated version of convolve. More...
 
template<typename ImageT >
ImageT::SinglePixel edgePixel (lsst::afw::image::detail::Image_tag)
 Return an off-the-edge pixel appropriate for a given Image type. More...
 
template<typename MaskedImageT >
MaskedImageT::SinglePixel edgePixel (lsst::afw::image::detail::MaskedImage_tag)
 Return an off-the-edge pixel appropriate for a given MaskedImage type. More...
 
template<class UF >
UF::result_type int1d (UF const &func, IntRegion< typename UF::result_type > &reg, typename UF::result_type const &abserr=DEFABSERR, typename UF::result_type const &relerr=DEFRELERR)
 Front end for the 1d integrator. More...
 
template<class BF , class YREG >
BF::result_type int2d (BF const &func, IntRegion< typename BF::result_type > &reg, YREG const &yreg, typename BF::result_type const &abserr=DEFABSERR, typename BF::result_type const &relerr=DEFRELERR)
 Front end for the 2d integrator. More...
 
template<class TF , class YREG , class ZREG >
TF::result_type int3d (TF const &func, IntRegion< typename TF::result_type > &reg, YREG const &yreg, ZREG const &zreg, typename TF::result_type const &abserr=DEFABSERR, typename TF::result_type const &relerr=DEFRELERR)
 Front end for the 3d integrator. More...
 
template<class BF >
BF::result_type int2d (BF const &func, IntRegion< typename BF::result_type > &reg, IntRegion< typename BF::result_type > &yreg, typename BF::result_type const &abserr=DEFABSERR, typename BF::result_type const &relerr=DEFRELERR)
 Front end for the 2d integrator. More...
 
template<class TF >
TF::result_type int3d (TF const &func, IntRegion< typename TF::result_type > &reg, IntRegion< typename TF::result_type > &yreg, IntRegion< typename TF::result_type > &zreg, typename TF::result_type const &abserr=DEFABSERR, typename TF::result_type const &relerr=DEFRELERR)
 Front end for the 3d integrator. More...
 
template<typename UnaryFunctionT >
UnaryFunctionT::result_type integrate (UnaryFunctionT func, typename UnaryFunctionT::argument_type const a, typename UnaryFunctionT::argument_type const b, double eps=1.0e-6)
 The 1D integrator. More...
 
template<typename BinaryFunctionT >
BinaryFunctionT::result_type integrate2d (BinaryFunctionT func, typename BinaryFunctionT::first_argument_type const x1, typename BinaryFunctionT::first_argument_type const x2, typename BinaryFunctionT::second_argument_type const y1, typename BinaryFunctionT::second_argument_type const y2, double eps=1.0e-6)
 The 2D integrator. More...
 
boost::shared_ptr< InterpolatemakeInterpolate (std::vector< double > const &x, std::vector< double > const &y, Interpolate::Style const style=Interpolate::AKIMA_SPLINE)
 
Interpolate::Style stringToInterpStyle (std::string const &style)
 Conversion function to switch a string to an Interpolate::Style. More...
 
Interpolate::Style lookupMaxInterpStyle (int const n)
 Get the highest order Interpolation::Style available for 'n' points. More...
 
int lookupMinInterpPoints (Interpolate::Style const style)
 Get the minimum number of points needed to use the requested interpolation style. More...
 
void printKernel (lsst::afw::math::Kernel const &kernel, bool doNormalize, double x=0, double y=0, std::string pixelFmt="%7.3f")
 Print the pixel values of a Kernel to std::cout. More...
 
template<typename ReturnT >
FitResults minimize (lsst::afw::math::Function1< ReturnT > const &function, std::vector< double > const &initialParameterList, std::vector< double > const &stepSizeList, std::vector< double > const &measurementList, std::vector< double > const &varianceList, std::vector< double > const &xPositionList, double errorDef)
 
template<typename ReturnT >
FitResults minimize (lsst::afw::math::Function2< ReturnT > const &function, std::vector< double > const &initialParameterList, std::vector< double > const &stepSizeList, std::vector< double > const &measurementList, std::vector< double > const &varianceList, std::vector< double > const &xPositionList, std::vector< double > const &yPositionList, double errorDef)
 
template<typename ImageT >
ImageT::Ptr offsetImage (ImageT const &inImage,float dx,float dy,std::string const &algorithmName,unsigned int buffer)
 Return an image offset by (dx, dy) using the specified algorithm. More...
 
template<typename ImageT >
ImageT::Ptr rotateImageBy90 (ImageT const &image, int nQuarter)
 
template<typename ImageT >
boost::shared_ptr< ImageT > flipImage (ImageT const &inImage, bool flipLR, bool flipTB)
 
template<typename ImageT >
boost::shared_ptr< ImageT > binImage (ImageT const &inImage, int const binX, int const binY, lsst::afw::math::Property const flags=lsst::afw::math::MEAN)
 
template<typename ImageT >
boost::shared_ptr< ImageT > binImage (ImageT const &inImage, int const binsize, lsst::afw::math::Property const flags=lsst::afw::math::MEAN)
 
template<typename ImageT >
void randomUniformImage (ImageT *image, Random &rand)
 
template<typename ImageT >
void randomUniformPosImage (ImageT *image, Random &rand)
 
template<typename ImageT >
void randomUniformIntImage (ImageT *image, Random &rand, unsigned long n)
 
template<typename ImageT >
void randomFlatImage (ImageT *image, Random &rand, double const a, double const b)
 
template<typename ImageT >
void randomGaussianImage (ImageT *image, Random &rand)
 
template<typename ImageT >
void randomChisqImage (ImageT *image, Random &rand, double const nu)
 
template<typename ImageT >
void randomPoissonImage (ImageT *image, Random &rand, double const mu)
 
template<typename PixelT >
lsst::afw::image::Image
< PixelT >::Ptr 
statisticsStack (std::vector< typename lsst::afw::image::Image< PixelT >::Ptr > &images, Property flags, StatisticsControl const &sctrl=StatisticsControl(), std::vector< lsst::afw::image::VariancePixel > const &wvector=std::vector< lsst::afw::image::VariancePixel >(0))
 A function to compute some statistics of a stack of Images. More...
 
template<typename PixelT >
void statisticsStack (lsst::afw::image::Image< PixelT > &out, std::vector< typename lsst::afw::image::Image< PixelT >::Ptr > &images, Property flags, StatisticsControl const &sctrl=StatisticsControl(), std::vector< lsst::afw::image::VariancePixel > const &wvector=std::vector< lsst::afw::image::VariancePixel >(0))
 
template<typename PixelT >
lsst::afw::image::MaskedImage
< PixelT >::Ptr 
statisticsStack (std::vector< typename lsst::afw::image::MaskedImage< PixelT >::Ptr > &images, Property flags, StatisticsControl const &sctrl=StatisticsControl(), std::vector< lsst::afw::image::VariancePixel > const &wvector=std::vector< lsst::afw::image::VariancePixel >(0))
 A function to compute some statistics of a stack of MaskedImages. More...
 
template<typename PixelT >
void statisticsStack (lsst::afw::image::MaskedImage< PixelT > &out, std::vector< typename lsst::afw::image::MaskedImage< PixelT >::Ptr > &images, Property flags, StatisticsControl const &sctrl=StatisticsControl(), std::vector< lsst::afw::image::VariancePixel > const &wvector=std::vector< lsst::afw::image::VariancePixel >(0))
 
template<typename PixelT >
boost::shared_ptr< std::vector
< PixelT > > 
statisticsStack (std::vector< boost::shared_ptr< std::vector< PixelT > > > &vectors, Property flags, StatisticsControl const &sctrl=StatisticsControl(), std::vector< lsst::afw::image::VariancePixel > const &wvector=std::vector< lsst::afw::image::VariancePixel >(0))
 A function to compute some statistics of a stack of std::vectors. More...
 
template<typename PixelT >
lsst::afw::image::MaskedImage
< PixelT >::Ptr 
statisticsStack (lsst::afw::image::Image< PixelT > const &image, Property flags, char dimension, StatisticsControl const &sctrl=StatisticsControl())
 A function to compute statistics on the rows or columns of an image. More...
 
template<typename PixelT >
lsst::afw::image::MaskedImage
< PixelT >::Ptr 
statisticsStack (lsst::afw::image::MaskedImage< PixelT > const &image, Property flags, char dimension, StatisticsControl const &sctrl=StatisticsControl())
 A function to compute statistics on the rows or columns of an image. More...
 
Property stringToStatisticsProperty (std::string const property)
 Conversion function to switch a string to a Property (see Statistics.h) More...
 
boost::shared_ptr
< SeparableKernel
makeWarpingKernel (std::string name)
 Return a warping kernel given its name. More...
 
template<typename DestExposureT , typename SrcExposureT >
int warpExposure (DestExposureT &destExposure, SrcExposureT const &srcExposure, WarpingControl const &control, typename DestExposureT::MaskedImageT::SinglePixel padValue=lsst::afw::math::edgePixel< typename DestExposureT::MaskedImageT >(typename lsst::afw::image::detail::image_traits< typename DestExposureT::MaskedImageT >::image_category()))
 Warp (remap) one exposure to another. More...
 
template<typename DestExposureT , typename SrcExposureT >
int warpExposure (DestExposureT &destExposure, SrcExposureT const &srcExposure, SeparableKernel &warpingKernel, int const interpLength=0, typename DestExposureT::MaskedImageT::SinglePixel padValue=lsst::afw::math::edgePixel< typename DestExposureT::MaskedImageT >(typename lsst::afw::image::detail::image_traits< typename DestExposureT::MaskedImageT >::image_category()), lsst::afw::gpu::DevicePreference devPref=lsst::afw::gpu::DEFAULT_DEVICE_PREFERENCE)
 Warp (remap) one exposure to another. More...
 
template<typename DestImageT , typename SrcImageT >
int warpImage (DestImageT &destImage, lsst::afw::image::Wcs const &destWcs, SrcImageT const &srcImage, lsst::afw::image::Wcs const &srcWcs, WarpingControl const &control, typename DestImageT::SinglePixel padValue=lsst::afw::math::edgePixel< DestImageT >(typename lsst::afw::image::detail::image_traits< DestImageT >::image_category()))
 Warp an Image or MaskedImage to a new Wcs. See also convenience function warpExposure() to warp an Exposure. More...
 
template<typename DestImageT , typename SrcImageT >
int warpImage (DestImageT &destImage, lsst::afw::image::Wcs const &destWcs, SrcImageT const &srcImage, lsst::afw::image::Wcs const &srcWcs, SeparableKernel &warpingKernel, int const interpLength=0, typename DestImageT::SinglePixel padValue=lsst::afw::math::edgePixel< DestImageT >(typename lsst::afw::image::detail::image_traits< DestImageT >::image_category()), lsst::afw::gpu::DevicePreference devPref=lsst::afw::gpu::DEFAULT_DEVICE_PREFERENCE)
 A variant of warpImage that uses an older, deprecated interface. More...
 
template<typename DestImageT , typename SrcImageT >
int warpImage (DestImageT &destImage, SrcImageT const &srcImage, lsst::afw::geom::AffineTransform const &affineTransform, WarpingControl const &control, typename DestImageT::SinglePixel padValue=lsst::afw::math::edgePixel< DestImageT >(typename lsst::afw::image::detail::image_traits< DestImageT >::image_category()))
 A variant of warpImage that uses an affine transformation instead of a WCS to describe the transformation. More...
 
template<typename DestImageT , typename SrcImageT >
int warpImage (DestImageT &destImage, SrcImageT const &srcImage, SeparableKernel &warpingKernel, lsst::afw::geom::AffineTransform const &affineTransform, int const interpLength=0, typename DestImageT::SinglePixel padValue=lsst::afw::math::edgePixel< DestImageT >(typename lsst::afw::image::detail::image_traits< DestImageT >::image_category()), lsst::afw::gpu::DevicePreference devPref=lsst::afw::gpu::DEFAULT_DEVICE_PREFERENCE)
 A variant of the affine transformation warpImage that uses an older, deprecated interface. More...
 
template<typename DestImageT , typename SrcImageT >
int warpCenteredImage (DestImageT &destImage, SrcImageT const &srcImage, lsst::afw::geom::LinearTransform const &linearTransform, lsst::afw::geom::Point2D const &centerPosition, WarpingControl const &control, typename DestImageT::SinglePixel padValue=lsst::afw::math::edgePixel< DestImageT >(typename lsst::afw::image::detail::image_traits< DestImageT >::image_category()))
 Warp an image with a LinearTranform about a specified point. This enables warping an image of e.g. a PSF without translating the centroid. More...
 
template<typename DestImageT , typename SrcImageT >
int warpCenteredImage (DestImageT &destImage, SrcImageT const &srcImage, SeparableKernel &warpingKernel, lsst::afw::geom::LinearTransform const &linearTransform, lsst::afw::geom::Point2D const &centerPosition, int const interpLength=0, typename DestImageT::SinglePixel padValue=lsst::afw::math::edgePixel< DestImageT >(typename lsst::afw::image::detail::image_traits< DestImageT >::image_category()), lsst::afw::gpu::DevicePreference devPref=lsst::afw::gpu::DEFAULT_DEVICE_PREFERENCE)
 A variant of warpCenteredImage that supports the old, deprecated interface. More...
 
Statistics makeStatistics (afwImage::Mask< afwImage::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl)
 Specialization to handle Masks. More...
 

Variables

double const MOCK_INF = 1.e10
 
double const DEFABSERR = 1.e-15
 
double const DEFRELERR = 1.e-6
 
generic_kernel_tag generic_kernel_tag_
 Used as default value in argument lists. More...
 
deltafunction_kernel_tag deltafunction_kernel_tag_
 Used as default value in argument lists. More...
 

Typedef Documentation

typedef std::vector<boost::shared_ptr< Kernel > > lsst::afw::math::KernelList

Definition at line 542 of file Kernel.h.

Definition at line 56 of file Statistics.h.

Enumeration Type Documentation

control what is calculated

Enumerator
NOTHING 

We don't want anything.

ERRORS 

Include errors of requested quantities.

NPOINT 

number of sample points

MEAN 

estimate sample mean

STDEV 

estimate sample standard deviation

VARIANCE 

estimate sample variance

MEDIAN 

estimate sample median

IQRANGE 

estimate sample inter-quartile range

MEANCLIP 

estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)

STDEVCLIP 

estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)

VARIANCECLIP 

estimate sample N-sigma clipped variance (N set in StatisticsControl, default=3)

MIN 

estimate sample minimum

MAX 

estimate sample maximum

SUM 

find sum of pixels in the image

MEANSQUARE 

find mean value of square of pixel values

ORMASK 

get the or-mask of all pixels used.

Definition at line 63 of file Statistics.h.

63  {
64  NOTHING = 0x0,
65  ERRORS = 0x1,
66  NPOINT = 0x2,
67  MEAN = 0x4,
68  STDEV = 0x8,
69  VARIANCE = 0x10,
70  MEDIAN = 0x20,
71  IQRANGE = 0x40,
72  MEANCLIP = 0x80,
73  STDEVCLIP = 0x100,
74  VARIANCECLIP = 0x200,
75  MIN = 0x400,
77  MAX = 0x800,
78  SUM = 0x1000,
79  MEANSQUARE = 0x2000,
80  ORMASK = 0x4000
81 };
get the or-mask of all pixels used.
Definition: Statistics.h:80
estimate sample minimum
Definition: Statistics.h:76
estimate sample standard deviation
Definition: Statistics.h:68
find mean value of square of pixel values
Definition: Statistics.h:79
estimate sample maximum
Definition: Statistics.h:77
We don&#39;t want anything.
Definition: Statistics.h:64
Include errors of requested quantities.
Definition: Statistics.h:65
estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)
Definition: Statistics.h:73
estimate sample median
Definition: Statistics.h:70
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
Definition: Statistics.h:72
number of sample points
Definition: Statistics.h:66
estimate sample inter-quartile range
Definition: Statistics.h:71
estimate sample mean
Definition: Statistics.h:67
estimate sample variance
Definition: Statistics.h:69
find sum of pixels in the image
Definition: Statistics.h:78
Enumerator
THROW_EXCEPTION 
REDUCE_INTERP_ORDER 
INCREASE_NXNYSAMPLE 

Definition at line 50 of file Background.h.

Function Documentation

template<typename ImageT >
boost::shared_ptr< ImageT > lsst::afw::math::binImage ( ImageT const &  in,
int const  binX,
int const  binY,
lsst::afw::math::Property const  flags = lsst::afw::math::MEAN 
)
Parameters
inThe image to bin
binXOutput pixels are binX*binY input pixels
binYOutput pixels are binX*binY input pixels
flagshow to generate super-pixels

Definition at line 48 of file binImage.cc.

53 {
54  if (flags != lsst::afw::math::MEAN) {
55  throw LSST_EXCEPT(pexExcept::InvalidParameterError,
56  (boost::format("Only afwMath::MEAN is supported, saw 0x%x") % flags).str());
57  }
58  if (binX <= 0 || binY <= 0) {
59  throw LSST_EXCEPT(pexExcept::DomainError,
60  (boost::format("Binning must be >= 0, saw %dx%d") % binX % binY).str());
61  }
62 
63  int const outWidth = in.getWidth()/binX;
64  int const outHeight = in.getHeight()/binY;
65 
66  typename ImageT::Ptr out = typename ImageT::Ptr(
67  new ImageT(geom::Extent2I(outWidth, outHeight))
68  );
69  out->setXY0(in.getXY0());
70  *out = typename ImageT::SinglePixel(0);
71 
72  for (int oy = 0, iy = 0; oy < out->getHeight(); ++oy) {
73  for (int i = 0; i != binY; ++i, ++iy) {
74  typename ImageT::x_iterator optr = out->row_begin(oy);
75  for (typename ImageT::x_iterator iptr = in.row_begin(iy), iend = iptr + binX*outWidth;
76  iptr < iend; ) {
77  typename ImageT::SinglePixel val = *iptr; ++iptr;
78  for (int j = 1; j != binX; ++j, ++iptr) {
79  val += *iptr;
80  }
81  *optr += val; ++optr;
82  }
83  }
84  for (typename ImageT::x_iterator ptr = out->row_begin(oy), end = out->row_end(oy); ptr != end; ++ptr) {
85  *ptr /= binX*binY;
86  }
87  }
88 
89  return out;
90 }
bool val
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
estimate sample mean
Definition: Statistics.h:67
template<typename ImageT >
boost::shared_ptr< ImageT > lsst::afw::math::binImage ( ImageT const &  in,
int const  binsize,
lsst::afw::math::Property const  flags = lsst::afw::math::MEAN 
)
Parameters
inThe image to bin
binsizeOutput pixels are binsize*binsize input pixels
flagshow to generate super-pixels

Definition at line 39 of file binImage.cc.

43 {
44  return binImage(in, binsize, binsize, flags);
45 }
boost::shared_ptr< ImageT > binImage(ImageT const &inImage, int const binX, int const binY, lsst::afw::math::Property const flags=lsst::afw::math::MEAN)
Definition: binImage.cc:48
template<typename OutImageT , typename InImageT , typename KernelT >
void lsst::afw::math::convolve ( OutImageT &  convolvedImage,
InImageT const &  inImage,
KernelT const &  kernel,
bool  doNormalize,
bool  doCopyEdge = false 
)

Old, deprecated version of convolve.

Deprecated:
This version has no ability to control interpolation parameters.
Parameters
convolvedImageconvolved image; must be the same size as inImage
inImageimage to convolve
kernelconvolution kernel
doNormalizeif true, normalize the kernel, else use "as is"
doCopyEdgeif false (default), set edge pixels to the standard edge pixel; if true, copy edge pixels from input and set EDGE bit of mask

Definition at line 347 of file ConvolveImage.cc.

354 {
355  ConvolutionControl convolutionControl;
356  convolutionControl.setDoNormalize(doNormalize);
357  convolutionControl.setDoCopyEdge(doCopyEdge);
358  afwMath::convolve(convolvedImage, inImage, kernel, convolutionControl);
359 }
void convolve(OutImageT &convolvedImage, InImageT const &inImage, KernelT const &kernel, ConvolutionControl const &convolutionControl=ConvolutionControl())
Convolve an Image or MaskedImage with a Kernel, setting pixels of an existing output image...
template<typename ImageT >
ImageT::SinglePixel lsst::afw::math::edgePixel ( lsst::afw::image::detail::Image_tag  )

Return an off-the-edge pixel appropriate for a given Image type.

The value is quiet_NaN if that exists for the pixel type, else 0

Definition at line 138 of file ConvolveImage.h.

141  {
142  typedef typename ImageT::SinglePixel SinglePixelT;
143  return SinglePixelT(
144  std::numeric_limits<SinglePixelT>::has_quiet_NaN ?
145  std::numeric_limits<SinglePixelT>::quiet_NaN() : 0);
146  }
template<typename MaskedImageT >
MaskedImageT::SinglePixel lsst::afw::math::edgePixel ( lsst::afw::image::detail::MaskedImage_tag  )

Return an off-the-edge pixel appropriate for a given MaskedImage type.

The components are:

  • image = quiet_NaN if that exists for the pixel type, else 0
  • mask = NO_DATA bit set
  • variance = infinity

Definition at line 157 of file ConvolveImage.h.

160  {
161  typedef typename MaskedImageT::Image::Pixel ImagePixelT;
162  typedef typename MaskedImageT::Variance::Pixel VariancePixelT;
163 
164  return typename MaskedImageT::SinglePixel(
165  std::numeric_limits<ImagePixelT>::has_quiet_NaN ?
166  std::numeric_limits<ImagePixelT>::quiet_NaN() : 0,
167  MaskedImageT::Mask::getPlaneBitMask("NO_DATA"),
168  std::numeric_limits<VariancePixelT>::infinity());
169  }
template<typename ImageT >
boost::shared_ptr< ImageT > lsst::afw::math::flipImage ( ImageT const &  inImage,
bool  flipLR,
bool  flipTB 
)

Flip an image left–right and/or top–bottom

Parameters
inImageThe image to flip
flipLRFlip left <–> right?
flipTBFlip top <–> bottom?

Definition at line 99 of file rotateImage.cc.

102  {
103  typename ImageT::Ptr outImage(new ImageT(inImage, true)); // Output image
104 
105  if (flipLR) {
106  if (flipTB) {
107  for (int y = 0; y != inImage.getHeight(); ++y) {
108  typename ImageT::x_iterator optr = outImage->x_at(inImage.getWidth() - 1,
109  inImage.getHeight() - y - 1);
110  for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
111  iptr != end; ++iptr, optr -= 1) {
112  *optr = *iptr;
113  }
114  }
115  } else {
116  for (int y = 0; y != inImage.getHeight(); ++y) {
117  typename ImageT::x_iterator optr = outImage->x_at(inImage.getWidth() - 1, y);
118  for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
119  iptr != end; ++iptr, optr -= 1) {
120  *optr = *iptr;
121  }
122  }
123  }
124  } else {
125  if (flipTB) {
126  for (int y = 0; y != inImage.getHeight(); ++y) {
127  typename ImageT::x_iterator optr = outImage->row_begin(inImage.getHeight() - y - 1);
128  for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
129  iptr != end; ++iptr, ++optr) {
130  *optr = *iptr;
131  }
132  }
133  } else {
134  ; // nothing to do
135  }
136  }
137 
138  return outImage;
139 }
int y
template<class UF >
UF::result_type lsst::afw::math::int1d ( UF const &  func,
IntRegion< typename UF::result_type > &  reg,
typename UF::result_type const &  abserr = DEFABSERR,
typename UF::result_type const &  relerr = DEFRELERR 
)
inline

Front end for the 1d integrator.

Definition at line 776 of file Integrate.h.

780  {
781 
782  typedef typename UF::result_type UfResult;
783  using namespace details;
784 
785  integ_dbg2 << "start int1d: " << reg.Left() << ".." << reg.Right() << std::endl;
786 
787  if ((reg.Left() <= -MOCK_INF && reg.Right() > 0) || (reg.Right() >= MOCK_INF && reg.Left() < 0)) {
788  reg.AddSplit(0);
789  }
790 
791  if (reg.NSplit() > 0) {
792  std::vector<IntRegion<UfResult> > children;
793  reg.SubDivide(&children);
794  integ_dbg2 << "Subdivided into " << children.size() << " children\n";
795  UfResult answer = UfResult();
796  UfResult err = 0;
797  for (size_t i = 0; i<children.size(); i++) {
798  IntRegion<UfResult>& child = children[i];
799  integ_dbg2 << "i = " << i;
800  integ_dbg2 << ": bounds = " << child.Left() << ", " << child.Right() << std::endl;
801  answer += int1d(func, child, abserr, relerr);
802  err += child.Err();
803  integ_dbg2 << "subint = " << child.Area() << " +- " << child.Err() << std::endl;
804  }
805  reg.SetArea(answer, err);
806  return answer;
807 
808  } else {
809  if (reg.Left() <= -MOCK_INF) {
810  integ_dbg2 << "left = -infinity, right = " << reg.Right() << std::endl;
811  assert(reg.Right() <= 0.0);
812  IntRegion<UfResult> modreg(1.0/(reg.Right() - 1.0), 0.0, reg.getDbgout());
813  intGKP(Aux2<UF>(func), modreg, abserr, relerr);
814  reg.SetArea(modreg.Area(), modreg.Err());
815  } else if (reg.Right() >= MOCK_INF) {
816  integ_dbg2 << "left = " << reg.Left() << ", right = infinity\n";
817  assert(reg.Left() >= 0.0);
818  IntRegion<UfResult> modreg(0.0, 1.0/(reg.Left() + 1.0), reg.getDbgout());
819  intGKP(Aux1<UF>(func), modreg, abserr, relerr);
820  reg.SetArea(modreg.Area(), modreg.Err());
821  } else {
822  integ_dbg2 << "left = " << reg.Left();
823  integ_dbg2 << ", right = " << reg.Right() << std::endl;
824  intGKP(func, reg, abserr, relerr);
825  }
826  integ_dbg2 << "done int1d answer = " << reg.Area();
827  integ_dbg2 << " +- " << reg.Err() << std::endl;
828  return reg.Area();
829  }
830 }
UF::result_type int1d(UF const &func, IntRegion< typename UF::result_type > &reg, typename UF::result_type const &abserr=DEFABSERR, typename UF::result_type const &relerr=DEFRELERR)
Front end for the 1d integrator.
Definition: Integrate.h:776
double const MOCK_INF
Definition: Integrate.h:175
#define integ_dbg2
Definition: Integrate.h:183
void intGKP(UF const &func, IntRegion< typename UF::result_type > &reg, typename UF::result_type const epsabs, typename UF::result_type const epsrel, std::map< typename UF::result_type, typename UF::result_type > *fxmap=0)
An adaptive integration algorithm which computes the integral of f over the region reg...
Definition: Integrate.h:450
template<class BF , class YREG >
BF::result_type lsst::afw::math::int2d ( BF const &  func,
IntRegion< typename BF::result_type > &  reg,
YREG const &  yreg,
typename BF::result_type const &  abserr = DEFABSERR,
typename BF::result_type const &  relerr = DEFRELERR 
)
inline

Front end for the 2d integrator.

Definition at line 837 of file Integrate.h.

842  {
843 
844  using namespace details;
845  integ_dbg2 << "Starting int2d: range = ";
846  integ_dbg2 << reg.Left() << ".." << reg.Right() << std::endl;
847  Int2DAuxType<BF, YREG> faux(func, yreg, abserr*1.0e-3, relerr*1.0e-3);
848  typename BF::result_type answer = int1d(faux, reg, abserr, relerr);
849  integ_dbg2 << "done int2d answer = " << answer << " +- " << reg.Err() << std::endl;
850  return answer;
851 }
UF::result_type int1d(UF const &func, IntRegion< typename UF::result_type > &reg, typename UF::result_type const &abserr=DEFABSERR, typename UF::result_type const &relerr=DEFRELERR)
Front end for the 1d integrator.
Definition: Integrate.h:776
#define integ_dbg2
Definition: Integrate.h:183
template<class BF >
BF::result_type lsst::afw::math::int2d ( BF const &  func,
IntRegion< typename BF::result_type > &  reg,
IntRegion< typename BF::result_type > &  yreg,
typename BF::result_type const &  abserr = DEFABSERR,
typename BF::result_type const &  relerr = DEFRELERR 
)
inline

Front end for the 2d integrator.

Definition at line 878 of file Integrate.h.

883  {
884  using namespace details;
885  return int2d(func, reg, ConstantReg1<typename BF::result_type>(yreg), abserr, relerr);
886 }
BF::result_type int2d(BF const &func, IntRegion< typename BF::result_type > &reg, YREG const &yreg, typename BF::result_type const &abserr=DEFABSERR, typename BF::result_type const &relerr=DEFRELERR)
Front end for the 2d integrator.
Definition: Integrate.h:837
template<class TF , class YREG , class ZREG >
TF::result_type lsst::afw::math::int3d ( TF const &  func,
IntRegion< typename TF::result_type > &  reg,
YREG const &  yreg,
ZREG const &  zreg,
typename TF::result_type const &  abserr = DEFABSERR,
typename TF::result_type const &  relerr = DEFRELERR 
)
inline

Front end for the 3d integrator.

Definition at line 857 of file Integrate.h.

863  {
864 
865  using namespace details;
866  integ_dbg2 << "Starting int3d: range = ";
867  integ_dbg2 << reg.Left() << ".." << reg.Right() << std::endl;
868  Int3DAuxType<TF, YREG, ZREG> faux(func, yreg, zreg, abserr*1.e-3, relerr*1.e-3);
869  typename TF::result_type answer = int1d(faux, reg, abserr, relerr);
870  integ_dbg2 << "done int3d answer = " << answer << " +- " << reg.Err() << std::endl;
871  return answer;
872 }
UF::result_type int1d(UF const &func, IntRegion< typename UF::result_type > &reg, typename UF::result_type const &abserr=DEFABSERR, typename UF::result_type const &relerr=DEFRELERR)
Front end for the 1d integrator.
Definition: Integrate.h:776
#define integ_dbg2
Definition: Integrate.h:183
template<class TF >
TF::result_type lsst::afw::math::int3d ( TF const &  func,
IntRegion< typename TF::result_type > &  reg,
IntRegion< typename TF::result_type > &  yreg,
IntRegion< typename TF::result_type > &  zreg,
typename TF::result_type const &  abserr = DEFABSERR,
typename TF::result_type const &  relerr = DEFRELERR 
)
inline

Front end for the 3d integrator.

Definition at line 892 of file Integrate.h.

898  {
899  using namespace details;
900  return int3d(func, reg, ConstantReg1<typename TF::result_type>(yreg),
901  ConstantReg2<typename TF::result_type>(zreg), abserr, relerr);
902 }
TF::result_type int3d(TF const &func, IntRegion< typename TF::result_type > &reg, YREG const &yreg, ZREG const &zreg, typename TF::result_type const &abserr=DEFABSERR, typename TF::result_type const &relerr=DEFRELERR)
Front end for the 3d integrator.
Definition: Integrate.h:857
template<typename UnaryFunctionT >
UnaryFunctionT::result_type lsst::afw::math::integrate ( UnaryFunctionT  func,
typename UnaryFunctionT::argument_type const  a,
typename UnaryFunctionT::argument_type const  b,
double  eps = 1.0e-6 
)

The 1D integrator.

Note
This simply wraps the int1d function above and handles the instantiation of the intRegion.

Definition at line 917 of file Integrate.h.

920  {
921 
922  typedef typename UnaryFunctionT::argument_type Arg;
923  IntRegion<Arg> region(a, b);
924 
925  return int1d(func, region, DEFABSERR, eps);
926 }
double const DEFABSERR
Definition: Integrate.h:260
UF::result_type int1d(UF const &func, IntRegion< typename UF::result_type > &reg, typename UF::result_type const &abserr=DEFABSERR, typename UF::result_type const &relerr=DEFRELERR)
Front end for the 1d integrator.
Definition: Integrate.h:776
afw::table::Key< double > b
template<typename BinaryFunctionT >
BinaryFunctionT::result_type lsst::afw::math::integrate2d ( BinaryFunctionT  func,
typename BinaryFunctionT::first_argument_type const  x1,
typename BinaryFunctionT::first_argument_type const  x2,
typename BinaryFunctionT::second_argument_type const  y1,
typename BinaryFunctionT::second_argument_type const  y2,
double  eps = 1.0e-6 
)

The 2D integrator.

Note
Adapted from RHL's SDSS code

Definition at line 977 of file Integrate.h.

982  {
983  using namespace details;
984  // note the more stringent eps requirement to ensure the requested limit
985  // can be reached.
986  FunctionWrapper<BinaryFunctionT> fwrap(func, x1, x2, eps);
987  return integrate(fwrap, y1, y2, eps);
988 }
UnaryFunctionT::result_type integrate(UnaryFunctionT func, typename UnaryFunctionT::argument_type const a, typename UnaryFunctionT::argument_type const b, double eps=1.0e-6)
The 1D integrator.
Definition: Integrate.h:917
Interpolate::Style lsst::afw::math::lookupMaxInterpStyle ( int const  n)

Get the highest order Interpolation::Style available for 'n' points.

Parameters
nNumber of points

Definition at line 285 of file Interpolate.cc.

286  {
287  if (n < 1) {
288  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "n must be greater than 0");
289  } else if (n > 4) {
290  return Interpolate::AKIMA_SPLINE;
291  } else {
292  static std::vector<Interpolate::Style> styles;
293  if (styles.empty()) {
294  styles.resize(5);
295 
296  styles[0] = Interpolate::UNKNOWN; // impossible to reach as we check for n < 1
297  styles[1] = Interpolate::CONSTANT;
298  styles[2] = Interpolate::LINEAR;
299  styles[3] = Interpolate::CUBIC_SPLINE;
300  styles[4] = Interpolate::CUBIC_SPLINE;
301  }
302  return styles[n];
303  }
304 }
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int lsst::afw::math::lookupMinInterpPoints ( Interpolate::Style const  style)

Get the minimum number of points needed to use the requested interpolation style.

Parameters
styleThe style in question

Definition at line 309 of file Interpolate.cc.

310  {
311  static std::vector<int> minPoints;
312  if (minPoints.empty()) {
313  minPoints.resize(Interpolate::NUM_STYLES);
314  minPoints[Interpolate::CONSTANT] = 1;
315  minPoints[Interpolate::LINEAR] = 2;
316  minPoints[Interpolate::NATURAL_SPLINE] = 3;
317  minPoints[Interpolate::CUBIC_SPLINE] = 3;
318  minPoints[Interpolate::CUBIC_SPLINE_PERIODIC] = 3;
319  minPoints[Interpolate::AKIMA_SPLINE] = 5;
320  minPoints[Interpolate::AKIMA_SPLINE_PERIODIC] = 5;
321  }
322 
323  if (style >= 0 && style < Interpolate::NUM_STYLES) {
324  return minPoints[style];
325  } else {
326  throw LSST_EXCEPT(pex::exceptions::OutOfRangeError,
327  str(boost::format("Style %d is out of range 0..%d")
328  % style % (Interpolate::NUM_STYLES - 1)));
329  }
330 }
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<typename PixelT >
boost::shared_ptr< Approximate< PixelT > > lsst::afw::math::makeApproximate ( std::vector< double > const &  x,
std::vector< double > const &  y,
image::MaskedImage< PixelT > const &  im,
geom::Box2I const &  bbox,
ApproximateControl const &  ctrl 
)

Construct a new Approximate object, inferring the type from the type of the given MaskedImage.

A factory function to make Approximate objects.

Parameters
xthe x-values of points
ythe y-values of points
imThe values at (x, y)
bboxRange where approximation should be valid
ctrldesired approximation algorithm

Definition at line 295 of file Approximate.cc.

301 {
302  switch (ctrl.getStyle()) {
303  case ApproximateControl::CHEBYSHEV:
304  return PTR(Approximate<PixelT>)(new ApproximateChebyshev<PixelT>(x, y, im, bbox, ctrl));
305  default:
306  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
307  str(boost::format("Unknown ApproximationStyle: %d") % ctrl.getStyle()));
308  }
309 }
int y
#define PTR(...)
Definition: base.h:41
double x
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<typename ImageT >
boost::shared_ptr< Background > lsst::afw::math::makeBackground ( ImageT const &  img,
BackgroundControl const &  bgCtrl 
)

A convenience function that uses function overloading to make the correct type of Background.

cf. std::make_pair()

Examples:
spatialCellExample.cc.

Definition at line 467 of file Background.h.

467  {
468  return PTR(Background)(new BackgroundMI(img, bgCtrl));
469 }
#define PTR(...)
Definition: base.h:41
boost::shared_ptr< Interpolate > lsst::afw::math::makeInterpolate ( std::vector< double > const &  x,
std::vector< double > const &  y,
Interpolate::Style const  style 
)

A factory function to make Interpolate objects

Parameters
xthe x-values of points
ythe values at x[]
styledesired interpolator
Examples:
splineInterpolate.cc.

Definition at line 353 of file Interpolate.cc.

357 {
358  switch (style) {
359  case Interpolate::CONSTANT:
360  return PTR(Interpolate)(new InterpolateConstant(x, y, style));
361  default: // use GSL
362  return PTR(Interpolate)(new InterpolateGsl(x, y, style));
363  }
364 }
#define PTR(...)
Definition: base.h:41
Statistics lsst::afw::math::makeStatistics ( afwImage::Mask< afwImage::MaskPixel > const &  msk,
int const  flags,
StatisticsControl const &  sctrl 
)
related

Specialization to handle Masks.

Note
Although short, the definition can't be in the header as it must follow the specialization definition (g++ complained when this was in the header.)
Parameters
mskImage (or MaskedImage) whose properties we want
flagsDescribe what we want to calculate
sctrlControl how things are calculated
Examples:
imageStatistics.cc, and statistics.cc.

Definition at line 1082 of file Statistics.cc.

1086  {
1087  return Statistics(msk, msk, msk, flags, sctrl);
1088 }
boost::shared_ptr< afwMath::SeparableKernel > lsst::afw::math::makeWarpingKernel ( std::string  name)

Return a warping kernel given its name.

Intended for use with warpImage() and warpExposure().

Allowed names are:

  • bilinear: return a BilinearWarpingKernel
  • lanczos#: return a LanczosWarpingKernel of order #, e.g. lanczos4
  • nearest: return a NearestWarpingKernel

A warping kernel is a subclass of SeparableKernel with the following properties (though for the sake of speed few, if any, of these are enforced):

  • Width and height are even. This is unusual for a kernel, but it is more efficient because if the extra pixel was included it would always have value 0.
  • The center pixels should be adjacent to the kernel center. Again, this avoids extra pixels that are sure to have value 0.
  • It has two parameters: fractional x and fractional row position on the source image. The fractional position is the offset of the pixel position on the source from the center of a nearby source pixel:
    • The pixel whose center is just below or to the left of the source position: 0 <= fractional x and y < 0 and the kernel center is the default (size-1)/2.
    • The pixel whose center is just above or to the right of the source position: -1.0 < fractional x and y <= 0 and the kernel center must be set to (size+1)/2.

Definition at line 197 of file warpExposure.cc.

197  {
198  typedef boost::shared_ptr<afwMath::SeparableKernel> KernelPtr;
199  boost::cmatch matches;
200  static const boost::regex LanczosRE("lanczos(\\d+)");
201  if (name == "bilinear") {
202  return KernelPtr(new BilinearWarpingKernel());
203  } else if (boost::regex_match(name.c_str(), matches, LanczosRE)) {
204  std::string orderStr(matches[1].first, matches[1].second);
205  int order;
206  std::istringstream(orderStr) >> order;
207  return KernelPtr(new LanczosWarpingKernel(order));
208  } else if (name == "nearest") {
209  return KernelPtr(new NearestWarpingKernel());
210  } else {
211  throw LSST_EXCEPT(pexExcept::InvalidParameterError,
212  "unknown warping kernel name: \"" + name + "\"");
213  }
214 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<typename ReturnT >
FitResults lsst::afw::math::minimize ( lsst::afw::math::Function1< ReturnT > const &  function,
std::vector< double > const &  initialParameterList,
std::vector< double > const &  stepSizeList,
std::vector< double > const &  measurementList,
std::vector< double > const &  varianceList,
std::vector< double > const &  xPositionList,
double  errorDef 
)
template<typename ReturnT >
FitResults lsst::afw::math::minimize ( lsst::afw::math::Function2< ReturnT > const &  function,
std::vector< double > const &  initialParameterList,
std::vector< double > const &  stepSizeList,
std::vector< double > const &  measurementList,
std::vector< double > const &  varianceList,
std::vector< double > const &  xPositionList,
std::vector< double > const &  yPositionList,
double  errorDef 
)
template<typename ImageT >
ImageT::Ptr lsst::afw::math::offsetImage ( ImageT const &  inImage,
float  dx,
float  dy,
std::string const &  algorithmName,
unsigned int  buffer 
)

Return an image offset by (dx, dy) using the specified algorithm.

Note
The image pixels are always offset by a fraction of a pixel and the image origin (XY0) picks is modified to handle the integer portion of the offset. In the special case that the offset in both x and y lies in the range (-1, 1) the origin is not changed. Otherwise the pixels are shifted by (-0.5, 0.5] pixels and the origin shifted accordingly.
Exceptions
lsst::pex::exceptions::InvalidParameterErrorif the algorithm is invalid
Parameters
inImageThe image to offset
dxmove the image this far in the column direction
dymove the image this far in the row direction
algorithmNameType of resampling Kernel to use
bufferWidth of buffer (border) around kernel image to allow for warping edge effects (pixels). Values < 0 are treated as 0. This is only used during computation; the final image has the same dimensions as the kernel.

Definition at line 55 of file offsetImage.cc.

64  {
65  SeparableKernel::Ptr offsetKernel = makeWarpingKernel(algorithmName);
66 
67  typename ImageT::Ptr buffImage;
68  if (buffer > 0) {
69  // Paste input image into buffered image
70  afwGeom::Extent2I const &dims = inImage.getDimensions();
71  typename ImageT::Ptr buffered(new ImageT(dims.getX() + 2 * buffer, dims.getY() + 2 * buffer));
72  buffImage = buffered;
73  afwGeom::Box2I box(afwGeom::Point2I(buffer, buffer), dims);
74  typename ImageT::Ptr buffSmall(new ImageT(*buffImage, box, afwImage::LOCAL, false));
75  *buffSmall <<= inImage;
76  } else {
77  buffImage = boost::make_shared<ImageT>(inImage);
78  }
79 
80  if (offsetKernel->getWidth() > buffImage->getWidth() ||
81  offsetKernel->getHeight() > buffImage->getHeight()) {
82  throw LSST_EXCEPT(pexExcept::LengthError,
83  (boost::format("Image of size %dx%d is too small to offset using a %s kernel"
84  "(minimum %dx%d)") %
85  buffImage->getWidth() % buffImage->getHeight() % algorithmName %
86  offsetKernel->getWidth() % offsetKernel->getHeight()).str());
87  }
88 
89 // typename ImageT::Ptr convImage(new ImageT(buffImage, true)); // output image, a deep copy
90  typename ImageT::Ptr convImage(new ImageT(buffImage->getDimensions())); // Convolved image
91 
92  int dOrigX, dOrigY;
93  double fracX, fracY;
94  // If the offset in both axes is in (-1, 1) use it as is, and don't shift the origin
95  if (dx > -1 && dx < 1 && dy > -1 && dy < 1) {
96  dOrigX = 0;
97  dOrigY = 0;
98  fracX = dx;
99  fracY = dy;
100  } else {
101  dOrigX = static_cast<int>(std::floor(dx + 0.5));
102  dOrigY = static_cast<int>(std::floor(dy + 0.5));
103  fracX = dx - dOrigX;
104  fracY = dy - dOrigY;
105  }
106 
107  // We seem to have to pass -fracX, -fracY to setKernelParameters, for reasons RHL doesn't understand
108  double dKerX = -fracX;
109  double dKerY = -fracY;
110 
111  //
112  // If the shift is -ve, the generated shift kernel (e.g. Lanczos5) is quite asymmetric, with the
113  // largest coefficients to the left of centre. We therefore move the centre of calculated shift kernel
114  // one to the right to center up the largest coefficients
115  //
116  if (dKerX < 0) {
117  offsetKernel->setCtrX(offsetKernel->getCtrX() + 1);
118  }
119  if (dKerY < 0) {
120  offsetKernel->setCtrY(offsetKernel->getCtrY() + 1);
121  }
122 
123  offsetKernel->setKernelParameters(std::make_pair(dKerX, dKerY));
124 
125  convolve(*convImage, *buffImage, *offsetKernel, true, true);
126 
127  typename ImageT::Ptr outImage;
128  if (buffer > 0) {
129  afwGeom::Box2I box(afwGeom::Point2I(buffer, buffer), inImage.getDimensions());
130  typename ImageT::Ptr out(new ImageT(*convImage, box, afwImage::LOCAL, true));
131  outImage = out;
132  } else {
133  outImage = convImage;
134  }
135 
136  // adjust the origin; do this after convolution since convolution also sets XY0
137  outImage->setXY0(geom::Point2I(inImage.getX0() + dOrigX, inImage.getY0() + dOrigY));
138 
139  return outImage;
140 }
boost::shared_ptr< SeparableKernel > makeWarpingKernel(std::string name)
Return a warping kernel given its name.
An integer coordinate rectangle.
Definition: Box.h:53
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
Extent< int, N > floor(Extent< double, N > const &input)
void convolve(OutImageT &convolvedImage, InImageT const &inImage, KernelT const &kernel, ConvolutionControl const &convolutionControl=ConvolutionControl())
Convolve an Image or MaskedImage with a Kernel, setting pixels of an existing output image...
boost::shared_ptr< BoundedField > lsst::afw::math::operator* ( double const  scale,
boost::shared_ptr< BoundedField const >  bf 
)

Definition at line 103 of file BoundedField.cc.

103  {
104  return *bf*scale;
105 }
template<typename ImageT >
void lsst::afw::math::randomChisqImage ( ImageT *  image,
Random &  rand,
double const  nu 
)

Set image to random numbers with a chi^2_{nu} distribution

Parameters
imageThe image to set
randdefinition of random number algorithm, seed, etc.
nunumber of degrees of freedom

Definition at line 165 of file RandomImage.cc.

168  {
169  lsst::afw::image::for_each_pixel(*image, do_chisq<typename ImageT::Pixel>(rand, nu));
170 }
void for_each_pixel(Image< LhsT > &lhs, pixelOp0< LhsT > const &func)
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
template<typename ImageT >
void lsst::afw::math::randomFlatImage ( ImageT *  image,
Random &  rand,
double const  a,
double const  b 
)

Set image to random numbers uniformly distributed in the range [a, b)

Parameters
imageThe image to set
randdefinition of random number algorithm, seed, etc.
a(inclusive) lower limit for random variates
b(exclusive) upper limit for random variates

Definition at line 143 of file RandomImage.cc.

147  {
148  lsst::afw::image::for_each_pixel(*image, do_flat<typename ImageT::Pixel>(rand, a, b));
149 }
void for_each_pixel(Image< LhsT > &lhs, pixelOp0< LhsT > const &func)
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
afw::table::Key< double > b
template<typename ImageT >
void lsst::afw::math::randomGaussianImage ( ImageT *  image,
Random &  rand 
)

Set image to random numbers with a gaussian N(0, 1) distribution

Parameters
imageThe image to set
randdefinition of random number algorithm, seed, etc.

Definition at line 155 of file RandomImage.cc.

157  {
158  lsst::afw::image::for_each_pixel(*image, do_gaussian<typename ImageT::Pixel>(rand));
159 }
void for_each_pixel(Image< LhsT > &lhs, pixelOp0< LhsT > const &func)
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
template<typename ImageT >
void lsst::afw::math::randomPoissonImage ( ImageT *  image,
Random &  rand,
double const  mu 
)

Set image to random numbers with a Poisson distribution with mean mu (n.b. not per-pixel)

Parameters
imageThe image to set
randdefinition of random number algorithm, seed, etc.
mumean of distribution

Definition at line 177 of file RandomImage.cc.

180  {
181  lsst::afw::image::for_each_pixel(*image, do_poisson<typename ImageT::Pixel>(rand, mu));
182 }
void for_each_pixel(Image< LhsT > &lhs, pixelOp0< LhsT > const &func)
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
template<typename ImageT >
void lsst::afw::math::randomUniformImage ( ImageT *  image,
Random &  rand 
)

Set image to random numbers uniformly distributed in the range [0, 1)

Parameters
imageThe image to set
randdefinition of random number algorithm, seed, etc.

Definition at line 112 of file RandomImage.cc.

114  {
115  lsst::afw::image::for_each_pixel(*image, do_uniform<typename ImageT::Pixel>(rand));
116 }
void for_each_pixel(Image< LhsT > &lhs, pixelOp0< LhsT > const &func)
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
template<typename ImageT >
void lsst::afw::math::randomUniformIntImage ( ImageT *  image,
Random &  rand,
unsigned long  n 
)

Set image to random integers uniformly distributed in the range 0 ... n - 1

Parameters
imageThe image to set
randdefinition of random number algorithm, seed, etc.
n(exclusive) upper limit for random variates

Definition at line 132 of file RandomImage.cc.

135  {
136  lsst::afw::image::for_each_pixel(*image, do_uniformInt<typename ImageT::Pixel>(rand, n));
137 }
void for_each_pixel(Image< LhsT > &lhs, pixelOp0< LhsT > const &func)
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
template<typename ImageT >
void lsst::afw::math::randomUniformPosImage ( ImageT *  image,
Random &  rand 
)

Set image to random numbers uniformly distributed in the range (0, 1)

Parameters
imageThe image to set
randdefinition of random number algorithm, seed, etc.

Definition at line 122 of file RandomImage.cc.

124  {
125  lsst::afw::image::for_each_pixel(*image, do_uniformPos<typename ImageT::Pixel>(rand));
126 }
void for_each_pixel(Image< LhsT > &lhs, pixelOp0< LhsT > const &func)
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
template<typename ImageT >
ImageT::Ptr lsst::afw::math::rotateImageBy90 ( ImageT const &  inImage,
int  nQuarter 
)

Rotate an image by an integral number of quarter turns

Parameters
inImageThe image to rotate
nQuarterthe desired number of quarter turns

Definition at line 41 of file rotateImage.cc.

43  {
44  typename ImageT::Ptr outImage; // output image
45 
46  while (nQuarter < 0) {
47  nQuarter += 4;
48  }
49 
50  switch (nQuarter%4) {
51  case 0:
52  outImage.reset(new ImageT(inImage, true)); // a deep copy of inImage
53  break;
54  case 1:
55  outImage.reset(new ImageT(afwGeom::Extent2I(inImage.getHeight(), inImage.getWidth())));
56 
57  for (int y = 0; y != inImage.getHeight(); ++y) {
58  typename ImageT::y_iterator optr = outImage->col_begin(inImage.getHeight() - y - 1);
59  for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
60  iptr != end; ++iptr, ++optr) {
61  *optr = *iptr;
62  }
63  }
64 
65  break;
66  case 2:
67  outImage.reset(new ImageT(inImage.getDimensions()));
68 
69  for (int y = 0; y != inImage.getHeight(); ++y) {
70  typename ImageT::x_iterator optr = outImage->x_at(inImage.getWidth() - 1,
71  inImage.getHeight() - y - 1);
72  for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
73  iptr != end; ++iptr, optr -= 1) {
74  *optr = *iptr;
75  }
76  }
77  break;
78  case 3:
79  outImage.reset(new ImageT(afwGeom::Extent2I(inImage.getHeight(), inImage.getWidth())));
80 
81  for (int y = 0; y != inImage.getHeight(); ++y) {
82  typename ImageT::y_iterator optr = outImage->y_at(y, inImage.getWidth() - 1);
83  for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
84  iptr != end; ++iptr, optr -= 1) {
85  *optr = *iptr;
86  }
87  }
88 
89  break;
90  }
91 
92  return outImage;
93 }
int y
template<typename OutImageT , typename InImageT >
void lsst::afw::math::scaledPlus ( OutImageT &  outImage,
double  c1,
InImageT const &  inImage1,
double  c2,
InImageT const &  inImage2 
)

Compute the scaled sum of two images

outImage = c1 inImage1 + c2 inImage2

For example to linearly interpolate between two images set: c1 = 1.0 - fracDist c2 = fracDist where fracDist is the fractional distance of outImage from inImage1: location of outImage - location of inImage1 fracDist = ----------------------------------------— location of inImage2 - location of inImage1

Exceptions
lsst::pex::exceptions::InvalidParameterErrorif outImage is not same dimensions as inImage1 and inImage2.
Parameters
outImageoutput image
c1coefficient for image 1
inImage1input image 1
c2coefficient for image 2
inImage2input image 2

Definition at line 217 of file ConvolveImage.cc.

223 {
224  if (outImage.getDimensions() != inImage1.getDimensions()) {
225  std::ostringstream os;
226  os << "outImage dimensions = ( " << outImage.getWidth() << ", " << outImage.getHeight()
227  << ") != (" << inImage1.getWidth() << ", " << inImage1.getHeight()
228  << ") = inImage1 dimensions";
229  throw LSST_EXCEPT(pexExcept::InvalidParameterError, os.str());
230  } else if (inImage1.getDimensions() != inImage2.getDimensions()) {
231  std::ostringstream os;
232  os << "inImage1 dimensions = ( " << inImage1.getWidth() << ", " << inImage1.getHeight()
233  << ") != (" << inImage2.getWidth() << ", " << inImage2.getHeight()
234  << ") = inImage2 dimensions";
235  throw LSST_EXCEPT(pexExcept::InvalidParameterError, os.str());
236  }
237 
238  typedef typename InImageT::const_x_iterator InConstXIter;
239  typedef typename OutImageT::x_iterator OutXIter;
240  for (int y = 0; y != inImage1.getHeight(); ++y) {
241  InConstXIter const end1 = inImage1.row_end(y);
242  InConstXIter inIter1 = inImage1.row_begin(y);
243  InConstXIter inIter2 = inImage2.row_begin(y);
244  OutXIter outIter = outImage.row_begin(y);
245  for (; inIter1 != end1; ++inIter1, ++inIter2, ++outIter) {
246  *outIter = (*inIter1 * c1) + (*inIter2 * c2);
247  }
248  }
249 }
int y
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<typename PixelT >
lsst::afw::image::Image<PixelT>::Ptr lsst::afw::math::statisticsStack ( std::vector< typename lsst::afw::image::Image< PixelT >::Ptr > &  images,
Property  flags,
StatisticsControl const &  sctrl = StatisticsControl(),
std::vector< lsst::afw::image::VariancePixel > const &  wvector = std::vector< lsst::afw::image::VariancePixel >(0) 
)

A function to compute some statistics of a stack of Images.

Parameters
imagesImages to process
flagsstatistics requested
sctrlControl structure
wvectorvector containing weights
template<typename PixelT >
void lsst::afw::math::statisticsStack ( lsst::afw::image::Image< PixelT > &  out,
std::vector< typename lsst::afw::image::Image< PixelT >::Ptr > &  images,
Property  flags,
StatisticsControl const &  sctrl = StatisticsControl(),
std::vector< lsst::afw::image::VariancePixel > const &  wvector = std::vector< lsst::afw::image::VariancePixel >(0) 
)

@ brief compute statistical stack of Image. Write to output image in-situ

Parameters
outOutput image
imagesImages to process
flagsstatistics requested
sctrlControl structure
wvectorvector containing weights
template<typename PixelT >
lsst::afw::image::MaskedImage<PixelT>::Ptr lsst::afw::math::statisticsStack ( std::vector< typename lsst::afw::image::MaskedImage< PixelT >::Ptr > &  images,
Property  flags,
StatisticsControl const &  sctrl = StatisticsControl(),
std::vector< lsst::afw::image::VariancePixel > const &  wvector = std::vector< lsst::afw::image::VariancePixel >(0) 
)

A function to compute some statistics of a stack of MaskedImages.

Parameters
imagesMaskedImages to process
flagsstatistics requested
sctrlcontrol structure
wvectorvector containing weights
template<typename PixelT >
void lsst::afw::math::statisticsStack ( lsst::afw::image::MaskedImage< PixelT > &  out,
std::vector< typename lsst::afw::image::MaskedImage< PixelT >::Ptr > &  images,
Property  flags,
StatisticsControl const &  sctrl = StatisticsControl(),
std::vector< lsst::afw::image::VariancePixel > const &  wvector = std::vector< lsst::afw::image::VariancePixel >(0) 
)

@ brief compute statistical stack of MaskedImage. Write to output image in-situ

Parameters
outOutput image
imagesMaskedImages to process
flagsstatistics requested
sctrlcontrol structure
wvectorvector containing weights
template<typename PixelT >
boost::shared_ptr<std::vector<PixelT> > lsst::afw::math::statisticsStack ( std::vector< boost::shared_ptr< std::vector< PixelT > > > &  vectors,
Property  flags,
StatisticsControl const &  sctrl = StatisticsControl(),
std::vector< lsst::afw::image::VariancePixel > const &  wvector = std::vector< lsst::afw::image::VariancePixel >(0) 
)

A function to compute some statistics of a stack of std::vectors.

Parameters
vectorsVectors to process
flagsstatistics requested
sctrlcontrol structure
wvectorvector containing weights
template<typename PixelT >
lsst::afw::image::MaskedImage<PixelT>::Ptr lsst::afw::math::statisticsStack ( lsst::afw::image::Image< PixelT > const &  image,
Property  flags,
char  dimension,
StatisticsControl const &  sctrl = StatisticsControl() 
)

A function to compute statistics on the rows or columns of an image.

template<typename PixelT >
lsst::afw::image::MaskedImage<PixelT>::Ptr lsst::afw::math::statisticsStack ( lsst::afw::image::MaskedImage< PixelT > const &  image,
Property  flags,
char  dimension,
StatisticsControl const &  sctrl = StatisticsControl() 
)

A function to compute statistics on the rows or columns of an image.

Interpolate::Style lsst::afw::math::stringToInterpStyle ( std::string const &  style)

Conversion function to switch a string to an Interpolate::Style.

Parameters
styledesired type of interpolation

Definition at line 262 of file Interpolate.cc.

264 {
265  static std::map<std::string, Interpolate::Style> gslInterpTypeStrings;
266  if (gslInterpTypeStrings.empty()) {
267  gslInterpTypeStrings["CONSTANT"] = Interpolate::CONSTANT;
268  gslInterpTypeStrings["LINEAR"] = Interpolate::LINEAR;
269  gslInterpTypeStrings["CUBIC_SPLINE"] = Interpolate::CUBIC_SPLINE;
270  gslInterpTypeStrings["NATURAL_SPLINE"] = Interpolate::NATURAL_SPLINE;
271  gslInterpTypeStrings["CUBIC_SPLINE_PERIODIC"] = Interpolate::CUBIC_SPLINE_PERIODIC;
272  gslInterpTypeStrings["AKIMA_SPLINE"] = Interpolate::AKIMA_SPLINE;
273  gslInterpTypeStrings["AKIMA_SPLINE_PERIODIC"] = Interpolate::AKIMA_SPLINE_PERIODIC;
274  }
275 
276  if ( gslInterpTypeStrings.find(style) == gslInterpTypeStrings.end()) {
277  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "Interp style not found: "+style);
278  }
279  return gslInterpTypeStrings[style];
280 }
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
afwMath::Property lsst::afw::math::stringToStatisticsProperty ( std::string const  property)

Conversion function to switch a string to a Property (see Statistics.h)

Definition at line 715 of file Statistics.cc.

715  {
716  static std::map<std::string, Property> statisticsProperty;
717  if (statisticsProperty.size() == 0) {
718  statisticsProperty["NOTHING"] = NOTHING;
719  statisticsProperty["ERRORS"] = ERRORS;
720  statisticsProperty["NPOINT"] = NPOINT;
721  statisticsProperty["MEAN"] = MEAN;
722  statisticsProperty["STDEV"] = STDEV;
723  statisticsProperty["VARIANCE"] = VARIANCE;
724  statisticsProperty["MEDIAN"] = MEDIAN;
725  statisticsProperty["IQRANGE"] = IQRANGE;
726  statisticsProperty["MEANCLIP"] = MEANCLIP;
727  statisticsProperty["STDEVCLIP"] = STDEVCLIP;
728  statisticsProperty["VARIANCECLIP"] = VARIANCECLIP;
729  statisticsProperty["MIN"] = MIN;
730  statisticsProperty["MAX"] = MAX;
731  statisticsProperty["SUM"] = SUM;
732  statisticsProperty["MEANSQUARE"] = MEANSQUARE;
733  statisticsProperty["ORMASK"] = ORMASK;
734  }
735  return statisticsProperty[property];
736 }
get the or-mask of all pixels used.
Definition: Statistics.h:80
estimate sample minimum
Definition: Statistics.h:76
estimate sample standard deviation
Definition: Statistics.h:68
find mean value of square of pixel values
Definition: Statistics.h:79
estimate sample maximum
Definition: Statistics.h:77
We don&#39;t want anything.
Definition: Statistics.h:64
Include errors of requested quantities.
Definition: Statistics.h:65
estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)
Definition: Statistics.h:73
estimate sample median
Definition: Statistics.h:70
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
Definition: Statistics.h:72
number of sample points
Definition: Statistics.h:66
estimate sample inter-quartile range
Definition: Statistics.h:71
estimate sample mean
Definition: Statistics.h:67
estimate sample variance
Definition: Statistics.h:69
find sum of pixels in the image
Definition: Statistics.h:78
UndersampleStyle lsst::afw::math::stringToUndersampleStyle ( std::string const &  style)

Conversion function to switch a string to an UndersampleStyle.

Definition at line 148 of file Background.cc.

148  {
149  static std::map<std::string, UndersampleStyle> undersampleStrings;
150  if (undersampleStrings.size() == 0) {
151  undersampleStrings["THROW_EXCEPTION"] = THROW_EXCEPTION;
152  undersampleStrings["REDUCE_INTERP_ORDER"] = REDUCE_INTERP_ORDER;
153  undersampleStrings["INCREASE_NXNYSAMPLE"] = INCREASE_NXNYSAMPLE;
154  }
155 
156  if (undersampleStrings.find(style) == undersampleStrings.end()) {
157  throw LSST_EXCEPT(ex::InvalidParameterError, "Understample style not defined: "+style);
158  }
159  return undersampleStrings[style];
160 }
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<typename DestImageT , typename SrcImageT >
int lsst::afw::math::warpCenteredImage ( DestImageT &  destImage,
SrcImageT const &  srcImage,
lsst::afw::geom::LinearTransform const &  linearTransform,
lsst::afw::geom::Point2D const &  centerPosition,
afwMath::WarpingControl const &  control,
typename DestImageT::SinglePixel  padValue = lsst::afw::math::edgePixel<DestImageT>(            typename lsst::afw::image::detail::image_traits<DestImageT>::image_category()) 
)

Warp an image with a LinearTranform about a specified point. This enables warping an image of e.g. a PSF without translating the centroid.

Parameters
destImageremapped image
srcImagesource image
linearTransformlinear transformation to apply
centerPositionpixel position for location of linearTransform
controlcontrol parameters
padValueuse this value for undefined (edge) pixels

Definition at line 678 of file warpExposure.cc.

685  {
686  // force src and dest to be the same size and xy0
687  if (
688  (destImage.getWidth() != srcImage.getWidth()) ||
689  (destImage.getHeight() != srcImage.getHeight()) ||
690  (destImage.getXY0() != srcImage.getXY0())
691  ) {
692  std::ostringstream errStream;
693  errStream << "src and dest images must have same size and xy0.";
694  throw LSST_EXCEPT(pexExcept::InvalidParameterError, errStream.str());
695  }
696 
697  // set the xy0 coords to 0,0 to make life easier
698  SrcImageT srcImageCopy(srcImage, true);
699  srcImageCopy.setXY0(0, 0);
700  destImage.setXY0(0, 0);
701  afwGeom::Extent2D cLocal = afwGeom::Extent2D(centerPosition) - afwGeom::Extent2D(srcImage.getXY0());
702 
703  // for the affine transform, the centerPosition will not only get sheared, but also
704  // moved slightly. So we'll include a translation to move it back by an amount
705  // centerPosition - translatedCenterPosition
706  afwGeom::AffineTransform affTran(linearTransform, cLocal - linearTransform(cLocal));
707 
708  // now warp
709 #if 0
710  static float t = 0.0;
711  float t_before = 1.0*clock()/CLOCKS_PER_SEC;
712  int n = warpImage(destImage, srcImageCopy, affTran, control, padValue);
713  float t_after = 1.0*clock()/CLOCKS_PER_SEC;
714  float dt = t_after - t_before;
715  t += dt;
716  std::cout <<srcImage.getWidth()<<"x"<<srcImage.getHeight()<<": "<< dt <<" "<< t <<std::endl;
717 #else
718  int n = warpImage(destImage, srcImageCopy, affTran, control, padValue);
719 #endif
720 
721  // fix the origin and we're done.
722  destImage.setXY0(srcImage.getXY0());
723 
724  return n;
725 }
int warpImage(DestImageT &destImage, lsst::afw::image::Wcs const &destWcs, SrcImageT const &srcImage, lsst::afw::image::Wcs const &srcWcs, WarpingControl const &control, typename DestImageT::SinglePixel padValue=lsst::afw::math::edgePixel< DestImageT >(typename lsst::afw::image::detail::image_traits< DestImageT >::image_category()))
Warp an Image or MaskedImage to a new Wcs. See also convenience function warpExposure() to warp an Ex...
An affine coordinate transformation consisting of a linear transformation and an offset.
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
Extent< double, 2 > Extent2D
Definition: Extent.h:358
template<typename DestImageT , typename SrcImageT >
int lsst::afw::math::warpCenteredImage ( DestImageT &  destImage,
SrcImageT const &  srcImage,
afwMath::SeparableKernel warpingKernel,
lsst::afw::geom::LinearTransform const &  linearTransform,
lsst::afw::geom::Point2D const &  centerPosition,
int const  interpLength = 0,
typename DestImageT::SinglePixel  padValue = lsst::afw::math::edgePixel<DestImageT>(            typename lsst::afw::image::detail::image_traits<DestImageT>::image_category()),
lsst::afw::gpu::DevicePreference  devPref = lsst::afw::gpu::DEFAULT_DEVICE_PREFERENCE 
)

A variant of warpCenteredImage that supports the old, deprecated interface.

Parameters
destImageremapped image
srcImagesource image
warpingKernelwarping kernel; determines warping algorithm
linearTransformlinear transformation to apply
centerPositionpixel corresponding to location of linearTransform
interpLengthDistance over which WCS can be linearily interpolated 0 means no interpolation and uses an optimized branch of the code 1 also performs no interpolation but it runs the interpolation code branch
padValueuse this value for undefined (edge) pixels
devPrefSpecifies whether to use CPU or GPU device

Definition at line 729 of file warpExposure.cc.

738  {
739  afwMath::WarpingControl control(warpingKernel, interpLength, devPref);
740  return warpCenteredImage(destImage, srcImage, linearTransform, centerPosition, control, padValue);
741 }
Parameters to control convolution.
Definition: warpExposure.h:239
int warpCenteredImage(DestImageT &destImage, SrcImageT const &srcImage, lsst::afw::geom::LinearTransform const &linearTransform, lsst::afw::geom::Point2D const &centerPosition, WarpingControl const &control, typename DestImageT::SinglePixel padValue=lsst::afw::math::edgePixel< DestImageT >(typename lsst::afw::image::detail::image_traits< DestImageT >::image_category()))
Warp an image with a LinearTranform about a specified point. This enables warping an image of e...
template<typename DestExposureT , typename SrcExposureT >
int lsst::afw::math::warpExposure ( DestExposureT &  destExposure,
SrcExposureT const &  srcExposure,
afwMath::WarpingControl const &  control,
typename DestExposureT::MaskedImageT::SinglePixel  padValue = lsst::afw::math::edgePixel<typename DestExposureT::MaskedImageT>(                typename lsst::afw::image::detail::image_traits<                    typename DestExposureT::MaskedImageT>::image_category()) 
)

Warp (remap) one exposure to another.

This is a convenience wrapper around warpImage().

Parameters
destExposureRemapped exposure. Wcs and xy0 are read, MaskedImage is set, and Calib and Filter are copied from srcExposure. All other attributes are left alone (including Detector and Psf)
srcExposureSource exposure
controlcontrol parameters
padValueuse this value for undefined (edge) pixels

Definition at line 303 of file warpExposure.cc.

309 {
310  if (!destExposure.hasWcs()) {
311  throw LSST_EXCEPT(pexExcept::InvalidParameterError, "destExposure has no Wcs");
312  }
313  if (!srcExposure.hasWcs()) {
314  throw LSST_EXCEPT(pexExcept::InvalidParameterError, "srcExposure has no Wcs");
315  }
316  typename DestExposureT::MaskedImageT mi = destExposure.getMaskedImage();
317  boost::shared_ptr<afwImage::Calib> calibCopy(new afwImage::Calib(*srcExposure.getCalib()));
318  destExposure.setCalib(calibCopy);
319  destExposure.setFilter(srcExposure.getFilter());
320  return warpImage(mi, *destExposure.getWcs(), srcExposure.getMaskedImage(), *srcExposure.getWcs(),
321  control, padValue);
322 }
int warpImage(DestImageT &destImage, lsst::afw::image::Wcs const &destWcs, SrcImageT const &srcImage, lsst::afw::image::Wcs const &srcWcs, WarpingControl const &control, typename DestImageT::SinglePixel padValue=lsst::afw::math::edgePixel< DestImageT >(typename lsst::afw::image::detail::image_traits< DestImageT >::image_category()))
Warp an Image or MaskedImage to a new Wcs. See also convenience function warpExposure() to warp an Ex...
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<typename DestExposureT , typename SrcExposureT >
int lsst::afw::math::warpExposure ( DestExposureT &  destExposure,
SrcExposureT const &  srcExposure,
afwMath::SeparableKernel warpingKernel,
int const  interpLength = 0,
typename DestExposureT::MaskedImageT::SinglePixel  padValue = lsst::afw::math::edgePixel<typename DestExposureT::MaskedImageT>(            typename lsst::afw::image::detail::image_traits<typename DestExposureT::MaskedImageT>::image_category()),
lsst::afw::gpu::DevicePreference  devPref = lsst::afw::gpu::DEFAULT_DEVICE_PREFERENCE 
)

Warp (remap) one exposure to another.

This variant uses an older, deprecated interface.

Parameters
destExposureRemapped exposure. Wcs and xy0 are read, MaskedImage is set, and Calib and Filter are copied from srcExposure. All other attributes are left alone (including Detector and Psf)
srcExposureSource exposure
warpingKernelWarping kernel; determines warping algorithm
interpLengthDistance over which WCS can be linearily interpolated
padValueuse this value for undefined (edge) pixels
devPrefSpecifies whether to use CPU or GPU device

Definition at line 325 of file warpExposure.cc.

333 {
334  if (!destExposure.hasWcs()) {
335  throw LSST_EXCEPT(pexExcept::InvalidParameterError, "destExposure has no Wcs");
336  }
337  if (!srcExposure.hasWcs()) {
338  throw LSST_EXCEPT(pexExcept::InvalidParameterError, "srcExposure has no Wcs");
339  }
340  typename DestExposureT::MaskedImageT mi = destExposure.getMaskedImage();
341  boost::shared_ptr<afwImage::Calib> calibCopy(new afwImage::Calib(*srcExposure.getCalib()));
342  destExposure.setCalib(calibCopy);
343  destExposure.setFilter(srcExposure.getFilter());
344  return warpImage(mi, *destExposure.getWcs(),
345  srcExposure.getMaskedImage(), *srcExposure.getWcs(), warpingKernel, interpLength,
346  padValue, devPref);
347 }
int warpImage(DestImageT &destImage, lsst::afw::image::Wcs const &destWcs, SrcImageT const &srcImage, lsst::afw::image::Wcs const &srcWcs, WarpingControl const &control, typename DestImageT::SinglePixel padValue=lsst::afw::math::edgePixel< DestImageT >(typename lsst::afw::image::detail::image_traits< DestImageT >::image_category()))
Warp an Image or MaskedImage to a new Wcs. See also convenience function warpExposure() to warp an Ex...
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<typename DestImageT , typename SrcImageT >
int lsst::afw::math::warpImage ( DestImageT &  destImage,
lsst::afw::image::Wcs const &  destWcs,
SrcImageT const &  srcImage,
lsst::afw::image::Wcs const &  srcWcs,
afwMath::WarpingControl const &  control,
typename DestImageT::SinglePixel  padValue = lsst::afw::math::edgePixel<DestImageT>(              typename lsst::afw::image::detail::image_traits<DestImageT>::image_category()) 
)

Warp an Image or MaskedImage to a new Wcs. See also convenience function warpExposure() to warp an Exposure.

Edge pixels are set to padValue; these are pixels that cannot be computed because they are too near the edge of srcImage or miss srcImage entirely.

Returns
the number of valid pixels in destImage (those that are not edge pixels).
Note
This function is able to use GPU acceleration when interpLength > 0.

Algorithm Without Interpolation:

For each integer pixel position in the remapped Exposure:

  • The associated pixel position on srcImage is determined using the destination and source WCS
  • The warping kernel's parameters are set based on the fractional part of the pixel position on srcImage
  • The warping kernel is applied to srcImage at the integer portion of the pixel position to compute the remapped pixel value
  • A flux-conservation factor is determined from the source and destination WCS and is applied to the remapped pixel

The scaling of intensity for relative area of source and destination uses two minor approximations:

  • The area of the sky marked out by a pixel on the destination image corresponds to a parallellogram on the source image.
  • The area varies slowly enough across the image that we can get away with computing the source area shifted by half a pixel up and to the left of the true area.

Algorithm With Interpolation:

Interpolation simply reduces the number of times WCS is used to map between destination and source pixel position. This computation is only made at a grid of points on the destination image, separated by interpLen pixels along rows and columns. All other source pixel positions are determined by linear interpolation between those grid points. Everything else remains the same.

Exceptions
lsst::pex::exceptions::InvalidParameterErrorif destImage is srcImage
lsst::pex::exceptions::MemoryErrorwhen allocation of CPU memory fails
lsst::afw::gpu::GpuMemoryErrorwhen allocation or transfer to/from GPU memory fails
lsst::afw::gpu::GpuRuntimeErrorwhen GPU code run fails
Todo:
Should support an additional color-based position correction in the remapping (differential chromatic refraction). This can be done either object-by-object or pixel-by-pixel.
Todo:
Need to deal with oversampling and/or weight maps. If done we can use faster kernels than sinc.
Parameters
destImageremapped image
destWcsWCS of remapped image
srcImagesource image
srcWcsWCS of source image
controlcontrol parameters
padValueuse this value for undefined (edge) pixels

Definition at line 614 of file warpExposure.cc.

621  {
622  afwGeom::Point2D const destXY0(destImage.getXY0());
623  afwMath::detail::WcsPositionFunctor const computeSrcPos(destXY0, destWcs, srcWcs);
624  return doWarpImage(destImage, srcImage, computeSrcPos, control, padValue);
625 }
template<typename DestImageT , typename SrcImageT >
int lsst::afw::math::warpImage ( DestImageT &  destImage,
lsst::afw::image::Wcs const &  destWcs,
SrcImageT const &  srcImage,
lsst::afw::image::Wcs const &  srcWcs,
afwMath::SeparableKernel warpingKernel,
int const  interpLength = 0,
typename DestImageT::SinglePixel  padValue = lsst::afw::math::edgePixel<DestImageT>(            typename lsst::afw::image::detail::image_traits<DestImageT>::image_category()),
lsst::afw::gpu::DevicePreference  devPref = lsst::afw::gpu::DEFAULT_DEVICE_PREFERENCE 
)

A variant of warpImage that uses an older, deprecated interface.

Parameters
destImageremapped image
destWcsWCS of remapped image
srcImagesource image
srcWcsWCS of source image
warpingKernelwarping kernel; determines warping algorithm
interpLengthDistance over which WCS can be linearily interpolated 0 means no interpolation and uses an optimized branch of the code 1 also performs no interpolation but it runs the interpolation code branch
padValueuse this value for undefined (edge) pixels
devPrefSpecifies whether to use CPU or GPU device

Definition at line 628 of file warpExposure.cc.

637  {
638  afwGeom::Point2D const destXY0(destImage.getXY0());
639  afwMath::detail::WcsPositionFunctor const computeSrcPos(destXY0, destWcs, srcWcs);
640  afwMath::WarpingControl control(warpingKernel, interpLength, devPref);
641  return doWarpImage(destImage, srcImage, computeSrcPos, control, padValue);
642 }
Parameters to control convolution.
Definition: warpExposure.h:239
template<typename DestImageT , typename SrcImageT >
int lsst::afw::math::warpImage ( DestImageT &  destImage,
SrcImageT const &  srcImage,
lsst::afw::geom::AffineTransform const &  affineTransform,
afwMath::WarpingControl const &  control,
typename DestImageT::SinglePixel  padValue = lsst::afw::math::edgePixel<DestImageT>(            typename lsst::afw::image::detail::image_traits<DestImageT>::image_category()) 
)

A variant of warpImage that uses an affine transformation instead of a WCS to describe the transformation.

Parameters
destImageremapped image
srcImagesource image
affineTransformaffine transformation to apply
controlcontrol parameters
padValueuse this value for undefined (edge) pixels

Definition at line 646 of file warpExposure.cc.

652  {
653  afwGeom::Point2D const destXY0(destImage.getXY0());
654  afwMath::detail::AffineTransformPositionFunctor const computeSrcPos(destXY0, affineTransform);
655  return doWarpImage(destImage, srcImage, computeSrcPos, control, padValue);
656 }
template<typename DestImageT , typename SrcImageT >
int lsst::afw::math::warpImage ( DestImageT &  destImage,
SrcImageT const &  srcImage,
afwMath::SeparableKernel warpingKernel,
lsst::afw::geom::AffineTransform const &  affineTransform,
int const  interpLength = 0,
typename DestImageT::SinglePixel  padValue = lsst::afw::math::edgePixel<DestImageT>(            typename lsst::afw::image::detail::image_traits<DestImageT>::image_category()),
lsst::afw::gpu::DevicePreference  devPref = lsst::afw::gpu::DEFAULT_DEVICE_PREFERENCE 
)

A variant of the affine transformation warpImage that uses an older, deprecated interface.

Parameters
destImageremapped image
srcImagesource image
warpingKernelwarping kernel; determines warping algorithm
affineTransformaffine transformation to apply
interpLengthDistance over which WCS can be linearily interpolated 0 means no interpolation and uses an optimized branch of the code 1 also performs no interpolation but it runs the interpolation code branch
padValueuse this value for undefined (edge) pixels
devPrefSpecifies whether to use CPU or GPU device

Definition at line 660 of file warpExposure.cc.

669 {
670  afwGeom::Point2D const destXY0(destImage.getXY0());
671  afwMath::detail::AffineTransformPositionFunctor const computeSrcPos(destXY0, affineTransform);
672  afwMath::WarpingControl control(warpingKernel, interpLength, devPref);
673  return doWarpImage(destImage, srcImage, computeSrcPos, control, padValue);
674 }
Parameters to control convolution.
Definition: warpExposure.h:239

Variable Documentation

double const lsst::afw::math::DEFABSERR = 1.e-15

Definition at line 260 of file Integrate.h.

double const lsst::afw::math::DEFRELERR = 1.e-6

Definition at line 261 of file Integrate.h.

afwMath::deltafunction_kernel_tag lsst::afw::math::deltafunction_kernel_tag_

Used as default value in argument lists.

Definition at line 45 of file Kernel.cc.

afwMath::generic_kernel_tag lsst::afw::math::generic_kernel_tag_

Used as default value in argument lists.

Definition at line 44 of file Kernel.cc.

double const lsst::afw::math::MOCK_INF = 1.e10

Definition at line 175 of file Integrate.h.