IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 6, 2005, 6:43:52 PM (21 years ago)
Author:
Paul Price
Message:

Importing current working PAP version (many bug fixes since this branch) straight on top of this version, and tidying up a bit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pois/src/poisStamp.c

    r3836 r5717  
    1111    stamp->matrix = NULL;
    1212    stamp->vector = NULL;
    13     psMemSetDeallocator(stamp, (psFreeFcn)poisStampFree);
     13    psMemSetDeallocator(stamp, (psFreeFunc)poisStampFree);
    1414
    1515    return stamp;
     
    1818void poisStampFree(poisStamp *stamp)
    1919{
    20     psFree(stamp->matrix);
    21     psFree(stamp->vector);
     20    if (stamp->matrix) {
     21        psFree(stamp->matrix);
     22    }
     23    if (stamp->vector) {
     24        psFree(stamp->vector);
     25    }
     26    psFree(stamp);
    2227}
     28
     29
     30// Return true if the stamp is OK
     31bool poisCheckStamp(const psImage *image, // Image to check for threshold
     32                    const psImage *mask, // Mask to check for bad pixels
     33                    int x, int y,       // Pixel coordinates
     34                    const poisConfig *config // Configuration
     35    )
     36{
     37    if (x < config->footprint + config->xKernel ||
     38        y < config->footprint + config->yKernel ||
     39        x > config->xImage - config->footprint - config->xKernel ||
     40        y > config->yImage - config->footprint - config->yKernel ||
     41        image->data.F32[y][x] < config->threshold) {
     42        psTrace("pois.checkStamp", 9, "Rejecting stamp at %d,%d (border/threshold)\n", x, y);
     43        return false;
     44    }
     45
     46    // Check the footprint
     47    bool ok = true;                     // Is the footprint OK?
     48    int footprint = config->footprint;  // Footprint size
     49    for (int v = y - footprint; v <= y + footprint && ok; v++) {
     50        for (int u = x - footprint; u <= x + footprint && ok; u++) {
     51            if (mask->data.U8[v][u] &
     52                (POIS_MASK_BAD | POIS_MASK_NEAR_BAD | POIS_MASK_STAMP)) {
     53                psTrace("pois.checkStamp", 9, "Rejecting stamp at %d,%d (bad footprint)\n", x, y);
     54                ok = false;
     55            }
     56        }
     57    }
     58   
     59    return ok;
     60}
     61
Note: See TracChangeset for help on using the changeset viewer.