IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18365


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

Location:
trunk/ppMerge/src
Files:
3 edited

Legend:

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

    r18112 r18365  
    162162    psMetadataAddBool(arguments, PS_LIST_TAIL, "-mask-chip",    0, "Measure mask statistics by chip?", false);
    163163
     164    psMetadataAddBool(arguments, PS_LIST_TAIL, "-mask-smooth-suspect",  0, "smooth suspect pixels?", false);
     165    psMetadataAddF32(arguments, PS_LIST_TAIL, "-mask-smooth-scale",  0, "smoothing sigma for suspect pixels", NAN);
     166
     167    // chip & cell selections are used to limit chips to be processed
     168    int argnum;
     169    if ((argnum = psArgumentGet (argc, argv, "-chip"))) {
     170        psArgumentRemove (argnum, &argc, argv);
     171        psMetadataAddStr (config->arguments, PS_LIST_TAIL, "CHIP_SELECTIONS", PS_DATA_STRING, "", argv[argnum]);
     172        psArgumentRemove (argnum, &argc, argv);
     173    }
     174    if ((argnum = psArgumentGet (argc, argv, "-cell"))) {
     175        psArgumentRemove (argnum, &argc, argv);
     176        psMetadataAddStr (config->arguments, PS_LIST_TAIL, "CELL_SELECTIONS", PS_DATA_STRING, "", argv[argnum]);
     177        psArgumentRemove (argnum, &argc, argv);
     178    }
     179
    164180    if (argc == 1 || !psArgumentParse(arguments, &argc, argv) || argc != 3) {
    165181        usage(argv[0], arguments);
     
    269285    VALUE_ARG_RECIPE_BOOL("-mask-chip",     "MASK.CHIPSTATS");
    270286
     287    VALUE_ARG_RECIPE_BOOL("-mask-smooth-suspect", "MASK.SMOOTH.SUSPECT");
     288    VALUE_ARG_RECIPE_FLOAT("-mask-smooth-scale", "MASK.SMOOTH.SCALE", F32);
    271289
    272290    const char *maskModeStr = psMetadataLookupStr(NULL, arguments, "-mask-mode"); // Mode to identify bad pix
  • trunk/ppMerge/src/ppMergeCamera.c

    r17929 r18365  
    3030        return false;
    3131    }
     32
     33    // Chip selection: turn on only the chips specified.
     34    bool status;
     35    char *chipLine = psMetadataLookupStr(&status, config->arguments, "CHIP_SELECTIONS");
     36    psArray *chips = psStringSplitArray (chipLine, ",", false);
     37    if (chips->n > 0) {
     38        pmFPASelectChip (fpa, -1, true); // deselect all chips
     39        for (int i = 0; i < chips->n; i++) {
     40            int chipNum = atoi(chips->data[i]);
     41            if (! pmFPASelectChip(fpa, chipNum, false)) {
     42                psError(PS_ERR_IO, false, "Chip number %d doesn't exist in camera.\n", chipNum);
     43                psFree (chips);
     44                return false;
     45            }
     46        }
     47    }
     48    psFree (chips);
     49
     50    // Cell selection: turn on only the cells specified.  Note that this affects the same cell
     51    // for all chips
     52    char *cellLine = psMetadataLookupStr(&status, config->arguments, "CELL_SELECTIONS");
     53    psArray *cells = psStringSplitArray (cellLine, ",", false);
     54    if (cells->n > 0) {
     55        for (int i = 0; i < fpa->chips->n; i++) {
     56            pmChip *chip = fpa->chips->data[i];
     57            pmChipSelectCell (chip, -1, true); // deselect all cells
     58            for (int j = 0; j < cells->n; j++) {
     59                int cellNum = atoi(cells->data[j]);
     60                if (! pmChipSelectCell(chip, cellNum, false)) {
     61                    psError(PS_ERR_IO, false, "Cell number %d doesn't exist in camera.\n", cellNum);
     62                    psFree (cells);
     63                    return false;
     64                }
     65            }
     66        }
     67    }
     68    psFree (cells);
    3269
    3370    pmFPAfile *output = pmFPAfileDefineOutput(config, fpa, name);
     
    229266                pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // HDU for cell
    230267                if (!hdu || hdu->blankPHU) {
    231                     psFree(cell->concepts);
    232                     cell->concepts = NULL;
    233268                    cell->data_exists = false;
    234269                    cell->file_exists = false;
    235270                    culled++;
     271                    if (cell->concepts) {
     272                        psFree(cell->concepts);
     273                        cell->concepts = NULL;
     274                    }
    236275                }
    237276            }
    238277            if (culled == cells->n) {
    239                 psFree(chip->concepts);
    240                 chip->concepts = NULL;
    241278                chip->data_exists = false;
    242279                chip->file_exists = false;
     280                if (chip->concepts) {
     281                    psFree(chip->concepts);
     282                    chip->concepts = NULL;
     283                }
    243284            }
    244285        }
  • 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.