source: branches/fitshead-branch/Detection/spectrumDetect.cc @ 1441

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

Added a simpler search routine for 1-D data, called spectrumDetect (in
Detection/), that doesn't use the extra row that is involved in the
lutz_detect routine. This should make the 1-D search run 2x as fast...
Changed the calls to lutz_detect in cubicSearch & reconSearch to
spectrumDetect for the 1-D cases.

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 <vector>
17
18enum STATUS { NONOBJECT, OBJECT };
19
20void Image::spectrumDetect()
21{
22  STATUS status;
23  vector <Detection> *obj = new vector <Detection>;
24  Pixel pix;
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){
38        status = OBJECT;
39        obj->resize(obj->size()+1);
40      }
41      obj->back().addPixel(pix);
42    }
43    else if(obj->size()>0){
44      if(obj->back().getSize() >= this->minSize){ // is it big enough?
45        obj->back().calcParams(); // work out midpoints, fluxes etc
46        this->addObject(obj->back());  // add to list.
47        this->maskObject(obj->back());
48      }
49      obj->pop_back();
50      status = NONOBJECT;
51    }
52
53  }
54
55  // clean up and remove declared arrays
56  delete obj;
57}
Note: See TracBrowser for help on using the repository browser.