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

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

Put the Voxel and Pixel classes into their own file voxel.hh and voxel.cc, and adjusted the #include statements of the necessary files. Also added them into the Makefile.

File size: 1.3 KB
Line 
1#include <Cubes/cubes.hh>
2#include <Detection/voxel.hh>
3#include <Detection/detection.hh>
4
5enum STATUS { NONOBJECT, OBJECT };
6
7void Image::spectrumDetect()
8{
9/**
10 *  A detection algorithm that searches in a single 1-D spectrum.  It
11 *  simply scans along the spectrum, storing connected sets of
12 *  detected pixels, where "detected" means according to the
13 *  Image::isDetection(long,long) function.
14 *
15 *  Upon return, the detected objects are stored in the
16 *  Image::objectList vector.
17 *
18 */
19
20  STATUS status;
21  Detection *obj = new Detection;
22  Pixel *pix = new Pixel;
23  bool isObject;
24
25  status = NONOBJECT;
26  for(int pos=0;pos<(this->axisDim[0]+1);pos++){
27
28    isObject=false;
29    if(pos<this->axisDim[0]){
30      pix->setXYF(pos, 0, this->array[pos] );
31      isObject = this->isDetection(pos,0);
32    }
33
34    if(isObject){
35      if(status != OBJECT) status = OBJECT;
36      obj->addPixel(*pix);
37    }
38    else{
39      if(status == OBJECT){ // if we were on an object and have left
40        if(obj->getSize() >= this->minSize){ // if it's big enough
41          obj->calcParams(); // work out midpoints, fluxes etc
42          this->addObject(*obj);  // add to list.
43        }
44        obj->clearDetection();
45      }
46      status = NONOBJECT;
47    }
48
49  }
50
51  // clean up and remove declared memory
52  delete obj;
53  delete pix;
54}
Note: See TracBrowser for help on using the repository browser.