LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
LSSTDataManagementBasePackage
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
lsst::afw::math Namespace Reference

Namespaces

 detail
 
 details
 
 warper
 

Classes

class  InterpolateConstant
 
class  InterpolateGsl
 
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
 A class that can be used to generate sequences of random numbers according to a number of different algorithms. More...
 
class  CandidateVisitor
 
class  SpatialCellCandidate
 Base class for candidate objects in a SpatialCell. More...
 
class  SpatialCellImageCandidate
 Base class for candidate objects in a SpatialCell that are able to return an Image of some sort (e.g. More...
 
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
 A class to evaluate image statistics. More...
 
class  infinite_iterator
 This iterator will never increment. More...
 
class  MaskImposter
 A Mask wrapper to provide an infinite_iterator for Mask::row_begin(). 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< std::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  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)
 A factory function to make Approximate objects. More...
 
UndersampleStyle stringToUndersampleStyle (std::string const &style)
 Conversion function to switch a string to an UndersampleStyle. More...
 
template<typename ImageT >
boost::shared_ptr< ImageT > binImage (ImageT const &in, int const binsize, lsst::afw::math::Property const flags)
 
template<typename ImageT >
boost::shared_ptr< ImageT > binImage (ImageT const &in, int const binX, int const binY, lsst::afw::math::Property const flags)
 
boost::shared_ptr< BoundedFieldoperator* (double const scale, boost::shared_ptr< BoundedField const > bf)
 
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...
 
boost::shared_ptr< InterpolatemakeInterpolate (std::vector< double > const &x, std::vector< double > const &y, Interpolate::Style const style)
 A factory function to make Interpolate objects. More...
 
boost::shared_ptr< InterpolatemakeInterpolate (ndarray::Array< double const, 1 > const &x, ndarray::Array< double const, 1 > const &y, Interpolate::Style const style)
 
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 >
void randomUniformImage (ImageT *image, Random &rand)
 Set image to random numbers uniformly distributed in the range [0, 1) More...
 
template<typename ImageT >
void randomUniformPosImage (ImageT *image, Random &rand)
 Set image to random numbers uniformly distributed in the range (0, 1) More...
 
template<typename ImageT >
void randomUniformIntImage (ImageT *image, Random &rand, unsigned long n)
 Set image to random integers uniformly distributed in the range 0 ... More...
 
template<typename ImageT >
void randomFlatImage (ImageT *image, Random &rand, double const a, double const b)
 Set image to random numbers uniformly distributed in the range [a, b) More...
 
template<typename ImageT >
void randomGaussianImage (ImageT *image, Random &rand)
 Set image to random numbers with a gaussian N(0, 1) distribution. More...
 
template<typename ImageT >
void randomChisqImage (ImageT *image, Random &rand, double const nu)
 Set image to random numbers with a chi^2_{nu} distribution. More...
 
template<typename ImageT >
void randomPoissonImage (ImageT *image, Random &rand, double const mu)
 Set image to random numbers with a Poisson distribution with mean mu (n.b. More...
 
template<typename ImageT >
ImageT::Ptr rotateImageBy90 (ImageT const &inImage, int nQuarter)
 Rotate an image by an integral number of quarter turns. More...
 
template<typename ImageT >
boost::shared_ptr< ImageT > flipImage (ImageT const &inImage, bool flipLR, bool flipTB)
 Flip an image left–right and/or top–bottom. More...
 
Statistics makeStatistics (afwImage::Mask< afwImage::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl)
 Specialization to handle Masks. 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...
 
template<typename OutImageT , typename InImageT >
void scaledPlus (OutImageT &outImage, double c1, InImageT const &inImage1, double c2, InImageT const &inImage2)
 Compute the scaled sum of two images. More...
 
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...
 
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 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))
 @ brief compute statistical stack of Image. More...
 
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))
 @ brief compute statistical stack of MaskedImage. More...
 
template<typename PixelT >
std::shared_ptr< std::vector
< PixelT > > 
statisticsStack (std::vector< std::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 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. More...
 
template<typename DestImageT , typename SrcImageT >
int warpImage (DestImageT &destImage, SrcImageT const &srcImage, lsst::afw::geom::XYTransform const &xyTransform, 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 XYTransform instead of a pair of WCS to describe the transformation. 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. 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 539 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
estimate sample N-sigma clipped variance (N set in StatisticsControl, default=3)
Definition: Statistics.h:74
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  binsize,
lsst::afw::math::Property const  flags 
)
Parameters
inThe image to bin
binsizeOutput pixels are binsize*binsize input pixels
flagshow to generate super-pixels

Definition at line 41 of file binImage.cc.

45 {
46  return binImage(in, binsize, binsize, flags);
47 }
boost::shared_ptr< ImageT > binImage(ImageT const &in, int const binsize, lsst::afw::math::Property const flags)
Definition: binImage.cc:41
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 
)
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 50 of file binImage.cc.

55 {
56  if (flags != lsst::afw::math::MEAN) {
57  throw LSST_EXCEPT(pexExcept::InvalidParameterError,
58  (boost::format("Only afwMath::MEAN is supported, saw 0x%x") % flags).str());
59  }
60  if (binX <= 0 || binY <= 0) {
61  throw LSST_EXCEPT(pexExcept::DomainError,
62  (boost::format("Binning must be >= 0, saw %dx%d") % binX % binY).str());
63  }
64 
65  int const outWidth = in.getWidth()/binX;
66  int const outHeight = in.getHeight()/binY;
67 
68  typename ImageT::Ptr out = typename ImageT::Ptr(
69  new ImageT(geom::Extent2I(outWidth, outHeight))
70  );
71  out->setXY0(in.getXY0());
72  *out = typename ImageT::SinglePixel(0);
73 
74  for (int oy = 0, iy = 0; oy < out->getHeight(); ++oy) {
75  for (int i = 0; i != binY; ++i, ++iy) {
76  typename ImageT::x_iterator optr = out->row_begin(oy);
77  for (typename ImageT::x_iterator iptr = in.row_begin(iy), iend = iptr + binX*outWidth;
78  iptr < iend; ) {
79  typename ImageT::SinglePixel val = *iptr; ++iptr;
80  for (int j = 1; j != binX; ++j, ++iptr) {
81  val += *iptr;
82  }
83  *optr += val; ++optr;
84  }
85  }
86  for (typename ImageT::x_iterator ptr = out->row_begin(oy), end = out->row_end(oy); ptr != end; ++ptr) {
87  *ptr /= binX*binY;
88  }
89  }
90 
91  return out;
92 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
estimate sample mean
Definition: Statistics.h:67
ImageT val
Definition: CR.cc:159
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 338 of file ConvolveImage.cc.

345 {
346  ConvolutionControl convolutionControl;
347  convolutionControl.setDoNormalize(doNormalize);
348  convolutionControl.setDoCopyEdge(doCopyEdge);
349  afwMath::convolve(convolvedImage, inImage, kernel, convolutionControl);
350 }
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 131 of file ConvolveImage.h.

134  {
135  typedef typename ImageT::SinglePixel SinglePixelT;
136  return SinglePixelT(
137  std::numeric_limits<SinglePixelT>::has_quiet_NaN ?
138  std::numeric_limits<SinglePixelT>::quiet_NaN() : 0);
139  }
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 150 of file ConvolveImage.h.

153  {
154  typedef typename MaskedImageT::Image::Pixel ImagePixelT;
155  typedef typename MaskedImageT::Variance::Pixel VariancePixelT;
156 
157  return typename MaskedImageT::SinglePixel(
158  std::numeric_limits<ImagePixelT>::has_quiet_NaN ?
159  std::numeric_limits<ImagePixelT>::quiet_NaN() : 0,
160  MaskedImageT::Mask::getPlaneBitMask("NO_DATA"),
161  std::numeric_limits<VariancePixelT>::infinity());
162  }
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 101 of file rotateImage.cc.

104  {
105  typename ImageT::Ptr outImage(new ImageT(inImage, true)); // Output image
106 
107  if (flipLR) {
108  if (flipTB) {
109  for (int y = 0; y != inImage.getHeight(); ++y) {
110  typename ImageT::x_iterator optr = outImage->x_at(inImage.getWidth() - 1,
111  inImage.getHeight() - y - 1);
112  for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
113  iptr != end; ++iptr, optr -= 1) {
114  *optr = *iptr;
115  }
116  }
117  } else {
118  for (int y = 0; y != inImage.getHeight(); ++y) {
119  typename ImageT::x_iterator optr = outImage->x_at(inImage.getWidth() - 1, y);
120  for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
121  iptr != end; ++iptr, optr -= 1) {
122  *optr = *iptr;
123  }
124  }
125  }
126  } else {
127  if (flipTB) {
128  for (int y = 0; y != inImage.getHeight(); ++y) {
129  typename ImageT::x_iterator optr = outImage->row_begin(inImage.getHeight() - y - 1);
130  for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
131  iptr != end; ++iptr, ++optr) {
132  *optr = *iptr;
133  }
134  }
135  } else {
136  ; // nothing to do
137  }
138  }
139 
140  return outImage;
141 }
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 286 of file Interpolate.cc.

287  {
288  if (n < 1) {
289  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "n must be greater than 0");
290  } else if (n > 4) {
291  return Interpolate::AKIMA_SPLINE;
292  } else {
293  static std::vector<Interpolate::Style> styles;
294  if (styles.empty()) {
295  styles.resize(5);
296 
297  styles[0] = Interpolate::UNKNOWN; // impossible to reach as we check for n < 1
298  styles[1] = Interpolate::CONSTANT;
299  styles[2] = Interpolate::LINEAR;
300  styles[3] = Interpolate::CUBIC_SPLINE;
301  styles[4] = Interpolate::CUBIC_SPLINE;
302  }
303  return styles[n];
304  }
305 }
metadata import lsst afw display as afwDisplay n
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
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 331 of file Interpolate.cc.

332  {
333  static std::vector<int> minPoints;
334  if (minPoints.empty()) {
335  minPoints.resize(Interpolate::NUM_STYLES);
336  minPoints[Interpolate::CONSTANT] = 1;
337  minPoints[Interpolate::LINEAR] = 2;
338  minPoints[Interpolate::NATURAL_SPLINE] = 3;
339  minPoints[Interpolate::CUBIC_SPLINE] = 3;
340  minPoints[Interpolate::CUBIC_SPLINE_PERIODIC] = 3;
341  minPoints[Interpolate::AKIMA_SPLINE] = 5;
342  minPoints[Interpolate::AKIMA_SPLINE_PERIODIC] = 5;
343  }
344 
345  if (style >= 0 && style < Interpolate::NUM_STYLES) {
346  return minPoints[style];
347  } else {
348  throw LSST_EXCEPT(pex::exceptions::OutOfRangeError,
349  str(boost::format("Style %d is out of range 0..%d")
350  % style % (Interpolate::NUM_STYLES - 1)));
351  }
352 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
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 
)

A factory function to make Approximate objects.

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

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
double x
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
#define PTR(...)
Definition: base.h:41
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 375 of file Interpolate.cc.

379 {
380  switch (style) {
381  case Interpolate::CONSTANT:
382  return PTR(Interpolate)(new InterpolateConstant(x, y, style));
383  default: // use GSL
384  return PTR(Interpolate)(new InterpolateGsl(x, y, style));
385  }
386 }
#define PTR(...)
Definition: base.h:41
boost::shared_ptr< Interpolate > lsst::afw::math::makeInterpolate ( ndarray::Array< double const, 1 > const &  x,
ndarray::Array< double const, 1 > const &  y,
Interpolate::Style const  style 
)

Definition at line 388 of file Interpolate.cc.

391 {
392  return makeInterpolate(std::vector<double>(x.begin(), x.end()), std::vector<double>(y.begin(), y.end()),
393  style);
394 }
int y
boost::shared_ptr< Interpolate > makeInterpolate(std::vector< double > const &x, std::vector< double > const &y, Interpolate::Style const style)
A factory function to make Interpolate objects.
Definition: Interpolate.cc:375
double x
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 1107 of file Statistics.cc.

1111  {
1112  return Statistics(msk, msk, msk, flags, sctrl);
1113 }
std::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 191 of file warpExposure.cc.

191  {
192  typedef std::shared_ptr<afwMath::SeparableKernel> KernelPtr;
193  boost::cmatch matches;
194  static const boost::regex LanczosRE("lanczos(\\d+)");
195  if (name == "bilinear") {
196  return KernelPtr(new BilinearWarpingKernel());
197  } else if (boost::regex_match(name.c_str(), matches, LanczosRE)) {
198  std::string orderStr(matches[1].first, matches[1].second);
199  int order;
200  std::istringstream(orderStr) >> order;
201  return KernelPtr(new LanczosWarpingKernel(order));
202  } else if (name == "nearest") {
203  return KernelPtr(new NearestWarpingKernel());
204  } else {
205  throw LSST_EXCEPT(pexExcept::InvalidParameterError,
206  "unknown warping kernel name: \"" + name + "\"");
207  }
208 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
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  buffImage->assign(inImage, box);
75  } else {
76  buffImage = std::make_shared<ImageT>(inImage);
77  }
78 
79  if (offsetKernel->getWidth() > buffImage->getWidth() ||
80  offsetKernel->getHeight() > buffImage->getHeight()) {
81  throw LSST_EXCEPT(pexExcept::LengthError,
82  (boost::format("Image of size %dx%d is too small to offset using a %s kernel"
83  "(minimum %dx%d)") %
84  buffImage->getWidth() % buffImage->getHeight() % algorithmName %
85  offsetKernel->getWidth() % offsetKernel->getHeight()).str());
86  }
87 
88 // typename ImageT::Ptr convImage(new ImageT(buffImage, true)); // output image, a deep copy
89  typename ImageT::Ptr convImage(new ImageT(buffImage->getDimensions())); // Convolved image
90 
91  int dOrigX, dOrigY;
92  double fracX, fracY;
93  // If the offset in both axes is in (-1, 1) use it as is, and don't shift the origin
94  if (dx > -1 && dx < 1 && dy > -1 && dy < 1) {
95  dOrigX = 0;
96  dOrigY = 0;
97  fracX = dx;
98  fracY = dy;
99  } else {
100  dOrigX = static_cast<int>(std::floor(dx + 0.5));
101  dOrigY = static_cast<int>(std::floor(dy + 0.5));
102  fracX = dx - dOrigX;
103  fracY = dy - dOrigY;
104  }
105 
106  // We seem to have to pass -fracX, -fracY to setKernelParameters, for reasons RHL doesn't understand
107  double dKerX = -fracX;
108  double dKerY = -fracY;
109 
110  //
111  // If the shift is -ve, the generated shift kernel (e.g. Lanczos5) is quite asymmetric, with the
112  // largest coefficients to the left of centre. We therefore move the centre of calculated shift kernel
113  // one to the right to center up the largest coefficients
114  //
115  if (dKerX < 0) {
116  offsetKernel->setCtrX(offsetKernel->getCtrX() + 1);
117  }
118  if (dKerY < 0) {
119  offsetKernel->setCtrY(offsetKernel->getCtrY() + 1);
120  }
121 
122  offsetKernel->setKernelParameters(std::make_pair(dKerX, dKerY));
123 
124  convolve(*convImage, *buffImage, *offsetKernel, true, true);
125 
126  typename ImageT::Ptr outImage;
127  if (buffer > 0) {
128  afwGeom::Box2I box(afwGeom::Point2I(buffer, buffer), inImage.getDimensions());
129  typename ImageT::Ptr out(new ImageT(*convImage, box, afwImage::LOCAL, true));
130  outImage = out;
131  } else {
132  outImage = convImage;
133  }
134 
135  // adjust the origin; do this after convolution since convolution also sets XY0
136  outImage->setXY0(geom::Point2I(inImage.getX0() + dOrigX, inImage.getY0() + dOrigY));
137 
138  return outImage;
139 }
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,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
Extent< int, N > floor(Extent< double, N > const &input)
Return the component-wise floor (round towards more negative).
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)
Set each pixel in an Image&lt;LhsT&gt; to 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)
Set each pixel in an Image&lt;LhsT&gt; to 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)
Set each pixel in an Image&lt;LhsT&gt; to 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)
Set each pixel in an Image&lt;LhsT&gt; to 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)
Set each pixel in an Image&lt;LhsT&gt; to 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)
Set each pixel in an Image&lt;LhsT&gt; to func()
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
metadata import lsst afw display as afwDisplay n
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)
Set each pixel in an Image&lt;LhsT&gt; to 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 43 of file rotateImage.cc.

45  {
46  typename ImageT::Ptr outImage; // output image
47 
48  while (nQuarter < 0) {
49  nQuarter += 4;
50  }
51 
52  switch (nQuarter%4) {
53  case 0:
54  outImage.reset(new ImageT(inImage, true)); // a deep copy of inImage
55  break;
56  case 1:
57  outImage.reset(new ImageT(afwGeom::Extent2I(inImage.getHeight(), inImage.getWidth())));
58 
59  for (int y = 0; y != inImage.getHeight(); ++y) {
60  typename ImageT::y_iterator optr = outImage->col_begin(inImage.getHeight() - y - 1);
61  for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
62  iptr != end; ++iptr, ++optr) {
63  *optr = *iptr;
64  }
65  }
66 
67  break;
68  case 2:
69  outImage.reset(new ImageT(inImage.getDimensions()));
70 
71  for (int y = 0; y != inImage.getHeight(); ++y) {
72  typename ImageT::x_iterator optr = outImage->x_at(inImage.getWidth() - 1,
73  inImage.getHeight() - y - 1);
74  for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
75  iptr != end; ++iptr, optr -= 1) {
76  *optr = *iptr;
77  }
78  }
79  break;
80  case 3:
81  outImage.reset(new ImageT(afwGeom::Extent2I(inImage.getHeight(), inImage.getWidth())));
82 
83  for (int y = 0; y != inImage.getHeight(); ++y) {
84  typename ImageT::y_iterator optr = outImage->y_at(y, inImage.getWidth() - 1);
85  for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
86  iptr != end; ++iptr, optr -= 1) {
87  *optr = *iptr;
88  }
89  }
90 
91  break;
92  }
93 
94  return outImage;
95 }
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 215 of file ConvolveImage.cc.

221 {
222  if (outImage.getDimensions() != inImage1.getDimensions()) {
223  std::ostringstream os;
224  os << "outImage dimensions = ( " << outImage.getWidth() << ", " << outImage.getHeight()
225  << ") != (" << inImage1.getWidth() << ", " << inImage1.getHeight()
226  << ") = inImage1 dimensions";
227  throw LSST_EXCEPT(pexExcept::InvalidParameterError, os.str());
228  } else if (inImage1.getDimensions() != inImage2.getDimensions()) {
229  std::ostringstream os;
230  os << "inImage1 dimensions = ( " << inImage1.getWidth() << ", " << inImage1.getHeight()
231  << ") != (" << inImage2.getWidth() << ", " << inImage2.getHeight()
232  << ") = inImage2 dimensions";
233  throw LSST_EXCEPT(pexExcept::InvalidParameterError, os.str());
234  }
235 
236  typedef typename InImageT::const_x_iterator InConstXIter;
237  typedef typename OutImageT::x_iterator OutXIter;
238  for (int y = 0; y != inImage1.getHeight(); ++y) {
239  InConstXIter const end1 = inImage1.row_end(y);
240  InConstXIter inIter1 = inImage1.row_begin(y);
241  InConstXIter inIter2 = inImage2.row_begin(y);
242  OutXIter outIter = outImage.row_begin(y);
243  for (; inIter1 != end1; ++inIter1, ++inIter2, ++outIter) {
244  *outIter = (*inIter1 * c1) + (*inIter2 * c2);
245  }
246  }
247 }
int y
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
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 >
std::shared_ptr<std::vector<PixelT> > lsst::afw::math::statisticsStack ( std::vector< std::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 263 of file Interpolate.cc.

265 {
266  static std::map<std::string, Interpolate::Style> gslInterpTypeStrings;
267  if (gslInterpTypeStrings.empty()) {
268  gslInterpTypeStrings["CONSTANT"] = Interpolate::CONSTANT;
269  gslInterpTypeStrings["LINEAR"] = Interpolate::LINEAR;
270  gslInterpTypeStrings["CUBIC_SPLINE"] = Interpolate::CUBIC_SPLINE;
271  gslInterpTypeStrings["NATURAL_SPLINE"] = Interpolate::NATURAL_SPLINE;
272  gslInterpTypeStrings["CUBIC_SPLINE_PERIODIC"] = Interpolate::CUBIC_SPLINE_PERIODIC;
273  gslInterpTypeStrings["AKIMA_SPLINE"] = Interpolate::AKIMA_SPLINE;
274  gslInterpTypeStrings["AKIMA_SPLINE_PERIODIC"] = Interpolate::AKIMA_SPLINE_PERIODIC;
275  }
276 
277  if ( gslInterpTypeStrings.find(style) == gslInterpTypeStrings.end()) {
278  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "Interp style not found: "+style);
279  }
280  return gslInterpTypeStrings[style];
281 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
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 717 of file Statistics.cc.

717  {
718  static std::map<std::string, Property> statisticsProperty;
719  if (statisticsProperty.size() == 0) {
720  statisticsProperty["NOTHING"] = NOTHING;
721  statisticsProperty["ERRORS"] = ERRORS;
722  statisticsProperty["NPOINT"] = NPOINT;
723  statisticsProperty["MEAN"] = MEAN;
724  statisticsProperty["STDEV"] = STDEV;
725  statisticsProperty["VARIANCE"] = VARIANCE;
726  statisticsProperty["MEDIAN"] = MEDIAN;
727  statisticsProperty["IQRANGE"] = IQRANGE;
728  statisticsProperty["MEANCLIP"] = MEANCLIP;
729  statisticsProperty["STDEVCLIP"] = STDEVCLIP;
730  statisticsProperty["VARIANCECLIP"] = VARIANCECLIP;
731  statisticsProperty["MIN"] = MIN;
732  statisticsProperty["MAX"] = MAX;
733  statisticsProperty["SUM"] = SUM;
734  statisticsProperty["MEANSQUARE"] = MEANSQUARE;
735  statisticsProperty["ORMASK"] = ORMASK;
736  }
737  return statisticsProperty[property];
738 }
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
estimate sample N-sigma clipped variance (N set in StatisticsControl, default=3)
Definition: Statistics.h:74
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 147 of file Background.cc.

147  {
148  static std::map<std::string, UndersampleStyle> undersampleStrings;
149  if (undersampleStrings.size() == 0) {
150  undersampleStrings["THROW_EXCEPTION"] = THROW_EXCEPTION;
151  undersampleStrings["REDUCE_INTERP_ORDER"] = REDUCE_INTERP_ORDER;
152  undersampleStrings["INCREASE_NXNYSAMPLE"] = INCREASE_NXNYSAMPLE;
153  }
154 
155  if (undersampleStrings.find(style) == undersampleStrings.end()) {
156  throw LSST_EXCEPT(ex::InvalidParameterError, "Understample style not defined: "+style);
157  }
158  return undersampleStrings[style];
159 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
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 564 of file warpExposure.cc.

571  {
572  // force src and dest to be the same size and xy0
573  if (
574  (destImage.getWidth() != srcImage.getWidth()) ||
575  (destImage.getHeight() != srcImage.getHeight()) ||
576  (destImage.getXY0() != srcImage.getXY0())
577  ) {
578  std::ostringstream errStream;
579  errStream << "src and dest images must have same size and xy0.";
580  throw LSST_EXCEPT(pexExcept::InvalidParameterError, errStream.str());
581  }
582 
583  // set the xy0 coords to 0,0 to make life easier
584  SrcImageT srcImageCopy(srcImage, true);
585  srcImageCopy.setXY0(0, 0);
586  destImage.setXY0(0, 0);
587  afwGeom::Extent2D cLocal = afwGeom::Extent2D(centerPosition) - afwGeom::Extent2D(srcImage.getXY0());
588 
589  // for the affine transform, the centerPosition will not only get sheared, but also
590  // moved slightly. So we'll include a translation to move it back by an amount
591  // centerPosition - translatedCenterPosition
592  afwGeom::AffineTransform affTran(linearTransform, cLocal - linearTransform(cLocal));
593  afwGeom::AffineXYTransform affXYTransform(affTran);
594 
595  // now warp
596 #if 0
597  static float t = 0.0;
598  float t_before = 1.0*clock()/CLOCKS_PER_SEC;
599  int n = warpImage(destImage, srcImageCopy, affTran, control, padValue);
600  float t_after = 1.0*clock()/CLOCKS_PER_SEC;
601  float dt = t_after - t_before;
602  t += dt;
603  std::cout <<srcImage.getWidth()<<"x"<<srcImage.getHeight()<<": "<< dt <<" "<< t <<std::endl;
604 #else
605  int n = warpImage(destImage, srcImageCopy, affXYTransform, control, padValue);
606 #endif
607 
608  // fix the origin and we're done.
609  destImage.setXY0(srcImage.getXY0());
610 
611  return n;
612 }
Extent< double, 2 > Extent2D
Definition: Extent.h:361
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.
metadata import lsst afw display as afwDisplay n
An affine coordinate transformation consisting of a linear transformation and an offset.
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
Wrap an AffineTransform.
Definition: XYTransform.h:152
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 282 of file warpExposure.cc.

288 {
289  if (!destExposure.hasWcs()) {
290  throw LSST_EXCEPT(pexExcept::InvalidParameterError, "destExposure has no Wcs");
291  }
292  if (!srcExposure.hasWcs()) {
293  throw LSST_EXCEPT(pexExcept::InvalidParameterError, "srcExposure has no Wcs");
294  }
295  typename DestExposureT::MaskedImageT mi = destExposure.getMaskedImage();
296  std::shared_ptr<afwImage::Calib> calibCopy(new afwImage::Calib(*srcExposure.getCalib()));
297  destExposure.setCalib(calibCopy);
298  destExposure.setFilter(srcExposure.getFilter());
299  return warpImage(mi, *destExposure.getWcs(), srcExposure.getMaskedImage(), *srcExposure.getWcs(),
300  control, padValue);
301 }
Describe an exposure&#39;s calibration.
Definition: Calib.h:82
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.
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
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).

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
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 534 of file warpExposure.cc.

541  {
542  afwGeom::Point2D const destXY0(destImage.getXY0());
543  afwImage::XYTransformFromWcsPair xyTransform{destWcs.clone(), srcWcs.clone()};
544  afwMath::detail::XYTransformPositionFunctor const computeSrcPos{destXY0, xyTransform};
545  return doWarpImage(destImage, srcImage, computeSrcPos, control, padValue);
546 }
XYTransformFromWcsPair: An XYTransform obtained by putting two Wcs objects &quot;back to back&quot;...
Definition: Wcs.h:449
A coordinate class intended to represent absolute positions.
virtual boost::shared_ptr< afw::geom::XYTransform > clone() const
The following methods are needed to devirtualize the XYTransform parent class.
Definition: Wcs.cc:1292
template<typename DestImageT , typename SrcImageT >
int lsst::afw::math::warpImage ( DestImageT &  destImage,
SrcImageT const &  srcImage,
lsst::afw::geom::XYTransform const &  xyTransform,
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 XYTransform instead of a pair of WCS to describe the transformation.

Parameters
destImageremapped image
srcImagesource image
xyTransformxy transform mapping source position to destination position in the forward direction (but only the reverse direction is used)
controlcontrol parameters
padValueuse this value for undefined (edge) pixels

Definition at line 550 of file warpExposure.cc.

556  {
557  afwGeom::Point2D const destXY0(destImage.getXY0());
558  afwMath::detail::XYTransformPositionFunctor const computeSrcPos(destXY0, xyTransform);
559  return doWarpImage(destImage, srcImage, computeSrcPos, control, padValue);
560 }
A coordinate class intended to represent absolute positions.

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.