source: tags/release-1.1.5/src/Detection/spectrumDetect.cc @ 1441

Last change on this file since 1441 was 393, checked in by MatthewWhiting, 17 years ago

Fixed up headers for trunk as well.

File size: 2.5 KB
Line 
1// -----------------------------------------------------------------------
2// spectrumDetect.cc: Search a 1D Image for objects.
3// -----------------------------------------------------------------------
4// Copyright (C) 2006, Matthew Whiting, ATNF
5//
6// This program is free software; you can redistribute it and/or modify it
7// under the terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 2 of the License, or (at your
9// option) any later version.
10//
11// Duchamp is distributed in the hope that it will be useful, but WITHOUT
12// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14// for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with Duchamp; if not, write to the Free Software Foundation,
18// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
19//
20// Correspondence concerning Duchamp may be directed to:
21//    Internet email: Matthew.Whiting [at] atnf.csiro.au
22//    Postal address: Dr. Matthew Whiting
23//                    Australia Telescope National Facility, CSIRO
24//                    PO Box 76
25//                    Epping NSW 1710
26//                    AUSTRALIA
27// -----------------------------------------------------------------------
28#include <duchamp/Cubes/cubes.hh>
29#include <duchamp/PixelMap/Scan.hh>
30
31using namespace PixelInfo;
32
33enum STATUS { NONOBJECT, OBJECT };
34
35namespace duchamp
36{
37
38  std::vector<Scan> Image::spectrumDetect()
39  {
40    /**
41     *  A detection algorithm that searches in a single 1-D spectrum.  It
42     *  simply scans along the spectrum, storing connected sets of
43     *  detected pixels as Scans, where "detected" means according to the
44     *  Image::isDetection(long,long) function.
45     *
46     *  When finished a vector of the detected scans is returned.
47     *
48     */
49
50    STATUS status;
51    Scan obj;
52    std::vector<Scan> outputlist;
53    bool isObject;
54
55    status = NONOBJECT;
56    for(int pos=0;pos<(this->axisDim[0]+1);pos++){
57
58      if(pos<this->axisDim[0]){
59        isObject = this->isDetection(pos,0);
60      }
61      else isObject=false;
62
63      if(isObject){
64        if(status != OBJECT){
65          status = OBJECT;
66          obj.define(0, pos, 1);
67        }
68        else obj.growRight();
69      }
70      else{
71        if(status == OBJECT){ // if we were on an object and have left
72          if(obj.getXlen() >= this->minSize){ // if it's big enough
73            outputlist.push_back(obj);  // add to list.
74          }
75          obj.clear();
76        }
77        status = NONOBJECT;
78      }
79
80    }
81
82    return outputlist;
83 
84  }
85
86}
Note: See TracBrowser for help on using the repository browser.