[3] | 1 | #include <iostream> |
---|
| 2 | #include <iomanip> |
---|
| 3 | #include <vector> |
---|
| 4 | #include <Cubes/cubes.hh> |
---|
| 5 | #include <Utils/utils.hh> |
---|
[190] | 6 | #include <Utils/Statistics.hh> |
---|
[3] | 7 | |
---|
| 8 | using std::vector; |
---|
| 9 | using std::setw; |
---|
| 10 | |
---|
[86] | 11 | void growObject(Detection &object, Cube &cube) |
---|
[3] | 12 | { |
---|
[86] | 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 | */ |
---|
[3] | 23 | |
---|
| 24 | |
---|
| 25 | vector <bool> isInObj(cube.getSize(),false); |
---|
[82] | 26 | float thresh1; |
---|
| 27 | float thresh2; |
---|
| 28 | long chanpos; |
---|
[3] | 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 | |
---|
[190] | 36 | StatsContainer<float> growthStats = cube.getStats(); |
---|
| 37 | |
---|
| 38 | growthStats.setThresholdSNR(cube.pars().getGrowthCut()); |
---|
| 39 | growthStats.setUseFDR(false); |
---|
| 40 | |
---|
[3] | 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 | |
---|
[82] | 47 | if((xnbr!=0)||(ynbr!=0)||(znbr!=0)){ |
---|
| 48 | // ignore when all=0 ie. the current object pixel |
---|
[3] | 49 | |
---|
[82] | 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; |
---|
[3] | 54 | |
---|
[82] | 55 | if((newx<cube.getDimX())&&(newx>=0)&& |
---|
| 56 | (newy<cube.getDimY())&&(newy>=0)&& |
---|
| 57 | (newz<cube.getDimZ())&&(newz>=0)){ |
---|
[3] | 58 | |
---|
[82] | 59 | pixnew.setX(newx); |
---|
| 60 | pixnew.setY(newy); |
---|
| 61 | pixnew.setZ(newz); |
---|
[190] | 62 | |
---|
[82] | 63 | float flux; |
---|
| 64 | if(cube.isRecon()) flux = cube.getReconValue(newx,newy,newz); |
---|
[190] | 65 | else flux = cube.getPixValue(newx,newy,newz); |
---|
[82] | 66 | pixnew.setF(flux); |
---|
[3] | 67 | |
---|
[82] | 68 | long chanpos = newx + newy * cube.getDimX(); |
---|
| 69 | long pos = newx + newy * cube.getDimX() + |
---|
| 70 | newz * cube.getDimX() * cube.getDimY(); |
---|
[190] | 71 | if( (!isInObj[pos]) && growthStats.isDetection(flux) ){ |
---|
[82] | 72 | isInObj[pos] = true; |
---|
| 73 | object.addPixel(pixnew); |
---|
[86] | 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 | |
---|