source: trunk/src/Detection/spectrumDetect.cc @ 269

Last change on this file since 269 was 258, checked in by Matthew Whiting, 17 years ago

Merging pixel-map-branch revisions 236:257 back into trunk.
The use of the PixelMap? functions is sorted now, so we put everything back into a uniform location.

File size: 1.1 KB
Line 
1#include <Cubes/cubes.hh>
2#include <PixelMap/Scan.hh>
3
4using namespace PixelInfo;
5
6enum STATUS { NONOBJECT, OBJECT };
7
8std::vector<Scan> Image::spectrumDetect()
9{
10/**
11 *  A detection algorithm that searches in a single 1-D spectrum.  It
12 *  simply scans along the spectrum, storing connected sets of
13 *  detected pixels as Scans, where "detected" means according to the
14 *  Image::isDetection(long,long) function.
15 *
16 *  When finished a vector of the detected scans is returned.
17 *
18 */
19
20  STATUS status;
21  Scan obj;
22  std::vector<Scan> outputlist;
23  bool isObject;
24
25  status = NONOBJECT;
26  for(int pos=0;pos<(this->axisDim[0]+1);pos++){
27
28    if(pos<this->axisDim[0]){
29      isObject = this->isDetection(pos,0);
30    }
31    else isObject=false;
32
33    if(isObject){
34      if(status != OBJECT){
35        status = OBJECT;
36        obj.define(0, pos, 1);
37      }
38      else obj.growRight();
39    }
40    else{
41      if(status == OBJECT){ // if we were on an object and have left
42        if(obj.getXlen() >= this->minSize){ // if it's big enough
43          outputlist.push_back(obj);  // add to list.
44        }
45        obj.clear();
46      }
47      status = NONOBJECT;
48    }
49
50  }
51
52  return outputlist;
53 
54}
Note: See TracBrowser for help on using the repository browser.