IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 13, 2007, 4:14:30 PM (19 years ago)
Author:
Paul Price
Message:

Adding enhancement to extract the pixels for each stamp from the image, so that pmSubtractionCalculateEquation doesn't need to look at the input image (so I can later put in a fake target PSF). The stamps are extracted as 'kernels' so that offsets need not be performed.

File:
1 edited

Legend:

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

    r14455 r14480  
    3333    stamp->x = 0;
    3434    stamp->y = 0;
     35    stamp->xNorm = 0.0;
     36    stamp->yNorm = 0.0;
    3537    stamp->matrix = NULL;
    3638    stamp->vector = NULL;
    3739    stamp->status = status;
     40
     41    stamp->reference = NULL;
     42    stamp->input = NULL;
     43    stamp->weight = NULL;
    3844
    3945    return stamp;
     
    137143                stamp->x = xBest;
    138144                stamp->y = yBest;
     145                stamp->xNorm = 2.0 * (float)(xBest - numCols/2.0) / (float)numCols;
     146                stamp->yNorm = 2.0 * (float)(yBest - numRows/2.0) / (float)numRows;
     147
     148                // Reset the postage stamps since we're making a new stamp
     149                psFree(stamp->reference);
     150                psFree(stamp->input);
     151                psFree(stamp->weight);
     152                stamp->reference = stamp->input = stamp->weight = NULL;
     153
    139154                if (fluxBest > threshold) {
    140155                    stamp->status = PM_SUBTRACTION_STAMP_CALCULATE;
     
    154169    return stamps;
    155170}
     171
     172
     173bool pmSubtractionExtractStamps(psArray *stamps, psImage *reference, psImage *input, psImage *weight,
     174                                int footprint, const pmSubtractionKernels *kernels)
     175{
     176    PS_ASSERT_ARRAY_NON_NULL(stamps, false);
     177    PS_ASSERT_IMAGE_NON_NULL(reference, false);
     178    PS_ASSERT_IMAGE_TYPE(reference, PS_TYPE_F32, false);
     179    if (input) {
     180        PS_ASSERT_IMAGE_NON_NULL(input, false);
     181        PS_ASSERT_IMAGES_SIZE_EQUAL(input, reference, false);
     182        PS_ASSERT_IMAGE_TYPE(input, PS_TYPE_F32, false);
     183    }
     184    if (weight) {
     185        PS_ASSERT_IMAGE_NON_NULL(weight, false);
     186        PS_ASSERT_IMAGES_SIZE_EQUAL(weight, reference, false);
     187        PS_ASSERT_IMAGE_TYPE(weight, PS_TYPE_F32, false);
     188    }
     189
     190    int numCols = reference->numCols, numRows = reference->numRows; // Size of images
     191    int size = kernels->size + footprint; // Size of postage stamps
     192
     193    if (!weight) {
     194        // Use the input as a rough approximation to the variance map, and HOPE that it's positive.
     195        weight = input;
     196    }
     197
     198    for (int i = 0; i < stamps->n; i++) {
     199        pmSubtractionStamp *stamp = stamps->data[i]; // Stamp of interest
     200
     201
     202        int x = stamp->x, y = stamp->y; // Stamp coordinates
     203        if (x < size || x > numCols - size || y < size || y > numRows - size) {
     204            psError(PS_ERR_UNKNOWN, false, "Stamp %d (%d,%d) is within the image border.\n", i, x, y);
     205            return false;
     206        }
     207
     208        psRegion region = psRegionSet(x - size, x + size + 1, y - size, y + size + 1); // Region of interest
     209
     210        psImage *refSub = psImageSubset(reference, region); // Subimage with stamp
     211        stamp->reference = psKernelAllocFromImage(refSub, size, size);
     212        psFree(refSub);                 // Drop reference
     213
     214        if (input) {
     215            psImage *inSub = psImageSubset(input, region); // Subimage with stamp
     216            stamp->input = psKernelAllocFromImage(inSub, size, size);
     217            psFree(inSub);              // Drop reference
     218        }
     219
     220        psImage *wtSub = psImageSubset(weight, region); // Subimage with stamp
     221        stamp->weight = psKernelAllocFromImage(wtSub, size, size);
     222        psFree(wtSub);                 // Drop reference
     223
     224    }
     225
     226    return true;
     227}
     228
     229
Note: See TracChangeset for help on using the changeset viewer.