IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 29, 2008, 2:55:44 PM (18 years ago)
Author:
eugene
Message:

add smoothing of suspect pixels; chip and cell options; skip unused chips and cells as needed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppMerge/src/ppMergeMask.c

    r17430 r18365  
    3737    psMaskType maskGrowVal = psMetadataLookupU8(NULL, config->arguments, "MASK.GROWVAL"); // Value for grown mask
    3838
     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
    3942    psStats *statistics = psStatsAlloc(meanStat | stdevStat); // Statistics for background
    4043
     
    4245    pmChip *outChip = pmFPAfileThisChip(config->files, view, outName); // Output chip
    4346    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    }
    4458
    4559    // For each input file, get the statistics, which can be calculated at the chip or cell levels
     
    5872        pmCell *inCell;                 // Input cell
    5973        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
    6079            pmHDU *hdu = pmHDUFromCell(inCell); // HDU for cell
    6180            if (!hdu || hdu->blankPHU) {
     
    99118            }
    100119
    101             pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // Output cell
    102120            pmReadout *outRO = NULL;    // Output readout
    103121            if (outCell->readouts && outCell->readouts->n == 1) {
     
    111129            int numCols = readout->image->numCols, numRows = readout->image->numRows; // Image size
    112130            int numPix = numCols * numRows; // Number of pixels
    113             int numCells = chipStats ? readout->parent->parent->cells->n : 1; // Number of cells
    114131            int num = PS_MIN(numPix, sample / numCells); // Number of values to add
    115132            if (!chipStats) {
     
    166183            inView->cell = -1;
    167184            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
    168190                pmHDU *hdu = pmHDUFromCell(inCell); // HDU for cell
    169191                if (!hdu || hdu->blankPHU) {
     
    206228    *outView = *view;
    207229    while ((outCell = pmFPAviewNextCell(outView, outFPA, 1))) {
     230
     231        // skipp inactive cells
     232        if (!outCell->process) continue;
     233
    208234        pmHDU *hdu = pmHDUFromCell(outCell); // HDU for cell
    209235        if (!hdu || hdu->blankPHU) {
     
    216242        assert(outCell->readouts && outCell->readouts->n == 1);
    217243        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
    218252        if (!pmMaskIdentifyBadPixels(outRO, maskVal, maskBad, maskMode)) {
    219253            psError(PS_ERR_UNKNOWN, false, "Unable to mask bad pixels");
     
    359393    pmChip *outChip;                    // Chip of interest
    360394    while ((outChip = pmFPAviewNextChip(view, outFPA, 1))) {
     395
     396        if (!outChip->process) continue;
     397
    361398        if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
    362399            goto PPMERGE_MASK_ERROR;
     
    370407        }
    371408
    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        }
    384423        if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
    385424            goto PPMERGE_MASK_ERROR;
Note: See TracChangeset for help on using the changeset viewer.