Class AnalyticKernel

Inheritance Relationships

Base Types

Class Documentation

class AnalyticKernel : public lsst::afw::table::io::PersistableFacade<AnalyticKernel>, public lsst::afw::math::Kernel

A kernel described by a function.

The function’s x, y arguments are as follows:

  • -getCtr() for the lower left corner pixel

  • 0, 0 for the center pixel

  • (getDimensions() - 1) - getCtr() for the upper right pixel

Note: each pixel is set to the value of the kernel function at the center of the pixel (rather than averaging the function over the area of the pixel).

Public Types

typedef lsst::afw::math::Function2<Pixel> KernelFunction
typedef std::shared_ptr<lsst::afw::math::Function2<Pixel>> KernelFunctionPtr

Public Functions

AnalyticKernel()

Construct an empty spatially invariant AnalyticKernel of size 0x0

AnalyticKernel(int width, int height, KernelFunction const &kernelFunction, Kernel::SpatialFunction const &spatialFunction = NullSpatialFunction())

Construct a spatially invariant AnalyticKernel, or a spatially varying AnalyticKernel where the spatial model is described by one function (that is cloned to give one per analytic function parameter).

Parameters
  • width: width of kernel

  • height: height of kernel

  • kernelFunction: kernel function; a deep copy is made

  • spatialFunction: spatial function; one deep copy is made for each kernel function parameter; if omitted or set to Kernel::NullSpatialFunction() then the kernel is spatially invariant

AnalyticKernel(int width, int height, KernelFunction const &kernelFunction, std::vector<Kernel::SpatialFunctionPtr> const &spatialFunctionList)

Construct a spatially varying AnalyticKernel, where the spatial model is described by a list of functions (one per analytic function parameter).

Parameters
  • width: width of kernel

  • height: height of kernel

  • kernelFunction: kernel function; a deep copy is made

  • spatialFunctionList: list of spatial functions, one per kernel function parameter; a deep copy is made of each function

Exceptions
  • lsst::pex::exceptions::InvalidParameterError: if the length of spatialFunctionList != # kernel function parameters.

AnalyticKernel(const AnalyticKernel&)
AnalyticKernel(AnalyticKernel&&)
AnalyticKernel &operator=(const AnalyticKernel&)
AnalyticKernel &operator=(AnalyticKernel&&)
~AnalyticKernel()
std::shared_ptr<Kernel> clone() const

Return a pointer to a deep copy of this kernel

This kernel exists instead of a copy constructor so one can obtain a copy of an actual kernel instead of a useless copy of the base class.

Every kernel subclass must override this method.

Return

a pointer to a deep copy of the kernel

std::shared_ptr<Kernel> resized(int width, int height) const

Return a pointer to a clone with specified kernel dimensions

Must be implemented by derived classes.

Return

a pointer to a clone with new dimensions.

Parameters
  • width: Number of columns in pixels

  • height: Number of rows in pixels

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

This special version accepts any size image (though you can get in trouble if the image is large enough that the image is evaluated outside its domain).

Return

The kernel sum

Note

computeNewImage has been retired; it doesn’t need to be a member

Parameters
  • image: image whose pixels are to be set (output) xy0 of the image will be set to -kernel.getCtr() - border, where border = (image.getDimensions() - kernel.getDimensions()) / 2

  • doNormalize: normalize the image (so sum is 1)?

  • x: x (column position) at which to compute spatial function

  • y: y (row position) at which to compute spatial function

Exceptions
  • lsst::pex::exceptions::InvalidParameterError: if the image is the wrong size

  • lsst::pex::exceptions::OverflowError: if doNormalize is true and the kernel sum is exactly 0

std::vector<double> getKernelParameters() const

Return the current kernel parameters

If the kernel is spatially varying then the parameters are those last computed. See also computeKernelParametersFromSpatialModel. If there are no kernel parameters then returns an empty vector.

virtual KernelFunctionPtr getKernelFunction() const

Get a deep copy of the kernel function

std::string toString(std::string const &prefix = "") const

Return a string representation of the kernel

bool isPersistable() const

Return true if this particular object can be persisted using afw::table::io.

Protected Functions

double doComputeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize) const

Low-level version of computeImage

Before this is called the image dimensions are checked, the image’s xy0 is set and the kernel’s parameters are set. This routine sets the pixels, including normalization if requested.

Return

The kernel sum

Parameters
  • image: image whose pixels are to be set (output)

  • doNormalize: normalize the image (so sum is 1)?

std::string getPersistenceName() const

Return the unique name used to persist this object and look up its factory.

Must be less than ArchiveIndexSchema::MAX_NAME_LENGTH characters.

void write(OutputArchiveHandle &handle) const

Write the object to one or more catalogs.

The handle object passed to this function provides an interface for adding new catalogs and adding nested objects to the same archive (while checking for duplicates). See OutputArchiveHandle for more information.

void setKernelParameter(unsigned int ind, double value) const

Set one kernel parameter

Classes that have kernel parameters must subclass this function.

This function is marked “const”, despite modifying unimportant internals, so that computeImage can be const.

Exceptions
  • lsst::pex::exceptions::InvalidParameterError: always (unless subclassed)

Protected Attributes

KernelFunctionPtr _kernelFunctionPtr