lsst.afw  13.0-109-g62eb66483
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>
35 class Image;
36 template <typename PixelT, typename U, typename V>
37 class MaskedImage;
38 }
39 namespace math {
40 template <typename T>
42 
51 public:
53  enum Style {
54  UNKNOWN = -1,
56  NUM_STYLES
57  };
58 
66  ApproximateControl(Style style, int orderX, int orderY = -1, bool weighting = true);
68  Style getStyle() const { return _style; }
70  void setStyle(Style const style) { _style = style; }
72  int getOrderX() const { return _orderX; }
74  void setOrderX(int const orderX) { _orderX = orderX; }
76  int getOrderY() const { return _orderY; }
78  void setOrderY(int const orderY) { _orderY = orderY; }
80  bool getWeighting() const { return _weighting; }
82  void setWeighting(bool const weighting) { _weighting = weighting; }
83 
84 private:
85  Style _style;
86  int _orderX;
87  int _orderY;
88  bool _weighting;
89 };
90 
100 template <typename PixelT>
101 std::shared_ptr<Approximate<PixelT>> makeApproximate(std::vector<double> const& x,
102  std::vector<double> const& y,
103  image::MaskedImage<PixelT> const& im,
104  geom::Box2I const& bbox, ApproximateControl const& ctrl);
105 
109 template <typename PixelT>
110 class Approximate {
111 public:
112  typedef float OutPixelT;
113 
114  friend std::shared_ptr<Approximate<PixelT>> makeApproximate<>(std::vector<double> const& x,
115  std::vector<double> const& y,
116  image::MaskedImage<PixelT> const& im,
117  geom::Box2I const& bbox,
118  ApproximateControl const& ctrl);
120  virtual ~Approximate() {}
122  std::shared_ptr<image::Image<OutPixelT>> getImage(int orderX = -1, int orderY = -1) const {
123  return doGetImage(orderX, orderY);
124  }
126  std::shared_ptr<image::MaskedImage<OutPixelT>> getMaskedImage(int orderX = -1, int orderY = -1) const {
127  return doGetMaskedImage(orderX, orderY);
128  }
129 
130 protected:
134  Approximate(std::vector<double> const& x,
135  std::vector<double> const& y,
136  geom::Box2I const& bbox,
137  ApproximateControl const& ctrl
138  )
139  : _xVec(x), _yVec(y), _bbox(bbox), _ctrl(ctrl) {}
140 
141  std::vector<double> const _xVec;
142  std::vector<double> const _yVec;
145 private:
146  Approximate(Approximate const&);
147  Approximate& operator=(Approximate const&);
148  virtual std::shared_ptr<image::Image<OutPixelT>> doGetImage(int orderX, int orderY) const = 0;
149  virtual std::shared_ptr<image::MaskedImage<OutPixelT>> doGetMaskedImage(int orderX, int orderY) const = 0;
150 };
151 }
152 }
153 } // lsst::afw::math
154 
155 #endif // LSST_AFW_MATH_APPROXIMATE_H
float OutPixelT
The pixel type of returned images.
Definition: Approximate.h:112
std::shared_ptr< image::MaskedImage< OutPixelT > > getMaskedImage(int orderX=-1, int orderY=-1) const
Return the approximate image as a MaskedImage.
Definition: Approximate.h:126
std::shared_ptr< image::Image< OutPixelT > > getImage(int orderX=-1, int orderY=-1) const
Return the approximate image as a Image.
Definition: Approximate.h:122
geom::Box2I const _bbox
Domain for approximation.
Definition: Approximate.h:143
bool getWeighting() const
Return whether inverse variance weighting will be used in calculation.
Definition: Approximate.h:80
Use a 2-D Chebyshev polynomial.
Definition: Approximate.h:55
int getOrderX() const
Return the order of approximation to use in the x-direction.
Definition: Approximate.h:72
ApproximateControl const _ctrl
desired approximation algorithm
Definition: Approximate.h:144
void setOrderX(int const orderX)
Set the order of approximation to use in the x-direction.
Definition: Approximate.h:74
Style getStyle() const
Return the Style.
Definition: Approximate.h:68
std::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:279
void setWeighting(bool const weighting)
Set whether inverse variance weighting will be used in calculation.
Definition: Approximate.h:82
Approximate values for a MaskedImage.
Definition: Approximate.h:41
An integer coordinate rectangle.
Definition: Box.h:55
Control how to make an approximation.
Definition: Approximate.h:50
A base class for image defects.
Definition: cameraGeom.dox:3
void setStyle(Style const style)
Set the Style.
Definition: Approximate.h:70
std::vector< double > const _xVec
the x-values of points
Definition: Approximate.h:141
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:81
int getOrderY() const
Return the order of approximation to use in the y-direction.
Definition: Approximate.h:76
Style
Choose the type of approximation to use.
Definition: Approximate.h:53
double x
void setOrderY(int const orderY)
Set the order of approximation to use in the y-direction.
Definition: Approximate.h:78
table::Key< int > orderX
std::vector< double > const _yVec
the y-values of points
Definition: Approximate.h:142
Approximate(std::vector< double > const &x, std::vector< double > const &y, geom::Box2I const &bbox, ApproximateControl const &ctrl)
Base class ctor.
Definition: Approximate.h:134