Changeset 18652 for trunk/psModules/src/imcombine/pmSubtraction.c
- Timestamp:
- Jul 21, 2008, 3:54:17 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/imcombine/pmSubtraction.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtraction.c
r18287 r18652 27 27 28 28 #define PIXEL_LIST_BUFFER 100 // Number of entries to add to pixel list at a time 29 29 #define MIN_SAMPLE_STATS 7 // Minimum number to use sample statistics; otherwise use quartiles 30 30 31 31 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// … … 513 513 // with large N. Therefore, let's just treat this as a Gaussian distribution. 514 514 515 double mean = 0.0; // Mean deviation516 515 int numStamps = 0; // Number of used stamps 516 psVector *mask = psVectorAlloc(stamps->num, PS_TYPE_MASK); // Mask, for statistics 517 psVectorInit(mask, 0); 517 518 for (int i = 0; i < stamps->num; i++) { 518 519 pmSubtractionStamp *stamp = stamps->stamps->data[i]; // Stamp of interest 519 520 if (stamp->status != PM_SUBTRACTION_STAMP_USED) { 521 mask->data.PS_TYPE_MASK_DATA[i] = 0xff; 520 522 continue; 521 523 } 522 mean += deviations->data.F32[i];523 524 numStamps++; 524 525 } 525 mean /= numStamps; 526 527 double rms = 0.0; // Standard deviation 528 for (int i = 0; i < stamps->num; i++) { 529 pmSubtractionStamp *stamp = stamps->stamps->data[i]; // Stamp of interest 530 if (stamp->status != PM_SUBTRACTION_STAMP_USED) { 531 continue; 532 } 533 rms += PS_SQR(deviations->data.F32[i] - mean); 534 } 535 rms = sqrt(rms / (numStamps - 1)); 526 psTrace("psModules.imcombine", 1, "Number of good stamps: %d\n", numStamps); 527 528 if (numStamps == 0) { 529 psError(PS_ERR_UNKNOWN, true, "No good stamps found."); 530 psFree(mask); 531 return -1; 532 } 533 534 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV | 535 PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_QUARTILE); // Statistics for deviatns 536 if (!psVectorStats(stats, deviations, NULL, mask, 0xff)) { 537 psError(PS_ERR_UNKNOWN, false, "Unable to measure statistics for deviations."); 538 psFree(stats); 539 psFree(mask); 540 return -1; 541 } 542 psFree(mask); 543 544 double mean, rms; // Mean and RMS of deviations 545 if (numStamps < MIN_SAMPLE_STATS) { 546 mean = stats->sampleMean; 547 rms = stats->sampleStdev; 548 } else { 549 mean = stats->sampleMedian; 550 rms = 0.74 * (stats->sampleUQ - stats->sampleLQ); 551 } 552 553 psTrace("psModules.imcombine", 1, "Mean: %f\n", mean); 554 psTrace("psModules.imcombine", 1, "RMS deviation: %f\n", rms); 536 555 537 556 if (rmsPtr) { … … 540 559 if (numPtr) { 541 560 *numPtr = numStamps; 542 }543 544 if (numStamps == 0) {545 psError(PS_ERR_UNKNOWN, true, "No good stamps found.");546 return -1;547 561 } 548 562
Note:
See TracChangeset
for help on using the changeset viewer.
