LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
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-2015 AURA/LSST.
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 <https://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  void setStyle(Style const style) { _style = style; }
62  int getOrderX() const { return _orderX; }
64  void setOrderX(int const orderX) { _orderX = orderX; }
66  int getOrderY() const { return _orderY; }
68  void setOrderY(int const orderY) { _orderY = orderY; }
70  bool getWeighting() const { return _weighting; }
72  void setWeighting(bool const weighting) { _weighting = weighting; }
73 private:
75  int _orderX;
76  int _orderY;
77  bool _weighting;
78 };
79 
83 template<typename PixelT>
85 makeApproximate(std::vector<double> const &x, std::vector<double> const &y,
86  image::MaskedImage<PixelT> const& im, geom::Box2I const& bbox,
87  ApproximateControl const& ctrl);
88 
93 template<typename PixelT>
94 class Approximate {
95 public:
96  typedef float OutPixelT;
97 
98  friend PTR(Approximate<PixelT>)
99  makeApproximate<>(std::vector<double> const &x, std::vector<double> const &y,
100  image::MaskedImage<PixelT> const& im, geom::Box2I const& bbox,
101  ApproximateControl const& ctrl);
103  virtual ~Approximate() {}
105  PTR(image::Image<OutPixelT>) getImage(int orderX=-1, int orderY=-1) const {
106  return doGetImage(orderX, orderY);
107  }
109  PTR(image::MaskedImage<OutPixelT>) getMaskedImage(int orderX=-1, int orderY=-1) const {
110  return doGetMaskedImage(orderX, orderY);
111  }
112 protected:
116  Approximate(std::vector<double> const &x,
117  std::vector<double> const &y,
118  geom::Box2I const& bbox,
119  ApproximateControl const& ctrl
120  ) : _xVec(x), _yVec(y), _bbox(bbox), _ctrl(ctrl) {}
121 
122  std::vector<double> const _xVec;
123  std::vector<double> const _yVec;
126 private:
127  Approximate(Approximate const&);
128  Approximate& operator=(Approximate const&);
129  virtual PTR(image::Image<OutPixelT>) doGetImage(int orderX, int orderY) const = 0;
130  virtual PTR(image::MaskedImage<OutPixelT>) doGetMaskedImage(int orderX, int orderY) const = 0;
131 };
132 
133 }}} // lsst::afw::math
134 
135 #endif // LSST_AFW_MATH_APPROXIMATE_H
int y
geom::Box2I const _bbox
Domain for approximation.
Definition: Approximate.h:124
std::vector< double > const _yVec
the y-values of points
Definition: Approximate.h:123
Approximate(std::vector< double > const &x, std::vector< double > const &y, geom::Box2I const &bbox, ApproximateControl const &ctrl)
Base class ctor.
Definition: Approximate.h:116
Use a 2-D Chebyshev polynomial.
Definition: Approximate.h:52
void setOrderX(int const orderX)
Set the order of approximation to use in the x-direction.
Definition: Approximate.h:64
float OutPixelT
The pixel type of returned images.
Definition: Approximate.h:96
#define PTR(...)
Definition: base.h:41
int getOrderY() const
Return the order of approximation to use in the y-direction.
Definition: Approximate.h:66
std::vector< double > const _xVec
the x-values of points
Definition: Approximate.h:122
void setWeighting(bool const weighting)
Set whether inverse variance weighting will be used in calculation.
Definition: Approximate.h:72
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
geom::Box2I const & _bbox
Definition: fits_io_mpl.h:80
void setStyle(Style const style)
Set the Style.
Definition: Approximate.h:60
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
double x
ApproximateControl const _ctrl
desired approximation algorithm
Definition: Approximate.h:125
ApproximateControl(Style style, int orderX, int orderY=-1, bool weighting=true)
ctor
Definition: Approximate.cc:48
void setOrderY(int const orderY)
Set the order of approximation to use in the y-direction.
Definition: Approximate.h:68
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:295
table::Key< int > orderX
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:62
bool getWeighting() const
Return whether inverse variance weighting will be used in calculation.
Definition: Approximate.h:70