IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 29, 2010, 6:02:38 PM (16 years ago)
Author:
Paul Price
Message:

Fairly extensive change to make subtractions more stable on images with limited lit area in the presence of spatial variation. Took the polynomials which were scaled over the entire image and scale them only over the lit area. Removed some fprintf statements. Fixed the problem causing the background term to always come out 1.0.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/ppSub/src/ppSubThreshold.c

    r24862 r26739  
    2727    psImageMaskType maskIgnore,         // Ignore pixels with this mask
    2828    psImageMaskType maskThresh,         // Give pixels this mask if below threshold
     29    psRegion *region,                   // Region of interest
    2930    const char *description             // Description of image
    3031    )
     
    3738    psImage *image = ro->image;         // Image
    3839    psImage *mask = ro->mask;           // Mask
    39     int numCols = ro->image->numCols, numRows = ro->image->numRows; // Size of image
     40
     41    psImage *subImage = psImageSubset(image, *region); // Image with region of interest
     42    psImage *subMask = psImageSubset(mask, *region);  // Maks with region of interest
    4043
    4144    psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics
    4245    psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS);                               // Random number generator
    43     if (!psImageBackground(stats, NULL, image, mask, maskIgnore, rng)) {
     46    if (!psImageBackground(stats, NULL, subImage, subMask, maskIgnore, rng)) {
    4447        psError(PS_ERR_UNKNOWN, false, "Unable to determine threshold.");
    4548        psFree(rng);
     
    4952    psFree(rng);
    5053
     54    psFree(subImage);
     55    psFree(subMask);
     56
    5157    float threshold = stats->robustMedian - thresh * stats->robustStdev; // Threshold below which to clip
    5258    psFree(stats);
    5359    psLogMsg("ppSub", PS_LOG_INFO, "Masking pixels below %f in %s", threshold, description);
    5460
    55     for (int y = 0; y < numRows; y++) {
    56         for (int x = 0; x < numCols; x++) {
     61    for (int y = region->y0; y < region->y1; y++) {
     62        for (int x = region->x0; x < region->x1; x++) {
    5763            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskIgnore) {
    5864                continue;
     
    94100        return false;
    95101    }
    96     if (!lowThreshold(in, thresh, maskVal, maskThresh, "input convolved image")) {
    97         psError(PS_ERR_UNKNOWN, false, "Unable to threshold input image.");
    98         return false;
    99     }
    100102
    101103    pmReadout *ref = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV"); // Reference image
     
    104106        return false;
    105107    }
    106     if (!lowThreshold(ref, thresh, maskVal, maskThresh, "reference convolved image")) {
    107         psError(PS_ERR_UNKNOWN, false, "Unable to threshold input image.");
    108         return false;
     108
     109    psMetadataIterator *regIter = psMetadataIteratorAlloc(in->analysis, PS_LIST_HEAD,
     110                                                          "^" PM_SUBTRACTION_ANALYSIS_REGION "$");
     111    psMetadataItem *regItem;        // Item with region
     112    while ((regItem = psMetadataGetAndIncrement(regIter))) {
     113        psAssert(regItem->type == PS_DATA_REGION && regItem->data.V, "Expect region type");
     114        psRegion *region = regItem->data.V; // Region of interest
     115        if (!lowThreshold(in, thresh, maskVal, maskThresh, region, "input convolved image")) {
     116            psError(PS_ERR_UNKNOWN, false, "Unable to threshold input image.");
     117            return false;
     118        }
     119        if (!lowThreshold(ref, thresh, maskVal, maskThresh, region, "reference convolved image")) {
     120            psError(PS_ERR_UNKNOWN, false, "Unable to threshold input image.");
     121            return false;
     122        }
    109123    }
     124    psFree(regIter);
    110125
    111126    psFree(view);
Note: See TracChangeset for help on using the changeset viewer.