source: tags/release-1.1.2/src/Cubes/cubes.hh @ 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: 25.9 KB
Line 
1// -----------------------------------------------------------------------
2// cubes.hh: Definitions of the DataArray, Cube and Image classes.
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#ifndef CUBES_H
29#define CUBES_H
30
31#include <iostream>
32#include <string>
33#include <vector>
34
35#include <duchamp/param.hh>
36#include <duchamp/fitsHeader.hh>
37#include <duchamp/Detection/detection.hh>
38#include <duchamp/Detection/columns.hh>
39#include <duchamp/Cubes/plots.hh>
40#include <duchamp/Utils/Statistics.hh>
41#include <duchamp/PixelMap/Scan.hh>
42#include <duchamp/PixelMap/Object2D.hh>
43
44
45namespace duchamp
46{
47
48
49  /** Search a reconstructed array for significant detections. */
50  std::vector <Detection>
51  searchReconArray(long *dim, float *originalArray, float *reconArray,
52                   Param &par, Statistics::StatsContainer<float> &stats);
53  std::vector <Detection>
54  searchReconArraySimple(long *dim, float *originalArray, float *reconArray,
55                         Param &par, Statistics::StatsContainer<float> &stats);
56
57  /** Search a 3-dimensional array for significant detections. */
58  std::vector <Detection>
59  search3DArray(long *dim, float *Array, Param &par,
60                Statistics::StatsContainer<float> &stats);
61  std::vector <Detection>
62  search3DArraySimple(long *dim, float *Array, Param &par,
63                      Statistics::StatsContainer<float> &stats);
64
65  /**
66   * Base class for the image container.
67   *
68   * Definition of an n-dimensional data array:
69   *     array of pixel values, size & dimensions
70   *     array of Detection objects
71   */
72
73  class DataArray
74  {
75  public:
76    DataArray();  ///< Basic DataArray constructor
77    DataArray(short int nDim); ///< Basic nDim-dimensional DataArray constructor
78    DataArray(short int nDim, long size);///< Basic nDim-dimensional DataArray constructor, specifying size.
79    DataArray(short int nDim, long *dimensions); ///< Basic nDim-dimensional DataArray constructor, specifying size of dimensions.
80    virtual ~DataArray(); ///< Basic DataArray constructor
81
82    //-----------------------------------------
83    // Obvious inline accessor functions.
84    //
85    long               getDimX(){if(numDim>0) return axisDim[0];else return 0;};
86    long               getDimY(){if(numDim>1) return axisDim[1];else return 1;};
87    long               getDimZ(){if(numDim>2) return axisDim[2];else return 1;};
88    long               getSize(){ return numPixels; };
89    short int          getNumDim(){ return numDim; };
90    virtual float      getPixValue(long pos){ return array[pos]; };
91    virtual void       setPixValue(long pos, float f){array[pos] = f;};
92    Detection          getObject(long number){ return objectList->at(number); };
93    std::vector <Detection> getObjectList(){ return *objectList; };
94    std::vector <Detection> *pObjectList(){ return objectList; };
95    std::vector <Detection> &ObjectList(){ std::vector<Detection> &rlist = *objectList; return rlist; };
96    long               getNumObj(){ return objectList->size(); };
97
98    /** Delete all objects from the list of detections. */
99    void               clearDetectionList(){
100      //objectList->clear();
101      delete objectList;
102      objectList = new std::vector<Detection>;
103    };
104
105    /** Read a parameter set from file. */
106    int                readParam(std::string paramfile){
107      /**
108       *  Uses Param::readParams() to read parameters from a file.
109       *  \param paramfile The file to be read.
110       */
111      return par.readParams(paramfile);
112    };
113
114    //-----------------------------------------
115    // Related to the various arrays
116    //
117    /**  Return first three dimensional axes. */
118    void               getDim(long &x, long &y, long &z);
119    /** Return array of dimensional sizes.*/
120    void               getDimArray(long *output);
121    long *             getDimArray(){return axisDim;};
122
123    /** Return pixel value array. */
124    void               getArray(float *output);
125    float *            getArray(){return array;};
126
127    /** Save pixel value array. */
128    virtual void       saveArray(float *input, long size);
129
130    //-----------------------------------------
131    // Related to the object lists
132    //
133    /** Adds a single detection to the object list.*/
134    void               addObject(Detection object);
135
136    /** Adds all objects in a detection list to the object list. */
137    void               addObjectList(std::vector <Detection> newlist);   
138
139    /** Add pixel offsets to object coordinates. */
140    void               addObjectOffsets();
141
142    //-----------------------------------------
143    // Parameter list related.
144    //
145    /** Output the Param set.*/
146    void               showParam(std::ostream &stream){ stream << par; };
147    /** Return the Param set.*/
148    Param              getParam(){ return par; };
149    /** Save a Param set to the Cube.*/
150    void               saveParam(Param &newpar){par = newpar;};
151    /** Provides a reference to the Param set.*/
152    Param&             pars(){ Param &rpar = par; return rpar; };
153    /** Is the voxel number given by vox a BLANK value?*/
154    bool               isBlank(int vox);
155
156    // --------------------------------------------
157    // Statistics
158    //
159    /**  Returns the StatsContainer. */
160    Statistics::StatsContainer<float> getStats(){ return Stats; };
161
162    /** Provides a reference to the StatsContainer. */
163    Statistics::StatsContainer<float>& stats(){
164      Statistics::StatsContainer<float> &rstats = Stats;  return rstats;
165    };
166 
167    /** Save a StatsContainer to the Cube. */
168    void saveStats(Statistics::StatsContainer<float> newStats){ Stats = newStats;};
169
170    /** A detection test for value. */
171    bool isDetection(float value);
172
173    /**  A detection test for pixel.  */
174    bool isDetection(long voxel);
175
176
177    /** Output operator for DataArray.*/
178    friend std::ostream& operator<< (std::ostream& theStream, DataArray &array);
179 
180
181  protected:
182    short int                numDim;     ///< Number of dimensions.
183    long                    *axisDim;    ///< Array of dimensions of cube
184    ///   (ie. how large in each
185    ///   direction).
186    long                     numPixels;  ///< Total number of pixels in cube.
187    float                   *array;      ///< Array of data.
188    std::vector <Detection> *objectList; ///< The list of detected objects.
189    Param                    par;        ///< A parameter list.
190    Statistics::StatsContainer<float> Stats; ///< The statistics for the DataArray.
191  };
192
193
194
195  //=========================================================================
196
197  /**
198   * Definition of an data-cube object (3D):
199   *     a DataArray object limited to dim=3
200   */
201
202  class Cube : public DataArray
203  {
204  public:
205    Cube();                 ///< Basic Cube constructor.
206    Cube(long nPix);        ///< Alternative Cube constructor.
207    Cube(long *dimensions); ///< Alternative Cube constructor.
208    virtual ~Cube();        ///< Basic Cube destructor.
209
210    // INLINE functions -- definitions included after class declaration.
211    /** Is the voxel number given by vox a BLANK value? */
212    bool        isBlank(int vox){ return par.isBlank(array[vox]); };
213
214    /** Is the voxel at (x,y,z) a BLANK value? */
215    bool        isBlank(long x, long y, long z){
216      return par.isBlank(array[z*axisDim[0]*axisDim[1] + y*axisDim[0] + x]); };
217
218    /** Does the Cube::recon array exist? */
219    bool        isRecon(){ return reconExists; };
220
221    float       getPixValue(long pos){ return array[pos]; };
222    float       getPixValue(long x, long y, long z){
223      return array[z*axisDim[0]*axisDim[1] + y*axisDim[0] + x]; };
224    short       getDetectMapValue(long pos){ return detectMap[pos]; };
225    short       getDetectMapValue(long x, long y){ return detectMap[y*axisDim[0]+x]; };
226    float       getReconValue(long pos){ return recon[pos]; };
227    float       getReconValue(long x, long y, long z){
228      return recon[z*axisDim[0]*axisDim[1] + y*axisDim[0] + x];};
229    float       getBaselineValue(long pos){ return baseline[pos]; };
230    float       getBaselineValue(long x, long y, long z){
231      return baseline[z*axisDim[0]*axisDim[1] + y*axisDim[0] + x]; };
232    void        setPixValue(long pos, float f){array[pos] = f;};;
233    void        setPixValue(long x, long y, long z, float f){
234      array[z*axisDim[0]*axisDim[1] + y*axisDim[0] + x] = f;};
235    void        setDetectMapValue(long pos, short f){ detectMap[pos] = f;};
236    void        setDetectMapValue(long x, long y, short f){ detectMap[y*axisDim[0] + x] = f;};
237    void        setReconValue(long pos, float f){recon[pos] = f;};
238    void        setReconValue(long x, long y, long z, float f){
239      recon[z*axisDim[0]*axisDim[1] + y*axisDim[0] + x] = f; };
240    void        setReconFlag(bool f){reconExists = f;};
241
242    std::vector<Column::Col> getLogCols(){return logCols;};
243    void        setLogCols(std::vector<Column::Col> C){logCols=C;};
244    std::vector<Column::Col> getFullCols(){return fullCols;};
245    void        setFullCols(std::vector<Column::Col> C){fullCols=C;};
246
247    // additional functions -- in Cubes/cubes.cc
248    /** Allocate memory correctly, with WCS defining the correct axes. */
249    void        initialiseCube(long *dimensions);
250
251    /** Read in a FITS file, with subsection correction. */
252    int         getCube();
253
254    /** Read in command-line options. */
255    //   int         getopts(int argc, char ** argv);
256    int         getopts(int argc, char ** argv){return par.getopts(argc,argv);};
257
258    /** Read in reconstructed & smoothed arrays from FITS files on disk. */
259    void        readSavedArrays();
260
261    /** Save an external array to the Cube's pixel array */
262    void        saveArray(float *input, long size);
263
264    /** Save an external array to the Cube's reconstructed array. */
265    void        saveRecon(float *input, long size);
266
267    /** Save reconstructed array to an external array. */
268    void        getRecon(float *output);
269    float *     getRecon(){return recon; };
270
271    /** Set Milky Way channels to zero. */
272    void        removeMW();
273
274    //------------------------
275    // Statistics for cube
276    //
277
278    /** Calculate the statistics for the Cube (older version). */
279    void        setCubeStatsOld();
280
281    /** Calculate the statistics for the Cube. */
282    void        setCubeStats();
283
284    /** Set up thresholds for the False Discovery Rate routine. */
285    void        setupFDR();
286    /** Set up thresholds for the False Discovery Rate routine using a
287        particular array. */
288    void        setupFDR(float *input);
289
290    /** A detection test for a given voxel. */
291    bool        isDetection(long x, long y, long z);
292
293    //-----------------------------
294    // Dealing with the detections
295    //
296
297    /** Calculate the WCS parameters for each Cube Detection. */
298    void        calcObjectWCSparams();
299
300    /** Sort the list of detections. */
301    void        sortDetections();
302
303    /** Update the map of detected pixels. */
304    void        updateDetectMap();
305
306    /** Update the map of detected pixels for a given Detection. */
307    void        updateDetectMap(Detection obj);
308
309    /** Clear the map of detected pixels. */
310    void        clearDetectMap(){
311      for(int i=0;i<axisDim[0]*axisDim[1];i++) detectMap[i]=0;
312    };
313
314    /** Find the flux enclosed by a Detection. */
315    float       enclosedFlux(Detection obj);
316
317    /** Set up the output column definitions for the Cube and its
318        Detection list. */
319    void        setupColumns();
320
321    /** Is the object at the edge of the image? */
322    bool        objAtSpatialEdge(Detection obj);
323
324    /** Is the object at an end of the spectrum? */
325    bool        objAtSpectralEdge(Detection obj);
326
327    /** Set warning flags for the detections. */
328    void        setObjectFlags();
329
330    // ----------------------------
331    // Dealing with the WCS
332    //
333    /** Return the FitsHeader object. */
334    FitsHeader  getHead(){ return head; };
335    /** Define the FitsHeader object. */
336    void        setHead(FitsHeader F){head = F;};
337    /** Provide a reference to the FitsHeader object.*/
338    FitsHeader& header(){ FitsHeader &h = head; return h; };
339
340    /** Convert a point from WCS to Pixel coords. */
341    int         wcsToPix(const double *world, double *pix);
342
343    /** Convert a set of points from WCS to Pixel coords. */
344    int         wcsToPix(const double *world, double *pix, const int npts);
345
346    /** Convert a point from Pixel to WCS coords. */
347    int         pixToWCS(const double *pix, double *world);
348
349    /** Convert a set of points from Pixel to WCS coords. */
350    int         pixToWCS(const double *pix, double *world, const int npts);
351
352    //-------------------------------------------
353    // FITS-I/O related functions -- not in cubes.cc
354    //
355    /** Function to read in FITS file.*/
356    int         getCube(std::string fname);  // in Cubes/getImage.cc
357
358    /** Function to retrieve FITS data array */
359    int         getFITSdata(std::string fname);   // in FitsIO/dataIO.cc
360
361    /** Save a mask array to disk.*/
362    void        saveMaskCube();       // in Cubes/saveImage.cc
363
364    /** Save Smoothed array to disk.*/
365    void        saveSmoothedCube();       // in Cubes/saveImage.cc
366
367    /** Save Reconstructed array to disk. */
368    void        saveReconstructedCube();  // in Cubes/saveImage.cc
369
370    /** Read in reconstructed array from FITS file. */
371    int         readReconCube();  // in Cubes/readRecon.cc
372 
373    /** Read in Hanning-smoothed array from FITS file. */
374    int         readSmoothCube();     // in Cubes/readSmooth.cc 
375
376    //-------------------------------------
377    // Functions that act on the cube
378    //
379
380    /** Remove excess BLANK pixels from spatial edge of cube. */
381    void        trimCube();         // in Cubes/trimImage.cc
382
383    /** Replace BLANK pixels to spatial edge of cube. */
384    void        unTrimCube();       // in Cubes/trimImage.cc
385
386    /** Removes the baselines from the spectra, and stores in Cube::baseline */
387    void        removeBaseline();   // in Cubes/baseline.cc
388
389    /** Replace the baselines stored in Cube::baseline */
390    void        replaceBaseline();  // in Cubes/baseline.cc
391
392    /** Multiply all pixel values by -1. */
393    void        invert();           // in Cubes/invertCube.cc
394
395    /** Undo the inversion, and invert fluxes of all detected objects. */
396    void        reInvert();         // in Cubes/invertCube.cc
397
398    //-------------------------------------
399    // Reconstruction, Searching and Merging functions
400    //
401    // in ATrous/ReconSearch.cc
402    /** Front-end to reconstruction & searching functions.*/
403    void        ReconSearch();
404    /** Switcher to reconstruction functions */
405    void        ReconCube();
406    /** Performs 1-dimensional a trous reconstruction on the Cube. */
407    void        ReconCube1D();
408    /** Performs 2-dimensional a trous reconstruction on the Cube. */
409    void        ReconCube2D();
410    /** Performs 3-dimensional a trous reconstruction on the Cube. */
411    void        ReconCube3D();
412
413    // in Cubes/CubicSearch.cc
414    /** Front-end to the cubic searching routine. */
415    void        CubicSearch();
416
417    // in Cubes/smoothCube.cc
418    /** Smooth the cube with the requested method.*/
419    void        SmoothCube();
420    /** Front-end to the smoothing and searching functions. */
421    void        SmoothSearch();
422    /** A function to spatially smooth the cube and search the result. */
423    void        SpatialSmoothNSearch();
424    /** A function to Hanning-smooth the cube. */
425    void        SpectralSmooth();
426    /** A function to spatially-smooth the cube. */
427    void        SpatialSmooth();
428
429    void        Simple3DSearch(){
430      /**
431       * Basic front-end to the simple 3d searching function -- does
432       * nothing more.
433       *
434       * This function just runs the search3DArraySimple function,
435       * storing the results in the Cube::objectList vector. No stats
436       * are calculated beforehand, and no logging or detection map
437       * updating is done.
438       */
439      *objectList = search3DArraySimple(axisDim,array,par,Stats);
440    };
441
442    void        Simple3DSearchRecon(){
443      /**
444       * Basic front-end to the 3d searching function used in the
445       * reconstruction case -- does nothing more.
446       *
447       * This function just runs the searchReconArraySimple function,
448       * storing the results in the Cube::objectList vector. No stats
449       * are calculated beforehand, and no logging or detection map
450       * updating is done. The recon array is assumed to have been
451       * defined already.
452       */
453      *objectList = searchReconArraySimple(axisDim,array,recon,par,Stats);
454    };
455
456    void        Simple3DSearchSmooth(){
457      /**
458       * Basic front-end to the simple 3d searching function run on the
459       * smoothed array -- does nothing more.
460       *
461       * This function just runs the search3DArraySimple function on the
462       * recon array (which contains the smoothed array), storing the
463       * results in the Cube::objectList vector. No stats are calculated
464       * beforehand, and no logging or detection map updating is
465       * done. The recon array is assumed to have been defined already.
466       */
467      *objectList = search3DArraySimple(axisDim,recon,par,Stats);
468    };
469
470    // in Cubes/Merger.cc
471    /** Merge all objects in the detection list so that only distinct
472        ones are left. */
473    void        ObjectMerger();
474 
475    //-------------------------------------
476    // Text outputting of detected objects.
477    //   in Cubes/detectionIO.cc
478    //
479    /** Set up the output file with parameters and stats. */
480    void        prepareOutputFile();
481
482    /** Write the statistical information to the output file. */
483    void        outputStats();
484
485    /** Output detections to the output file and standard output. */
486    void        outputDetectionList();
487
488    /** Output detections to the log file. */
489    void        logDetectionList();
490
491    /** Output a single detection to the log file. */
492    void        logDetection(Detection obj, int counter);
493
494    /** Output detections to a Karma annotation file. */
495    void        outputDetectionsKarma(std::ostream &stream);
496
497    /** Output detections to a VOTable. */
498    void        outputDetectionsVOTable(std::ostream &stream);
499
500    // ----------------------------------
501    // Graphical plotting of the cube and the detections.
502    //
503    //  in Cubes/plotting.cc
504    /** Plot a spatial map of detections based on number of detected
505        channels. */
506    void        plotDetectionMap(std::string pgDestination);
507
508    /** Plot a spatial map of detections based on 0th moment map of each
509        object. */
510    void        plotMomentMap(std::string pgDestination);
511
512    /** Plot a spatial map of detections based on 0th moment map of each
513        object to a number of PGPLOT devices. */
514    void        plotMomentMap(std::vector<std::string> pgDestination);
515
516    /** Draw WCS axes over a PGPLOT map. */
517    void        plotWCSaxes();
518
519    //  in Cubes/outputSpectra.cc
520    /** Print spectra of each detected object. */
521    void        outputSpectra();
522
523    /** Print spectrum of a single object */
524    void        plotSpectrum(Detection obj,Plot::SpectralPlot &plot);
525    /** Plot the image cutout for a single object */
526    void        plotSource(Detection obj, Plot::CutoutPlot &plot);
527
528    //  in Cubes/drawMomentCutout.cc
529    /** Draw the 0th moment map for a single object. */
530    void        drawMomentCutout(Detection &object);
531
532    /** Draw a scale bar indicating angular size of the cutout. */
533    void        drawScale(float xstart,float ystart,float channel);
534
535    /** Draw a yellow line around the edge of the spatial extent of
536        pixels. */
537    void        drawFieldEdge();
538
539  private:
540    float      *recon;            ///< reconstructed array - used when
541    ///   doing a trous reconstruction.
542    bool        reconExists;      ///< flag saying whether there is a
543    ///   reconstruction
544    short      *detectMap;        ///< "moment map" - x,y locations of
545    ///   detected pixels
546    float      *baseline;         ///< array of spectral baseline
547    ///   values.
548                             
549    bool        reconAllocated;   ///< have we allocated memory for the
550    ///   recon array?
551    bool        baselineAllocated;///< have we allocated memory for the
552    ///   baseline array?
553    FitsHeader  head;             ///< the WCS and other header
554    ///   information.
555    std::vector<Column::Col> fullCols;    ///< the list of all columns as
556    ///   printed in the results file
557    std::vector<Column::Col> logCols;     ///< the list of columns as printed in
558    ///   the log file
559
560  };
561
562  ////////////
563  //// Cube inline function definitions
564  ////////////
565
566  inline int Cube::wcsToPix(const double *world, double *pix)
567  {
568    /**
569     *  Use the WCS in the FitsHeader to convert from WCS to pixel coords for
570     *   a single point.
571     *  \param world The world coordinates.
572     *  \param pix The returned pixel coordinates.
573     */
574    return this->head.wcsToPix(world,pix);
575  }
576  inline int Cube::wcsToPix(const double *world, double *pix, const int npts)
577  {
578    /**
579     *  Use the WCS in the FitsHeader to convert from WCS to pixel coords for
580     *   a set of points.
581     *  \param world The world coordinates.
582     *  \param pix The returned pixel coordinates.
583     *  \param npts The number of points being converted.
584     */
585    return this->head.wcsToPix(world,pix,npts);
586  }
587  inline int Cube::pixToWCS(const double *pix, double *world)
588  {
589    /**
590     *  Use the WCS in the FitsHeader to convert from pixel to WCS coords for
591     *   a single point.
592     *  \param pix The pixel coordinates.
593     *  \param world The returned world coordinates.
594     */
595    return this->head.pixToWCS(pix,world);
596  }
597  inline int Cube::pixToWCS(const double *pix, double *world, const int npts)
598  {
599    /**
600     *  Use the WCS in the FitsHeader to convert from pixel to WCS coords for
601     *   a set of points.
602     *  \param pix The pixel coordinates.
603     *  \param world The returned world coordinates.
604     *  \param npts The number of points being converted.
605     */
606    return this->head.pixToWCS(pix,world,npts);
607  }
608
609
610  //============================================================================
611
612  /**
613   *  A DataArray object limited to two dimensions, and with some additional
614   *   special functions.
615   *
616   *  It is used primarily for searching a 1- or 2-D array with
617   *   lutz_detect() and spectrumDetect().
618   */
619
620  class Image : public DataArray
621  {
622  public:
623    Image(){numPixels=0; numDim=2;};
624    Image(long nPix);
625    Image(long *dimensions);
626    virtual ~Image(){};
627
628    //--------------------
629    // Defining the array
630    //
631    /** Save an external array to the Cube's pixel array */
632    void      saveArray(float *input, long size);
633
634    /** Extract a spectrum from an array and save to the local pixel array. */
635    void      extractSpectrum(float *Array, long *dim, long pixel);
636
637    /** Extract an image from an array and save to the local pixel array. */
638    void      extractImage(float *Array, long *dim, long channel);
639
640    /** Extract a spectrum from a cube and save to the local pixel array. */
641    void      extractSpectrum(Cube &cube, long pixel);
642
643    /** Extract an image from a cube and save to the local pixel array. */
644    void      extractImage(Cube &cube, long channel);
645
646    //--------------------
647    // Accessing the data.
648    //
649    float     getPixValue(long pos){ return array[pos]; };
650    float     getPixValue(long x, long y){return array[y*axisDim[0] + x];};
651    // the next few should have checks against array overflow...
652    void      setPixValue(long pos, float f){array[pos] = f;};;
653    void      setPixValue(long x, long y, float f){array[y*axisDim[0] + x] = f;};
654    bool      isBlank(int vox){return par.isBlank(array[vox]);};
655    bool      isBlank(long x,long y){return par.isBlank(array[y*axisDim[0]+x]);};
656
657    //-----------------------
658    // Detection-related
659    //
660    // in Detection/lutz_detect.cc:
661    /** Detect objects in a 2-D image */
662    std::vector<PixelInfo::Object2D> lutz_detect();
663
664    // in Detection/spectrumDetect.cc:
665    /** Detect objects in a 1-D spectrum */
666    std::vector<PixelInfo::Scan> spectrumDetect();
667
668    int       getMinSize(){return minSize;};
669    void      setMinSize(int i){minSize=i;};
670
671    /**  A detection test for a pixel location.  */
672    bool      isDetection(long x, long y){
673      /**
674       * Test whether a pixel (x,y) is a statistically significant detection,
675       * according to the set of statistics in the local StatsContainer object.
676       */
677      long voxel = y*axisDim[0] + x;
678      if(isBlank(x,y)) return false;
679      else return Stats.isDetection(array[voxel]);
680    }; 
681
682    /** Blank out a set of channels marked as being Milky Way channels */
683    void      removeMW();
684
685  private:
686    int       minSize;    ///< the minimum number of pixels for a
687    ///   detection to be accepted.
688  };
689
690
691  /****************************************************************/
692  //////////////////////////////////////////////////////
693  // Prototypes for functions that use above classes
694  //////////////////////////////////////////////////////
695
696  /** Grow an object to a lower threshold */
697  void growObject(Detection &object, Cube &cube);
698
699  /** Draw the edge of the BLANK region on a map.*/
700  void drawBlankEdges(float *dataArray, int xdim, int ydim, Param &par);
701
702}
703
704#endif
Note: See TracBrowser for help on using the repository browser.