Changeset 18365 for trunk/ppMerge/src/ppMergeMask.c
- Timestamp:
- Jun 29, 2008, 2:55:44 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ppMerge/src/ppMergeMask.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppMerge/src/ppMergeMask.c
r17430 r18365 37 37 psMaskType maskGrowVal = psMetadataLookupU8(NULL, config->arguments, "MASK.GROWVAL"); // Value for grown mask 38 38 39 bool smoothSuspect = psMetadataLookupBool(&mdok, config->arguments, "MASK.SMOOTH.SUSPECT"); // Radius to grow mask 40 float smoothScale = psMetadataLookupF32(&mdok, config->arguments, "MASK.SMOOTH.SCALE"); // Radius to grow mask 41 39 42 psStats *statistics = psStatsAlloc(meanStat | stdevStat); // Statistics for background 40 43 … … 42 45 pmChip *outChip = pmFPAfileThisChip(config->files, view, outName); // Output chip 43 46 psFree(outName); 47 48 int numCells = 1; 49 if (chipStats) { 50 // count the number of active cells for this chip: 51 numCells = 0; 52 for (int i = 0; i < outChip->cells->n; i++) { 53 pmCell *cell = outChip->cells->data[i]; 54 if (!cell->process) continue; 55 numCells ++; 56 } 57 } 44 58 45 59 // For each input file, get the statistics, which can be calculated at the chip or cell levels … … 58 72 pmCell *inCell; // Input cell 59 73 while ((inCell = pmFPAviewNextCell(inView, inFPA, 1))) { 74 75 // the output FPA structure carries the information about which cells to process 76 pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // Output cell 77 if (!outCell->process) continue; 78 60 79 pmHDU *hdu = pmHDUFromCell(inCell); // HDU for cell 61 80 if (!hdu || hdu->blankPHU) { … … 99 118 } 100 119 101 pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // Output cell102 120 pmReadout *outRO = NULL; // Output readout 103 121 if (outCell->readouts && outCell->readouts->n == 1) { … … 111 129 int numCols = readout->image->numCols, numRows = readout->image->numRows; // Image size 112 130 int numPix = numCols * numRows; // Number of pixels 113 int numCells = chipStats ? readout->parent->parent->cells->n : 1; // Number of cells114 131 int num = PS_MIN(numPix, sample / numCells); // Number of values to add 115 132 if (!chipStats) { … … 166 183 inView->cell = -1; 167 184 while ((inCell = pmFPAviewNextCell(inView, inFPA, 1))) { 185 186 // the output FPA structure carries the information about which cells to process 187 pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // Output cell 188 if (!outCell->process) continue; 189 168 190 pmHDU *hdu = pmHDUFromCell(inCell); // HDU for cell 169 191 if (!hdu || hdu->blankPHU) { … … 206 228 *outView = *view; 207 229 while ((outCell = pmFPAviewNextCell(outView, outFPA, 1))) { 230 231 // skipp inactive cells 232 if (!outCell->process) continue; 233 208 234 pmHDU *hdu = pmHDUFromCell(outCell); // HDU for cell 209 235 if (!hdu || hdu->blankPHU) { … … 216 242 assert(outCell->readouts && outCell->readouts->n == 1); 217 243 pmReadout *outRO = outCell->readouts->data[0]; // Output readout 244 245 if (smoothSuspect) { 246 // XXX test output of suspect pixel image 247 psImage *suspects = psMetadataLookupPtr(NULL, outRO->analysis, PM_MASK_ANALYSIS_SUSPECT); // Suspect img 248 assert (suspects); 249 psImageSmooth (suspects, smoothScale, 3); // extend smoothing region to 3-sigma 250 } 251 218 252 if (!pmMaskIdentifyBadPixels(outRO, maskVal, maskBad, maskMode)) { 219 253 psError(PS_ERR_UNKNOWN, false, "Unable to mask bad pixels"); … … 359 393 pmChip *outChip; // Chip of interest 360 394 while ((outChip = pmFPAviewNextChip(view, outFPA, 1))) { 395 396 if (!outChip->process) continue; 397 361 398 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 362 399 goto PPMERGE_MASK_ERROR; … … 370 407 } 371 408 372 psList *inChips = psListAlloc(NULL); 373 for (int i=0; i < numFiles; i++) { 374 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", i); // Input file 375 pmChip *chip = pmFPAviewThisChip(view, file->fpa); 376 psListAdd(inChips, PS_LIST_TAIL, chip); 377 } 378 if (!pmConceptsAverageChips(outChip, inChips, true)) { 379 psError(PS_ERR_UNKNOWN, false, "Unable to average Chip concepts."); 380 psFree(inChips); 381 goto PPMERGE_MASK_ERROR; 382 } 383 psFree(inChips); 409 if (outChip->data_exists) { 410 psList *inChips = psListAlloc(NULL); 411 for (int i=0; i < numFiles; i++) { 412 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", i); // Input file 413 pmChip *chip = pmFPAviewThisChip(view, file->fpa); 414 psListAdd(inChips, PS_LIST_TAIL, chip); 415 } 416 if (!pmConceptsAverageChips(outChip, inChips, true)) { 417 psError(PS_ERR_UNKNOWN, false, "Unable to average Chip concepts."); 418 psFree(inChips); 419 goto PPMERGE_MASK_ERROR; 420 } 421 psFree(inChips); 422 } 384 423 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 385 424 goto PPMERGE_MASK_ERROR;
Note:
See TracChangeset
for help on using the changeset viewer.
