IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 9, 2007, 10:25:52 AM (19 years ago)
Author:
Paul Price
Message:

Extensive changes to the way spatial variation of the kernel is implemented. I was doing it the stupid way, rather than the smart way outlined in Alard 2000 (A&ASS, 144, 363). Fixed up the normalisation of the kernels (essential for proper flux conservation with spatial variation). Put in support for dividing an image up into regions.

File:
1 edited

Legend:

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

    r14342 r14455  
    4242
    4343psArray *pmSubtractionFindStamps(psArray *stamps, const psImage *image, const psImage *subMask,
    44                                  float threshold, float spacing)
     44                                 const psRegion *region, float threshold, float spacing)
    4545{
    4646    PS_ASSERT_IMAGE_NON_NULL(image, NULL);
     
    5252    }
    5353    PS_ASSERT_FLOAT_LARGER_THAN(spacing, 0.0, NULL);
     54    if (region) {
     55        if (psRegionIsNaN(*region)) {
     56            psString string = psRegionToString(*region);
     57            psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Input region (%s) contains NAN values", string);
     58            psFree(string);
     59            return false;
     60        }
     61        if (region->x0 < 0 || region->x1 > image->numCols ||
     62            region->y0 < 0 || region->y1 > image->numRows) {
     63            psString string = psRegionToString(*region);
     64            psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Input region (%s) does not fit in image (%dx%d)",
     65                    string, image->numCols, image->numRows);
     66            psFree(string);
     67            return false;
     68        }
     69    }
    5470
    55     // Size of image
    56     int numRows = image->numRows;
    57     int numCols = image->numCols;
     71    int numRows = image->numRows, numCols = image->numCols; // Size of image
     72
     73    // Get region in which to find stamps: [xMin:xMax,yMin:yMax]
     74    int xMin = 0, xMax = numCols, yMin = 0, yMax = numRows;
     75    if (region) {
     76        xMin = PS_MAX(region->x0, xMin);
     77        xMax = PS_MIN(region->x1, xMax);
     78        yMin = PS_MAX(region->y0, yMin);
     79        yMax = PS_MIN(region->y1, yMax);
     80    }
     81    int xSize = xMax - xMin, ySize = yMax - yMin; // Size of region of interest
    5882
    5983    // Number of stamps
    60     int xNumStamps = numCols / spacing + 1;
    61     int yNumStamps = numRows / spacing + 1;
     84    int xNumStamps = xSize / spacing + 1;
     85    int yNumStamps = ySize / spacing + 1;
    6286
    6387    int numFound = 0;                   // Number of stamps found
     
    92116
    93117                // Bounds of region to search for stamp
    94                 int yMin = j * numRows / (yNumStamps + 1);
    95                 int yMax = (j + 1) * numRows / (yNumStamps + 1) - 1;
    96                 int xMin = i * numCols / (xNumStamps + 1);
    97                 int xMax = (i + 1) * numCols / (xNumStamps + 1) - 1;
    98                 assert(yMax < image->numRows && xMax < image->numCols && yMin >= 0 && xMin >= 0);
     118                int yStart = yMin + j * ySize / (yNumStamps + 1);
     119                int yStop = yMin + (j + 1) * ySize / (yNumStamps + 1) - 1;
     120                int xStart = xMin + i * xSize / (xNumStamps + 1);
     121                int xStop = xMin + (i + 1) * xSize / (xNumStamps + 1) - 1;
     122                assert(yStop < numRows && xStop < numCols && yStart >= 0 && xStart >= 0);
    99123
    100                 for (int y = yMin; y <= yMax ; y++) {
    101                     for (int x = xMin; x <= xMax ; x++) {
     124                for (int y = yStart; y <= yStop ; y++) {
     125                    for (int x = xStart; x <= xStop ; x++) {
    102126                        if ((!subMask || !(subMask->data.PS_TYPE_MASK_DATA[y][x] &
    103127                                           (PM_SUBTRACTION_MASK_BORDER | PM_SUBTRACTION_MASK_FOOTPRINT |
Note: See TracChangeset for help on using the changeset viewer.