Changeset 23677 for branches/pap/pswarp/src/pswarpPixelFraction.c
- Timestamp:
- Apr 2, 2009, 11:55:52 AM (17 years ago)
- File:
-
- 1 edited
-
branches/pap/pswarp/src/pswarpPixelFraction.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap/pswarp/src/pswarpPixelFraction.c
r21323 r23677 34 34 PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_IMAGE_MASK, false); 35 35 36 if (stats) { 37 PS_ASSERT_METADATA_NON_NULL(stats, false); 36 if (!stats) { 37 // No point in continuing --- we record results to the statistics 38 return true; 38 39 } 39 40 PS_ASSERT_PTR_NON_NULL(config, false); 40 41 PS_ASSERT_METADATA_NON_NULL(config->arguments, false); 41 42 42 bool status; 43 44 float minFrac = psMetadataLookupF32(NULL, config->arguments, "ACCEPT.FRAC"); ///< Minimum fraction 43 bool status; 45 44 46 45 // load the recipe … … 52 51 53 52 // output mask bits 54 psImageMaskType maskValue = psMetadataLookupImageMask(&status, recipe, "MASK.OUTPUT"); 53 psImageMaskType maskValue = psMetadataLookupImageMask(&status, recipe, "MASK.OUTPUT"); 55 54 psAssert (status, "MASK.OUTPUT was not defined"); 56 55 … … 59 58 60 59 int numCols = image->numCols, numRows = image->numRows; ///< Size of image 61 long numPix = numCols * numRows;62 60 63 61 // Range of valid pixels 64 62 int xMin = INT_MAX, xMax = -INT_MAX, yMin = INT_MAX, yMax = -INT_MAX; 65 63 66 long num Bad = 0;///< Number of bad pixels64 long numGood = 0; ///< Number of bad pixels 67 65 for (int y = 0; y < numRows; y++) { 68 66 for (int x = 0; x < numCols; x++) { 69 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValue) { 70 numBad++; 71 } else { 67 if (!(mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValue)) 72 68 if (y > yMax) { 73 69 yMax = y; … … 86 82 } 87 83 88 float goodFrac = (numPix - numBad) / (float)numPix; ///< Fraction of good pixels89 bool accept = (goodFrac >= minFrac ? true : false); ///< Accept this readout?90 91 84 if (stats) { 92 psMetadataAddBool(stats, PS_LIST_HEAD, "ACCEPT", 0, "Accept this readout?", accept);93 94 85 psMetadataAddS32(stats, PS_LIST_TAIL, "RANGE.XMIN", 0, "Minimum valid x value", xMin); 95 86 psMetadataAddS32(stats, PS_LIST_TAIL, "RANGE.XMAX", 0, "Maximum valid x value", xMax); … … 98 89 } 99 90 100 return accept;91 return true; 101 92 } 102 93
Note:
See TracChangeset
for help on using the changeset viewer.
