Changeset 15807
- Timestamp:
- Dec 13, 2007, 7:53:28 AM (18 years ago)
- Location:
- branches/eam_branch_20071212/ppMerge/src
- Files:
-
- 2 edited
-
ppMergeMaskByImageStats.c (modified) (2 diffs)
-
ppMergeMaskReadoutByPixelStats.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20071212/ppMerge/src/ppMergeMaskByImageStats.c
r15804 r15807 15 15 #include "ppMergeMask.h" 16 16 17 // this function measures the statistics of the pixel values for a single readout (median and stdev) 18 // and identifies pixels which deviate from the median by more than MASK.SUSPECT * stdev. 17 19 18 20 // Generate a mask image consisting of pixels which are outliers from the image mean … … 65 67 view->chip, view->cell, view->readout); 66 68 float frac = options->sample / (float)(roIn->image->numCols * roIn->image->numRows); 69 70 // measure the global image stats: median and stdev 71 // XXX note that this now will accept any of several stats options 72 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); 73 stats->nSubsample = frac * image->numCols * image->numRows; 74 if (!psImageBackground(stats, NULL, image, mask, maskVal, rng) || 75 !isfinite(stats->robustMedian) || !isfinite(stats->robustUQ) || !isfinite(stats->robustLQ)) { 76 psError(PS_ERR_UNKNOWN, false, "Unable to measure image statistics.\n"); 77 psFree(stats); 78 psFree(rng); 79 return NULL; 80 } 81 psFree(rng); 82 83 float median = stats->robustMedian; // Median value 84 float stdev = stats->robustStdev; // Estimate of the standard deviation 85 psFree(stats); 86 67 87 suspect = pmMaskFlagSuspectPixels(suspect, roIn, options->maskSuspect, 68 options->combine->maskVal, frac, rng); 88 options->combine->maskVal, median, stdev); 89 90 psMetadataAddF32(roIn->analysis, PS_LIST_TAIL, "MEDIAN", 0, "median", median); 91 psMetadataAddF32(roIn->analysis, PS_LIST_TAIL, "STDEV", 0, "stdev", stdev); 69 92 } 70 93 -
branches/eam_branch_20071212/ppMerge/src/ppMergeMaskReadoutByPixelStats.c
r15804 r15807 9 9 #include <pslib.h> 10 10 #include <psmodules.h> 11 12 // this function measures the statistics of the inputs->n representations of a given pixel (median and stdev) and identifies pixels 13 // which deviate from the median by more than MASK.PIXEL.SUSPECT * stdev. 14 15 // it also identifies pixels for which the stdev is more than MASK.PIXEL.NOISY * the image stdev 11 16 12 17 // XXX: Maybe add support for S16 and S32 types. Currently, only F32 supported. … … 27 32 } 28 33 29 // XXX is it possible / desired to use the weight in this analysis? 30 for (int i = 0; i < inputs->n; i++) { 31 pmReadout *readout = inputs->data[i]; // Readout of interest 32 if (params->weights && !readout->weight) { 33 psError(PS_ERR_UNEXPECTED_NULL, true, 34 "Rejection based on weights requested, but no weights supplied for image %d.\n", i); 35 return false; 36 } 37 } 34 // XXX note : we are ignoring weights for now. 38 35 39 36 bool first = !output->image; // First pass through? … … 77 74 psTrace("psModules.imcombine", 7, "Output minimum: %d,%d\n", output->col0, output->row0); 78 75 76 // Get the correct statistics option for weights 79 77 psStatsOptions combineStdev = 0; // Statistics option for weights 80 if (params->weights) { 81 82 if (!output->weight) { 83 output->weight = psImageAlloc(xSize, ySize, PS_TYPE_F32); 84 } 85 if (output->weight->numCols < xSize || output->weight->numRows < ySize) { 86 psImage *newWeight = psImageAlloc(xSize, ySize, PS_TYPE_F32); 87 psImageInit(newWeight, 0.0); 88 psImageOverlaySection(newWeight, output->weight, output->col0, output->row0, "="); 89 psFree(output->weight); 90 output->weight = newWeight; 91 } 92 93 if (first) { 94 psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, 95 "Using input weights to combine images", ""); 96 } 97 98 // Get the correct statistics option for weights 99 switch (params->combine) { 100 case PS_STAT_SAMPLE_MEAN: 101 case PS_STAT_SAMPLE_MEDIAN: 102 combineStdev = PS_STAT_SAMPLE_STDEV; 103 break; 104 case PS_STAT_ROBUST_MEDIAN: 105 combineStdev = PS_STAT_ROBUST_STDEV; 106 break; 107 case PS_STAT_FITTED_MEAN: 108 combineStdev = PS_STAT_FITTED_STDEV; 109 break; 110 case PS_STAT_CLIPPED_MEAN: 111 combineStdev = PS_STAT_CLIPPED_STDEV; 112 break; 113 default: 114 psAbort("Should never get here --- checked params->combine before.\n"); 115 } 116 stats->options |= combineStdev; 117 } 78 switch (params->combine) { 79 case PS_STAT_SAMPLE_MEAN: 80 case PS_STAT_SAMPLE_MEDIAN: 81 combineStdev = PS_STAT_SAMPLE_STDEV; 82 break; 83 case PS_STAT_ROBUST_MEDIAN: 84 combineStdev = PS_STAT_ROBUST_STDEV; 85 break; 86 case PS_STAT_FITTED_MEAN: 87 combineStdev = PS_STAT_FITTED_STDEV; 88 break; 89 case PS_STAT_CLIPPED_MEAN: 90 combineStdev = PS_STAT_CLIPPED_STDEV; 91 break; 92 default: 93 psAbort("Should never get here --- checked params->combine before.\n"); 94 } 95 stats->options |= combineStdev; 118 96 119 97 // We loop through each pixel in the output image. We loop through each input readout. We determine if … … 129 107 psU8 *maskData = mask->data.U8; // Dereference mask 130 108 131 psVector *weights = NULL; // Stack of weights132 psVector *errors = NULL; // Stack of errors (sqrt of variance/weights), for psVectorStats133 psF32 *weightsData = NULL; // Dereference weights134 if (params->weights) {135 weights = psVectorAlloc(inputs->n, PS_TYPE_F32); // Stack of weights136 weightsData = weights->data.F32;137 }138 109 psVector *index = NULL; // The indices to sort the pixels 139 110 … … 172 143 psF32 **outputImage = output->image->data.F32; // Output image 173 144 psU8 **outputMask = output->mask->data.U8; // Output mask 174 psF32 **outputWeight = NULL; // Output weight map175 if (output->weight) {176 outputWeight = output->weight->data.F32;177 }178 145 179 146 psVector *invScale = NULL; // Inverse scale; pre-calculated for efficiency
Note:
See TracChangeset
for help on using the changeset viewer.
