1 | #ifndef FILTER_H |
---|
2 | #define FILTER_H |
---|
3 | |
---|
4 | #include <vector> |
---|
5 | #include <string> |
---|
6 | |
---|
7 | /** |
---|
8 | * A class to store details of the wavelet's filter. |
---|
9 | * This stores all details of and functions related to the filter used to |
---|
10 | * generate the wavelets used in the reconstruction (and baseline |
---|
11 | * subtraction) functions. |
---|
12 | * |
---|
13 | * It stores the coefficients of the filter, as well as the number of scales |
---|
14 | * associated with it, and the sigma factors, that relate the value of the rms |
---|
15 | * at a given scale with the measured value. |
---|
16 | */ |
---|
17 | |
---|
18 | class Filter |
---|
19 | { |
---|
20 | public: |
---|
21 | // these are all in atrous.cc |
---|
22 | Filter(); ///< Constructor |
---|
23 | virtual ~Filter(); ///< Destructor |
---|
24 | |
---|
25 | /** Define the parameters for a given filter. */ |
---|
26 | void define(int code); |
---|
27 | |
---|
28 | /** Calculate the number of scales possible with a given filter and data size. */ |
---|
29 | int getNumScales(long length); |
---|
30 | |
---|
31 | /** Calculate the maximum number of pixels able to be analysed with a filter at a given scale. */ |
---|
32 | int getMaxSize(int scale); |
---|
33 | |
---|
34 | /** Return the width of the filter */ |
---|
35 | int width(){return filter1D.size();}; |
---|
36 | |
---|
37 | // these are inline functions. |
---|
38 | std::string getName(){return name;}; |
---|
39 | double coeff(int i){return filter1D[i];}; |
---|
40 | void setCoeff(int i, double val){filter1D[i] = val;}; |
---|
41 | int maxFactor(int dim){return maxNumScales[dim-1];}; |
---|
42 | void setMaxFactor(int dim, int val){maxNumScales[dim-1] = val;}; |
---|
43 | double sigmaFactor(int dim, int scale){return (*sigmaFactors[dim-1])[scale];}; |
---|
44 | void setSigmaFactor(int dim, int scale, double val){(*sigmaFactors[dim])[scale] = val;}; |
---|
45 | |
---|
46 | private: |
---|
47 | std::string name; ///< what is the filter called? |
---|
48 | std::vector <double> filter1D; ///< filter coefficients. |
---|
49 | std::vector <int> maxNumScales; ///< max number of scales for the sigmaFactor arrays, for each dim. |
---|
50 | std::vector < std::vector <double>* > sigmaFactors; ///< arrays of sigmaFactors, one for each dim. |
---|
51 | |
---|
52 | // these are all in atrous.cc |
---|
53 | void loadSpline(); ///< set up parameters for using the B3 Spline filter. |
---|
54 | void loadTriangle(); ///< set up parameters for using the Triangle function. |
---|
55 | void loadHaar(); ///< set up parameters for using the Haar wavelet. |
---|
56 | |
---|
57 | }; |
---|
58 | |
---|
59 | #endif |
---|
60 | |
---|