source: trunk/src/ATrous/filter.cc @ 1455

Last change on this file since 1455 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
RevLine 
[299]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// -----------------------------------------------------------------------
[139]28#include <iostream>
29#include <sstream>
[393]30#include <duchamp/duchamp.hh>
31#include <duchamp/ATrous/filter.hh>
[3]32#include <math.h>
[258]33#include <vector>
[3]34
[378]35namespace duchamp
[3]36{
[365]37
[1339]38    Filter::Filter():
39        name("")
[378]40  {
[1339]41      this->sigmaFactors = std::vector< std::vector<double>* >(3);
42      this->maxNumScales = std::vector<unsigned int>(3,0);
[378]43  }
[365]44
[378]45  Filter::Filter(const Filter& f)
46  {
47    operator=(f);
48  }
[365]49
[378]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  }
[3]59
[378]60  //-----------------------------------------------------------------------
[3]61
[378]62  Filter::~Filter()
63  {
[468]64    this->filter1D.clear();
65    this->maxNumScales.clear();
66    this->sigmaFactors.clear();
[378]67  }
68  //-----------------------------------------------------------------------
69
70
[1026]71  unsigned int Filter::getNumScales(size_t length)
[378]72  {
[846]73    unsigned int num;
[1026]74    if(length==0) return 0;
[378]75    switch(this->filter1D.size()){
76    case 5:
[855]77      num = int(log(double(length-1))/M_LN2) - 1;
[3]78      break;
[378]79    case 3:
[855]80      num = int(log(double(length-1))/M_LN2);
[378]81      break;
82    default:
[855]83      num = 1 + int(log(double(length-1)/double(this->filter1D.size()-1))/M_LN2);
[378]84      break;
[3]85    }
[846]86    return num;
[220]87  }
[378]88  //-----------------------------------------------------------------------
[220]89
[846]90  unsigned int Filter::getMaxSize(int scale)
[378]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    }
[220]103  }
[1339]104 
[3]105}
Note: See TracBrowser for help on using the repository browser.