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

Last change on this file since 208 was 201, checked in by Matthew Whiting, 18 years ago
  • New functionality added: ability to smooth a cube (in each individual spectrum) using a hanning filter before searching.
  • This comes with associated input parameters: flagSmooth and hanningWidth.
  • Hanning smoothing implemented via a new class that does the smoothing
  • Other minor changes:
    • changed the way getIAUName is called.
    • new colour names in mycpgplot
    • a << operator for the StatsContainer? class
    • more robust ProgressBar? functions
    • updated the Makefile.in
File size: 1.8 KB
Line 
1#include <duchamp.hh>
2#include <Cubes/cubes.hh>
3#include <ATrous/atrous.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  std::cout<<"  Smoothing... ";
25  if(par.isVerbose()) bar.init(xySize);
26
27  for(int pix=0;pix<xySize;pix++){
28
29    if( par.isVerbose() ) bar.update(pix+1);
30   
31    for(int z=0;z<zdim;z++){
32      if(this->isBlank(z*xySize+pix)) spectrum[z]=0.;
33      else spectrum[z] = this->array[z*xySize+pix];
34    }
35
36    float *smoothed = hann.smooth(spectrum,zdim);
37
38    for(int z=0;z<zdim;z++){
39      if(this->isBlank(z*xySize+pix))
40        this->recon[z*xySize+pix]=this->array[z*xySize+pix];
41      else
42        this->recon[z*xySize+pix] = smoothed[z];
43    }
44    delete [] smoothed;
45  }
46  this->reconExists = true;
47  bar.remove();
48  std::cout << "All Done.\n";
49
50  delete [] spectrum;
51
52}
53
54
55void Cube::SmoothSearch()
56{
57  /**
58   * Cube::SmoothSearch()
59   *   The Cube is first smoothed, using Cube::SmoothCube().
60   *   It is then searched, using searchReconArray.
61   *   The resulting object list is stored in the Cube, and outputted
62   *    to the log file if the user so requests.
63   */
64 
65  this->SmoothCube();
66  this->setCubeStats();
67  std::cout << "  Searching... " << std::flush;
68 
69  this->objectList = search3DArray(this->axisDim,this->recon,
70                                   this->par,this->Stats);
71
72  this->updateDetectMap();
73  if(this->par.getFlagLog()) this->logDetectionList();
74 
75
76}
Note: See TracBrowser for help on using the repository browser.