source: tags/release-1.0.5/src/Detection/spectrumDetect.cc @ 1455

Last change on this file since 1455 was 177, checked in by Matthew Whiting, 18 years ago

Some minor fixes to code:

  • Fixed potential bug in Cube::initialiseCube
  • Fixed #include commands for the Detect functions
  • Tidied up linear_regression.cc
  • Renamed cubicSearch.cc to CubicSearch?.cc and changed Makefile.in to match.
File size: 1.3 KB
Line 
1/**
2 *  spectrumDetect.cc
3 *
4 * A detection algorithm that searches in a single 1-D spectrum.
5 *
6 * INPUTS:
7 *    image     -- an Image object, containing a 1-D image that has been
8 *                 processed such that its pValue array is defined.
9 * OUTPUTS:
10 *   The detection and mask arrays in image will be filled, according to
11 *   the location of the objects in the image.
12 *
13 */
14
15#include <Cubes/cubes.hh>
16#include <Detection/detection.hh>
17
18enum STATUS { NONOBJECT, OBJECT };
19
20void Image::spectrumDetect()
21{
22  STATUS status;
23  Detection *obj = new Detection;
24  Pixel *pix = new Pixel;
25  bool isObject;
26
27  status = NONOBJECT;
28  for(int pos=0;pos<(this->axisDim[0]+1);pos++){
29
30    isObject=false;
31    if(pos<this->axisDim[0]){
32      pix->setXYF(pos, 0, this->array[pos] );
33      isObject = this->isDetection(pos,0);
34    }
35
36    if(isObject){
37      if(status != OBJECT) status = OBJECT;
38      obj->addPixel(*pix);
39    }
40    else{
41      if(status == OBJECT){ // if we were on an object and have left
42        if(obj->getSize() >= this->minSize){ // if it's big enough
43          obj->calcParams(); // work out midpoints, fluxes etc
44          this->addObject(*obj);  // add to list.
45          this->maskObject(*obj);
46        }
47        obj->clearDetection();
48      }
49      status = NONOBJECT;
50    }
51
52  }
53
54  // clean up and remove declared memory
55  delete obj,pix;
56}
Note: See TracBrowser for help on using the repository browser.