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
warpExposure.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*- // fixed format comment for emacs
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008, 2009, 2010 LSST Corporation.
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 
35 #ifndef LSST_AFW_MATH_WARPEXPOSURE_H
36 #define LSST_AFW_MATH_WARPEXPOSURE_H
37 
38 #include <memory>
39 #include <string>
40 
41 #include "lsst/base.h"
42 #include "lsst/pex/exceptions.h"
43 #include "lsst/afw/geom.h"
47 #include "lsst/afw/math/Function.h"
49 #include "lsst/afw/math/Kernel.h"
50 
51 namespace lsst {
52 namespace afw {
53 namespace image {
54  class Wcs;
55 }
56 namespace math {
57 
71  public:
73  int order
74  )
75  :
76  SeparableKernel(2 * order, 2 * order,
78  {}
79 
80  virtual ~LanczosWarpingKernel() {}
81 
82  virtual PTR(Kernel) clone() const;
83 
84  int getOrder() const;
85 
86  protected:
87  virtual void setKernelParameter(unsigned int ind, double value) const;
88  };
89 
100  public:
102  :
103  SeparableKernel(2, 2, BilinearFunction1(0.0), BilinearFunction1(0.0))
104  {}
105 
107 
108  virtual PTR(Kernel) clone() const;
109 
118  public:
120 
125  double fracPos)
126  :
127  Function1<Kernel::Pixel>(1)
128  {
129  this->_params[0] = fracPos;
130  }
131  virtual ~BilinearFunction1() {}
132 
133  virtual Function1Ptr clone() const {
134  return Function1Ptr(new BilinearFunction1(this->_params[0]));
135  }
136 
137  virtual Kernel::Pixel operator() (double x) const;
138 
139  virtual std::string toString(std::string const& ="") const;
140  };
141 
142  protected:
143  virtual void setKernelParameter(unsigned int ind, double value) const;
144  };
145 
156  public:
158  :
160  {}
161 
163 
164  virtual PTR(Kernel) clone() const;
165 
174  public:
176 
181  double fracPos)
182  :
183  Function1<Kernel::Pixel>(1)
184  {
185  this->_params[0] = fracPos;
186  }
187  virtual ~NearestFunction1() {}
188 
189  virtual Function1Ptr clone() const {
190  return Function1Ptr(new NearestFunction1(this->_params[0]));
191  }
192 
193  virtual Kernel::Pixel operator() (double x) const;
194 
195  virtual std::string toString(std::string const& ="") const;
196  };
197 
198  protected:
199  virtual void setKernelParameter(unsigned int ind, double value) const;
200  };
201 
227 
236  public:
243  explicit WarpingControl(
244  std::string const &warpingKernelName,
245  std::string const &maskWarpingKernelName = "",
247  int cacheSize = 0,
252  int interpLength = 0,
254  lsst::afw::image::MaskPixel growFullMask = 0
256  ) :
257  _warpingKernelPtr(makeWarpingKernel(warpingKernelName)),
258  _maskWarpingKernelPtr(),
259  _cacheSize(cacheSize),
260  _interpLength(interpLength),
261  _growFullMask(growFullMask)
262  {
263  setMaskWarpingKernelName(maskWarpingKernelName);
264  }
265 
266 
267  virtual ~WarpingControl() {};
268 
272  int getCacheSize() const { return _cacheSize; };
273 
283  int cacheSize
284  ) { _cacheSize = cacheSize; };
285 
289  int getInterpLength() const { return _interpLength; };
290 
300  int interpLength
301  ) { _interpLength = interpLength; };
302 
306  PTR(SeparableKernel) getWarpingKernel() const;
307 
311  void setWarpingKernelName(
312  std::string const &warpingKernelName
313  );
314 
320  void setWarpingKernel(
321  SeparableKernel const &warpingKernel
322  );
323 
327  PTR(SeparableKernel) getMaskWarpingKernel() const;
328 
332  bool hasMaskWarpingKernel() const { return static_cast<bool>(_maskWarpingKernelPtr); }
333 
337  void setMaskWarpingKernelName(
338  std::string const &maskWarpingKernelName
340  );
341 
347  void setMaskWarpingKernel(
348  SeparableKernel const &maskWarpingKernel
349  );
350 
354  lsst::afw::image::MaskPixel getGrowFullMask() const { return _growFullMask; };
355 
360  lsst::afw::image::MaskPixel growFullMask
361  ) { _growFullMask = growFullMask; }
362 
363  private:
370  void _testWarpingKernels(
371  SeparableKernel const &warpingKernel,
372  SeparableKernel const &maskWarpingKernel
373  ) const;
374 
375  PTR(SeparableKernel) _warpingKernelPtr;
376  PTR(SeparableKernel) _maskWarpingKernelPtr;
377  int _cacheSize;
378  int _interpLength;
379  lsst::afw::image::MaskPixel _growFullMask;
380  };
381 
382 
388  template<typename DestExposureT, typename SrcExposureT>
389  int warpExposure(
390  DestExposureT &destExposure,
391  SrcExposureT const &srcExposure,
394  WarpingControl const &control,
395  typename DestExposureT::MaskedImageT::SinglePixel padValue =
396  lsst::afw::math::edgePixel<typename DestExposureT::MaskedImageT>(
397  typename lsst::afw::image::detail::image_traits<
398  typename DestExposureT::MaskedImageT>::image_category())
400  );
401 
442  template<typename DestImageT, typename SrcImageT>
443  int warpImage(
444  DestImageT &destImage,
445  lsst::afw::image::Wcs const &destWcs,
446  SrcImageT const &srcImage,
447  lsst::afw::image::Wcs const &srcWcs,
448  WarpingControl const &control,
449  typename DestImageT::SinglePixel padValue = lsst::afw::math::edgePixel<DestImageT>(
450  typename lsst::afw::image::detail::image_traits<DestImageT>::image_category())
452  );
453 
458  template<typename DestImageT, typename SrcImageT>
459  int warpImage(
460  DestImageT &destImage,
461  SrcImageT const &srcImage,
462  lsst::afw::geom::XYTransform const &xyTransform,
463  WarpingControl const &control,
465  typename DestImageT::SinglePixel padValue = lsst::afw::math::edgePixel<DestImageT>(
466  typename lsst::afw::image::detail::image_traits<DestImageT>::image_category())
468  );
469 
470 
475  template<typename DestImageT, typename SrcImageT>
476  int warpCenteredImage(
477  DestImageT &destImage,
478  SrcImageT const &srcImage,
479  lsst::afw::geom::LinearTransform const &linearTransform,
480  lsst::afw::geom::Point2D const &centerPosition,
481  WarpingControl const &control,
482  typename DestImageT::SinglePixel padValue = lsst::afw::math::edgePixel<DestImageT>(
483  typename lsst::afw::image::detail::image_traits<DestImageT>::image_category())
485  );
486 
487  namespace details {
488  template <typename A, typename B>
489  bool isSameObject(A const&, B const&) { return false; }
490 
491  template <typename A>
492  bool isSameObject(A const& a, A const& b) { return &a == &b; }
493  }
494 
495 }}} // lsst::afw::math
496 
497 #endif // !defined(LSST_AFW_MATH_WARPEXPOSURE_H)
std::uint16_t MaskPixel
An include file to include the header files for lsst::afw::geom.
Declare the Kernel class and subclasses.
boost::shared_ptr< SeparableKernel > makeWarpingKernel(std::string name)
Return a warping kernel given its name.
table::Key< std::string > name
Definition: ApCorrMap.cc:71
1-dimensional Lanczos function
Include files required for standard LSST Exception handling.
A kernel described by a pair of functions: func(x, y) = colFunc(x) * rowFunc(y)
Definition: Kernel.h:983
Define a collection of useful Functions.
Parameters to control convolution.
Definition: warpExposure.h:235
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:107
void setCacheSize(int cacheSize)
set the cache size for the interpolation kernel(s)
Definition: warpExposure.h:282
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.
tbl::Key< int > cacheSize
Definition: CoaddPsf.cc:351
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.
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
int getOrder() const
get the order of the kernel
int getInterpLength() const
get the interpolation length (pixels)
Definition: warpExposure.h:289
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.
void setInterpLength(int interpLength)
set the interpolation length
Definition: warpExposure.h:299
void setGrowFullMask(lsst::afw::image::MaskPixel growFullMask)
set mask bits to grow to full width of image/variance kernel
Definition: warpExposure.h:359
1-dimensional bilinear interpolation function.
Definition: warpExposure.h:117
bool isSameObject(A const &, B const &)
Definition: warpExposure.h:489
A Function taking one argument.
Definition: Function.h:229
boost::shared_ptr< Function1< Kernel::Pixel > > Function1Ptr
Definition: warpExposure.h:175
SeparableKernel()
Construct an empty spatially invariant SeparableKernel of size 0x0.
ImageT::SinglePixel edgePixel(lsst::afw::image::detail::Image_tag)
Return an off-the-edge pixel appropriate for a given Image type.
double x
Bilinear warping: fast; good for undersampled data.
Definition: warpExposure.h:99
Convolve and convolveAtAPoint functions for Image and Kernel.
virtual std::string toString(std::string const &prefix="") const
Return a string representation of the kernel.
tbl::Key< std::string > warpingKernelName
Definition: CoaddPsf.cc:353
boost::shared_ptr< Function1< Kernel::Pixel > > Function1Ptr
Definition: warpExposure.h:119
#define PTR(...)
Definition: base.h:41
int getCacheSize() const
get the cache size for the interpolation kernel(s)
Definition: warpExposure.h:272
virtual void setKernelParameter(unsigned int ind, double value) const
Set one kernel parameter.
Nearest neighbor warping: fast; good for undersampled data.
Definition: warpExposure.h:155
Define the basic Function classes.
virtual Function1Ptr clone() const
Return a pointer to a deep copy of this function.
Definition: warpExposure.h:189
afw::table::Key< double > b
Lanczos warping: accurate but slow and can introduce ringing artifacts.
Definition: warpExposure.h:70
Point< double, 2 > Point2D
Definition: Point.h:288
1-dimensional nearest neighbor interpolation function.
Definition: warpExposure.h:173
lsst::afw::image::MaskPixel getGrowFullMask() const
get mask bits to grow to full width of image/variance kernel
Definition: warpExposure.h:354
WarpingControl(std::string const &warpingKernelName, std::string const &maskWarpingKernelName="", int cacheSize=0, int interpLength=0, lsst::afw::image::MaskPixel growFullMask=0)
Construct a WarpingControl object.
Definition: warpExposure.h:243
Basic LSST definitions.
virtual boost::shared_ptr< Kernel > clone() const
Return a pointer to a deep copy of this kernel.
Definition: warpExposure.cc:98
Kernels are used for convolution with MaskedImages and (eventually) Images.
Definition: Kernel.h:131
Definition of default types for Masks and Variance Images.
virtual Function1Ptr clone() const
Return a pointer to a deep copy of this function.
Definition: warpExposure.h:133