LSSTApplications  20.0.0
LSSTDataManagementBasePackage
Kernel.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008-2016 AURA/LSST.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 
25 #ifndef LSST_AFW_MATH_KERNEL_H
26 #define LSST_AFW_MATH_KERNEL_H
27 /*
28  * Declare the Kernel class and subclasses.
29  */
30 #include <memory>
31 #include <type_traits>
32 #include <utility>
33 #include <vector>
34 
35 #include "boost/mpl/or.hpp"
36 
37 #include "lsst/geom.h"
38 #include "lsst/afw/image/Image.h"
39 #include "lsst/afw/image/Utils.h"
40 #include "lsst/afw/math/Function.h"
41 #include "lsst/afw/math/traits.h"
42 
44 
45 namespace lsst {
46 namespace afw {
47 
48 namespace math {
49 
112 public:
113  typedef double Pixel;
117 
118  // Traits values for this class of Kernel
120 
126  explicit Kernel();
127 
141  explicit Kernel(int width, int height, unsigned int nKernelParams,
142  SpatialFunction const &spatialFunction = NullSpatialFunction());
143 
155  explicit Kernel(int width, int height, const std::vector<SpatialFunctionPtr> spatialFunctionList);
156 
157  // prevent copying and assignment (to avoid problems from type slicing)
158  Kernel(const Kernel &) = delete;
159  Kernel(Kernel &&) = delete;
160  Kernel &operator=(const Kernel &) = delete;
161  Kernel &operator=(Kernel &&) = delete;
162 
163  ~Kernel() override = default;
164 
176  virtual std::shared_ptr<Kernel> clone() const = 0;
177 
188  virtual std::shared_ptr<Kernel> resized(int width, int height) const = 0;
189 
207  double computeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize, double x = 0.0,
208  double y = 0.0) const;
209 
213  lsst::geom::Extent2I const getDimensions() const { return lsst::geom::Extent2I(_width, _height); }
214 
216  _width = dims.getX();
217  _height = dims.getY();
218  }
219  inline void setWidth(int width) { _width = width; }
220  inline void setHeight(int height) { _height = height; }
221 
225  inline int getWidth() const { return _width; }
226 
230  inline int getHeight() const { return _height; }
231 
235  inline lsst::geom::Point2I getCtr() const { return lsst::geom::Point2I(_ctrX, _ctrY); }
236 
242  [[deprecated("Use `getCtr` instead. To be removed after 20.0.0.")]] // DM-22814
243  inline int
244  getCtrX() const {
245  return _ctrX;
246  }
247 
253  [[deprecated("Use `getCtr` instead. To be removed after 20.0.0.")]] // DM-22814
254  inline int
255  getCtrY() const {
256  return _ctrY;
257  }
258 
262  inline lsst::geom::Box2I getBBox() const {
263  return lsst::geom::Box2I(lsst::geom::Point2I(-_ctrX, -_ctrY), lsst::geom::Extent2I(_width, _height));
264  }
265 
269  inline unsigned int getNKernelParameters() const { return _nKernelParams; }
270 
274  inline int getNSpatialParameters() const {
275  return this->isSpatiallyVarying() ? _spatialFunctionList[0]->getNParameters() : 0;
276  }
277 
288  SpatialFunctionPtr getSpatialFunction(unsigned int index) const;
289 
297 
300  virtual double getKernelParameter(unsigned int i) const { return getKernelParameters()[i]; }
301 
310 
319 
331 
335  inline void setCtr(lsst::geom::Point2I ctr) {
336  _ctrX = ctr.getX();
337  _ctrY = ctr.getY();
338  _setKernelXY();
339  }
340 
346  [[deprecated("Use `setCtr` instead. To be removed after 20.0.0.")]] // DM-22814
347  inline void
348  setCtrX(int ctrX) {
349  _ctrX = ctrX;
350  _setKernelXY();
351  }
352 
358  [[deprecated("Use `setCtr` instead. To be removed after 20.0.0.")]] // DM-22814
359  inline void
360  setCtrY(int ctrY) {
361  _ctrY = ctrY;
362  _setKernelXY();
363  }
364 
369  std::vector<std::vector<double>> spatialParams;
371  for (; spFuncIter != _spatialFunctionList.end(); ++spFuncIter) {
372  spatialParams.push_back((*spFuncIter)->getParameters());
373  }
374  return spatialParams;
375  }
376 
380  inline bool isSpatiallyVarying() const { return _spatialFunctionList.size() != 0; }
381 
388  inline void setKernelParameters(std::vector<double> const &params) {
389  if (this->isSpatiallyVarying()) {
390  throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError, "Kernel is spatially varying");
391  }
392  const unsigned int nParams = this->getNKernelParameters();
393  if (nParams != params.size()) {
395  (boost::format("Number of parameters is wrong, saw %d expected %d") % nParams %
396  params.size())
397  .str());
398  }
399  for (unsigned int ii = 0; ii < nParams; ++ii) {
400  this->setKernelParameter(ii, params[ii]);
401  }
402  }
403 
410  inline void setKernelParameters(std::pair<double, double> const &params) {
411  this->setKernelParameter(0, params.first);
412  this->setKernelParameter(1, params.second);
413  }
414 
424 
431  void computeKernelParametersFromSpatialModel(std::vector<double> &kernelParams, double x, double y) const;
432 
436  virtual std::string toString(std::string const &prefix = "") const;
437 
444  virtual void computeCache(int const
445  ) {}
446 
450  virtual int getCacheSize() const { return 0; };
451 
452 #if 0 // fails to compile with icc; is it actually used?
453  virtual void toFile(std::string fileName) const;
454 #endif
455 
456  struct PersistenceHelper;
457 
458 protected:
459  std::string getPythonModule() const override;
460 
471  virtual void setKernelParameter(unsigned int ind, double value) const;
472 
481  void setKernelParametersFromSpatialModel(double x, double y) const;
482 
494  virtual double doComputeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize) const = 0;
495 
497 
498 private:
499  int _width;
500  int _height;
501  int _ctrX;
502  int _ctrY;
503  unsigned int _nKernelParams;
504 
505  // Set the Kernel's ideas about the x- and y- coordinates
506  virtual void _setKernelXY() {}
507 };
508 
510 
518 class FixedKernel : public afw::table::io::PersistableFacade<FixedKernel>, public Kernel {
519 public:
523  explicit FixedKernel();
524 
529  );
530 
534  explicit FixedKernel(lsst::afw::math::Kernel const &kernel,
535  lsst::geom::Point2D const &pos
536  );
537 
538  FixedKernel(const FixedKernel &) = delete;
539  FixedKernel(FixedKernel &&) = delete;
540  FixedKernel &operator=(const FixedKernel &) = delete;
542 
543  ~FixedKernel() override = default;
544 
545  std::shared_ptr<Kernel> clone() const override;
546 
547  std::shared_ptr<Kernel> resized(int width, int height) const override;
548 
549  std::string toString(std::string const &prefix = "") const override;
550 
551  virtual Pixel getSum() const { return _sum; }
552 
553  bool isPersistable() const noexcept override { return true; }
554 
555  class Factory;
556 
557 protected:
558  double doComputeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize) const override;
559 
560  std::string getPersistenceName() const override;
561 
562  void write(OutputArchiveHandle &handle) const override;
563 
564 private:
566  Pixel _sum;
567 };
568 
582 class AnalyticKernel : public afw::table::io::PersistableFacade<AnalyticKernel>, public Kernel {
583 public:
586 
590  explicit AnalyticKernel();
591 
604  explicit AnalyticKernel(int width, int height, KernelFunction const &kernelFunction,
605  Kernel::SpatialFunction const &spatialFunction = NullSpatialFunction());
606 
620  explicit AnalyticKernel(int width, int height, KernelFunction const &kernelFunction,
621  std::vector<Kernel::SpatialFunctionPtr> const &spatialFunctionList);
622 
623  AnalyticKernel(const AnalyticKernel &) = delete;
627 
628  ~AnalyticKernel() override = default;
629 
630  std::shared_ptr<Kernel> clone() const override;
631 
632  std::shared_ptr<Kernel> resized(int width, int height) const override;
633 
654  double computeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize, double x = 0.0,
655  double y = 0.0) const;
656 
657  std::vector<double> getKernelParameters() const override;
658 
662  virtual KernelFunctionPtr getKernelFunction() const;
663 
664  std::string toString(std::string const &prefix = "") const override;
665 
666  bool isPersistable() const noexcept override { return true; }
667 
668  class Factory;
669 
670 protected:
671  double doComputeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize) const override;
672 
673  std::string getPersistenceName() const override;
674 
675  void write(OutputArchiveHandle &handle) const override;
676 
677 protected:
678  void setKernelParameter(unsigned int ind, double value) const override;
679 
681 };
682 
690 class DeltaFunctionKernel : public afw::table::io::PersistableFacade<DeltaFunctionKernel>, public Kernel {
691 public:
692  // Traits values for this class of Kernel
694 
704  explicit DeltaFunctionKernel(int width, int height, lsst::geom::Point2I const &point);
705 
710 
711  ~DeltaFunctionKernel() override = default;
712 
713  std::shared_ptr<Kernel> clone() const override;
714 
715  std::shared_ptr<Kernel> resized(int width, int height) const override;
716 
717  lsst::geom::Point2I getPixel() const { return _pixel; }
718 
719  std::string toString(std::string const &prefix = "") const override;
720 
721  bool isPersistable() const noexcept override { return true; }
722 
723  class Factory;
724 
725 protected:
726  double doComputeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize) const override;
727 
728  std::string getPersistenceName() const override;
729 
730  void write(OutputArchiveHandle &handle) const override;
731 
732 private:
733  lsst::geom::Point2I _pixel;
734 };
735 
750 class LinearCombinationKernel : public afw::table::io::PersistableFacade<LinearCombinationKernel>,
751  public Kernel {
752 public:
756  explicit LinearCombinationKernel();
757 
764  explicit LinearCombinationKernel(KernelList const &kernelList,
765  std::vector<double> const &kernelParameters);
766 
774  explicit LinearCombinationKernel(KernelList const &kernelList,
775  Kernel::SpatialFunction const &spatialFunction);
776 
786  explicit LinearCombinationKernel(KernelList const &kernelList,
787  std::vector<Kernel::SpatialFunctionPtr> const &spatialFunctionList);
788 
793 
794  ~LinearCombinationKernel() override = default;
795 
796  std::shared_ptr<Kernel> clone() const override;
797 
798  std::shared_ptr<Kernel> resized(int width, int height) const override;
799 
800  std::vector<double> getKernelParameters() const override;
801 
805  virtual KernelList const &getKernelList() const;
806 
811 
815  int getNBasisKernels() const { return static_cast<int>(_kernelList.size()); };
816 
822  void checkKernelList(const KernelList &kernelList) const;
823 
827  bool isDeltaFunctionBasis() const { return _isDeltaFunctionBasis; };
828 
864 
865  std::string toString(std::string const &prefix = "") const override;
866 
867  bool isPersistable() const noexcept override { return true; }
868 
869  class Factory;
870 
871 protected:
872  double doComputeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize) const override;
873 
874  std::string getPersistenceName() const override;
875 
876  void write(OutputArchiveHandle &handle) const override;
877 
878  void setKernelParameter(unsigned int ind, double value) const override;
879 
880 private:
884  void _setKernelList(KernelList const &kernelList);
885 
886  KernelList _kernelList;
889  std::vector<double> _kernelSumList;
890  mutable std::vector<double> _kernelParams;
891  bool _isDeltaFunctionBasis;
892 };
893 
907 class SeparableKernel : public afw::table::io::PersistableFacade<SeparableKernel>, public Kernel {
908 public:
911 
915  explicit SeparableKernel();
916 
929  explicit SeparableKernel(int width, int height, KernelFunction const &kernelColFunction,
930  KernelFunction const &kernelRowFunction,
931  Kernel::SpatialFunction const &spatialFunction = NullSpatialFunction());
932 
946  explicit SeparableKernel(int width, int height, KernelFunction const &kernelColFunction,
947  KernelFunction const &kernelRowFunction,
948  std::vector<Kernel::SpatialFunctionPtr> const &spatialFunctionList);
949 
950  SeparableKernel(const SeparableKernel &) = delete;
954 
955  ~SeparableKernel() override = default;
956 
957  std::shared_ptr<Kernel> clone() const override;
958 
959  std::shared_ptr<Kernel> resized(int width, int height) const override;
960 
977  double computeVectors(std::vector<Pixel> &colList, std::vector<Pixel> &rowList, bool doNormalize,
978  double x = 0.0, double y = 0.0) const;
979 
980  double getKernelParameter(unsigned int i) const override {
981  unsigned int const ncol = _kernelColFunctionPtr->getNParameters();
982  if (i < ncol) {
983  return _kernelColFunctionPtr->getParameter(i);
984  } else {
985  i -= ncol;
986  return _kernelRowFunctionPtr->getParameter(i);
987  }
988  }
989  std::vector<double> getKernelParameters() const override;
990 
995 
1000 
1001  std::string toString(std::string const &prefix = "") const override;
1002 
1003  /***
1004  * Compute a cache of values for the x and y kernel functions
1005  *
1006  * A value of 0 disables the cache for maximum accuracy.
1007  * 10,000 typically results in a warping error of a fraction of a count.
1008  * 100,000 typically results in a warping error of less than 0.01 count.
1009  *
1010  * @param cacheSize cache size (number of double precision array elements in the x and y caches)
1011  */
1012  void computeCache(int const cacheSize) override;
1013 
1017  int getCacheSize() const override;
1018 
1019 protected:
1020  double doComputeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize) const override;
1021 
1022  void setKernelParameter(unsigned int ind, double value) const override;
1023 
1024 private:
1038  double basicComputeVectors(std::vector<Pixel> &colList, std::vector<Pixel> &rowList,
1039  bool doNormalize) const;
1040 
1041  KernelFunctionPtr _kernelColFunctionPtr;
1042  KernelFunctionPtr _kernelRowFunctionPtr;
1043  mutable std::vector<Pixel> _localColList; // used by doComputeImage
1044  mutable std::vector<Pixel> _localRowList;
1045  mutable std::vector<double> _kernelX; // used by SeparableKernel::basicComputeVectors
1046  mutable std::vector<double> _kernelY;
1047  //
1048  // Cached values of the row- and column- kernels
1049  //
1050  mutable std::vector<std::vector<double>> _kernelRowCache;
1051  mutable std::vector<std::vector<double>> _kernelColCache;
1052 
1053  virtual void _setKernelXY() override {
1054  lsst::geom::Extent2I const dim = getDimensions();
1055  lsst::geom::Point2I const ctr = getCtr();
1056 
1057  assert(dim[0] == static_cast<int>(_kernelX.size()));
1058  for (int i = 0; i != dim.getX(); ++i) {
1059  _kernelX[i] = i - ctr.getX();
1060  }
1061 
1062  assert(dim[1] == static_cast<int>(_kernelY.size()));
1063  for (int i = 0; i != dim.getY(); ++i) {
1064  _kernelY[i] = i - ctr.getY();
1065  }
1066  }
1067 };
1068 } // namespace math
1069 } // namespace afw
1070 } // namespace lsst
1071 
1072 #endif // !defined(LSST_AFW_MATH_KERNEL_H)
y
int y
Definition: SpanSet.cc:49
lsst::afw::math::AnalyticKernel::operator=
AnalyticKernel & operator=(AnalyticKernel &&)=delete
lsst::afw::image
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Definition: imageAlgorithm.dox:1
lsst::afw::math::Kernel::getBBox
lsst::geom::Box2I getBBox() const
return parent bounding box, with XY0 = -center
Definition: Kernel.h:262
lsst::afw::math::Kernel::setKernelParametersFromSpatialModel
void setKernelParametersFromSpatialModel(double x, double y) const
Set the kernel parameters from the spatial model (if any).
Definition: Kernel.cc:228
lsst::afw::math::Kernel::setKernelParameter
virtual void setKernelParameter(unsigned int ind, double value) const
Set one kernel parameter.
Definition: Kernel.cc:224
lsst::afw::math::SeparableKernel::resized
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
Definition: SeparableKernel.cc:111
lsst::afw::math::SeparableKernel::operator=
SeparableKernel & operator=(const SeparableKernel &)=delete
std::string
STL class.
std::shared_ptr
STL class.
lsst::afw::math::Kernel::getNSpatialParameters
int getNSpatialParameters() const
Return the number of spatial parameters (0 if not spatially varying)
Definition: Kernel.h:274
lsst::afw::math::DeltaFunctionKernel::isPersistable
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
Definition: Kernel.h:721
lsst::afw::math::Kernel::getDimensions
lsst::geom::Extent2I const getDimensions() const
Return the Kernel's dimensions (width, height)
Definition: Kernel.h:213
lsst::afw::math::LinearCombinationKernel::LinearCombinationKernel
LinearCombinationKernel()
Construct an empty LinearCombinationKernel of size 0x0.
Definition: LinearCombinationKernel.cc:48
lsst::afw::math::Kernel::isSpatiallyVarying
bool isSpatiallyVarying() const
Return true iff the kernel is spatially varying (has a spatial function)
Definition: Kernel.h:380
kernelFunction
table::Key< int > kernelFunction
Definition: AnalyticKernel.cc:144
lsst::afw::math::DeltaFunctionKernel
A kernel that has only one non-zero pixel (of value 1)
Definition: Kernel.h:690
lsst::afw::math::FixedKernel::clone
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
Definition: FixedKernel.cc:61
lsst::afw::math::AnalyticKernel::toString
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
Definition: AnalyticKernel.cc:95
lsst::afw::math::LinearCombinationKernel::getKernelParameters
std::vector< double > getKernelParameters() const override
Return the current kernel parameters.
Definition: LinearCombinationKernel.cc:160
lsst::afw::math::Kernel::~Kernel
~Kernel() override=default
std::pair< double, double >
lsst::afw::math::AnalyticKernel::operator=
AnalyticKernel & operator=(const AnalyticKernel &)=delete
lsst::afw::math::Kernel::getHeight
int getHeight() const
Return the Kernel's height.
Definition: Kernel.h:230
lsst::afw::math::SeparableKernel::SeparableKernel
SeparableKernel()
Construct an empty spatially invariant SeparableKernel of size 0x0.
Definition: SeparableKernel.cc:43
lsst::afw::math::AnalyticKernel::doComputeImage
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
Definition: AnalyticKernel.cc:111
lsst::afw::math::deltafunction_kernel_tag
Kernel has only one non-zero pixel.
Definition: traits.h:56
lsst::afw::math::DeltaFunctionKernel::toString
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
Definition: DeltaFunctionKernel.cc:75
cacheSize
afw::table::Key< int > cacheSize
Definition: CoaddPsf.cc:339
lsst::afw::math::DeltaFunctionKernel::doComputeImage
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
Definition: DeltaFunctionKernel.cc:86
std::vector
STL class.
std::vector::size
T size(T... args)
lsst::afw::math::LinearCombinationKernel::operator=
LinearCombinationKernel & operator=(const LinearCombinationKernel &)=delete
lsst::afw::math::DeltaFunctionKernel::getPixel
lsst::geom::Point2I getPixel() const
Definition: Kernel.h:717
lsst::afw::math::DeltaFunctionKernel::clone
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
Definition: DeltaFunctionKernel.cc:52
pex.config.history.format
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174
lsst::afw::math::FixedKernel
A kernel created from an Image.
Definition: Kernel.h:518
lsst::afw
Definition: imageAlgorithm.dox:1
lsst::afw::math::FixedKernel::FixedKernel
FixedKernel(FixedKernel &&)=delete
lsst::afw::math::SeparableKernel::getKernelRowFunction
KernelFunctionPtr getKernelRowFunction() const
Get a deep copy of the row kernel function.
Definition: SeparableKernel.cc:144
lsst::afw::math::Kernel::clone
virtual std::shared_ptr< Kernel > clone() const =0
Return a pointer to a deep copy of this kernel.
lsst::afw::math::AnalyticKernel::computeImage
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.
Definition: AnalyticKernel.cc:82
lsst::afw::math::Kernel::setHeight
void setHeight(int height)
Definition: Kernel.h:220
lsst::afw::math::SeparableKernel::clone
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
Definition: SeparableKernel.cc:97
lsst::afw::math::FixedKernel::FixedKernel
FixedKernel(const FixedKernel &)=delete
lsst::afw::math::SeparableKernel::getCacheSize
int getCacheSize() const override
Get the current cache size (0 if none)
Definition: SeparableKernel.cc:320
lsst::afw::math::Kernel::growBBox
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,...
Definition: Kernel.cc:177
lsst::afw::math::Kernel::computeImage
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.
Definition: Kernel.cc:85
geom.h
lsst::afw::math::Kernel::Kernel
Kernel(Kernel &&)=delete
lsst::afw::math::SeparableKernel::~SeparableKernel
~SeparableKernel() override=default
lsst::afw::math::Kernel::getKernelParameter
virtual double getKernelParameter(unsigned int i) const
Return a particular Kernel Parameter (no bounds checking).
Definition: Kernel.h:300
lsst::afw::math::FixedKernel::isPersistable
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
Definition: Kernel.h:553
lsst::afw::math::Kernel::operator=
Kernel & operator=(Kernel &&)=delete
Image.h
lsst::afw::math::AnalyticKernel::_kernelFunctionPtr
KernelFunctionPtr _kernelFunctionPtr
Definition: Kernel.h:680
lsst::afw::math::Kernel::getCtr
lsst::geom::Point2I getCtr() const
Return index of kernel's center.
Definition: Kernel.h:235
lsst::afw::math::LinearCombinationKernel::LinearCombinationKernel
LinearCombinationKernel(const LinearCombinationKernel &)=delete
lsst::afw::math::AnalyticKernel::AnalyticKernel
AnalyticKernel(AnalyticKernel &&)=delete
lsst::afw::math::SeparableKernel::KernelFunctionPtr
std::shared_ptr< KernelFunction > KernelFunctionPtr
Definition: Kernel.h:910
lsst::afw::math::AnalyticKernel::KernelFunction
lsst::afw::math::Function2< Pixel > KernelFunction
Definition: Kernel.h:584
lsst::afw::math::FixedKernel::resized
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
Definition: FixedKernel.cc:67
lsst::afw::math::AnalyticKernel::setKernelParameter
void setKernelParameter(unsigned int ind, double value) const override
Set one kernel parameter.
Definition: AnalyticKernel.cc:135
std::vector::push_back
T push_back(T... args)
lsst::afw::math::Kernel::Kernel
Kernel(const Kernel &)=delete
lsst::afw::math::Kernel::NullSpatialFunction
lsst::afw::math::NullFunction2< double > NullSpatialFunction
Definition: Kernel.h:116
lsst::afw::math::LinearCombinationKernel::refactor
std::shared_ptr< Kernel > refactor() const
Refactor the kernel as a linear combination of N bases where N is the number of parameters for the sp...
Definition: LinearCombinationKernel.cc:162
lsst::afw::math::Kernel::toString
virtual std::string toString(std::string const &prefix="") const
Return a string representation of the kernel.
Definition: Kernel.cc:195
lsst::afw::math::Kernel::setCtr
void setCtr(lsst::geom::Point2I ctr)
Set index of kernel's center.
Definition: Kernel.h:335
lsst::afw::math::AnalyticKernel::AnalyticKernel
AnalyticKernel(const AnalyticKernel &)=delete
lsst::afw::math::FixedKernel::FixedKernel
FixedKernel()
Construct an empty FixedKernel of size 0x0.
Definition: FixedKernel.cc:42
lsst::afw::math::Kernel::getCacheSize
virtual int getCacheSize() const
Get the current size of the kernel cache (0 if none or if caches not supported)
Definition: Kernel.h:450
lsst::afw::math::LinearCombinationKernel::resized
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
Definition: LinearCombinationKernel.cc:115
lsst::afw::math::Kernel::doComputeImage
virtual double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const =0
Low-level version of computeImage.
lsst::afw::math::SeparableKernel::getKernelColFunction
KernelFunctionPtr getKernelColFunction() const
Get a deep copy of the col kernel function.
Definition: SeparableKernel.cc:140
lsst::afw::math::LinearCombinationKernel::toString
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
Definition: LinearCombinationKernel.cc:227
Utils.h
lsst::afw::math::LinearCombinationKernel
A kernel that is a linear combination of fixed basis kernels.
Definition: Kernel.h:751
lsst::afw::math::LinearCombinationKernel::setKernelParameter
void setKernelParameter(unsigned int ind, double value) const override
Set one kernel parameter.
Definition: LinearCombinationKernel.cc:270
lsst::afw::math::DeltaFunctionKernel::resized
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
Definition: DeltaFunctionKernel.cc:59
lsst::afw::math::SeparableKernel::getKernelParameters
std::vector< double > getKernelParameters() const override
Return the current kernel parameters.
Definition: SeparableKernel.cc:161
lsst::afw::math::DeltaFunctionKernel::operator=
DeltaFunctionKernel & operator=(DeltaFunctionKernel &&)=delete
x
double x
Definition: ChebyshevBoundedField.cc:277
lsst::afw::math::LinearCombinationKernel::getNBasisKernels
int getNBasisKernels() const
Get the number of basis kernels.
Definition: Kernel.h:815
lsst::afw::math::FixedKernel::getSum
virtual Pixel getSum() const
Definition: Kernel.h:551
lsst::afw::math::NullFunction2
a class used in function calls to indicate that no Function2 is being provided
Definition: Function.h:458
lsst::afw::math::Kernel::kernel_fill_factor
generic_kernel_tag kernel_fill_factor
Definition: Kernel.h:119
lsst::afw::math::LinearCombinationKernel::isDeltaFunctionBasis
bool isDeltaFunctionBasis() const
Return true if all basis kernels are instances of DeltaFunctionKernel.
Definition: Kernel.h:827
lsst::afw::math::Kernel::setWidth
void setWidth(int width)
Definition: Kernel.h:219
lsst::afw::math::LinearCombinationKernel::LinearCombinationKernel
LinearCombinationKernel(LinearCombinationKernel &&)=delete
lsst::afw::math::Kernel::setCtrY
void setCtrY(int ctrY)
Set y index of kernel's center.
Definition: Kernel.h:360
lsst::afw::math::AnalyticKernel::write
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
Definition: AnalyticKernel.cc:193
lsst::afw::math::DeltaFunctionKernel::~DeltaFunctionKernel
~DeltaFunctionKernel() override=default
lsst::afw::math::LinearCombinationKernel::~LinearCombinationKernel
~LinearCombinationKernel() override=default
lsst::afw::math::DeltaFunctionKernel::DeltaFunctionKernel
DeltaFunctionKernel(const DeltaFunctionKernel &)=delete
lsst::afw::math::Kernel::operator=
Kernel & operator=(const Kernel &)=delete
lsst::afw::math::FixedKernel::doComputeImage
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
Definition: FixedKernel.cc:104
lsst::afw::math::LinearCombinationKernel::write
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
Definition: LinearCombinationKernel.cc:370
lsst::afw::math::SeparableKernel::operator=
SeparableKernel & operator=(SeparableKernel &&)=delete
lsst::afw::math::Kernel::getSpatialParameters
std::vector< std::vector< double > > getSpatialParameters() const
Return the spatial parameters parameters (an empty vector if not spatially varying)
Definition: Kernel.h:368
lsst::afw::math::DeltaFunctionKernel::DeltaFunctionKernel
DeltaFunctionKernel(int width, int height, lsst::geom::Point2I const &point)
Construct a spatially invariant DeltaFunctionKernel.
Definition: DeltaFunctionKernel.cc:42
lsst::afw::math::Kernel::getCtrY
int getCtrY() const
Return y index of kernel's center.
Definition: Kernel.h:255
lsst::afw::math::FixedKernel::getPersistenceName
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
Definition: FixedKernel.cc:179
lsst::afw::math::SeparableKernel::doComputeImage
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
Definition: SeparableKernel.cc:172
lsst::afw::math::Kernel::shrinkBBox
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...
Definition: Kernel.cc:183
lsst::afw::math::FixedKernel::toString
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
Definition: FixedKernel.cc:127
lsst::afw::math::Kernel::getWidth
int getWidth() const
Return the Kernel's width.
Definition: Kernel.h:225
lsst::afw::math::Function::getParameter
virtual double getParameter(unsigned int ind) const
Get one function parameter without range checking.
Definition: Function.h:119
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
lsst::afw::math::AnalyticKernel::KernelFunctionPtr
std::shared_ptr< lsst::afw::math::Function2< Pixel > > KernelFunctionPtr
Definition: Kernel.h:585
lsst::afw::math::SeparableKernel::KernelFunction
lsst::afw::math::Function1< Pixel > KernelFunction
Definition: Kernel.h:909
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
lsst::afw::math::SeparableKernel::computeVectors
double computeVectors(std::vector< Pixel > &colList, std::vector< Pixel > &rowList, bool doNormalize, double x=0.0, double y=0.0) const
Compute the column and row arrays in place, where kernel(col, row) = colList(col) * rowList(row)
Definition: SeparableKernel.cc:123
lsst::afw::math::KernelList
std::vector< std::shared_ptr< Kernel > > KernelList
Definition: Kernel.h:509
lsst::afw::math::Kernel::_spatialFunctionList
std::vector< SpatialFunctionPtr > _spatialFunctionList
Definition: Kernel.h:496
lsst::afw::math::LinearCombinationKernel::clone
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
Definition: LinearCombinationKernel.cc:104
lsst::afw::math::Function2< double >
lsst::afw::table::io::Persistable
A base class for objects that can be persisted via afw::table::io Archive classes.
Definition: Persistable.h:74
lsst::afw::math::SeparableKernel::setKernelParameter
void setKernelParameter(unsigned int ind, double value) const override
Set one kernel parameter.
Definition: SeparableKernel.cc:186
lsst::afw::math::DeltaFunctionKernel::DeltaFunctionKernel
DeltaFunctionKernel(DeltaFunctionKernel &&)=delete
lsst::afw::math::AnalyticKernel
A kernel described by a function.
Definition: Kernel.h:582
lsst::afw::math::DeltaFunctionKernel::getPersistenceName
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
Definition: DeltaFunctionKernel.cc:151
lsst::afw::math::Kernel::setKernelParameters
void setKernelParameters(std::pair< double, double > const &params)
Set the kernel parameters of a 2-component spatially invariant kernel.
Definition: Kernel.h:410
lsst::afw::math::LinearCombinationKernel::getKernelList
virtual KernelList const & getKernelList() const
Get the fixed basis kernels.
Definition: LinearCombinationKernel.cc:156
lsst::afw::math::AnalyticKernel::getKernelParameters
std::vector< double > getKernelParameters() const override
Return the current kernel parameters.
Definition: AnalyticKernel.cc:104
lsst::afw::math::Kernel::getKernelParameters
virtual std::vector< double > getKernelParameters() const
Return the current kernel parameters.
Definition: Kernel.cc:175
lsst::afw::math::FixedKernel::operator=
FixedKernel & operator=(const FixedKernel &)=delete
lsst::pex::exceptions::InvalidParameterError
Reports invalid arguments.
Definition: Runtime.h:66
lsst::afw::math::AnalyticKernel::resized
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
Definition: AnalyticKernel.cc:72
lsst::afw::image.slicing.Factory
Factory
Definition: slicing.py:252
lsst::afw::math::Function::getNParameters
unsigned int getNParameters() const noexcept
Return the number of function parameters.
Definition: Function.h:112
Persistable.h
lsst::afw::math::DeltaFunctionKernel::write
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
Definition: DeltaFunctionKernel.cc:155
lsst::geom::Extent2I
Extent< int, 2 > Extent2I
Definition: Extent.h:397
lsst::afw::math::SeparableKernel::SeparableKernel
SeparableKernel(const SeparableKernel &)=delete
lsst::afw::math::DeltaFunctionKernel::kernel_fill_factor
deltafunction_kernel_tag kernel_fill_factor
Definition: Kernel.h:693
lsst::geom::Point< int, 2 >
lsst::afw::math::LinearCombinationKernel::checkKernelList
void checkKernelList(const KernelList &kernelList) const
Check that all kernels have the same size and center and that none are spatially varying.
Definition: LinearCombinationKernel.cc:132
lsst::afw::math::SeparableKernel::toString
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
Definition: SeparableKernel.cc:148
lsst::afw::math::SeparableKernel::getKernelParameter
double getKernelParameter(unsigned int i) const override
Return a particular Kernel Parameter (no bounds checking).
Definition: Kernel.h:980
lsst::afw::math::AnalyticKernel::AnalyticKernel
AnalyticKernel()
Construct an empty spatially invariant AnalyticKernel of size 0x0.
Definition: AnalyticKernel.cc:41
lsst::afw::table::io::PersistableFacade
A CRTP facade class for subclasses of Persistable.
Definition: Persistable.h:176
lsst::afw::math::Kernel::SpatialFunction
lsst::afw::math::Function2< double > SpatialFunction
Definition: Kernel.h:115
lsst::geom::Point2I
Point< int, 2 > Point2I
Definition: Point.h:321
lsst::afw::math::Kernel::computeCache
virtual void computeCache(int const)
Compute a cache of Kernel values, if desired.
Definition: Kernel.h:444
lsst::geom::Box2I
An integer coordinate rectangle.
Definition: Box.h:55
lsst::afw::math::AnalyticKernel::isPersistable
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
Definition: Kernel.h:666
lsst::afw::math::DeltaFunctionKernel::operator=
DeltaFunctionKernel & operator=(const DeltaFunctionKernel &)=delete
lsst::afw::math::LinearCombinationKernel::doComputeImage
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
Definition: LinearCombinationKernel.cc:247
lsst::afw::math::AnalyticKernel::getPersistenceName
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
Definition: AnalyticKernel.cc:191
lsst::afw::math::LinearCombinationKernel::getKernelSumList
std::vector< double > getKernelSumList() const
Get the sum of the pixels of each fixed basis kernel.
Definition: LinearCombinationKernel.cc:158
lsst::afw::math::Kernel::setSpatialParameters
void setSpatialParameters(const std::vector< std::vector< double >> params)
Set the parameters of all spatial functions.
Definition: Kernel.cc:119
lsst::afw::math::Kernel
Kernels are used for convolution with MaskedImages and (eventually) Images.
Definition: Kernel.h:111
lsst::afw::math::SeparableKernel::computeCache
void computeCache(int const cacheSize) override
Compute a cache of Kernel values, if desired.
Definition: SeparableKernel.cc:310
lsst::afw::math::LinearCombinationKernel::getPersistenceName
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
Definition: LinearCombinationKernel.cc:366
lsst::afw::math::Kernel::SpatialFunctionPtr
std::shared_ptr< lsst::afw::math::Function2< double > > SpatialFunctionPtr
Definition: Kernel.h:114
lsst::afw::image::Image< Pixel >
traits.h
lsst::afw::math::Kernel::getPythonModule
std::string getPythonModule() const override
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
Definition: Kernel.cc:235
lsst::afw::math::Kernel::setKernelParameters
void setKernelParameters(std::vector< double > const &params)
Set the kernel parameters of a spatially invariant kernel.
Definition: Kernel.h:388
lsst::afw::math::Kernel::getSpatialFunctionList
std::vector< SpatialFunctionPtr > getSpatialFunctionList() const
Return a list of clones of the spatial functions.
Definition: Kernel.cc:166
lsst::afw::math::AnalyticKernel::clone
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
Definition: AnalyticKernel.cc:60
lsst::afw::math::Function1
A Function taking one argument.
Definition: Function.h:202
lsst::afw::math::generic_kernel_tag
Tags carrying information about Kernels Kernel with no special properties.
Definition: traits.h:53
lsst::afw::math::FixedKernel::~FixedKernel
~FixedKernel() override=default
lsst::afw::math::FixedKernel::write
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
Definition: FixedKernel.cc:181
lsst::afw::math::LinearCombinationKernel::operator=
LinearCombinationKernel & operator=(LinearCombinationKernel &&)=delete
Function.h
lsst::afw::math::Kernel::Kernel
Kernel()
Construct a null Kernel of size 0,0.
Definition: Kernel.cc:58
lsst::afw::math::Kernel::resized
virtual std::shared_ptr< Kernel > resized(int width, int height) const =0
Return a pointer to a clone with specified kernel dimensions.
lsst::afw::math::FixedKernel::operator=
FixedKernel & operator=(FixedKernel &&)=delete
lsst::afw::table::io::Persistable::OutputArchiveHandle
io::OutputArchiveHandle OutputArchiveHandle
Definition: Persistable.h:108
lsst::afw::math::Kernel::getCtrX
int getCtrX() const
Return x index of kernel's center.
Definition: Kernel.h:244
lsst::geom::Extent< int, 2 >
lsst::afw::math::AnalyticKernel::~AnalyticKernel
~AnalyticKernel() override=default
lsst::afw::math::Kernel::getNKernelParameters
unsigned int getNKernelParameters() const
Return the number of kernel parameters (0 if none)
Definition: Kernel.h:269
lsst::afw::math::AnalyticKernel::getKernelFunction
virtual KernelFunctionPtr getKernelFunction() const
Get a deep copy of the kernel function.
Definition: AnalyticKernel.cc:91
lsst::afw::math::Kernel::setCtrX
void setCtrX(int ctrX)
Set x index of kernel's center.
Definition: Kernel.h:348
prefix
std::string prefix
Definition: SchemaMapper.cc:79
lsst::afw::math::SeparableKernel
A kernel described by a pair of functions: func(x, y) = colFunc(x) * rowFunc(y)
Definition: Kernel.h:907
lsst::afw::math::LinearCombinationKernel::isPersistable
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
Definition: Kernel.h:867
lsst::afw::math::SeparableKernel::SeparableKernel
SeparableKernel(SeparableKernel &&)=delete
lsst::afw::math::Kernel::setDimensions
void setDimensions(lsst::geom::Extent2I dims)
Definition: Kernel.h:215
bbox
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
lsst::pex::exceptions::RuntimeError
Reports errors that are due to events beyond the control of the program.
Definition: Runtime.h:104
lsst::afw::math::Kernel::computeKernelParametersFromSpatialModel
void computeKernelParametersFromSpatialModel(std::vector< double > &kernelParams, double x, double y) const
Compute the kernel parameters at a specified point.
Definition: Kernel.cc:144
lsst::afw::math::Kernel::Pixel
double Pixel
Definition: Kernel.h:113
lsst::afw::math::Kernel::getSpatialFunction
SpatialFunctionPtr getSpatialFunction(unsigned int index) const
Return a clone of the specified spatial function (one component of the spatial model)
Definition: Kernel.cc:153