LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
LSSTDataManagementBasePackage
Approximate.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 #if !defined(LSST_AFW_MATH_APPROXIMATE_H)
3 #define LSST_AFW_MATH_APPROXIMATE_H
4 
5 /*
6  * LSST Data Management System
7  * Copyright 2008, 2009, 2010 LSST Corporation.
8  *
9  * This product includes software developed by the
10  * LSST Project (http://www.lsst.org/).
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the LSST License Statement and
23  * the GNU General Public License along with this program. If not,
24  * see <http://www.lsstcorp.org/LegalNotices/>.
25  */
26 #include "lsst/base.h"
27 
28 namespace lsst {
29 namespace afw {
30 namespace geom {
31  class Box2I;
32 }
33 namespace image {
34 template<typename PixelT> class Image;
35 template<typename PixelT, typename U, typename V> class MaskedImage;
36 }
37 namespace math {
38 template<typename T> class Approximate;
39 
48 public:
50  enum Style {
51  UNKNOWN = -1,
54  };
55 
56  ApproximateControl(Style style, int orderX, int orderY=-1, bool weighting=true);
58  Style getStyle() const { return _style; }
60  int getOrderX() const { return _orderX; }
62  int getOrderY() const { return _orderY; }
64  bool getWeighting() const { return _weighting; }
65 private:
66  Style const _style;
67  int const _orderX;
68  int const _orderY;
69  bool const _weighting;
70 };
71 
75 template<typename PixelT>
77 makeApproximate(std::vector<double> const &x, std::vector<double> const &y,
78  image::MaskedImage<PixelT> const& im, geom::Box2I const& bbox,
79  ApproximateControl const& ctrl);
80 
85 template<typename PixelT>
86 class Approximate {
87 public:
88  typedef float OutPixelT;
89 
90  friend PTR(Approximate<PixelT>)
91  makeApproximate<>(std::vector<double> const &x, std::vector<double> const &y,
92  image::MaskedImage<PixelT> const& im, geom::Box2I const& bbox,
93  ApproximateControl const& ctrl);
95  virtual ~Approximate() {}
97  PTR(image::Image<OutPixelT>) getImage(int orderX=-1, int orderY=-1) const {
98  return doGetImage(orderX, orderY);
99  }
101  PTR(image::MaskedImage<OutPixelT>) getMaskedImage(int orderX=-1, int orderY=-1) const {
102  return doGetMaskedImage(orderX, orderY);
103  }
104 protected:
108  Approximate(std::vector<double> const &x,
109  std::vector<double> const &y,
110  geom::Box2I const& bbox,
111  ApproximateControl const& ctrl
112  ) : _xVec(x), _yVec(y), _bbox(bbox), _ctrl(ctrl) {}
113 
114  std::vector<double> const _xVec;
115  std::vector<double> const _yVec;
118 private:
119  Approximate(Approximate const&);
120  Approximate& operator=(Approximate const&);
121  virtual PTR(image::Image<OutPixelT>) doGetImage(int orderX, int orderY) const = 0;
122  virtual PTR(image::MaskedImage<OutPixelT>) doGetMaskedImage(int orderX, int orderY) const = 0;
123 };
124 
125 }}}
126 
127 #endif // LSST_AFW_MATH_APPROXIMATE_H
geom::Box2I const _bbox
Domain for approximation.
Definition: Approximate.h:116
std::vector< double > const _yVec
the y-values of points
Definition: Approximate.h:115
Approximate(std::vector< double > const &x, std::vector< double > const &y, geom::Box2I const &bbox, ApproximateControl const &ctrl)
Base class ctor.
Definition: Approximate.h:108
#define PTR(...)
Definition: base.h:41
Use a 2-D Chebyshev polynomial.
Definition: Approximate.h:52
int y
float OutPixelT
The pixel type of returned images.
Definition: Approximate.h:88
int getOrderY() const
Return the order of approximation to use in the y-direction.
Definition: Approximate.h:62
std::vector< double > const _xVec
the x-values of points
Definition: Approximate.h:114
Approximate values for a MaskedImage.
Definition: Approximate.h:38
An integer coordinate rectangle.
Definition: Box.h:53
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
Control how to make an approximation.
Definition: Approximate.h:47
Style getStyle() const
Return the Style.
Definition: Approximate.h:58
int x
geom::Box2I const & _bbox
Definition: fits_io_mpl.h:80
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:77
Style
Choose the type of approximation to use.
Definition: Approximate.h:50
ApproximateControl const _ctrl
desired approximation algorithm
Definition: Approximate.h:117
ApproximateControl(Style style, int orderX, int orderY=-1, bool weighting=true)
ctor
Definition: Approximate.cc:48
boost::shared_ptr< Approximate< PixelT > > makeApproximate(std::vector< double > const &x, std::vector< double > const &y, image::MaskedImage< PixelT > const &im, geom::Box2I const &bbox, ApproximateControl const &ctrl)
Construct a new Approximate object, inferring the type from the type of the given MaskedImage...
Definition: Approximate.cc:289
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:415
int getOrderX() const
Return the order of approximation to use in the x-direction.
Definition: Approximate.h:60
bool getWeighting() const
Return whether inverse variance weighting will be used in calculation.
Definition: Approximate.h:64