Changeset 18558 for trunk/ppMerge/src/ppMergeMask.c
- Timestamp:
- Jul 15, 2008, 10:29:11 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ppMerge/src/ppMergeMask.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppMerge/src/ppMergeMask.c
r18365 r18558 18 18 psRandom *rng, // Random number generator 19 19 psMetadata *stats // Statistics output 20 )20 ) 21 21 { 22 22 assert(config); … … 28 28 psStatsOptions meanStat = psMetadataLookupS32(NULL, config->arguments, "MEAN"); // Statistic for mean 29 29 psStatsOptions stdevStat = psMetadataLookupS32(NULL, config->arguments, "STDEV"); // Statistic for stdev 30 psMaskType maskVal = psMetadataLookupU8(NULL, config->arguments, "MASKVAL"); // Value to mask31 30 int sample = psMetadataLookupS32(NULL, config->arguments, "SAMPLE"); // Size of sample for statistics 32 31 bool chipStats = psMetadataLookupBool(&mdok, config->arguments, "MASK.CHIPSTATS"); // Statistics on chip? … … 35 34 pmMaskIdentifyMode maskMode = psMetadataLookupS32(NULL, config->arguments, "MASK.MODE"); // Mode for identifying bad pixels 36 35 int maskGrow = psMetadataLookupS32(NULL, config->arguments, "MASK.GROW"); // Radius to grow mask 37 psMaskType maskGrowVal = psMetadataLookupU8(NULL, config->arguments, "MASK.GROWVAL"); // Value for grown mask38 36 39 37 bool smoothSuspect = psMetadataLookupBool(&mdok, config->arguments, "MASK.SMOOTH.SUSPECT"); // Radius to grow mask 40 38 float smoothScale = psMetadataLookupF32(&mdok, config->arguments, "MASK.SMOOTH.SCALE"); // Radius to grow mask 41 39 40 psMaskType markVal; 41 psMaskType maskValRaw; 42 if (!pmConfigMaskSetBits (&maskValRaw, &markVal, config)) { 43 psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values"); 44 return false; 45 } 46 47 char *maskOutName = psMetadataLookupStr (&mdok, config->arguments, "MASK.SET.VALUE"); 48 psMaskType maskValOut = pmConfigMaskGet (maskOutName, config); 49 if (!maskValOut) { 50 psError (PS_ERR_UNKNOWN, true, "Undefined output mask bit value"); 51 return false; 52 } 53 42 54 psStats *statistics = psStatsAlloc(meanStat | stdevStat); // Statistics for background 43 55 … … 137 149 int x = pixel % numCols; 138 150 int y = pixel / numCols; 139 if ((mask && (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal)) || 140 !isfinite(image->data.F32[y][x]) || 141 (outMask && (outMask->data.PS_TYPE_MASK_DATA[y][x] & maskVal))) { 142 continue; 143 } 151 if (mask && (mask->data.PS_TYPE_MASK_DATA[y][x] & maskValRaw)) continue; 152 if (outMask && (outMask->data.PS_TYPE_MASK_DATA[y][x] & maskValOut)) continue; 153 if (!isfinite(image->data.F32[y][x])) continue; 144 154 145 155 values->data.F32[valueIndex++] = image->data.F32[y][x]; … … 155 165 } 156 166 157 if (!pmMaskFlagSuspectPixels(outRO, readout, psStatsGetValue(statistics, meanStat), 158 psStatsGetValue(statistics, stdevStat), maskSuspect, maskVal)) { 167 float mean = psStatsGetValue(statistics, meanStat); 168 float stdev = psStatsGetValue(statistics, stdevStat); 169 170 // this function increments the count for each suspect pixel in each input plane 171 // maskValRaw is used to test for valid input pixels 172 if (!pmMaskFlagSuspectPixels(outRO, readout, mean, stdev, maskSuspect, maskValRaw)) { 159 173 psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i); 160 174 psFree(inView); … … 189 203 190 204 pmHDU *hdu = pmHDUFromCell(inCell); // HDU for cell 191 if (!hdu || hdu->blankPHU) { 192 // No data here 193 continue; 194 } 205 if (!hdu || hdu->blankPHU) continue; 206 195 207 pmReadout *readout = inCell->readouts->data[0]; // Readout of interest 196 208 … … 198 210 pmReadout *outRO = pmFPAfileThisReadout(config->files, inView, "PPMERGE.OUTPUT.MASK"); 199 211 200 if (!pmMaskFlagSuspectPixels(outRO, readout, psStatsGetValue(statistics, meanStat), 201 psStatsGetValue(statistics, stdevStat), maskSuspect, maskVal)) { 212 float mean = psStatsGetValue(statistics, meanStat); 213 float stdev = psStatsGetValue(statistics, stdevStat); 214 215 if (!pmMaskFlagSuspectPixels(outRO, readout, mean, stdev, maskSuspect, maskValRaw)) { 202 216 psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i); 203 217 goto MERGE_MASK_ERROR; … … 229 243 while ((outCell = pmFPAviewNextCell(outView, outFPA, 1))) { 230 244 231 // skip pinactive cells245 // skip inactive cells 232 246 if (!outCell->process) continue; 233 247 234 248 pmHDU *hdu = pmHDUFromCell(outCell); // HDU for cell 235 if (!hdu || hdu->blankPHU) { 236 // No data here 237 continue; 238 } 249 if (!hdu || hdu->blankPHU) continue; 239 250 240 251 psTrace("ppMerge", 1, "Getting bad pixels for chip %d cell %d", outView->chip, outView->cell); … … 250 261 } 251 262 252 if (!pmMaskIdentifyBadPixels(outRO, maskVal, maskBad, maskMode)) { 263 // set the bad pixels to the value 'maskVal' 264 if (!pmMaskIdentifyBadPixels(outRO, maskValOut, maskBad, maskMode)) { 253 265 psError(PS_ERR_UNKNOWN, false, "Unable to mask bad pixels"); 254 266 goto MERGE_MASK_ERROR; … … 274 286 } 275 287 276 if (maskGrow Val> 0) {277 psImage *grown = psImageGrowMask(NULL, outRO->mask, maskVal , maskGrow, maskGrowVal); // Grown mask288 if (maskGrow > 0) { 289 psImage *grown = psImageGrowMask(NULL, outRO->mask, maskValOut, maskGrow, maskValOut); // Grown mask 278 290 psFree(outRO->mask); 279 291 outRO->mask = grown; … … 307 319 outRO->image = psImageAlloc(outRO->mask->numCols, outRO->mask->numRows, PS_TYPE_F32); 308 320 psImageInit(outRO->image, 1.0); 309 if (!ppStatsFPA(stats, outRO->parent->parent->parent, outView, 310 maskVal | pmConfigMask("BLANK", config), config)) { 321 if (!ppStatsFPA(stats, outRO->parent->parent->parent, outView, maskValOut, config)) { 311 322 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to generate stats for image."); 312 323 psFree(outRO); … … 337 348 } 338 349 339 340 341 342 343 350 bool ppMergeMask(pmConfig *config) 344 351 { … … 381 388 goto PPMERGE_MASK_ERROR; 382 389 } 390 391 // XXX this function should use pmConfigMaskReadHeader () to get the named values defined 392 // for the input masks. 383 393 384 394 psString outName = ppMergeOutputFile(config); // Name of output file … … 414 424 psListAdd(inChips, PS_LIST_TAIL, chip); 415 425 } 426 427 // XXX I need to call pmConfigMaskWriteHeader for the PHU somewhere, after it is created! 428 416 429 if (!pmConceptsAverageChips(outChip, inChips, true)) { 417 430 psError(PS_ERR_UNKNOWN, false, "Unable to average Chip concepts.");
Note:
See TracChangeset
for help on using the changeset viewer.
