source: tags/release-1.1.7/src/Detection/spectrumDetect.cc @ 1455

Last change on this file since 1455 was 528, checked in by MatthewWhiting, 15 years ago

Changing the documentation comments to match the askapsoft style. Also have split ChanMap? and Object3D into separate files.

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    /// @details
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    STATUS status;
49    Scan obj;
50    std::vector<Scan> outputlist;
51    bool isObject;
52
53    status = NONOBJECT;
54    for(int pos=0;pos<(this->axisDim[0]+1);pos++){
55
56      if(pos<this->axisDim[0]){
57        isObject = this->isDetection(pos,0);
58      }
59      else isObject=false;
60
61      if(isObject){
62        if(status != OBJECT){
63          status = OBJECT;
64          obj.define(0, pos, 1);
65        }
66        else obj.growRight();
67      }
68      else{
69        if(status == OBJECT){ // if we were on an object and have left
70          if(obj.getXlen() >= this->minSize){ // if it's big enough
71            outputlist.push_back(obj);  // add to list.
72          }
73          obj.clear();
74        }
75        status = NONOBJECT;
76      }
77
78    }
79
80    return outputlist;
81 
82  }
83
84}
Note: See TracBrowser for help on using the repository browser.