IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 8, 2007, 4:47:49 PM (19 years ago)
Author:
Paul Price
Message:

Bug fixes to get the output image and mask (and not the weight if not available) to be written out. Incorporating the new subtraction mask.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSub/src/ppSubReadout.c

    r13662 r13738  
    1010#include "ppSub.h"
    1111
    12 #define MASK_BAD      0x01              // Mask value for bad pixel
    13 #define MASK_STAMP    0x02              // Mask value for bad stamp (and bad stamp region)
    14 
    1512bool ppSubReadout(pmConfig *config, const pmFPAview *view)
    1613{
    1714    pmReadout *inRO = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT"); // Input readout
    1815    pmReadout *refRO = pmFPAfileThisReadout(config->files, view, "PPSUB.REF"); // Reference readout
    19 #if 0
    2016    pmCell *outCell = pmFPAfileThisCell(config->files, view, "PPSUB.OUTPUT"); // Output cell
    2117    pmReadout *outRO = pmReadoutAlloc(outCell); // Output readout
    22 #endif
    2318
    2419    psImage *input = inRO->image;       // Input image
     
    4944    if (!refRO->mask) {
    5045        refRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
    51         psImageInit(inRO->mask, 0);
     46        psImageInit(refRO->mask, 0);
    5247    }
    5348
    54     // Worried about the masks for bad pixels and bad stamps colliding, so make our own mask
    55     psImage *stampMask = psImageAlloc(numCols, numRows, PS_TYPE_MASK); // Mask to use for stamps
    56     for (int y = 0; y < numRows; y++) {
    57         for (int x = 0; x < numCols; x++) {
    58             stampMask->data.PS_TYPE_MASK_DATA[y][x] =
    59                 (refRO->mask->data.PS_TYPE_MASK_DATA[y][x] & maskBad) ? MASK_BAD : 0;
    60         }
    61     }
     49    // Mask for subtraction
     50    psImage *subMask = pmSubtractionMask(inRO->mask, refRO->mask, maskBad, size, footprint);
    6251
    6352#if 0
     
    8473    int numRejected = -1;               // Number of rejected stamps in each iteration
    8574    for (int i = 0; i < iter && numRejected != 0; i++) {
    86         stamps = pmSubtractionFindStamps(stamps, refRO->image, stampMask, MASK_BAD, MASK_STAMP,
    87                                          threshold, spacing, size + footprint);
     75        stamps = pmSubtractionFindStamps(stamps, refRO->image, subMask, threshold, spacing);
    8876        if (!stamps) {
    8977            psError(PS_ERR_UNKNOWN, false, "Unable to find stamps on reference image.");
     
    10391        }
    10492
    105         numRejected = pmSubtractionRejectStamps(stamps, refRO->image, inRO->image, stampMask, MASK_STAMP,
     93        numRejected = pmSubtractionRejectStamps(stamps, refRO->image, inRO->image, subMask,
    10694                                                solution, footprint, rej, kernels);
    10795        if (numRejected < 0) {
     
    11199        psLogMsg("ppSub", PS_LOG_INFO, "%d stamps rejected on iteration %d.", numRejected, i);
    112100    }
    113     psFree(stampMask);
    114101
    115102    if (numRejected > 0) {
     
    122109
    123110    psImage *convImage = NULL, *convWeight = NULL, *convMask = NULL; // Convolved images
    124     if (!pmSubtractionConvolve(&convImage, &convWeight, &convMask,
    125                                refRO->image, refRO->weight, refRO->mask,
    126                                MASK_BAD, maskBlank, solution, kernels)) {
     111    if (!pmSubtractionConvolve(&convImage, &convWeight, &convMask, refRO->image, refRO->weight, subMask,
     112                               maskBlank, solution, kernels)) {
    127113        psError(PS_ERR_UNKNOWN, false, "Unable to convolve reference image.");
    128114        goto ERROR;
    129115    }
     116    psFree(subMask);
    130117
    131118    // Do the subtraction
    132119    if (reverse) {
    133         (void)psBinaryOp(inRO->image, convImage, "-", inRO->image);
     120        outRO->image = (psImage*)psBinaryOp(NULL, convImage, "-", inRO->image);
    134121    } else {
    135         (void)psBinaryOp(inRO->image, inRO->image, "-", convImage);
     122        outRO->image = (psImage*)psBinaryOp(NULL, inRO->image, "-", convImage);
    136123    }
    137     (void)psBinaryOp(inRO->mask, convMask, "|", inRO->mask);
    138     (void)psBinaryOp(inRO->weight, convWeight, "+", inRO->weight);
     124    outRO->mask = (psImage*)psBinaryOp(NULL, convMask, "|", inRO->mask);
     125    if (convWeight) {
     126        outRO->weight = (psImage*)psBinaryOp(NULL, convWeight, "+", inRO->weight);
     127    }
    139128
    140129    psFree(convImage);
    141130    psFree(convMask);
    142131    psFree(convWeight);
     132
     133    outRO->data_exists = true;
     134    outCell->data_exists = true;
     135    outCell->parent->data_exists = true;
     136
     137    if (!pmFPACopyConcepts(outCell->parent->parent, inRO->parent->parent->parent)) {
     138        psError(PS_ERR_UNKNOWN, false, "Unable to copy concepts from input to output.");
     139        return false;
     140    }
    143141
    144142#if 0
Note: See TracChangeset for help on using the changeset viewer.