source: trunk/src/Detection/growObject.cc @ 269

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

Utils/Statistics?.hh -- minor coments
Cubes/cubes.cc -- setupFDR: ignore MW channels, fixed bug in threshold determination (won't affect detection threshold though), added plot to visualise threshold determination that's done only when new TEST flag is set.
Cubes/CubicSearch?.cc -- new simple search that only searches in images and keeps all detections (no minimum size requirement). No 1D searching done.
Cubes/cubes.hh -- prototypes for new searches
Cubes/Merger?.cc -- improved feedback for growth functionality
config.h -- new TEST_DEBUG flag defined.
ATrous/ReconSearch.cc -- new simple search
FitsIO/subsection.cc -- removed unnecessary output
Detection/detection.cc -- added ability to calculate centre-of-mass of detection
Detection/growObject.cc -- increased range over which object is grown, and added extra conditions on new pixels.
Detection/detection.hh -- centre-of-mass

Several changes:

  • Cube::setupFDR() improved:
    • MW channels are now ignored if needs be in determining cutoff.
    • A bug was fixed in the code that calculates the flux threshold from the p-value threshold.
    • A pgplot output to visualise the threshold determination is produced when the new TEST_DEBUG flag is defined.
  • This new TEST_DEBUG flag is set in the config.h file -- only the local one, not the one generated by configure.
  • The Detection class now has centre-of-mass parameters for x,y,z that are calculated in the calcFluxes() function. These are not outputted yet.
  • The growObject() function will now look at pixels over the full allowed range of neighbours given the threshSpatial/threshVelocity parameters. It also has new conditions on the new pixels (not-BLANK,not-MW,etc)
  • New versions of search3DArray and searchReconArry (with Simple on the end of the name) that do just the searching in 2D, with no requirement on the minimum number of pixels. No 1D searching is done.
  • Other minor changes to comments and user feedback.
File size: 3.1 KB
Line 
1#include <iostream>
2#include <iomanip>
3#include <vector>
4#include <Cubes/cubes.hh>
5#include <Utils/utils.hh>
6#include <Utils/Statistics.hh>
7#include <PixelMap/Voxel.hh>
8#include <Detection/detection.hh>
9
10using std::vector;
11using std::setw;
12
13using namespace PixelInfo;
14
15void growObject(Detection &object, Cube &cube)
16{
17  /**
18   *    A function to grow an object (given by the Detection) by
19   *    including neighbouring voxels out to some lower threshold than
20   *    what was previously used in the detection. 
21   *
22   *    Each pixel has each of its neighbours examined, and if one of
23   *    them is not in the object but above the growth threshold, it
24   *    is added to the object.
25   *
26   *    \param object Object to be grown.
27   *    \param cube Necessary to see both the Param list, containing
28   *    the growth threshold, and the actual array of pixel fluxes.
29   */
30
31
32  vector <bool> isInObj(cube.getSize(),false);
33  bool flagAdj = cube.pars().getFlagAdjacent();
34  int threshS = int(cube.pars().getThreshS());
35  if(flagAdj) threshS = 1;
36  int threshV = int(cube.pars().getThreshV());
37  long  chanpos;
38
39  for(int i=0;i<object.getSize();i++) {
40    Voxel vox = object.getPixel(i);
41    long pos = vox.getX() + vox.getY()*cube.getDimX() +
42      vox.getZ()*cube.getDimX()*cube.getDimY();
43    isInObj[pos] = true;
44  }
45 
46  StatsContainer<float> growthStats = cube.getStats();
47
48  growthStats.setThresholdSNR(cube.pars().getGrowthCut());
49  growthStats.setUseFDR(false);
50 
51  for(int pix=0; pix<object.getSize(); pix++){ // for each pixel in the object
52
53    for(int xnbr=-1*threshS; xnbr<=1*threshS; xnbr++){
54      for(int ynbr=-1*threshS; ynbr<=1*threshS; ynbr++){
55        for(int znbr=-1*threshV; znbr<=1*threshV; znbr++){
56
57          if((xnbr!=0)||(ynbr!=0)||(znbr!=0)){
58            // ignore when all=0 ie. the current object pixel
59
60            Voxel pixnew = object.getPixel(pix);
61            long newx = pixnew.getX() + xnbr;
62            long newy = pixnew.getY() + ynbr;
63            long newz = pixnew.getZ() + znbr;
64         
65            if((newx<cube.getDimX())&&(newx>=0)&&   // x in cube?
66               (newy<cube.getDimY())&&(newy>=0)&&   // y in cube?
67               (newz<cube.getDimZ())&&(newz>=0)&&   // z in cube?
68               !cube.isBlank(newx,newy,newz)   &&   // pixel not BLANK?
69               !cube.pars().isInMW(newz)       &&   // pixel not MW?
70               (flagAdj || hypot(xnbr,ynbr))     ){ // pixel not too far?
71           
72              pixnew.setX(newx);
73              pixnew.setY(newy);
74              pixnew.setZ(newz);
75
76              float flux;
77              if(cube.isRecon()) flux = cube.getReconValue(newx,newy,newz);
78              else               flux = cube.getPixValue(newx,newy,newz);
79              pixnew.setF(flux);
80
81              long chanpos = newx + newy * cube.getDimX();
82              long pos = newx + newy * cube.getDimX() +
83                newz * cube.getDimX() * cube.getDimY();
84              if( (!isInObj[pos]) && growthStats.isDetection(flux) ){
85                isInObj[pos] = true;
86                object.addPixel(pixnew);
87              } // end of if
88
89            } // end of if clause regarding newx, newy, newz
90
91          } // end of if clause regarding xnbr, ynbr, znbr
92
93        } // end of znbr loop
94      } // end of ynbr loop
95    } // end of xnbr loop
96     
97  } // end of pix loop
98
99  object.calcFluxes(cube.getArray(), cube.getDimArray());
100
101  isInObj.clear();
102
103}
104
Note: See TracBrowser for help on using the repository browser.