IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 26, 2009, 8:40:07 PM (17 years ago)
Author:
eugene
Message:

incorporating changes from 16bit mask upgrades (eam_branch_20081230)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPAMaskWeight.c

    r20749 r21183  
    4242            continue;
    4343        }
    44         masks->data[i] = psImageAlloc(image->numCols, image->numRows, PS_TYPE_U8);
     44        masks->data[i] = psImageAlloc(image->numCols, image->numRows, PS_TYPE_IMAGE_MASK);
    4545        psImageInit(masks->data[i], 0);
    4646    }
     
    9898//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    9999
    100 bool pmReadoutSetMask(pmReadout *readout, psMaskType satMask, psMaskType badMask)
     100bool pmReadoutSetMask(pmReadout *readout, psImageMaskType satMask, psImageMaskType badMask)
    101101{
    102102    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    124124    if (!readout->mask) {
    125125        // Generate a (throwaway) mask image, if required
    126         readout->mask = psImageAlloc(image->numCols, image->numRows, PS_TYPE_U8);
     126        readout->mask = psImageAlloc(image->numCols, image->numRows, PS_TYPE_IMAGE_MASK);
    127127    }
    128128    psImage *mask = readout->mask;      // The mask pixels
     
    131131    // Dereference pointers for speed
    132132    psF32 **imageData = image->data.F32;// The image
    133     psU8  **maskData  = mask->data.U8;  // The mask
     133    psImageMaskType **maskData = mask->data.PS_TYPE_IMAGE_MASK_DATA;  // The mask
    134134
    135135    for (int i = 0; i < image->numRows; i++) {
     
    153153// pixels.  currently, it will set mask bits if (value <= BAD) or (value >= SATURATION)
    154154// should we optionally ignore these tests?
    155 bool pmReadoutGenerateMask(pmReadout *readout, psMaskType satMask, psMaskType badMask)
     155bool pmReadoutGenerateMask(pmReadout *readout, psImageMaskType satMask, psImageMaskType badMask)
    156156{
    157157    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    294294}
    295295
    296 bool pmReadoutGenerateMaskWeight(pmReadout *readout, psMaskType satMask, psMaskType badMask, bool poisson)
     296bool pmReadoutGenerateMaskWeight(pmReadout *readout, psImageMaskType satMask, psImageMaskType badMask, bool poisson)
    297297{
    298298    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    306306}
    307307
    308 bool pmCellGenerateMaskWeight(pmCell *cell, psMaskType satMask, psMaskType badMask, bool poisson)
     308bool pmCellGenerateMaskWeight(pmCell *cell, psImageMaskType satMask, psImageMaskType badMask, bool poisson)
    309309{
    310310    PS_ASSERT_PTR_NON_NULL(cell, false);
     
    321321
    322322
    323 bool pmReadoutWeightRenormPixels(const pmReadout *readout, psMaskType maskVal,
     323bool pmReadoutWeightRenormPixels(const pmReadout *readout, psImageMaskType maskVal,
    324324                                 psStatsOptions meanStat, psStatsOptions stdevStat, psRandom *rng)
    325325{
     
    363363
    364364
    365 bool pmReadoutWeightRenormPhot(const pmReadout *readout, psMaskType maskVal, int num, float width,
     365bool pmReadoutWeightRenormPhot(const pmReadout *readout, psImageMaskType maskVal, int num, float width,
    366366                               psStatsOptions meanStat, psStatsOptions stdevStat, psRandom *rng)
    367367{
     
    411411    psVector *source = psVectorAlloc(num, PS_TYPE_F32); // Measurements of fake sources
    412412    psVector *guess = psVectorAlloc(num, PS_TYPE_F32); // Guess at significance
    413     psVector *photMask = psVectorAlloc(num, PS_TYPE_MASK); // Mask for fluxes
     413    psVector *photMask = psVectorAlloc(num, PS_TYPE_VECTOR_MASK); // Mask for fluxes
    414414    for (int i = 0; i < num; i++) {
    415415        // Coordinates of interest
     
    433433            float yGauss = gauss->data.F32[v]; // Value of Gaussian in y
    434434            for (int u = 0, x = xPix - size; u < fullSize; u++, x++) {
    435                 if (mask && mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
     435                if (mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) {
    436436                    continue;
    437437                }
     
    453453        }
    454454
    455         photMask->data.PS_TYPE_MASK_DATA[i] = ((isfinite(sumNoise) && isfinite(sumSource) &&
     455        photMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = ((isfinite(sumNoise) && isfinite(sumSource) &&
    456456                                                isfinite(sumWeight) && sumGauss > 0 && sumGauss2 > 0) ?
    457457                                               0 : 0xFF);
     
    493493        ratio->data.F32[i] = measuredSig / guess->data.F32[i];
    494494        if (guess->data.F32[i] <= 0.0 || source->data.F32[i] <= 0.0 || !isfinite(ratio->data.F32[i])) {
    495             photMask->data.PS_TYPE_MASK_DATA[i] = 0xFF;
     495            photMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xFF;
    496496        }
    497497        psTrace("psModules.camera", 9, "Ratio %d: %f, %f, %f\n",
     
    523523
    524524
    525 bool pmReadoutWeightRenorm(const pmReadout *readout, psMaskType maskVal, psStatsOptions meanStat,
     525bool pmReadoutWeightRenorm(const pmReadout *readout, psImageMaskType maskVal, psStatsOptions meanStat,
    526526                           psStatsOptions stdevStat, int width, psRandom *rng)
    527527{
     
    591591
    592592
    593 bool pmReadoutMaskNonfinite(pmReadout *readout, psMaskType maskVal)
     593bool pmReadoutMaskNonfinite(pmReadout *readout, psImageMaskType maskVal)
    594594{
    595595    PM_ASSERT_READOUT_NON_NULL(readout, false);
     
    601601
    602602    if (!readout->mask) {
    603         readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
     603        readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
    604604    }
    605605    psImage *mask = readout->mask;      // Readout's mask
     
    608608        for (int x = 0; x < numCols; x++) {
    609609            if (!isfinite(image->data.F32[y][x]) || (weight && !isfinite(weight->data.F32[y][x]))) {
    610                 mask->data.PS_TYPE_MASK_DATA[y][x] |= maskVal;
     610                mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= maskVal;
    611611            }
    612612        }
     
    618618
    619619
    620 bool pmReadoutMaskApply(pmReadout *readout, psMaskType maskVal)
     620bool pmReadoutMaskApply(pmReadout *readout, psImageMaskType maskVal)
    621621{
    622622    PM_ASSERT_READOUT_NON_NULL(readout, false);
     
    625625
    626626    int numCols = readout->image->numCols, numRows = readout->image->numRows; // Size of image
    627     psMaskType **maskData = readout->mask->data.PS_TYPE_MASK_DATA; // Dereference mask
     627    psImageMaskType **maskData = readout->mask->data.PS_TYPE_IMAGE_MASK_DATA; // Dereference mask
    628628    psF32 **imageData = readout->image->data.F32;// Dereference image
    629629    psF32 **weightData = readout->weight ? readout->weight->data.F32 : NULL; // Dereference weight map
     
    644644
    645645
    646 bool pmReadoutInterpolateBadPixels(pmReadout *readout, psMaskType maskVal, psImageInterpolateMode mode,
    647                                    float poorFrac, psMaskType maskPoor, psMaskType maskBad)
     646bool pmReadoutInterpolateBadPixels(pmReadout *readout, psImageMaskType maskVal, psImageInterpolateMode mode,
     647                                   float poorFrac, psImageMaskType maskPoor, psImageMaskType maskBad)
    648648{
    649649    PM_ASSERT_READOUT_NON_NULL(readout, false);
     
    667667    psVector *imagePix = psVectorAllocEmpty(PIXELS_BUFFER, PS_TYPE_F32); // Corresponding values for image
    668668    psVector *weightPix = psVectorAllocEmpty(PIXELS_BUFFER, PS_TYPE_F32); // Corresponding values for weight
    669     psVector *maskPix = psVectorAllocEmpty(PIXELS_BUFFER, PS_TYPE_MASK); // Corresponding values for mask
     669    psVector *maskPix = psVectorAllocEmpty(PIXELS_BUFFER, PS_TYPE_IMAGE_MASK); // Corresponding values for mask
     670    // NOTE: maskPix carries the actual image mask values -- do NOT use
     671    // PS_TYPE_VECTOR_MASK here; it is storage, and is not treated as a vector mask
    670672
    671673    long numBad = 0;                    // Number of bad pixels interpolated
    672674    for (int y = 0; y < numRows; y++) {
    673675        for (int x = 0; x < numCols; x++) {
    674             if (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
     676            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) {
    675677                double imageValue, weightValue; // Image and weight value from interpolation
    676                 psMaskType maskValue = 0; // Mask value from interpolation
    677                 psImageInterpolateStatus status = psImageInterpolate(&imageValue, &weightValue, &maskValue,
    678                                                                      x, y, interp);
     678                psImageMaskType maskValue = 0; // Mask value from interpolation
     679                psImageInterpolateStatus status = psImageInterpolate(&imageValue, &weightValue, &maskValue, x, y, interp);
    679680                if (status == PS_INTERPOLATE_STATUS_ERROR || status == PS_INTERPOLATE_STATUS_OFF) {
    680681                    psError(PS_ERR_UNKNOWN, false, "Unable to interpolate readout at %d,%d", x, y);
     
    697698                imagePix->data.F32[numBad] = imageValue;
    698699                weightPix->data.F32[numBad] = weightValue;
    699                 maskPix->data.PS_TYPE_MASK_DATA[numBad] = maskValue;
     700                maskPix->data.PS_TYPE_IMAGE_MASK_DATA[numBad] = maskValue;
    700701                numBad++;
    701702            }
     
    709710        image->data.F32[y][x] = imagePix->data.F32[i];
    710711        weight->data.F32[y][x] = weightPix->data.F32[i];
    711         mask->data.PS_TYPE_MASK_DATA[y][x] = maskPix->data.PS_TYPE_MASK_DATA[i];
     712        mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = maskPix->data.PS_TYPE_IMAGE_MASK_DATA[i];
    712713    }
    713714
Note: See TracChangeset for help on using the changeset viewer.