source: tags/release-1.2.2/src/ATrous/filter.hh

Last change on this file was 1026, checked in by MatthewWhiting, 12 years ago

A couple of important fixes for the reconstruction. One is to fix #154, making sure the min & max scales are applied appropriately. Second is to add a new parameter
reconConvergence, which takes the previously hard-coded convergence criterion and makes it available to be altered. Documentation is updated for this parameter as well.

File size: 4.4 KB
Line 
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// -----------------------------------------------------------------------
28#ifndef FILTER_H
29#define FILTER_H
30
31#include <vector>
32#include <string>
33
34namespace duchamp
35{
36
37  /// @brief A 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  class Filter
47  {
48  public:
49    // these are all in atrous.cc
50    /// @brief Constructor
51    Filter();
52    /// @brief Copy Constructor
53    Filter(const Filter& f);
54    /// @brief Copy operator
55    Filter& operator=(const Filter& f);
56    /// @brief Destructor
57    virtual ~Filter();               
58
59    /// @brief Define the parameters for a given filter.
60    void   define(int code);
61
62    /// @brief Calculate the number of scales possible with a given filter and data size.
63    unsigned int    getNumScales(size_t length);
64
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);
67
68    /// @brief Return the width of the filter
69    size_t    width(){return filter1D.size();};
70
71    // these are inline functions.
72    /// @brief Return the text name of the filter
73    std::string getName(){return name;};
74
75    /// @brief Return the i-th value of the coefficient array.
76    double coeff(int i){return filter1D[i];};
77
78    /// @brief Set the i-th value of the coefficient array.
79    void   setCoeff(int i, double val){filter1D[i] = val;};
80
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];};
83
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;};
86
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;};
91
92  private:
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.
97
98    // these are all in atrous.cc
99    /// @brief Set up parameters for using the B3-Spline filter.
100    void   loadSpline(); 
101    /// @brief Set up parameters for using the Triangle function.     
102    void   loadTriangle();
103    /// @brief Set up parameters for using the Haar wavelet.
104    void   loadHaar(); 
105
106  };
107
108}
109
110#endif
111
Note: See TracBrowser for help on using the repository browser.