source: trunk/src/ATrous/filter.hh

Last change on this file was 1339, checked in by MatthewWhiting, 10 years ago

Fixing #210, with new Filter classes deriving from Filter that take care of the specific instantiation, as well as a FilterFactory? class to handle the selection. Param::reconFilter is now a
pointer, but the interface to it remains via a reference.

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
34namespace duchamp
35{
36
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.
48
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();               
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    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.
97
98    };
99
100}
101
102#endif
103
Note: See TracBrowser for help on using the repository browser.