IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 20, 2009, 2:48:42 PM (17 years ago)
Author:
Paul Price
Message:

Implement stamp thresholds on both images. This is to avoid transients being selected as stamps.

File:
1 edited

Legend:

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

    r23851 r23937  
    232232
    233233
    234 pmSubtractionStampList *pmSubtractionStampsFind(pmSubtractionStampList *stamps, const psImage *image,
    235                                                 const psImage *subMask, const psRegion *region,
    236                                                 float threshold, int size, int footprint, float spacing,
     234pmSubtractionStampList *pmSubtractionStampsFind(pmSubtractionStampList *stamps, const psImage *image1,
     235                                                const psImage *image2, const psImage *subMask,
     236                                                const psRegion *region, float thresh1, float thresh2,
     237                                                int size, int footprint, float spacing,
    237238                                                pmSubtractionMode mode)
    238239{
    239     PS_ASSERT_IMAGE_NON_NULL(image, NULL);
    240     PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, NULL);
     240    if (!image1 && !image2) {
     241        psError(PS_ERR_UNEXPECTED_NULL, true, "Must specify an image");
     242        return NULL;
     243    }
     244    int numCols = 0, numRows = 0;       // Size of images
     245    if (image1) {
     246        PS_ASSERT_IMAGE_NON_NULL(image1, NULL);
     247        PS_ASSERT_IMAGE_TYPE(image1, PS_TYPE_F32, NULL);
     248        if (subMask) {
     249            PS_ASSERT_IMAGES_SIZE_EQUAL(image1, subMask, NULL);
     250        }
     251        numCols = image1->numCols;
     252        numRows = image1->numRows;
     253    }
     254    if (image2) {
     255        PS_ASSERT_IMAGE_NON_NULL(image2, NULL);
     256        PS_ASSERT_IMAGE_TYPE(image2, PS_TYPE_F32, NULL);
     257        if (subMask) {
     258            PS_ASSERT_IMAGES_SIZE_EQUAL(image2, subMask, NULL);
     259        }
     260        numCols = image2->numCols;
     261        numRows = image2->numRows;
     262    }
     263    if (image1 && image2) {
     264        PS_ASSERT_IMAGES_SIZE_EQUAL(image1, image2, NULL);
     265    }
    241266    if (subMask) {
    242267        PS_ASSERT_IMAGE_NON_NULL(subMask, NULL);
    243         PS_ASSERT_IMAGES_SIZE_EQUAL(image, subMask, NULL);
    244268        PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_IMAGE_MASK, NULL);
     269        PS_ASSERT_IMAGE_SIZE(subMask, numCols, numRows, NULL);
    245270    }
    246271    PS_ASSERT_INT_POSITIVE(size, NULL);
     
    254279            return false;
    255280        }
    256         if (region->x0 < 0 || region->x1 > image->numCols ||
    257             region->y0 < 0 || region->y1 > image->numRows) {
     281        if (region->x0 < 0 || region->x1 > numCols ||
     282            region->y0 < 0 || region->y1 > numRows) {
    258283            psString string = psRegionToString(*region);
    259284            psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Input region (%s) does not fit in image (%dx%d)",
    260                     string, image->numCols, image->numRows);
     285                    string, numCols, numRows);
    261286            psFree(string);
    262287            return false;
     
    264289    }
    265290
    266     int numRows = image->numRows, numCols = image->numCols; // Size of image
    267291    int border = size + footprint;      // Border size
    268292
     
    312336                    fluxList->n = index;
    313337
    314                     goodStamp = (fluxStamp > threshold) ? true : false;
     338                    goodStamp = true;
     339                    int x = xStamp + 0.5, y = yStamp + 0.5; // Pixel location
     340                    if (image1 && image1->data.F32[y][x] < thresh1) {
     341                        goodStamp = false;
     342                    } else if (image2 && image2->data.F32[y][x] < thresh2) {
     343                        goodStamp = false;
     344                    }
    315345                } else {
    316346                    psTrace("psModules.imcombine", 9, "No sources in subregion %d", i);
     
    319349                // Use a simple method of automatically finding stamps --- take the highest pixel in the
    320350                // subregion
    321                 fluxStamp = threshold;
     351                fluxStamp = 0.0;
    322352                psRegion *subRegion = stamps->regions->data[i]; // Sub-region of interest
     353
     354                const psImage *image = NULL; // Image for flux of stamp
     355                switch (mode) {
     356                  case PM_SUBTRACTION_MODE_1:
     357                    image = image2 ? image2 : image1;
     358                    break;
     359                  case PM_SUBTRACTION_MODE_2:
     360                    image = image1 ? image1 : image2;
     361                    break;
     362                  case PM_SUBTRACTION_MODE_UNSURE:
     363                  case PM_SUBTRACTION_MODE_DUAL:
     364                    // If both are available, we'll take the MIN value below in the hope of rejecting
     365                    // transients in both
     366                    image = (image1 && image2) ? NULL : (image1 ? image1 : image2);
     367                  default:
     368                    psAbort("Unrecognised mode: %x", mode);
     369                }
     370
    323371                for (int y = subRegion->y0; y <= subRegion->y1; y++) {
    324372                    for (int x = subRegion->x0; x <= subRegion->x1; x++) {
    325                         if (image->data.F32[y][x] > fluxStamp &&
     373                        if ((image1 && image1->data.F32[y][x] < thresh1) ||
     374                            (image2 && image2->data.F32[y][x] < thresh2)) {
     375                            continue;
     376                        }
     377                        float value = image ? image->data.F32[y][x] :
     378                            PS_MIN(image1->data.F32[y][x], image2->data.F32[y][x]); // Value of image
     379                        if (value > fluxStamp &&
    326380                            checkStampMask(x, y, numCols, numRows, subMask, mode, footprint, border)) {
    327381                            fluxStamp = image->data.F32[y][x];
Note: See TracChangeset for help on using the changeset viewer.