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

Last change on this file since 201 was 190, checked in by Matthew Whiting, 18 years ago

Large commit. The addition of a new Statistics namespace & class, plus a number of changes to the code to make the cube-wide statistics calculation work. The FDR calculations are incorporated into the new class, and a number of functions have been made into templates to ease the calculations. Details follow:

  • New namespace and class (StatsContainer? -- templated) in Statistics.hh, that holds mean,median,stddev & madfm, and provide accessor and calculator functions for these. It also holds the threshold values for sigma-clipping and FDR methods, as well as the PValue evaluation functions
  • The correctionFactor incorporated into the namespace, and given a conversion function that other functions can call (eg. the atrous_Xd_reconstruct functions).
  • Templated the statistics functions in getStats.cc.
  • Templated the sort functions, and made swap an inline one defined in utils.hh.
  • A number of changes to cubes.cc and cubes.hh:
    • DataArray? gains a StatsContainer? object, to store stats info.
    • Image has lost its pValue array (not needed as we calculate on the fly) and mask array (not used).
    • Image has also lost all its stats members, but keeps minPix.
    • Functions to go are Image::maskObject, Image::findStats. Removed calls to the former. Latter never used.
    • Cube::setCubeStats does the cube-wide stats calculations, including setupFDR (now a Cube function).
    • Cube loses the specMean etc arrays.
  • The Search functions (ReconSearch? and CubicSearch?) changed to accommodate the exchange of StatsContainer? objects. This changed the prototypes as well.
  • The growObject function incorporates the new StatsContainer? object.
  • Minor change to Merger, in the preparation for calling growObject.
  • A new par introduced: flagUserThreshold -- set to true when the user enters a value for the threshold.
  • Removed thresholding_functions.cc and incorporated its functions into cubes.cc and cubes.hh.
File size: 2.5 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
8using std::vector;
9using std::setw;
10
11void growObject(Detection &object, Cube &cube)
12{
13  /**
14   *  growObject(Detection, Cube)
15   *    A function to grow an object (given by the Detection)
16   *     out to some lower threshold.
17   *    The Cube is necessary to see both the Param list, containing
18   *     the growth threshold, and the actual array of pixel fluxes.
19   *    Each pixel has each of its neighbours examined, and if one of
20   *     them is not in the object but above the growth threshold, it
21   *     is added to the object.
22   */
23
24
25  vector <bool> isInObj(cube.getSize(),false);
26  float thresh1;
27  float thresh2;
28  long  chanpos;
29
30  for(int i=0;i<object.getSize();i++) {
31    long pos = object.getX(i) + object.getY(i)*cube.getDimX() +
32      object.getZ(i)*cube.getDimX()*cube.getDimY();
33    isInObj[pos] = true;
34  }
35 
36  StatsContainer<float> growthStats = cube.getStats();
37
38  growthStats.setThresholdSNR(cube.pars().getGrowthCut());
39  growthStats.setUseFDR(false);
40 
41  for(int pix=0; pix<object.getSize(); pix++){ // for each pixel in the object
42
43    for(int xnbr=-1; xnbr<=1; xnbr++){
44      for(int ynbr=-1; ynbr<=1; ynbr++){
45        for(int znbr=-1; znbr<=1; znbr++){
46
47          if((xnbr!=0)||(ynbr!=0)||(znbr!=0)){
48            // ignore when all=0 ie. the current object pixel
49
50            Voxel pixnew = object.getPixel(pix);
51            long newx = object.getX(pix) + xnbr;
52            long newy = object.getY(pix) + ynbr;
53            long newz = object.getZ(pix) + znbr;
54         
55            if((newx<cube.getDimX())&&(newx>=0)&&
56               (newy<cube.getDimY())&&(newy>=0)&&
57               (newz<cube.getDimZ())&&(newz>=0)){
58           
59              pixnew.setX(newx);
60              pixnew.setY(newy);
61              pixnew.setZ(newz);
62
63              float flux;
64              if(cube.isRecon()) flux = cube.getReconValue(newx,newy,newz);
65              else               flux = cube.getPixValue(newx,newy,newz);
66              pixnew.setF(flux);
67
68              long chanpos = newx + newy * cube.getDimX();
69              long pos = newx + newy * cube.getDimX() +
70                newz * cube.getDimX() * cube.getDimY();
71              if( (!isInObj[pos]) && growthStats.isDetection(flux) ){
72                isInObj[pos] = true;
73                object.addPixel(pixnew);
74              } // end of if
75
76            } // end of if clause regarding newx, newy, newz
77
78          } // end of if clause regarding xnbr, ynbr, znbr
79
80        } // end of znbr loop
81      } // end of ynbr loop
82    } // end of xnbr loop
83     
84  } // end of pix loop
85
86  object.calcParams();
87
88  isInObj.clear();
89
90}
91
Note: See TracBrowser for help on using the repository browser.