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

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

Range of alterations... :
Cubes/cubes.cc -- added new front-end to the getopt function, that reads the

command-line options. Makes calling it easier from other
programs.
Slight alteration to Image::removeMW()
Moved Cube::setupColumns() to here, with different flow.

Cubes/cubes.hh -- Prototypes for above.
mainDuchamp.cc -- Removed call to getopt -- now a Cube:: function
Detection/spectrumDetect.cc -- Trying a new way of doing it -- just Detection,

rather than a vector.

Detection/columns.cc -- Changed this around a bit. Made two new functions that

return a ColSet? for either the full case or the logging
case. Cube::setupColumns() now calls these

Detection/mergeIntoList.cc -- minor edit
Detection/columns.hh -- change declaration orders and new prototypes.

File size: 2.0 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  Detection *obj = new Detection;
25  Pixel pix;
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;
86}
Note: See TracBrowser for help on using the repository browser.