Changeset 15865 for trunk/psModules/src/detrend/pmMaskBadPixels.c
- Timestamp:
- Dec 16, 2007, 12:22:06 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/detrend/pmMaskBadPixels.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmMaskBadPixels.c
r14935 r15865 5 5 #include <stdio.h> 6 6 #include <math.h> 7 #include <strings.h> 7 8 #include <pslib.h> 8 9 … … 125 126 psFree(stats); 126 127 128 psTrace ("psModules.detrend", 3, "suspect: %f +/- %f\n", median, stdev); 129 127 130 if (!out) { 128 131 out = psImageAlloc(image->numCols, image->numRows, PS_TYPE_S32); … … 142 145 } 143 146 144 145 psImage *pmMaskIdentifyBadPixels(const psImage *suspects, float thresh, psMaskType maskVal) 147 psImage *pmMaskIdentifyBadPixels(const psImage *suspects, psMaskType maskVal, int nTotal, float thresh, pmMaskIdentifyMode mode) 146 148 { 147 149 PS_ASSERT_IMAGE_NON_NULL(suspects, NULL); … … 150 152 151 153 float limit = NAN; // Limit for masking 152 if (thresh > 0) { 154 155 switch (mode) { 156 case PM_MASK_ID_VALUE: 157 limit = thresh; 158 break; 159 160 case PM_MASK_ID_FRACTION: 161 limit = thresh * nTotal; 162 break; 163 164 case PM_MASK_ID_SIGMA: { 153 165 psStats *stats = psStatsAlloc(PS_STAT_CLIPPED_STDEV); // Statistics 154 166 stats->clipSigma = 5.0; … … 160 172 } 161 173 limit = thresh * stats->clippedStdev; 162 psFree(stats); 163 } else if (thresh < 0) { 174 psTrace ("psModules.detrend", 3, "bad: %f -> %f\n", stats->clippedStdev, limit); 175 psFree(stats); 176 break; 177 } 178 179 case PM_MASK_ID_POISSON: { 164 180 psStats *stats = psStatsAlloc(PS_STAT_MAX); // Statistics 165 181 if (!psImageStats(stats, suspects, NULL, 0)) { … … 189 205 limit = max + 1.0 - thresh * sqrtf((float)max + 1.0); 190 206 191 } else { 192 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 193 "Threshold (%f) must be a positive or negative real number.\n", thresh); 207 psTrace ("psModules.detrend", 3, "bad: mode: %d, stdev: %f, limit: %f\n", max, sqrtf((float)max + 1.0), limit); 208 break; 209 } 210 default: 211 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Invalid mask identify mode"); 194 212 return NULL; 195 213 } … … 212 230 } 213 231 232 psTrace ("psModules.detrend", 3, "bad pixel threshold: %f", limit); 233 214 234 for (int y = 0; y < suspects->numRows; y++) { 215 235 for (int x = 0; x < suspects->numCols; x++) { … … 222 242 return badpix; 223 243 } 244 245 pmMaskIdentifyMode pmMaskIdentifyModeFromString (const char *string) { 246 247 if (!strcasecmp (string, "VALUE")) { 248 return PM_MASK_ID_VALUE; 249 } 250 if (!strcasecmp (string, "FRACTION")) { 251 return PM_MASK_ID_FRACTION; 252 } 253 if (!strcasecmp (string, "SIGMA")) { 254 return PM_MASK_ID_SIGMA; 255 } 256 if (!strcasecmp (string, "POISSON")) { 257 return PM_MASK_ID_POISSON; 258 } 259 return PM_MASK_ID_NONE; 260 }
Note:
See TracChangeset
for help on using the changeset viewer.
