source: trunk/src/Cubes/smoothCube.cc @ 219

Last change on this file since 219 was 219, checked in by Matthew Whiting, 18 years ago
  • Fixed bug in the copy constructors of Detection class.
  • Improved the way the ProgressBar? worked (the update() function), and in the way it was implemented in several functions.
  • Changed fallback spectral units from XX to SPC (hopefully a bit more clear).
  • Changed spacing of the printing out of the parameters.
  • Some changes to comments for documentation purposes.
File size: 1.9 KB
Line 
1#include <Cubes/cubes.hh>
2#include <ATrous/atrous.hh>
3#include <Utils/feedback.hh>
4#include <Utils/Hanning.hh>
5
6void Cube::SmoothCube()
7{
8  /**
9   *  Cube::SmoothCube()
10   *
11   *   A function that smooths each spectrum in the cube using the
12   *    Hanning smoothing function. The degree of smoothing is given
13   *    by the parameter hannWidth.
14   */
15
16  Hanning::Hanning hann(this->par.getHanningWidth());
17 
18  long xySize = this->axisDim[0]*this->axisDim[1];
19  long zdim = this->axisDim[2];
20
21  float *spectrum = new float[this->axisDim[2]];
22
23  ProgressBar bar;
24  if(this->par.isVerbose()) {
25    std::cout<<"  Smoothing... ";
26    bar.init(xySize);
27  }
28
29  for(int pix=0;pix<xySize;pix++){
30
31    if( this->par.isVerbose() ) bar.update(pix+1);
32   
33    for(int z=0;z<zdim;z++){
34      if(this->isBlank(z*xySize+pix)) spectrum[z]=0.;
35      else spectrum[z] = this->array[z*xySize+pix];
36    }
37
38    float *smoothed = hann.smooth(spectrum,zdim);
39
40    for(int z=0;z<zdim;z++){
41      if(this->isBlank(z*xySize+pix))
42        this->recon[z*xySize+pix]=this->array[z*xySize+pix];
43      else
44        this->recon[z*xySize+pix] = smoothed[z];
45    }
46    delete [] smoothed;
47  }
48  this->reconExists = true;
49  if(this->par.isVerbose()) bar.fillSpace("All Done.\n");
50
51  delete [] spectrum;
52
53}
54
55
56void Cube::SmoothSearch()
57{
58  /**
59   * Cube::SmoothSearch()
60   *   The Cube is first smoothed, using Cube::SmoothCube().
61   *   It is then searched, using searchReconArray.
62   *   The resulting object list is stored in the Cube, and outputted
63   *    to the log file if the user so requests.
64   */
65 
66  this->SmoothCube();
67  if(this->par.isVerbose()) std::cout << "  ";
68  this->setCubeStats();
69  if(this->par.isVerbose()) std::cout << "  Searching... " << std::flush;
70 
71  this->objectList = search3DArray(this->axisDim,this->recon,
72                                   this->par,this->Stats);
73
74  this->updateDetectMap();
75  if(this->par.getFlagLog()) this->logDetectionList();
76 
77
78}
Note: See TracBrowser for help on using the repository browser.