[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 | |
---|
[1339] | 37 | /// @brief A base class to store details of the wavelet's filter. |
---|
| 38 | /// @details This stores all details of and functions related to the |
---|
| 39 | /// filter used to generate the wavelets used in the reconstruction |
---|
| 40 | /// (and baseline subtraction) functions. |
---|
| 41 | /// |
---|
| 42 | /// It stores the coefficients of the filter, as well as the number of scales |
---|
| 43 | /// associated with it, and the sigma factors, that relate the value of the rms |
---|
| 44 | /// at a given scale with the measured value. |
---|
| 45 | /// |
---|
| 46 | /// Specific filters should derive from this class, and define the |
---|
| 47 | /// filter coefficients in the constructor. |
---|
[232] | 48 | |
---|
[1339] | 49 | class Filter |
---|
| 50 | { |
---|
| 51 | public: |
---|
| 52 | // these are all in atrous.cc |
---|
| 53 | /// @brief Constructor |
---|
| 54 | Filter(); |
---|
| 55 | /// @brief Copy Constructor |
---|
| 56 | Filter(const Filter& f); |
---|
| 57 | /// @brief Copy operator |
---|
| 58 | Filter& operator=(const Filter& f); |
---|
| 59 | /// @brief Destructor |
---|
| 60 | virtual ~Filter(); |
---|
[232] | 61 | |
---|
[1339] | 62 | /// @brief Calculate the number of scales possible with a given filter and data size. |
---|
| 63 | unsigned int getNumScales(size_t length); |
---|
[232] | 64 | |
---|
[1339] | 65 | /// @brief Calculate the maximum number of pixels able to be analysed with a filter at a given scale. |
---|
| 66 | unsigned int getMaxSize(int scale); |
---|
[232] | 67 | |
---|
[1339] | 68 | /// @brief Return the width of the filter |
---|
| 69 | size_t width(){return filter1D.size();}; |
---|
[290] | 70 | |
---|
[1339] | 71 | // these are inline functions. |
---|
| 72 | /// @brief Return the text name of the filter |
---|
| 73 | std::string getName(){return name;}; |
---|
[290] | 74 | |
---|
[1339] | 75 | /// @brief Return the i-th value of the coefficient array. |
---|
| 76 | double coeff(int i){return filter1D[i];}; |
---|
[290] | 77 | |
---|
[1339] | 78 | /// @brief Set the i-th value of the coefficient array. |
---|
| 79 | void setCoeff(int i, double val){filter1D[i] = val;}; |
---|
[290] | 80 | |
---|
[1339] | 81 | /// @brief Return the maximum number of scales in the sigmaFactor array for the given dimension |
---|
| 82 | unsigned int maxFactor(int dim){return maxNumScales[dim-1];}; |
---|
[290] | 83 | |
---|
[1339] | 84 | /// @brief Set the maximum number of scales in the sigmaFactor array for the given dimension |
---|
| 85 | void setMaxFactor(int dim, int val){maxNumScales[dim-1] = val;}; |
---|
[232] | 86 | |
---|
[1339] | 87 | /// @brief Return the sigma scaling factor for the given dimension and scale of the wavelet transform. |
---|
| 88 | double sigmaFactor(int dim, int scale){return (*sigmaFactors[dim-1])[scale];}; |
---|
| 89 | /// @brief Set the sigma scaling factor for the given dimension and scale of the wavelet transform. |
---|
| 90 | void setSigmaFactor(int dim, int scale, double val){(*sigmaFactors[dim])[scale] = val;}; |
---|
[232] | 91 | |
---|
[1339] | 92 | protected: |
---|
| 93 | std::string name; ///< what is the filter called? |
---|
| 94 | std::vector <double> filter1D; ///< filter coefficients. |
---|
| 95 | std::vector <unsigned int> maxNumScales; ///< max number of scales for the sigmaFactor arrays, for each dim. |
---|
| 96 | std::vector < std::vector <double>* > sigmaFactors; ///< arrays of sigmaFactors, one for each dim. |
---|
[232] | 97 | |
---|
[1339] | 98 | }; |
---|
[232] | 99 | |
---|
[378] | 100 | } |
---|
| 101 | |
---|
[232] | 102 | #endif |
---|
| 103 | |
---|