Changeset 20621
- Timestamp:
- Nov 9, 2008, 7:17:43 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/detrend/pmRemnance.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmRemnance.c
r20620 r20621 8 8 #include "pmFPA.h" 9 9 #include "pmRemnance.h" 10 11 #define SIZE 30 // Size of accumulation patch 10 12 11 13 #define THRESHOLD 4.0 // Threshold above background … … 34 36 } 35 37 psFree(rng); 36 float thresh = stats->robustMedian + THRESHOLD * stats->robustStdev; // Threshold for significant pixels 37 psFree(stats); 38 float bg = stats->robustMedian; // Background level 38 39 39 40 // Starting at the bottom of the detector, mask pixels that are significant 41 psVector *colSums = psVectorAlloc(numCols, PS_TYPE_F32); // Sums for each column 42 psVectorInit(colSums, 0.0); 43 psVector *colNums = psVectorAlloc(numCols, PS_TYPE_S32); // Number for each column 44 psVectorInit(colNums, 0); 45 psVector *colAvgs = psVectorAlloc(numCols, PS_TYPE_F32); // Average for each column 46 psVector *colMask = psVectorAlloc(numCols, PS_TYPE_MASK); // Mask for each column 40 47 int numMasked = 0; // Number of pixels masked 41 for (int x = 0; x < numCols; x++) { 42 bool significant = true; // Are pixels significant? 43 for (int y = 0; significant && y < numRows; y++) { 44 if (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) { 45 continue; 48 int numAccumulations = ceil(numRows / (float)SIZE); // Number of accumulations up the columns 49 for (int i = 0; i < numAccumulations; i++) { 50 int min = i * SIZE; // Minimum coordinate 51 int max = PS_MIN(min + SIZE, numRows); // Maximum coordinate 52 for (int x = 0; x < numCols; x++) { 53 int num = 0; // Number of pixels in accumulation 54 float sum = 0.0; // Sum of pixels in accumulation 55 for (int y = min; y < max; y++) { 56 if (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) { 57 continue; 58 } 59 sum += image->data.F32[y][x] - bg; 60 num++; 46 61 } 47 if (image->data.F32[y][x] > thresh) { 48 mask->data.PS_TYPE_MASK_DATA[y][x] |= maskRem; 49 numMasked++; 50 } else { 51 significant = false; 62 colSums->data.F32[x] = sum; 63 colNums->data.S32[x] = num; 64 colAvgs->data.F32[x] = sum / (float)num; 65 colMask->data.PS_TYPE_MASK_DATA[x] = (colNums->data.S32[x] == 0 ? 0xFF : 0); 66 } 67 68 if (!psVectorStats(stats, colAvgs, NULL, colMask, 0xFF)) { 69 psError(PS_ERR_UNKNOWN, false, "Unable to perform statistics on column accumulations."); 70 psFree(colSums); 71 psFree(colNums); 72 psFree(colAvgs); 73 psFree(colMask); 74 psFree(stats); 75 return false; 76 } 77 78 float threshold = stats->robustMedian + THRESHOLD * stats->robustStdev; // Threshold for masking 79 80 max = PS_MIN(max + SIZE, numRows); 81 82 for (int x = 0; x < numCols; x++) { 83 if (colAvgs->data.F32[x] > threshold) { 84 for (int y = 0; y < max; y++) { 85 mask->data.PS_TYPE_MASK_DATA[y][x] = maskRem; 86 numMasked++; 87 } 52 88 } 53 89 } 54 90 } 91 92 psFree(colSums); 93 psFree(colNums); 94 psFree(colAvgs); 95 psFree(colMask); 96 psFree(stats); 97 55 98 56 99 psMetadataAddS32(ro->analysis, PS_LIST_TAIL, PM_REMNANCE_ANALYSIS_NUM, 0,
Note:
See TracChangeset
for help on using the changeset viewer.
