Last change
on this file since 208 was
208,
checked in by Matthew Whiting, 18 years ago
|
- Enabled saving and reading in of a smoothed array, in manner directly analogous to that for the recon array.
- New file : src/Cubes/readSmooth.cc
- The other new functions go in existing files eg. saveImage.cc
- Renamed some functions (like writeHeader...) to be more obvious what they do.
- The reading in is taken care of by new function Cube::readSavedArrays() -- handles both smoothed and recon'd arrays.
- Associated parameters in Param class
- Clarified names of FITS header strings in duchamp.hh.
- Updated the documentation to describe the ability to smooth a cube.
- Added description of feedback mechanisms in the Install appendix.
- Also, Hanning class improved to guard against memory leaks.
|
File size:
1.0 KB
|
Line | |
---|
1 | #ifndef HANNING_H |
---|
2 | #define HANNING_H |
---|
3 | |
---|
4 | #include <math.h> |
---|
5 | |
---|
6 | class Hanning |
---|
7 | { |
---|
8 | public: |
---|
9 | Hanning(){allocated=false;}; |
---|
10 | Hanning(int size){ |
---|
11 | if(size%2==0){ |
---|
12 | std::cerr << "Hanning: need an odd number for the size. " |
---|
13 | << "Changing "<< size << " to " << ++size<<".\n"; |
---|
14 | } |
---|
15 | hanningSize = size; |
---|
16 | coeffs = new float[size]; |
---|
17 | allocated = true; |
---|
18 | float a = (size+1.)/2.; |
---|
19 | for(int i=0;i<size;i++){ |
---|
20 | float x = i-(size-1)/2.; |
---|
21 | coeffs[i] = 0.5 + 0.5*cos(x * M_PI / a); |
---|
22 | } |
---|
23 | }; |
---|
24 | virtual ~Hanning(){if(allocated) delete [] coeffs;}; |
---|
25 | |
---|
26 | float *smooth(float *array, int npts){ |
---|
27 | float *newarray = new float[npts]; |
---|
28 | float scale = (hanningSize+1.)/2.; |
---|
29 | for(int i=0;i<npts;i++){ |
---|
30 | newarray[i] = 0.; |
---|
31 | for(int j=0;j<hanningSize;j++){ |
---|
32 | int x = j-(hanningSize-1)/2; |
---|
33 | if((i+x>0)&&(i+x<npts)) newarray[i]+=coeffs[j] * array[i+x]; |
---|
34 | } |
---|
35 | newarray[i] /= scale; |
---|
36 | } |
---|
37 | return newarray; |
---|
38 | }; |
---|
39 | |
---|
40 | |
---|
41 | private: |
---|
42 | int hanningSize; |
---|
43 | float *coeffs; |
---|
44 | bool allocated; |
---|
45 | |
---|
46 | }; |
---|
47 | |
---|
48 | #endif // HANNING_H |
---|
Note: See
TracBrowser
for help on using the repository browser.