IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 24113


Ignore:
Timestamp:
May 8, 2009, 12:07:28 PM (17 years ago)
Author:
eugene
Message:

allow suspect pixels to be masked based on absolute value as well as sigma level

Location:
trunk/psModules/src/detrend
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/detrend/pmMaskBadPixels.c

    r21183 r24113  
    8181
    8282
    83 bool pmMaskFlagSuspectPixels(pmReadout *output, const pmReadout *readout, float median, float stdev,
    84                              float rej, psImageMaskType maskVal)
     83bool pmMaskFlagSuspectPixelsBySigma(pmReadout *output, const pmReadout *readout, float median, float stdev,
     84                                    float rej, psImageMaskType maskVal)
    8585{
    8686    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    115115        // If we get down here and the statistics are missing, then we should go and mask the entire image
    116116        psWarning("Missing statistics --- flagging entire image as suspect.");
    117         return (psImage*)psBinaryOp(suspect, suspect, "+", psScalarAlloc(1.0, PS_TYPE_F32));
     117        psBinaryOp (suspect, suspect, "+", psScalarAlloc(1.0, PS_TYPE_F32));
     118        return true;
    118119    }
    119120
     
    128129        for (int x = 0; x < image->numCols; x++) {
    129130            if (fabs((image->data.F32[y][x] - median) / stdev) < rej) continue;
     131            if (mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal)) continue;
     132            suspect->data.F32[y][x] += 1.0;
     133        }
     134    }
     135    psFree(suspect);                    // Drop reference
     136
     137    psMetadataItem *numItem = psMetadataLookup(output->analysis, PM_MASK_ANALYSIS_NUM); // Item with number
     138    assert(numItem);
     139    numItem->data.S32++;
     140
     141    return true;
     142}
     143
     144bool pmMaskFlagSuspectPixelsByValue(pmReadout *output, const pmReadout *readout,
     145                                    float min, float max, psImageMaskType maskVal)
     146{
     147    PS_ASSERT_PTR_NON_NULL(readout, false);
     148    PS_ASSERT_IMAGE_NON_NULL(readout->image, false);
     149    PS_ASSERT_IMAGE_NON_EMPTY(readout->image, false);
     150    PS_ASSERT_IMAGE_TYPE(readout->image, PS_TYPE_F32, false);
     151    if (readout->mask) {
     152        PS_ASSERT_IMAGE_NON_EMPTY(readout->mask, false);
     153        PS_ASSERT_IMAGES_SIZE_EQUAL(readout->image, readout->mask, false);
     154        PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_IMAGE_MASK, false);
     155    }
     156    PS_ASSERT_PTR_NON_NULL(output, false);
     157
     158    bool mdok;                          // Status of MD lookup
     159    psImage *suspect = psMetadataLookupPtr(&mdok, output->analysis, PM_MASK_ANALYSIS_SUSPECT); // Suspect img
     160    if (suspect) {
     161        PS_ASSERT_IMAGE_NON_EMPTY(suspect, false);
     162        PS_ASSERT_IMAGE_TYPE(suspect, PS_TYPE_F32, false);
     163        PS_ASSERT_IMAGES_SIZE_EQUAL(readout->image, suspect, false);
     164        psMemIncrRefCounter(suspect);
     165    } else {
     166        suspect = psImageAlloc(readout->image->numCols, readout->image->numRows, PS_TYPE_F32);
     167        psImageInit(suspect, 0);
     168        psMetadataAddImage(output->analysis, PS_LIST_TAIL, PM_MASK_ANALYSIS_SUSPECT, PS_META_REPLACE,
     169                           "Suspect pixels", suspect);
     170        psMetadataAddS32(output->analysis, PS_LIST_TAIL, PM_MASK_ANALYSIS_NUM, PS_META_REPLACE,
     171                         "Number of input images", 0);
     172    }
     173
     174    psImage *image = readout->image;    // Image of interest
     175    psImage *mask = readout->mask;      // Corresponding mask
     176
     177    psTrace ("psModules.detrend", 3, "suspect: < %f or > %f\n", min, max);
     178
     179    // XXX this loop could result in pixels with suspect = 0.0 but no valid input pixels (all
     180    // masked).  need to track the number of good as well as suspect pixels?
     181    for (int y = 0; y < image->numRows; y++) {
     182        for (int x = 0; x < image->numCols; x++) {
     183            bool above = image->data.F32[y][x] > max;
     184            bool below = image->data.F32[y][x] < min;
     185            if (!above && !below) continue;
    130186            if (mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal)) continue;
    131187            suspect->data.F32[y][x] += 1.0;
  • trunk/psModules/src/detrend/pmMaskBadPixels.h

    r21183 r24113  
    5050/// high value in the suspect pixels image, allowing them to be identified.  The suspect pixels
    5151/// image is of type S32.  The relevant median and standard deviation must be supplied in the
    52 /// readout->analysis metadata as READOUT.MEDIAN, READOUT.STDEVe
    53 bool pmMaskFlagSuspectPixels(pmReadout *output, ///< Output readout, optionally with suspect pixels image
     52/// readout->analysis metadata as READOUT.MEDIAN, READOUT.STDEV
     53bool pmMaskFlagSuspectPixelsBySigma(pmReadout *output, ///< Output readout, optionally with suspect pixels image
    5454                             const pmReadout *readout, ///< Readout to inspect
    5555                             float median, ///< Image median
    5656                             float stdev, ///< Image standard deviation
    5757                             float rej, ///< Rejection threshold (standard deviations)
     58                             psImageMaskType maskVal ///< Mask value for statistics
     59    );
     60
     61/// Find out-of-range pixels and flag them
     62///
     63/// Pixels great > max or < min have the corresponding pixel in the "suspect pixels" image
     64/// incremented.  After accumulating over a suitable sample of images, bad pixels should have a
     65/// high value in the suspect pixels image, allowing them to be identified.  The suspect pixels
     66/// image is of type S32.  The relevant median and standard deviation must be supplied in the
     67/// readout->analysis metadata as READOUT.MEDIAN, READOUT.STDEV
     68bool pmMaskFlagSuspectPixelsByValue(pmReadout *output, ///< Output readout, optionally with suspect pixels image
     69                             const pmReadout *readout, ///< Readout to inspect
     70                             float min, ///< Image min acceptable value
     71                             float max, ///< Image max acceptable value
    5872                             psImageMaskType maskVal ///< Mask value for statistics
    5973    );
Note: See TracChangeset for help on using the changeset viewer.