source: tags/release-1.1/src/ATrous/filter.hh @ 1391

Last change on this file since 1391 was 299, checked in by Matthew Whiting, 17 years ago

Adding distribution text at the start of each file...

File size: 4.1 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
34/**
35 * A class to store details of the wavelet's filter.
36 * This stores all details of and functions related to the filter used to
37 *  generate the wavelets used in the reconstruction (and baseline
38 *  subtraction) functions.
39 *
40 * It stores the coefficients of the filter, as well as the number of scales
41 * associated with it, and the sigma factors, that relate the value of the rms
42 * at a given scale with the measured value.
43 */
44
45class Filter
46{
47public:
48  // these are all in atrous.cc
49  Filter();                         ///< Constructor
50  virtual ~Filter();                ///< Destructor
51
52  /** Define the parameters for a given filter. */
53  void   define(int code);
54
55  /** Calculate the number of scales possible with a given filter and
56      data size. */
57  int    getNumScales(long length);
58
59  /** Calculate the maximum number of pixels able to be analysed with
60      a filter at a given scale. */
61  int    getMaxSize(int scale);
62
63  /** Return the width of the filter */
64  int    width(){return filter1D.size();};
65
66  // these are inline functions.
67  /** Return the text name of the filter */
68  std::string getName(){return name;};
69
70  /** Return the i-th value of the coefficient array. */
71  double coeff(int i){return filter1D[i];};
72
73  /** Set the i-th value of the coefficient array. */
74  void   setCoeff(int i, double val){filter1D[i] = val;};
75
76  /** Return the maximum number of scales in the sigmaFactor array for
77      the given dimension */
78  int    maxFactor(int dim){return maxNumScales[dim-1];};
79
80  /** Set the maximum number of scales in the sigmaFactor array for
81      the given dimension */
82  void   setMaxFactor(int dim, int val){maxNumScales[dim-1] = val;};
83
84  /** Return the sigma scaling factor for the given dimension and
85      scale of the wavelet transform. */
86  double sigmaFactor(int dim, int scale){return (*sigmaFactors[dim-1])[scale];};
87  /** Set the sigma scaling factor for the given dimension and
88      scale of the wavelet transform. */
89  void   setSigmaFactor(int dim, int scale, double val){(*sigmaFactors[dim])[scale] = val;};
90
91private:
92  std::string name;                ///< what is the filter called?
93  std::vector <double> filter1D;   ///< filter coefficients.
94  std::vector <int> maxNumScales;  ///< max number of scales for the sigmaFactor arrays, for each dim.
95  std::vector < std::vector <double>* > sigmaFactors; ///< arrays of sigmaFactors, one for each dim.
96
97  // these are all in atrous.cc
98  void   loadSpline();        ///< set up parameters for using the
99                              ///   B3-Spline filter.
100  void   loadTriangle();      ///< set up parameters for using the
101                              ///   Triangle function.
102  void   loadHaar();          ///< set up parameters for using the
103                              ///   Haar wavelet.
104
105};
106
107#endif
108
Note: See TracBrowser for help on using the repository browser.