[299] | 1 | // ----------------------------------------------------------------------- |
---|
| 2 | // filter.hh: Defining a filter function for wavelet reconstruction. |
---|
| 3 | // ----------------------------------------------------------------------- |
---|
| 4 | // Copyright (C) 2006, Matthew Whiting, ATNF |
---|
| 5 | // |
---|
| 6 | // This program is free software; you can redistribute it and/or modify it |
---|
| 7 | // under the terms of the GNU General Public License as published by the |
---|
| 8 | // Free Software Foundation; either version 2 of the License, or (at your |
---|
| 9 | // option) any later version. |
---|
| 10 | // |
---|
| 11 | // Duchamp is distributed in the hope that it will be useful, but WITHOUT |
---|
| 12 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
| 13 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
---|
| 14 | // for more details. |
---|
| 15 | // |
---|
| 16 | // You should have received a copy of the GNU General Public License |
---|
| 17 | // along with Duchamp; if not, write to the Free Software Foundation, |
---|
| 18 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA |
---|
| 19 | // |
---|
| 20 | // Correspondence concerning Duchamp may be directed to: |
---|
| 21 | // Internet email: Matthew.Whiting [at] atnf.csiro.au |
---|
| 22 | // Postal address: Dr. Matthew Whiting |
---|
| 23 | // Australia Telescope National Facility, CSIRO |
---|
| 24 | // PO Box 76 |
---|
| 25 | // Epping NSW 1710 |
---|
| 26 | // AUSTRALIA |
---|
| 27 | // ----------------------------------------------------------------------- |
---|
[232] | 28 | #ifndef FILTER_H |
---|
| 29 | #define FILTER_H |
---|
| 30 | |
---|
| 31 | #include <vector> |
---|
| 32 | #include <string> |
---|
| 33 | |
---|
[378] | 34 | namespace duchamp |
---|
[232] | 35 | { |
---|
| 36 | |
---|
[378] | 37 | /** |
---|
| 38 | * A class to store details of the wavelet's filter. |
---|
| 39 | * This stores all details of and functions related to the filter used to |
---|
| 40 | * generate the wavelets used in the reconstruction (and baseline |
---|
| 41 | * subtraction) functions. |
---|
| 42 | * |
---|
| 43 | * It stores the coefficients of the filter, as well as the number of scales |
---|
| 44 | * associated with it, and the sigma factors, that relate the value of the rms |
---|
| 45 | * at a given scale with the measured value. |
---|
| 46 | */ |
---|
[232] | 47 | |
---|
[378] | 48 | class Filter |
---|
| 49 | { |
---|
| 50 | public: |
---|
| 51 | // these are all in atrous.cc |
---|
| 52 | Filter(); ///< Constructor |
---|
| 53 | Filter(const Filter& f); |
---|
| 54 | Filter& operator=(const Filter& f); |
---|
| 55 | virtual ~Filter(); ///< Destructor |
---|
[232] | 56 | |
---|
[378] | 57 | /** Define the parameters for a given filter. */ |
---|
| 58 | void define(int code); |
---|
[232] | 59 | |
---|
[378] | 60 | /** Calculate the number of scales possible with a given filter and |
---|
| 61 | data size. */ |
---|
| 62 | int getNumScales(long length); |
---|
[232] | 63 | |
---|
[378] | 64 | /** Calculate the maximum number of pixels able to be analysed with |
---|
| 65 | a filter at a given scale. */ |
---|
| 66 | int getMaxSize(int scale); |
---|
[290] | 67 | |
---|
[378] | 68 | /** Return the width of the filter */ |
---|
| 69 | int width(){return filter1D.size();}; |
---|
[290] | 70 | |
---|
[378] | 71 | // these are inline functions. |
---|
| 72 | /** Return the text name of the filter */ |
---|
| 73 | std::string getName(){return name;}; |
---|
[290] | 74 | |
---|
[378] | 75 | /** Return the i-th value of the coefficient array. */ |
---|
| 76 | double coeff(int i){return filter1D[i];}; |
---|
[290] | 77 | |
---|
[378] | 78 | /** Set the i-th value of the coefficient array. */ |
---|
| 79 | void setCoeff(int i, double val){filter1D[i] = val;}; |
---|
[290] | 80 | |
---|
[378] | 81 | /** Return the maximum number of scales in the sigmaFactor array for |
---|
| 82 | the given dimension */ |
---|
| 83 | int maxFactor(int dim){return maxNumScales[dim-1];}; |
---|
[232] | 84 | |
---|
[378] | 85 | /** Set the maximum number of scales in the sigmaFactor array for |
---|
| 86 | the given dimension */ |
---|
| 87 | void setMaxFactor(int dim, int val){maxNumScales[dim-1] = val;}; |
---|
[232] | 88 | |
---|
[378] | 89 | /** Return the sigma scaling factor for the given dimension and |
---|
| 90 | scale of the wavelet transform. */ |
---|
| 91 | double sigmaFactor(int dim, int scale){return (*sigmaFactors[dim-1])[scale];}; |
---|
| 92 | /** Set the sigma scaling factor for the given dimension and |
---|
| 93 | scale of the wavelet transform. */ |
---|
| 94 | void setSigmaFactor(int dim, int scale, double val){(*sigmaFactors[dim])[scale] = val;}; |
---|
[232] | 95 | |
---|
[378] | 96 | private: |
---|
| 97 | std::string name; ///< what is the filter called? |
---|
| 98 | std::vector <double> filter1D; ///< filter coefficients. |
---|
| 99 | std::vector <int> maxNumScales; ///< max number of scales for the sigmaFactor arrays, for each dim. |
---|
| 100 | std::vector < std::vector <double>* > sigmaFactors; ///< arrays of sigmaFactors, one for each dim. |
---|
[232] | 101 | |
---|
[378] | 102 | // these are all in atrous.cc |
---|
| 103 | void loadSpline(); ///< set up parameters for using the |
---|
| 104 | /// B3-Spline filter. |
---|
| 105 | void loadTriangle(); ///< set up parameters for using the |
---|
| 106 | /// Triangle function. |
---|
| 107 | void loadHaar(); ///< set up parameters for using the |
---|
| 108 | /// Haar wavelet. |
---|
| 109 | |
---|
| 110 | }; |
---|
| 111 | |
---|
| 112 | } |
---|
| 113 | |
---|
[232] | 114 | #endif |
---|
| 115 | |
---|