source: trunk/src/ATrous/atrous.cc @ 201

Last change on this file since 201 was 188, checked in by Matthew Whiting, 18 years ago
  • Changed the way the ReconSearch?-ing is done, with a new function ReconCube? that does the reconstruction, and is called by ReconSearch?.
  • Added default case for the atrous Filter class.
  • Improved the readRecon file, with checks for relevant flags, and saving from the fits call straight into the recon array (without an intermediate array).
File size: 5.5 KB
Line 
1// ATROUS.CC
2//  Functions necessary for the reconstruction routines.
3#include <iostream>
4#include <sstream>
5#include <duchamp.hh>
6#include <ATrous/atrous.hh>
7#include <math.h>
8
9int Filter::getNumScales(long length)
10{
11  switch(this->filter1D.size()){
12  case 5:
13    return int(log(double(length-1))/M_LN2) - 1;
14    break;
15  case 3:
16    return int(log(double(length-1))/M_LN2);
17    break;
18  default:
19    return 1 + int(log(double(length-1)/double(this->filter1D.size()-1))/M_LN2);
20    break;
21  }
22}
23
24int Filter::getMaxSize(int scale)
25{
26  switch(this->filter1D.size()){
27  case 5:
28    return int(pow(2,scale+1)) + 1;
29    break;
30  case 3:
31    return int(pow(2,scale)) + 1;
32    break;
33  default:
34    return int(pow(2,scale-1))*(this->filter1D.size()-1) + 1;
35    break;
36  }
37}
38
39Filter::Filter()
40{
41  this->sigmaFactors.resize(3);
42  for(int i=0;i<3;i++) this->sigmaFactors[i] = new vector<double>(20);
43  this->loadSpline();
44}
45
46
47void Filter::define(int filtercode)
48{
49  switch(filtercode)
50    {
51    case 2:
52      this->loadTriangle();
53      break;
54    case 3:
55      this->loadHaar();
56      break;
57    case 4:
58      //       this->loadTopHat();
59    case 1:
60    default:
61      if(filtercode!=1){
62        if(filtercode==4) {
63          std::stringstream errmsg;
64          errmsg << "TopHat Wavelet not being used currently."
65                 << "Using B3 spline instead.\n";
66          duchampWarning("Filter::define", errmsg.str());
67        }
68        else {
69          std::stringstream errmsg;
70          errmsg << "Filter code " << filtercode << " undefined. Using B3 spline.\n";
71          duchampWarning("Filter::define", errmsg.str());
72        }
73      }
74      this->loadSpline();
75      break;
76    }
77 
78}
79
80void Filter::loadSpline()
81{
82  double filter[5] = {0.0625, 0.25, 0.375, 0.25, 0.0625};
83  this->name = "B3 spline function";
84  this->filter1D.resize(5);
85  for(int i=0;i<5;i++) this->filter1D[i] = filter[i];
86  this->sigmaFactors.resize(3);
87  this->maxNumScales.resize(3);
88
89  this->maxNumScales[0] = 18;
90  double sigmaFactors1D[19] = {1.00000000000,7.23489806e-1,2.85450405e-1,1.77947535e-1,
91                               1.22223156e-1,8.58113122e-2,6.05703043e-2,4.28107206e-2,
92                               3.02684024e-2,2.14024008e-2,1.51336781e-2,1.07011079e-2,
93                               7.56682272e-3,5.35055108e-3,3.78341085e-3,2.67527545e-3,
94                               1.89170541e-3,1.33763772e-3,9.45852704e-4};
95  this->sigmaFactors[0]->resize(19);
96  for(int i=0;i<19;i++)(*this->sigmaFactors[0])[i] = sigmaFactors1D[i];
97
98  this->maxNumScales[1] = 11;
99  double sigmaFactors2D[12] = {1.00000000000,8.90796310e-1,2.00663851e-1,8.55075048e-2,
100                               4.12474444e-2,2.04249666e-2,1.01897592e-2,5.09204670e-3,
101                               2.54566946e-3,1.27279050e-3,6.36389722e-4,3.18194170e-4};
102  this->sigmaFactors[1]->resize(12);
103  for(int i=0;i<12;i++)(*this->sigmaFactors[1])[i] = sigmaFactors2D[i];
104
105  this->maxNumScales[2] = 7;
106  double sigmaFactors3D[8] = {1.00000000000,9.56543592e-1,1.20336499e-1,3.49500154e-2,
107                              1.18164242e-2,4.13233507e-3,1.45703714e-3,5.14791120e-4};
108  this->sigmaFactors[2]->resize(8);
109  for(int i=0;i<12;i++)(*this->sigmaFactors[2])[i] = sigmaFactors3D[i];
110}
111
112void Filter::loadTriangle()
113{
114  double filter[3] = {1./4., 1./2., 1./4.};
115  this->filter1D.resize(3);
116  for(int i=0;i<3;i++) this->filter1D[i] = filter[i];
117  this->name = "Triangle function";
118  this->sigmaFactors.resize(3);
119  this->maxNumScales.resize(3);
120
121  this->maxNumScales[0] = 18;
122  double sigmaFactors1D[19] = {1.00000000000,6.12372436e-1,3.30718914e-1,2.11947812e-1,
123                               1.45740298e-1,1.02310944e-1,7.22128185e-2,5.10388224e-2,
124                               3.60857673e-2,2.55157615e-2,1.80422389e-2,1.27577667e-2,
125                               9.02109930e-3,6.37887978e-3,4.51054902e-3,3.18942978e-3,
126                               2.25527449e-3,1.59471988e-3,1.12763724e-4};
127  this->sigmaFactors[0]->resize(19);
128  for(int i=0;i<19;i++)(*this->sigmaFactors[0])[i] = sigmaFactors1D[i];
129
130  this->maxNumScales[1] = 12;
131  double sigmaFactors2D[13] = {1.00000000000,8.00390530e-1,2.72878894e-1,1.19779282e-1,
132                               5.77664785e-2,2.86163283e-2,1.42747506e-2,7.13319703e-3,
133                               3.56607618e-3,1.78297280e-3,8.91478237e-4,4.45738098e-4,
134                               2.22868922e-4};
135  this->sigmaFactors[1]->resize(13);
136  for(int i=0;i<12;i++)(*this->sigmaFactors[1])[i] = sigmaFactors2D[i];
137
138  this->maxNumScales[2] = 8;
139  double sigmaFactors3D[9] = {1.00000000000,8.959544490e-1,1.92033014e-1,5.76484078e-2,
140                              1.94912393e-2,6.812783870e-3,2.40175885e-3,8.48538128e-4,
141                              2.99949455e-4};
142  this->sigmaFactors[2]->resize(9);
143  for(int i=0;i<12;i++)(*this->sigmaFactors[2])[i] = sigmaFactors3D[i];
144}
145
146void Filter::loadHaar()
147{
148  double filter[3] = {0., 1./2., 1./2.};
149  this->name = "Haar wavelet";
150  this->filter1D.resize(3);
151  for(int i=0;i<3;i++) this->filter1D[i] = filter[i];
152  this->sigmaFactors.resize(3);
153  this->maxNumScales.resize(3);
154
155  this->maxNumScales[0] = 6;
156  double sigmaFactors1D[7] = {1.00000000000,7.07167810e-1,5.00000000e-1,3.53553391e-1,
157                              2.50000000e-1,1.76776695e-1,1.25000000e-1};
158  this->sigmaFactors[0]->resize(7);
159  for(int i=0;i<19;i++)(*this->sigmaFactors[0])[i] = sigmaFactors1D[i];
160
161  this->maxNumScales[1] = 6;
162  double sigmaFactors2D[7] = {1.00000000000,4.33012702e-1,2.16506351e-1,1.08253175e-1,
163                              5.41265877e-2,2.70632939e-2,1.35316469e-2};
164  this->sigmaFactors[1]->resize(7);
165  for(int i=0;i<12;i++)(*this->sigmaFactors[1])[i] = sigmaFactors2D[i];
166
167  this->maxNumScales[2] = 8;
168  double sigmaFactors3D[9] = {1.00000000000,9.35414347e-1,3.30718914e-1,1.16926793e-1,
169                              4.13398642e-2,1.46158492e-2,5.16748303e-3,1.82698115e-3,
170                              6.45935379e-4};
171  this->sigmaFactors[2]->resize(9);
172  for(int i=0;i<12;i++)(*this->sigmaFactors[2])[i] = sigmaFactors3D[i];
173}
Note: See TracBrowser for help on using the repository browser.