IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 22, 2008, 12:45:36 PM (18 years ago)
Author:
Paul Price
Message:

Reworking the masking so as to avoid exploding the number of bad pixels in the convolved image. Introduced the bad/poor distinction. Bad pixels that are convolved now have a large 'poor' halo in the mask, with a smaller 'bad' halo. Got rid of the 'FOOTPRINT' mask value (internal subtraction mask): there's no need to convolve the mask in order to find out if a sprinkling of footprints are bad (not sure this is so efficient when a list of sources isn't supplied), and I needed the mask bits to signify the difference between 'bad' and 'poor'. Tested on a single subtraction, which seems to work.

File:
1 edited

Legend:

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

    r17297 r19164  
    7373static bool checkStampMask(int x, int y, // Coordinates of stamp
    7474                           const psImage *mask, // Mask
    75                            pmSubtractionMode mode // Mode for subtraction
     75                           pmSubtractionMode mode, // Mode for subtraction
     76                           int footprint // Footprint to check for Bad Stuff
    7677                           )
    7778{
     
    7980        return true;
    8081    }
    81     if (x < 0 || x >= mask->numCols || y < 0 || y >= mask->numRows) {
    82         return false;
    83     }
    84 
    85     psMaskType maskVal = PM_SUBTRACTION_MASK_BORDER | PM_SUBTRACTION_MASK_REJ; // Mask value
     82
     83    bool clean = true;                  // Is the footprint clean?
     84    int numCols = mask->numCols, numRows = mask->numRows; // Size of image
     85
     86    // Check the footprint bounds
     87    if (x < footprint || x >= numCols - footprint || y < footprint || y >= numRows - footprint) {
     88        clean = false;
     89    }
     90
     91    // Determine mask value
     92    psMaskType maskVal = PM_SUBTRACTION_MASK_BORDER | PM_SUBTRACTION_MASK_BAD_1 | PM_SUBTRACTION_MASK_BAD_2;
    8693    switch (mode) {
    8794      case PM_SUBTRACTION_MODE_1:
    88         maskVal |= PM_SUBTRACTION_MASK_FOOTPRINT_1;
     95        maskVal |= PM_SUBTRACTION_MASK_CONVOLVE_1;
    8996        break;
    9097      case PM_SUBTRACTION_MODE_2:
    91         maskVal |= PM_SUBTRACTION_MASK_FOOTPRINT_2;
     98        maskVal |= PM_SUBTRACTION_MASK_CONVOLVE_2;
    9299        break;
    93100      case PM_SUBTRACTION_MODE_UNSURE:
    94101      case PM_SUBTRACTION_MODE_DUAL:
    95         maskVal |= PM_SUBTRACTION_MASK_FOOTPRINT_1 | PM_SUBTRACTION_MASK_FOOTPRINT_2;
     102        maskVal |= PM_SUBTRACTION_MASK_CONVOLVE_1 | PM_SUBTRACTION_MASK_CONVOLVE_2;
    96103        break;
    97104      default:
     
    99106    }
    100107
    101     return (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) ? false : true;
     108    // Check the immediate pixel
     109    if (clean && (mask->data.PS_TYPE_MASK_DATA[y][x] & (maskVal | PM_SUBTRACTION_MASK_REJ))) {
     110        clean = false;
     111    }
     112
     113    int xMin = PS_MAX(x - footprint, 0), xMax = PS_MIN(x + footprint, numCols - 1); // Bounds in x
     114    int yMin = PS_MAX(y - footprint, 0), yMax = PS_MIN(y + footprint, numRows - 1); // Bounds in y
     115
     116    // Check the footprint
     117    if (clean) {
     118        for (int j = yMin; j <= yMax; j++) {
     119            for (int i = xMin; i <= xMax; i++) {
     120                if (mask->data.PS_TYPE_MASK_DATA[j][i] & maskVal) {
     121                    clean = false;
     122                    goto CHECK_STAMP_MASK_DONE;
     123                }
     124            }
     125        }
     126    }
     127CHECK_STAMP_MASK_DONE:
     128
     129    if (!clean) {
     130        // Mask the footprint, so we don't select something near it again
     131        for (int j = yMin; j <= yMax; j++) {
     132            for (int i = xMin; i <= xMax; i++) {
     133                mask->data.PS_TYPE_MASK_DATA[j][i] |= PM_SUBTRACTION_MASK_REJ;
     134            }
     135        }
     136    }
     137
     138    return clean;
    102139}
    103140
     
    259296            for (int y = subRegion->y0; y <= subRegion->y1; y++) {
    260297                for (int x = subRegion->x0; x <= subRegion->x1; x++) {
    261                     if (checkStampMask(x, y, subMask, mode) && image->data.F32[y][x] > fluxStamp) {
     298                    if (checkStampMask(x, y, subMask, mode, footprint) && image->data.F32[y][x] > fluxStamp) {
    262299                        fluxStamp = image->data.F32[y][x];
    263300                        xStamp = x;
     
    353390            continue;
    354391        }
    355         if (!checkStampMask(xPix, yPix, subMask, mode)) {
     392        if (!checkStampMask(xPix, yPix, subMask, mode, footprint)) {
    356393            // Not a good stamp
    357394            psTrace("psModules.imcombine", 9, "Rejecting input stamp (%d,%d) because bad mask",
Note: See TracChangeset for help on using the changeset viewer.