Changeset 24903
- Timestamp:
- Jul 22, 2009, 5:13:36 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
-
ippconfig/recipes/ppImage.config (modified) (1 diff)
-
ppImage/src/ppImage.h (modified) (1 diff)
-
ppImage/src/ppImageDetrendReadout.c (modified) (1 diff)
-
ppImage/src/ppImageOptions.c (modified) (2 diffs)
-
psModules/src/detrend/pmPattern.c (modified) (5 diffs)
-
psModules/src/detrend/pmPattern.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippconfig/recipes/ppImage.config
r24897 r24903 85 85 PATTERN.ITER S32 4 # Rejection iterations 86 86 PATTERN.REJ F32 2.5 # Rejection threshold 87 PATTERN.THRESH F32 10.0 # Ignore threshold 87 88 PATTERN.MEAN STR SAMPLE_MEAN # Statistic for mean 88 89 PATTERN.STDEV STR SAMPLE_STDEV # Statistic for standard deviation -
trunk/ppImage/src/ppImage.h
r24892 r24903 98 98 int patternIter; // Clipping iterations 99 99 float patternRej; // Clipping threshold 100 float patternThresh; // Ignore threshold 100 101 psStatsOptions patternMean; // Statistic for mean 101 102 psStatsOptions patternStdev; // Statistic for stdev -
trunk/ppImage/src/ppImageDetrendReadout.c
r24900 r24903 127 127 if (options->doPattern) { 128 128 if (!pmPatternRow(input, options->patternOrder, options->patternIter, options->patternRej, 129 options->patternMean, options->patternStdev, options->darkMask)) { 129 options->patternThresh, options->patternMean, options->patternStdev, 130 options->maskValue, options->darkMask)) { 130 131 psFree(detview); 131 132 return false; -
trunk/ppImage/src/ppImageOptions.c
r24892 r24903 93 93 options->patternIter = 0; // Clipping iterations 94 94 options->patternRej = NAN; // Clipping rejection threshold 95 options->patternThresh = NAN; // Threshold for ignoring pixels 95 96 options->patternMean = PS_STAT_NONE; // Statistic for mean 96 97 options->patternStdev = PS_STAT_NONE; // Statistic for standard deviation … … 312 313 options->patternIter = psMetadataLookupS32(NULL, recipe, "PATTERN.ITER"); 313 314 options->patternRej = psMetadataLookupF32(NULL, recipe, "PATTERN.REJ"); 315 options->patternThresh = psMetadataLookupF32(NULL, recipe, "PATTERN.THRESH"); 314 316 options->patternMean = psStatsOptionFromString(psMetadataLookupStr(NULL, recipe, "PATTERN.MEAN")); 315 317 options->patternStdev = psStatsOptionFromString(psMetadataLookupStr(NULL, recipe, "PATTERN.STDEV")); -
trunk/psModules/src/detrend/pmPattern.c
r24899 r24903 30 30 } 31 31 32 bool pmPatternRow(pmReadout *ro, int order, int iter, float rej, 32 bool pmPatternRow(pmReadout *ro, int order, int iter, float rej, float thresh, 33 33 psStatsOptions clipMean, psStatsOptions clipStdev, 34 psImageMaskType mask Bad)34 psImageMaskType maskVal, psImageMaskType maskBad) 35 35 { 36 36 PM_ASSERT_READOUT_NON_NULL(ro, false); … … 39 39 PS_ASSERT_INT_NONNEGATIVE(iter, false); 40 40 PS_ASSERT_FLOAT_LARGER_THAN(rej, 0.0, false); 41 PS_ASSERT_FLOAT_LARGER_THAN(thresh, 0.0, false); 41 42 42 43 psImage *image = ro->image; // Image to correct 44 psImage *mask = ro->mask; // Mask for image 43 45 int numCols = image->numCols, numRows = image->numRows; // Size of image 46 47 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); 48 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 49 if (!psImageBackground(stats, NULL, ro->image, ro->mask, maskVal, rng)) { 50 psWarning("Unable to calculate statistics on readout."); 51 psFree(stats); 52 psFree(rng); 53 return false; 54 } 55 float lower = stats->robustMedian - thresh * stats->robustStdev; // Lower bound for data 56 float upper = stats->robustMedian + thresh * stats->robustStdev; // Upper bound for data 57 psFree(stats); 58 psFree(rng); 44 59 45 60 // Indices are distributed [-1:1) … … 53 68 clip->clipIter = iter; 54 69 clip->clipSigma = rej; 55 psVector * mask = psVectorAlloc(numCols, PS_TYPE_VECTOR_MASK); // Mask for fitting70 psVector *clipMask = psVectorAlloc(numCols, PS_TYPE_VECTOR_MASK); // Mask for clipping 56 71 psPolynomial1D *poly = psPolynomial1DAlloc(PS_POLYNOMIAL_ORD, order); // Polynomial to fit 57 72 psVector *data = psVectorAlloc(numCols, PS_TYPE_F32); // Data to fit 58 73 59 74 for (int y = 0; y < numRows; y++) { 60 psVectorInit( mask, 0);75 psVectorInit(clipMask, 0); 61 76 data = psImageRow(data, image, y); 62 77 int num = 0; // Number of good pixels 63 78 for (int x = 0; x < numCols; x++) { 64 if (ro->mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] > 0) { 65 mask->data.PS_TYPE_VECTOR_MASK_DATA[x] = 0xFF; 79 if ((mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) || 80 data->data.F32[x] < lower || data->data.F32[x] > upper) { 81 clipMask->data.PS_TYPE_VECTOR_MASK_DATA[x] = 0xFF; 66 82 } else { 67 mask->data.PS_TYPE_VECTOR_MASK_DATA[x] = 0;83 clipMask->data.PS_TYPE_VECTOR_MASK_DATA[x] = 0; 68 84 num++; 69 85 } … … 74 90 continue; 75 91 } 76 if (!psVectorClipFitPolynomial1D(poly, clip, mask, 0xFF, data, NULL, indices)) {92 if (!psVectorClipFitPolynomial1D(poly, clip, clipMask, 0xFF, data, NULL, indices)) { 77 93 psWarning("Unable to fit polynomial to row %d", y); 78 94 psErrorClear(); … … 96 112 psFree(indices); 97 113 psFree(clip); 98 psFree( mask);114 psFree(clipMask); 99 115 psFree(poly); 100 116 psFree(data); -
trunk/psModules/src/detrend/pmPattern.h
r24899 r24903 24 24 int iter, ///< Number of clipping iterations 25 25 float rej, ///< Rejection threshold for clipping 26 float thresh, ///< Threshold for ignoring pixels 26 27 psStatsOptions clipMean, ///< Statistic to use for mean 27 28 psStatsOptions clipStdev, ///< Statistic to use for standard deviation 29 psImageMaskType maskVal, ///< Mask value to use 28 30 psImageMaskType maskBad ///< Mask value to give bad pixels 29 31 );
Note:
See TracChangeset
for help on using the changeset viewer.
