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 |
---|
29 | data size. */ |
---|
30 | int getNumScales(long length); |
---|
31 | |
---|
32 | /** Calculate the maximum number of pixels able to be analysed with |
---|
33 | a filter at a given scale. */ |
---|
34 | int getMaxSize(int scale); |
---|
35 | |
---|
36 | /** Return the width of the filter */ |
---|
37 | int width(){return filter1D.size();}; |
---|
38 | |
---|
39 | // these are inline functions. |
---|
40 | /** Return the text name of the filter */ |
---|
41 | std::string getName(){return name;}; |
---|
42 | |
---|
43 | /** Return the i-th value of the coefficient array. */ |
---|
44 | double coeff(int i){return filter1D[i];}; |
---|
45 | |
---|
46 | /** Set the i-th value of the coefficient array. */ |
---|
47 | void setCoeff(int i, double val){filter1D[i] = val;}; |
---|
48 | |
---|
49 | /** Return the maximum number of scales in the sigmaFactor array for |
---|
50 | the given dimension */ |
---|
51 | int maxFactor(int dim){return maxNumScales[dim-1];}; |
---|
52 | |
---|
53 | /** Set the maximum number of scales in the sigmaFactor array for |
---|
54 | the given dimension */ |
---|
55 | void setMaxFactor(int dim, int val){maxNumScales[dim-1] = val;}; |
---|
56 | |
---|
57 | /** Return the sigma scaling factor for the given dimension and |
---|
58 | scale of the wavelet transform. */ |
---|
59 | double sigmaFactor(int dim, int scale){return (*sigmaFactors[dim-1])[scale];}; |
---|
60 | /** Set the sigma scaling factor for the given dimension and |
---|
61 | scale of the wavelet transform. */ |
---|
62 | void setSigmaFactor(int dim, int scale, double val){(*sigmaFactors[dim])[scale] = val;}; |
---|
63 | |
---|
64 | private: |
---|
65 | std::string name; ///< what is the filter called? |
---|
66 | std::vector <double> filter1D; ///< filter coefficients. |
---|
67 | std::vector <int> maxNumScales; ///< max number of scales for the sigmaFactor arrays, for each dim. |
---|
68 | std::vector < std::vector <double>* > sigmaFactors; ///< arrays of sigmaFactors, one for each dim. |
---|
69 | |
---|
70 | // these are all in atrous.cc |
---|
71 | void loadSpline(); ///< set up parameters for using the |
---|
72 | /// B3-Spline filter. |
---|
73 | void loadTriangle(); ///< set up parameters for using the |
---|
74 | /// Triangle function. |
---|
75 | void loadHaar(); ///< set up parameters for using the |
---|
76 | /// Haar wavelet. |
---|
77 | |
---|
78 | }; |
---|
79 | |
---|
80 | #endif |
---|
81 | |
---|