source: tags/release-1.1.4/src/Cubes/cubes.hh @ 1441

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