Changeset 5717 for trunk/pois/src/poisRejectStamps.c
- Timestamp:
- Dec 6, 2005, 6:43:52 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/pois/src/poisRejectStamps.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pois/src/poisRejectStamps.c
r3875 r5717 6 6 #define SQUARE(x) ((x)*(x)) 7 7 8 psList *restrict poisRejectStamps(psArray *stamps,// Array of stamps9 psImage *mask,// Mask image10 const psVector *deviations, // Vector of deviations for the stamps11 const poisConfig *config // Configuration8 bool poisRejectStamps(psArray *stamps, // Array of stamps 9 psImage *mask, // Mask image 10 const psVector *deviations, // Vector of deviations for the stamps 11 const poisConfig *config // Configuration 12 12 ) 13 13 { … … 21 21 assert(deviations->type.type == PS_TYPE_F32); 22 22 23 psVector *devMask = psVectorAlloc(stamps->n, PS_TYPE_U8); // Mask for statistics23 bool masked = false; // Have we masked any stamps? 24 24 25 25 // Don't want the standard deviation, but rather the deviation from zero 26 double meanDev= 0.0;26 double sum = 0.0; 27 27 int numDev = 0; 28 28 for (int i = 0; i < deviations->n; i++) { 29 poisStamp *stamp = stamps->data[i];// The stamp30 // Only interested in the stamps that we're actually using31 if (stamp != NULL &&stamp->status == POIS_STAMP_USED) {32 meanDev+= SQUARE(deviations->data.F32[i]);33 numDev++;34 }29 poisStamp *stamp = stamps->data[i]; // The stamp 30 // Only interested in the stamps that we're actually using 31 if (stamp->status == POIS_STAMP_USED) { 32 sum += SQUARE(deviations->data.F32[i]); 33 numDev++; 34 } 35 35 } 36 float rmsDev = sqrt(meanDev/numDev);37 float limit = rmsDev * config->sigmaRej;38 psTrace("pois.rejectStamps", 2, " RMS deviation: %f\n", rmsDev);36 float meanDev = sqrtf(sum / (float)numDev); 37 float limit = meanDev * config->sigmaRej; 38 psTrace("pois.rejectStamps", 2, "Mean RMS deviation: %f\n", meanDev); 39 39 psTrace("pois.rejectStamps", 2, "Rejection limit: %f\n", limit); 40 40 41 41 // Reject stamps 42 psList *rejected = NULL; // rejected stamps43 42 for (int s = 0; s < deviations->n; s++) { 44 poisStamp *stamp = stamps->data[s]; 45 if (stamp == NULL) { 46 continue; 47 } 48 49 if (stamp->status == POIS_STAMP_USED && fabsf(deviations->data.F32[s]) > limit) { 50 psTrace("pois.rejectStamps", 1, "Rejecting stamp %d (%d,%d): %f\n", s, stamp->x, stamp->y, 51 deviations->data.F32[s]); 52 53 // Mask out the stamp in the image so you don't find it again 54 for (int y = stamp->y - config->footprint; y < stamp->y + config->footprint; y++) { 55 for (int x = stamp->x - config->footprint; x < stamp->x + config->footprint; x++) { 56 mask->data.U8[y][x] |= POIS_MASK_STAMP; 57 } 58 } 59 60 // Mark stamp for replacement 61 stamps->data[s] = NULL; 62 63 if (rejected == NULL) { 64 rejected = psListAlloc(stamp); 65 } else { 66 bool success = psListAdd(rejected, PS_LIST_TAIL, stamp); 67 assert(success); 68 } 69 psFree(stamp); 70 } // Bad stamps 43 poisStamp *stamp = stamps->data[s]; 44 if (stamp->status == POIS_STAMP_USED && 45 (fabsf(deviations->data.F32[s]) > limit || ! isfinite(deviations->data.F32[s]))) { 46 masked = true; 47 psTrace("pois.rejectStamps", 1, "Rejecting stamp %d (%d,%d): %f\n", s, stamp->x, stamp->y, 48 deviations->data.F32[s]); 49 50 // Mask out the stamp in the image so you don't find it again 51 for (int y = stamp->y - config->footprint; y < stamp->y + config->footprint; y++) { 52 for (int x = stamp->x - config->footprint; x < stamp->x + config->footprint; x++) { 53 mask->data.U8[y][x] |= POIS_MASK_STAMP; 54 } 55 } 56 57 // Set stamp for replacement 58 stamp->x = 0; 59 stamp->y = 0; 60 stamp->status = POIS_STAMP_RESET; 61 62 } // Bad stamps 71 63 } // Iterating over stamps 72 64 73 psFree(devMask); 74 75 return rejected; 65 return masked; 76 66 }
Note:
See TracChangeset
for help on using the changeset viewer.
