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 | |
---|
18 | enum STATUS { NONOBJECT, OBJECT }; |
---|
19 | |
---|
20 | void Image::spectrumDetect() |
---|
21 | { |
---|
22 | STATUS status; |
---|
23 | // vector <Detection> *obj = new vector <Detection>; |
---|
24 | Detection *obj = new Detection; |
---|
25 | Pixel *pix = new Pixel; |
---|
26 | bool isObject; |
---|
27 | |
---|
28 | status = NONOBJECT; |
---|
29 | for(int pos=0;pos<(this->axisDim[0]+1);pos++){ |
---|
30 | |
---|
31 | // isObject=false; |
---|
32 | // if(pos<this->axisDim[0]){ |
---|
33 | // pix->setXYF(pos, 0, this->array[pos] ); |
---|
34 | // isObject = this->isDetection(pos,0); |
---|
35 | // } |
---|
36 | |
---|
37 | // if(isObject){ |
---|
38 | // if(status != OBJECT){ |
---|
39 | // status = OBJECT; |
---|
40 | // obj->resize(obj->size()+1); |
---|
41 | // } |
---|
42 | // obj->back().addPixel(*pix); |
---|
43 | // } |
---|
44 | // else if(obj->size()>0){ |
---|
45 | // if(obj->back().getSize() >= this->minSize){ // is it big enough? |
---|
46 | // obj->back().calcParams(); // work out midpoints, fluxes etc |
---|
47 | // this->addObject(obj->back()); // add to list. |
---|
48 | // this->maskObject(obj->back()); |
---|
49 | // } |
---|
50 | // obj->pop_back(); |
---|
51 | // status = NONOBJECT; |
---|
52 | // } |
---|
53 | |
---|
54 | //////////////////////////////////////////////////// |
---|
55 | |
---|
56 | |
---|
57 | isObject=false; |
---|
58 | if(pos<this->axisDim[0]){ |
---|
59 | pix->setXYF(pos, 0, this->array[pos] ); |
---|
60 | isObject = this->isDetection(pos,0); |
---|
61 | } |
---|
62 | |
---|
63 | if(isObject){ |
---|
64 | if(status != OBJECT){ |
---|
65 | status = OBJECT; |
---|
66 | } |
---|
67 | obj->addPixel(*pix); |
---|
68 | } |
---|
69 | else{ |
---|
70 | if(status == OBJECT){ // if we were on an object and have left |
---|
71 | if(obj->getSize() >= this->minSize){ // if it's big enough |
---|
72 | obj->calcParams(); // work out midpoints, fluxes etc |
---|
73 | this->addObject(*obj); // add to list. |
---|
74 | this->maskObject(*obj); |
---|
75 | } |
---|
76 | obj->clearDetection(); |
---|
77 | } |
---|
78 | status = NONOBJECT; |
---|
79 | } |
---|
80 | |
---|
81 | |
---|
82 | } |
---|
83 | |
---|
84 | // clean up and remove declared arrays |
---|
85 | delete obj,pix; |
---|
86 | } |
---|