source: trunk/src/ATrous/filter.cc

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: 3.0 KB
Line 
1// -----------------------------------------------------------------------
2// filter.cc: 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#include <iostream>
29#include <sstream>
30#include <duchamp/duchamp.hh>
31#include <duchamp/ATrous/filter.hh>
32#include <math.h>
33#include <vector>
34
35namespace duchamp
36{
37
38    Filter::Filter():
39        name("")
40  {
41      this->sigmaFactors = std::vector< std::vector<double>* >(3);
42      this->maxNumScales = std::vector<unsigned int>(3,0);
43  }
44
45  Filter::Filter(const Filter& f)
46  {
47    operator=(f);
48  }
49
50  Filter& Filter::operator=(const Filter& f)
51  {
52    if(this==&f) return *this;
53    this->name = f.name;
54    this->filter1D = f.filter1D;
55    this->maxNumScales = f.maxNumScales;
56    this->sigmaFactors = f.sigmaFactors;
57    return *this;
58  }
59
60  //-----------------------------------------------------------------------
61
62  Filter::~Filter()
63  {
64    this->filter1D.clear();
65    this->maxNumScales.clear();
66    this->sigmaFactors.clear();
67  }
68  //-----------------------------------------------------------------------
69
70
71  unsigned int Filter::getNumScales(size_t length)
72  {
73    unsigned int num;
74    if(length==0) return 0;
75    switch(this->filter1D.size()){
76    case 5:
77      num = int(log(double(length-1))/M_LN2) - 1;
78      break;
79    case 3:
80      num = int(log(double(length-1))/M_LN2);
81      break;
82    default:
83      num = 1 + int(log(double(length-1)/double(this->filter1D.size()-1))/M_LN2);
84      break;
85    }
86    return num;
87  }
88  //-----------------------------------------------------------------------
89
90  unsigned int Filter::getMaxSize(int scale)
91  {
92    switch(this->filter1D.size()){
93    case 5:
94      return int(pow(2,scale+1)) + 1;
95      break;
96    case 3:
97      return int(pow(2,scale)) + 1;
98      break;
99    default:
100      return int(pow(2,scale-1))*(this->filter1D.size()-1) + 1;
101      break;
102    }
103  }
104 
105}
Note: See TracBrowser for help on using the repository browser.