Changeset 15865
- Timestamp:
- Dec 16, 2007, 12:22:06 PM (18 years ago)
- Location:
- trunk/psModules/src/detrend
- Files:
-
- 2 edited
-
pmMaskBadPixels.c (modified) (8 diffs)
-
pmMaskBadPixels.h (modified) (3 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 } -
trunk/psModules/src/detrend/pmMaskBadPixels.h
r12696 r15865 5 5 * @author Eugene Magnier, IfA 6 6 * 7 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $8 * @date $Date: 2007- 03-30 21:12:56 $7 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-12-16 22:22:06 $ 9 9 * Copyright 2004 Institute for Astronomy, University of Hawaii 10 10 */ … … 15 15 /// @addtogroup detrend Detrend Creation and Application 16 16 /// @{ 17 18 typedef enum { 19 PM_MASK_ID_NONE, 20 PM_MASK_ID_VALUE, 21 PM_MASK_ID_FRACTION, 22 PM_MASK_ID_SIGMA, 23 PM_MASK_ID_POISSON, 24 } pmMaskIdentifyMode; 25 26 pmMaskIdentifyMode pmMaskIdentifyModeFromString (const char *string); 17 27 18 28 /// Applies the bad pixel mask to the input … … 49 59 /// pixels (output image). If "thresh" is negative, a Poisson is assumed. 50 60 psImage *pmMaskIdentifyBadPixels(const psImage *suspects, ///< Accumulated suspect pixels image 61 psMaskType maskVal, ///< Value to set for bad pixels 62 int nTotal, 51 63 float thresh, ///< Threshold for bad pixel (standard deviations) 52 psMaskType maskVal ///< Value to set for bad pixels 64 pmMaskIdentifyMode mode 53 65 ); 54 66 /// @}
Note:
See TracChangeset
for help on using the changeset viewer.
