25 #ifndef LSST_AFW_MATH_KERNEL_H 26 #define LSST_AFW_MATH_KERNEL_H 31 #include <type_traits> 35 #include "boost/mpl/or.hpp" 144 explicit Kernel(
int width,
int height,
unsigned int nKernelParams,
211 double y = 0.0)
const;
219 _width = dims.getX();
220 _height = dims.getY();
222 inline void setWidth(
int width) { _width = width; }
363 spatialParams.
push_back((*spFuncIter)->getParameters());
365 return spatialParams;
384 if (nParams != params.
size()) {
386 (
boost::format(
"Number of parameters is wrong, saw %d expected %d") % nParams %
390 for (
unsigned int ii = 0; ii < nParams; ++ii) {
443 #if 0 // fails to compile with icc; is it actually used? 494 unsigned int _nKernelParams;
497 virtual void _setKernelXY() {}
542 virtual Pixel
getSum()
const {
return _sum; }
611 explicit AnalyticKernel(
int width,
int height, KernelFunction
const &kernelFunction,
646 double y = 0.0)
const;
653 virtual KernelFunctionPtr getKernelFunction()
const;
796 virtual KernelList
const &getKernelList()
const;
813 void checkKernelList(
const KernelList &kernelList)
const;
875 void _setKernelList(KernelList
const &kernelList);
877 KernelList _kernelList;
882 bool _isDeltaFunctionBasis;
920 explicit SeparableKernel(
int width,
int height, KernelFunction
const &kernelColFunction,
921 KernelFunction
const &kernelRowFunction,
937 explicit SeparableKernel(
int width,
int height, KernelFunction
const &kernelColFunction,
938 KernelFunction
const &kernelRowFunction,
969 double x = 0.0,
double y = 0.0)
const;
972 unsigned int const ncol = _kernelColFunctionPtr->getNParameters();
974 return _kernelColFunctionPtr->getParameter(i);
977 return _kernelRowFunctionPtr->getParameter(i);
985 KernelFunctionPtr getKernelColFunction()
const;
990 KernelFunctionPtr getKernelRowFunction()
const;
1030 bool doNormalize)
const;
1032 KernelFunctionPtr _kernelColFunctionPtr;
1033 KernelFunctionPtr _kernelRowFunctionPtr;
1044 virtual void _setKernelXY()
override {
1048 assert(dim[0] == static_cast<int>(_kernelX.
size()));
1049 for (
int i = 0; i != dim.getX(); ++i) {
1050 _kernelX[i] = i - ctr.getX();
1053 assert(dim[1] == static_cast<int>(_kernelY.
size()));
1054 for (
int i = 0; i != dim.getY(); ++i) {
1055 _kernelY[i] = i - ctr.getY();
1063 #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.
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.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
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.
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
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.