25 #ifndef LSST_AFW_MATH_KERNEL_H 26 #define LSST_AFW_MATH_KERNEL_H 31 #include <type_traits> 35 #include "boost/mpl/or.hpp" 141 explicit Kernel(
int width,
int height,
unsigned int nKernelParams,
208 double y = 0.0)
const;
216 _width = dims.getX();
217 _height = dims.getY();
219 inline void setWidth(
int width) { _width = width; }
360 spatialParams.
push_back((*spFuncIter)->getParameters());
362 return spatialParams;
381 if (nParams != params.
size()) {
383 (
boost::format(
"Number of parameters is wrong, saw %d expected %d") % nParams %
387 for (
unsigned int ii = 0; ii < nParams; ++ii) {
440 #if 0 // fails to compile with icc; is it actually used? 491 unsigned int _nKernelParams;
494 virtual void _setKernelXY() {}
539 virtual Pixel
getSum()
const {
return _sum; }
608 explicit AnalyticKernel(
int width,
int height, KernelFunction
const &kernelFunction,
643 double y = 0.0)
const;
650 virtual KernelFunctionPtr getKernelFunction()
const;
793 virtual KernelList
const &getKernelList()
const;
810 void checkKernelList(
const KernelList &kernelList)
const;
872 void _setKernelList(KernelList
const &kernelList);
874 KernelList _kernelList;
879 bool _isDeltaFunctionBasis;
917 explicit SeparableKernel(
int width,
int height, KernelFunction
const &kernelColFunction,
918 KernelFunction
const &kernelRowFunction,
934 explicit SeparableKernel(
int width,
int height, KernelFunction
const &kernelColFunction,
935 KernelFunction
const &kernelRowFunction,
966 double x = 0.0,
double y = 0.0)
const;
969 unsigned int const ncol = _kernelColFunctionPtr->getNParameters();
971 return _kernelColFunctionPtr->getParameter(i);
974 return _kernelRowFunctionPtr->getParameter(i);
982 KernelFunctionPtr getKernelColFunction()
const;
987 KernelFunctionPtr getKernelRowFunction()
const;
1027 bool doNormalize)
const;
1029 KernelFunctionPtr _kernelColFunctionPtr;
1030 KernelFunctionPtr _kernelRowFunctionPtr;
1041 virtual void _setKernelXY()
override {
1045 assert(dim[0] == static_cast<int>(_kernelX.
size()));
1046 for (
int i = 0; i != dim.getX(); ++i) {
1047 _kernelX[i] = i - ctr.getX();
1050 assert(dim[1] == static_cast<int>(_kernelY.
size()));
1051 for (
int i = 0; i != dim.getY(); ++i) {
1052 _kernelY[i] = i - ctr.getY();
1060 #endif // !defined(LSST_AFW_MATH_KERNEL_H)
virtual int getCacheSize() const
Get the current size of the kernel cache (0 if none or if caches not supported)
int getHeight() const
Return the Kernel's height.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
int getCtrX() const
Return x index of kernel's center.
int getCtrY() const
Return y index of kernel's center.
std::shared_ptr< KernelFunction > KernelFunctionPtr
afw::table::Key< int > cacheSize
virtual Pixel getSum() const
virtual void computeCache(int const)
Compute a cache of Kernel values, if desired.
An object passed to Persistable::write to allow it to persist itself.
virtual void setKernelParameter(unsigned int ind, double value) const
Set one kernel parameter.
lsst::afw::math::Function1< Pixel > KernelFunction
virtual double getKernelParameter(unsigned int i) const
Return a particular Kernel Parameter (no bounds checking).
void setKernelParameters(std::vector< double > const ¶ms)
Set the kernel parameters of a spatially invariant kernel.
Kernel & operator=(const Kernel &)=delete
A kernel described by a pair of functions: func(x, y) = colFunc(x) * rowFunc(y)
std::shared_ptr< lsst::afw::math::Function2< double > > SpatialFunctionPtr
double getKernelParameter(unsigned int i) const override
Return a particular Kernel Parameter (no bounds checking).
void setHeight(int height)
bool isDeltaFunctionBasis() const
Return true if all basis kernels are instances of DeltaFunctionKernel.
lsst::afw::math::NullFunction2< double > NullSpatialFunction
std::string getPythonModule() const override
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
lsst::afw::math::Function2< double > SpatialFunction
A Function taking two arguments.
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
int getNBasisKernels() const
Get the number of basis kernels.
virtual void write(OutputArchiveHandle &handle) const
Write the object to one or more catalogs.
A base class for objects that can be persisted via afw::table::io Archive classes.
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
a class used in function calls to indicate that no Function2 is being provided
bool isSpatiallyVarying() const
Return true iff the kernel is spatially varying (has a spatial function)
void setCtrY(int ctrY)
Set y index of kernel's center.
KernelFunctionPtr _kernelFunctionPtr
A base class for image defects.
std::vector< SpatialFunctionPtr > getSpatialFunctionList() const
Return a list of clones of the spatial functions.
lsst::geom::Box2I getBBox() const
return parent bounding box, with XY0 = -center
lsst::geom::Box2I growBBox(lsst::geom::Box2I const &bbox) const
Given a bounding box for pixels one wishes to compute by convolving an image with this kernel...
void setCtrX(int ctrX)
Set x index of kernel's center.
void computeKernelParametersFromSpatialModel(std::vector< double > &kernelParams, double x, double y) const
Compute the kernel parameters at a specified point.
A kernel that is a linear combination of fixed basis kernels.
void setKernelParameters(std::pair< double, double > const ¶ms)
Set the kernel parameters of a 2-component spatially invariant kernel.
virtual std::shared_ptr< Kernel > resized(int width, int height) const =0
Return a pointer to a clone with specified kernel dimensions.
A Function taking one argument.
lsst::geom::Point2I getCtr() const
Return index of kernel's center.
SpatialFunctionPtr getSpatialFunction(unsigned int index) const
Return a clone of the specified spatial function (one component of the spatial model) ...
double computeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize, double x=0.0, double y=0.0) const
Compute an image (pixellized representation of the kernel) in place.
void setDimensions(lsst::geom::Extent2I dims)
void setCtr(lsst::geom::Point2I ctr)
Set index of kernel's center.
virtual std::vector< double > getKernelParameters() const
Return the current kernel parameters.
generic_kernel_tag kernel_fill_factor
void setKernelParametersFromSpatialModel(double x, double y) const
Set the kernel parameters from the spatial model (if any).
int getWidth() const
Return the Kernel's width.
lsst::geom::Extent2I const getDimensions() const
Return the Kernel's dimensions (width, height)
unsigned int getNKernelParameters() const
Return the number of kernel parameters (0 if none)
void setSpatialParameters(const std::vector< std::vector< double >> params)
Set the parameters of all spatial functions.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Extent< int, 2 > Extent2I
Kernel has only one non-zero pixel.
table::Key< int > kernelFunction
lsst::geom::Box2I shrinkBBox(lsst::geom::Box2I const &bbox) const
Given a bounding box for an image one wishes to convolve with this kernel, return the bounding box fo...
std::vector< std::shared_ptr< Kernel > > KernelList
std::vector< SpatialFunctionPtr > _spatialFunctionList
lsst::afw::math::Function2< Pixel > KernelFunction
Kernel()
Construct a null Kernel of size 0,0.
virtual double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const =0
Low-level version of computeImage.
int getNSpatialParameters() const
Return the number of spatial parameters (0 if not spatially varying)
Reports invalid arguments.
std::vector< std::vector< double > > getSpatialParameters() const
Return the spatial parameters parameters (an empty vector if not spatially varying) ...
~Kernel() override=default
virtual std::string getPersistenceName() const
Return the unique name used to persist this object and look up its factory.
lsst::geom::Point2I getPixel() const
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...
deltafunction_kernel_tag kernel_fill_factor
A kernel described by a function.
std::shared_ptr< lsst::afw::math::Function2< Pixel > > KernelFunctionPtr
A CRTP facade class for subclasses of Persistable.
Kernels are used for convolution with MaskedImages and (eventually) Images.
An integer coordinate rectangle.
A kernel that has only one non-zero pixel (of value 1)
virtual std::shared_ptr< Kernel > clone() const =0
Return a pointer to a deep copy of this kernel.
virtual std::string toString(std::string const &prefix="") const
Return a string representation of the kernel.
Tags carrying information about Kernels Kernel with no special properties.
A kernel created from an Image.
Reports errors that are due to events beyond the control of the program.