IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 9, 2013, 4:06:36 PM (13 years ago)
Author:
eugene
Message:

merge from trunk

Location:
branches/eam_branches/ipp-20130904/ppImage/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130904/ppImage/src

  • branches/eam_branches/ipp-20130904/ppImage/src/ppImageAuxiliaryMask.c

    r35722 r36193  
    3535        return NULL;
    3636    }
     37    if (image->type.type != PS_TYPE_IMAGE_MASK) {
     38        psWarning("auxiliary mask image %s has unexpected type %d\n", realName, image->type.type);
     39        return false;
     40    }
    3741    psFree(realName);
    3842
     
    7276    }
    7377
    74     // Find a suitable detRun with type AUXMASK
    75 
    76     psTime *time = psMetadataLookupPtr(NULL, input->fpa->concepts, "FPA.TIME");
    77     if (time->sec == 0 && time->nsec == 0) {
    78         psLogMsg ("psModules.camera", PS_LOG_WARN, "FPA.TIME has not been set.\n");
    79     }
    80 
    81     char *cameraName = psMetadataLookupStr(NULL, input->fpa->concepts, "FPA.CAMERA");
    82     pmDetrendSelectOptions *detrendOptions = pmDetrendSelectOptionsAlloc(cameraName, *time, PM_DETREND_TYPE_AUXMASK);
    83 
    84     pmDetrendSelectResults *results = pmDetrendSelect(detrendOptions, config);
    85     psFree(detrendOptions);
    86     if (!results) {
    87         psError (psErrorCodeLast(), false, "no matching auxiliary mask found");
    88         return false;
    89     }
    90 
    91     pmFPALevel fileLevel = pmFPALevelFromName(results->level);
    92     if (fileLevel != PM_FPA_LEVEL_CHIP) {
    93          psError (PM_ERR_CONFIG, false, "invalid file level %d for selected auxiliary mask", fileLevel);
    94          return false;
    95     }
    96    
     78    pmFPAfile *auxmask = psMetadataLookupPtr(&status, config->files, "PPIMAGE.AUXMASK");
     79    if (!status) {
     80        psError(PS_ERR_UNEXPECTED_NULL, true, "PPIMAGE.CHIP file is not defined");
     81        return false;
     82    }
     83
    9784    // Go find the readout
    9885    // code to find the readouts was adapted from ppImageSubtractBackground
     
    129116        return true;
    130117    }
    131     // not needed psImage *image = ro->image;
     118
    132119    psImage *mask = ro->mask;
    133120
    134     // now read the auxiliary mask file
    135     psString class_id = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME");
    136 
    137     char *auxMaskFileName = pmDetrendFile(results->detID, class_id, config);
    138     if (!auxMaskFileName) {
    139          psError (PM_ERR_CONFIG, false, "unable to find auxiliary mask file name for %s %s", results->detID, class_id);
    140          return false;
    141     }
    142     psLogMsg ("ppImage", PS_LOG_INFO, "Auxiliary mask file: %s", auxMaskFileName);
    143 
    144     psFree(results);
    145     // record that we read this file in the config dump file.
    146     // Note: this value isn't used during updates though.
    147     pmConfigRunFilenameAddRead(config, "PPIMAGE.AUXMASK", auxMaskFileName);
    148     recordFileInHeader(chip, "DETREND.AUXMASK", "auxiliary mask", auxMaskFileName);
    149 
    150     psImage *auxMask = readAuxiliaryMask(config, auxMaskFileName);
    151     psFree(auxMaskFileName);
    152     if (!auxMask) {
    153         psError(PS_ERR_UNKNOWN, false, "failed to read auxiliary mask file");
    154         return false;
    155     }
    156 
    157     // if the cell has video and the recipe value
     121    if (mask->type.type != PS_TYPE_IMAGE_MASK) {
     122        psWarning("mask image has unexpected type %d\n", mask->type.type);
     123        return false;
     124    }
     125
     126    pmChip *auxMaskChip = pmFPAviewThisChip(view, auxmask->fpa);
     127    if (!auxMaskChip) {
     128        psWarning("failed to find pmChip for auxiliary mask");
     129        return false;
     130    }
     131    pmCell *auxMaskCell = auxMaskChip->cells->data[0];
     132    if (!auxMaskCell) {
     133        psWarning("failed to find pmCell for auxiliary mask");
     134        return false;
     135    }
     136    pmReadout *auxMaskReadout = auxMaskCell->readouts->data[0];
     137    if (!auxMaskReadout) {
     138        psWarning("failed to find pmReadout for auxiliary mask");
     139        return false;
     140    }
     141    psImage *auxMaskImage = auxMaskReadout->mask;
     142    if (!auxMaskImage) {
     143        psWarning("failed to find psImage for auxiliary mask");
     144        return false;
     145    }
     146    if (auxMaskImage->type.type != PS_TYPE_IMAGE_MASK) {
     147        psWarning("auxiliary mask image has unexpected type %d\n", auxMaskImage->type.type);
     148        return false;
     149    }
     150
     151    // if the cell has video and the recipe value is set or in the video mask
    158152    if (options->hasVideo && options->auxVideoMask && strcmp(options->auxVideoMask, "NULL")) {
    159153        psImage *videoMask = readAuxiliaryMask(config, options->auxVideoMask);
     
    166160        recordFileInHeader(chip, "DETREND.AUXVIDEOMASK", "auxiliary video mask", options->auxVideoMask);
    167161
    168         // compute auxMask *= videoMask
    169         if (!psBinaryOp(auxMask, auxMask, "*", videoMask)) {
    170             psError(PS_ERR_UNKNOWN, false, "mulitplication of auxiliary mask and auxiliary video mask failed");
     162        // compute auxMask |= videoMask
     163        if (!psBinaryOp(auxMaskImage, auxMaskImage, "|", videoMask)) {
     164            psError(PS_ERR_UNKNOWN, false, "combination of auxiliary mask and auxiliary video mask failed");
    171165            return false;
    172166        }
     
    174168    }
    175169
    176     if ((mask->numRows != auxMask->numRows) || (mask->numCols != auxMask->numCols) ||
    177         (mask->row0 != auxMask->row0) || (mask->col0 != auxMask->col0)) {
     170    if ((mask->numRows != auxMaskImage->numRows) || (mask->numCols != auxMaskImage->numCols) ||
     171        (mask->row0 != auxMaskImage->row0) || (mask->col0 != auxMaskImage->col0)) {
    178172        psError(PS_ERR_IO, false, "structure of auxiliary mask does not match this chip");
    179173        return false;
     
    187181    psAssert(staticMaskVal, "Need staticMaskVal!");
    188182
     183    // XXX: now that we are using an auxilary mask that matches the format of ps masks, we could just
     184    // do psBinaryOp(mask, mask, "|", auxMaskImage) but run an explicit loop so that we can measure
     185    // and log the number of additional pixels masked
    189186    int numCols = mask->numCols, numRows = mask->numRows; // Size of image
    190187    unsigned long numMasked = 0;
    191188    for (int y = 0; y < numRows; y++) {
    192189        for (int x = 0; x < numCols; x++) {
    193             // auxMask is floating point type image with pixel value 0 meaning mask it
    194             // XXX: support other types and get the mask value from the header
    195             if (auxMask->data.F32[y][x] == 0) {
     190            if (auxMaskImage->data.U16[y][x] != 0) {
    196191                if ((mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & staticMaskVal) == 0) {
    197192                    // pixel was not previously included in the static mask so mask it
     
    200195                }
    201196                // I don't need to do this.
     197                // image->data.F32[y][x] = 0.0;
    202198                // The background subtraction code runs after us and will do it there
    203                 // image->data.F32[y][x] = 0.0;
    204199            }
    205200        }
     
    213208    }
    214209
    215     psFree(auxMask);
    216 
    217210    return true;
    218211}
  • branches/eam_branches/ipp-20130904/ppImage/src/ppImageParseCamera.c

    r35685 r36193  
    7272                               PM_FPA_FILE_MASK, PM_DETREND_TYPE_VIDEOMASK)) {
    7373            psError(PS_ERR_IO, false, "Can't find a mask image source");
     74            psFree(options);
     75            return NULL;
     76        }
     77      }
     78      if (options->doAuxMask) {
     79        if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.AUXMASK", "MASK",
     80                               PM_FPA_FILE_MASK, PM_DETREND_TYPE_AUXMASK)) {
     81            psError(PS_ERR_IO, false, "Can't find a auxillary mask image source");
    7482            psFree(options);
    7583            return NULL;
Note: See TracChangeset for help on using the changeset viewer.