00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef SCIMATH_INTERPOLATE2D_H
00029 #define SCIMATH_INTERPOLATE2D_H
00030
00031
00032 #include <casacore/casa/aips.h>
00033
00034 namespace casacore {
00035
00036
00037 template <typename T> class Vector;
00038 template <typename T> class Matrix;
00039 class String;
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 class Interpolate2D {
00100 public:
00101
00102 enum Method {
00103
00104
00105 NEAREST,
00106
00107
00108 LINEAR,
00109
00110
00111 CUBIC,
00112
00113
00114 LANCZOS};
00115
00116
00117 Interpolate2D(Interpolate2D::Method method=Interpolate2D::LINEAR);
00118
00119
00120 Interpolate2D(const Interpolate2D &other);
00121
00122
00123 ~Interpolate2D();
00124
00125
00126 Interpolate2D &operator=(const Interpolate2D &other);
00127
00128
00129
00130
00131
00132 Bool interp (Float &result,
00133 const Vector<Double> &where,
00134 const Matrix<Float> &data) const;
00135 Bool interp (Float &result,
00136 const Vector<Double> &where,
00137 const Matrix<Float> &data,
00138 const Matrix<Bool> &mask) const;
00139
00140
00141
00142
00143
00144
00145 Bool interp (Double &result,
00146 const Vector<Double> &where,
00147 const Matrix<Double> &data) const;
00148 Bool interp (Double &result,
00149 const Vector<Double> &where,
00150 const Matrix<Double> &data,
00151 const Matrix<Bool> &mask) const;
00152
00153
00154
00155
00156
00157 Bool interp(Double &resultI, Double &resultJ,
00158 const Vector<Double> &where,
00159 const Matrix<Double> &dataI,
00160 const Matrix<Double> &dataJ,
00161 const Matrix<Bool> &mask) const;
00162 template <typename T>
00163 Bool interpLinear2(T &resultI, T &resultJ,
00164 const Vector<Double> &where,
00165 const Matrix<T> &dataI,
00166 const Matrix<T> &dataJ,
00167 const Matrix<Bool> &mask) const;
00168
00169
00170
00171
00172
00173
00174
00175 Bool interp (Bool &result,
00176 const Vector<Double> &where,
00177 const Matrix<Bool> &data) const;
00178
00179
00180
00181 Method interpolationMethod() const {return itsMethod;}
00182
00183
00184
00185 static Interpolate2D::Method stringToMethod(const String &method);
00186
00187 private:
00188
00189
00190 Bool anyBadMaskPixels (const Matrix<Bool>* &mask, Int i1, Int i2,
00191 Int j1, Int j2) const;
00192
00193
00194 template <typename T>
00195 Bool interpNearest(T &result, const Vector<Double> &where,
00196 const Matrix<T> &data,
00197 const Matrix<Bool>* &maskPtr) const;
00198 Bool interpNearestBool(Bool &result, const Vector<Double> &where,
00199 const Matrix<Bool> &data) const;
00200
00201
00202 template <typename T>
00203 Bool interpLinear(T &result, const Vector<Double> &where,
00204 const Matrix<T> &data,
00205 const Matrix<Bool>* &maskPtr) const;
00206 Bool interpLinearBool(Bool &result, const Vector<Double> &where,
00207 const Matrix<Bool> &data) const;
00208
00209
00210 template <typename T>
00211 Bool interpCubic(T &result, const Vector<Double> &where,
00212 const Matrix<T> &data,
00213 const Matrix<Bool>* &maskPtr) const;
00214 Bool interpCubicBool(Bool &result, const Vector<Double> &where,
00215 const Matrix<Bool> &data) const;
00216
00217
00218 template <typename T>
00219 Bool interpLanczos(T &result, const Vector<Double> &where,
00220 const Matrix<T> &data,
00221 const Matrix<Bool>* &maskPtr) const;
00222 Bool interpLanczosBool(Bool &result, const Vector<Double> &where,
00223 const Matrix<Bool> &data) const;
00224
00225 template <typename T>
00226 T sinc(const T x) const;
00227 template <typename T>
00228 T L(const T x, const Int a) const;
00229
00230
00231 void bcucof (Double c[4][4], const Double y[4],
00232 const Double y1[4],
00233 const Double y2[4], const Double y12[4]) const;
00234
00235 Interpolate2D::Method itsMethod;
00236
00237
00238 typedef Bool(Interpolate2D::*FuncPtrFloat)
00239 (Float &result,
00240 const Vector<Double> &where,
00241 const Matrix<Float> &data,
00242 const Matrix<Bool>* &maskPtr) const;
00243 typedef Bool(Interpolate2D::*FuncPtrDouble)
00244 (Double &result,
00245 const Vector<Double> &where,
00246 const Matrix<Double> &data,
00247 const Matrix<Bool>* &maskPtr) const;
00248 typedef Bool(Interpolate2D::*FuncPtrBool)
00249 (Bool &result,
00250 const Vector<Double> &where,
00251 const Matrix<Bool> &data) const;
00252
00253 FuncPtrFloat itsFuncPtrFloat;
00254 FuncPtrDouble itsFuncPtrDouble;
00255 FuncPtrBool itsFuncPtrBool;
00256
00257 };
00258
00259
00260 }
00261
00262 #ifndef CASACORE_NO_AUTO_TEMPLATES
00263 #include <casacore/scimath/Mathematics/Interpolate2D2.tcc>
00264 #endif //# CASACORE_NO_AUTO_TEMPLATES
00265 #endif
00266