IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 14, 2009, 10:40:50 AM (17 years ago)
Author:
Paul Price
Message:

Convolve subtraction mask so that we can easily identify bad stamps.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/imcombine/pmSubtractionMask.c

    r23849 r23851  
    3838
    3939psImage *pmSubtractionMask(const psImage *mask1, const psImage *mask2, psImageMaskType maskVal,
    40                            int size, int footprint, float badFrac, bool useFFT)
     40                           int size, int footprint, float badFrac, pmSubtractionMode mode)
    4141{
    4242    PS_ASSERT_IMAGE_NON_NULL(mask1, NULL);
     
    114114    }
    115115
    116     // XXX Could do something smarter here --- we will get images that are predominantly masked (where the
    117     // skycell isn't overlapped by a large fraction by the observation), so that convolving around every bad
    118     // pixel is wasting time.  As a first cut, I've put in a check on the fraction of bad pixels, but we could
    119     // imagine looking for the edge of big regions and convolving just at the edge.  As a second cut, allow
    120     // use of FFT convolution.
    121 
    122116    for (int y = 0; y < numRows; y++) {
    123117        for (int x = 0; x < numCols; x++) {
     
    131125    }
    132126
    133     // Block out the entire stamp footprint around bad input pixels.
    134 
    135127    // We want to block out with the CONVOLVE mask anything that would be bad if we convolved with a bad
    136     // reference pixel (within 'size').  Then we want to block out with the FOOTPRINT mask everything within a
     128    // reference pixel (within 'size').  Then we want to block out with the REJ mask everything within a
    137129    // footprint's distance of those (within 'footprint').
    138130
    139131    bool oldThreads = psImageConvolveSetThreads(true); // Old value of threading for psImageConvolve
    140132
     133    // Pixels that will be bad (or poor) if we convolve with a bad reference pixel
    141134    if (!psImageConvolveMask(mask, mask, PM_SUBTRACTION_MASK_BAD_1, PM_SUBTRACTION_MASK_CONVOLVE_1,
    142135                             -size, size, -size, size)) {
     
    148141                             -size, size, -size, size)) {
    149142        psError(PS_ERR_UNKNOWN, false, "Unable to convolve bad pixels from mask 2.");
     143        psFree(mask);
     144        return NULL;
     145    }
     146
     147    // Pixels that should not be chosen as stamps
     148    psImageMaskType maskRej = PM_SUBTRACTION_MASK_BAD_1 | PM_SUBTRACTION_MASK_BAD_2 |
     149        PM_SUBTRACTION_MASK_BORDER;     // Mask value for rejection
     150    switch (mode) {
     151      case PM_SUBTRACTION_MODE_1:
     152        maskRej |= PM_SUBTRACTION_MASK_CONVOLVE_1;
     153        break;
     154      case PM_SUBTRACTION_MODE_2:
     155        maskRej |= PM_SUBTRACTION_MASK_CONVOLVE_2;
     156        break;
     157      case PM_SUBTRACTION_MODE_UNSURE:
     158      case PM_SUBTRACTION_MODE_DUAL:
     159        maskRej |= PM_SUBTRACTION_MASK_CONVOLVE_1 | PM_SUBTRACTION_MASK_CONVOLVE_2;
     160        break;
     161      default:
     162        psAbort("Unsupported subtraction mode: %x", mode);
     163    }
     164    if (!psImageConvolveMask(mask, mask, maskRej, PM_SUBTRACTION_MASK_REJ,
     165                             -footprint, footprint, -footprint, footprint)) {
     166        psError(PS_ERR_UNKNOWN, false, "Unable to convolve bad pixels.");
    150167        psFree(mask);
    151168        return NULL;
Note: See TracChangeset for help on using the changeset viewer.