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/psModules/src/imcombine/pmSubtraction.c

    r26667 r26739  
    424424                } else if (*source & subConvPoor) {
    425425                    *target |= maskPoor;
     426                } else {
     427                    *target &= ~maskBad & ~maskPoor;
    426428                }
    427429            }
     
    574576}
    575577
     578void p_pmSubtractionPolynomialNormCoords(float *xOut, float *yOut, float xIn, float yIn,
     579                                         int xMin, int xMax, int yMin, int yMax)
     580{
     581    float xNormSize = xMax - xMin, yNormSize = yMax - yMin; // Size to use for normalisation
     582    *xOut = 2.0 * (float)(xIn - xMin - xNormSize/2.0) / xNormSize;
     583    *yOut = 2.0 * (float)(yIn - yMin - yNormSize/2.0) / yNormSize;
     584    return;
     585}
     586
    576587psImage *p_pmSubtractionPolynomialFromCoords(psImage *output, const pmSubtractionKernels *kernels,
    577                                              int numCols, int numRows, int x, int y)
     588                                             int x, int y)
    578589{
    579590    assert(kernels);
    580     assert(numCols > 0 && numRows > 0);
    581 
    582     // Size to use when calculating normalised coordinates (different from actual size when convolving
    583     // subimage)
    584     int xNormSize = (kernels->numCols > 0 ? kernels->numCols : numCols);
    585     int yNormSize = (kernels->numRows > 0 ? kernels->numRows : numRows);
    586 
    587     // Normalised coordinates
    588     float yNorm = 2.0 * (float)(y - yNormSize/2.0) / (float)yNormSize;
    589     float xNorm = 2.0 * (float)(x - xNormSize/2.0) / (float)xNormSize;
    590 
     591
     592    float xNorm, yNorm;                 // Normalised coordinates
     593    p_pmSubtractionPolynomialNormCoords(&xNorm, &yNorm, x, y,
     594                                        kernels->xMin, kernels->xMax, kernels->yMin, kernels->yMax);
    591595    return p_pmSubtractionPolynomial(output, kernels->spatialOrder, xNorm, yNorm);
    592596}
     
    10721076    // Only generate polynomial values every kernel footprint, since we have already assumed
    10731077    // (with the stamps) that it does not vary rapidly on this scale.
    1074     psImage *polyValues = p_pmSubtractionPolynomialFromCoords(NULL, kernels, numCols, numRows,
    1075                                                               xMin + x0 + size + 1,
    1076                                                               yMin + y0 + size + 1);
     1078    psImage *polyValues = p_pmSubtractionPolynomialFromCoords(NULL, kernels, xMin + x0 + size + 1,
     1079                                                              yMin + y0 + size + 1);        // Polynomial
    10771080    float background = doBG ? p_pmSubtractionSolutionBackground(kernels, polyValues) : 0.0; // Background term
    10781081
     
    12001203    bool threaded = pmSubtractionThreaded(); // Running threaded?
    12011204
    1202     // Outputs
    1203     if (kernels->mode == PM_SUBTRACTION_MODE_1 || kernels->mode == PM_SUBTRACTION_MODE_DUAL) {
    1204         if (!out1->image) {
    1205             out1->image = psImageAlloc(numCols, numRows, PS_TYPE_F32);
    1206         }
    1207         if (ro1->variance) {
    1208             if (!out1->variance) {
    1209                 out1->variance = psImageAlloc(numCols, numRows, PS_TYPE_F32);
    1210             }
    1211             psImageInit(out1->variance, 0.0);
    1212         }
    1213     }
    1214     if (kernels->mode == PM_SUBTRACTION_MODE_2 || kernels->mode == PM_SUBTRACTION_MODE_DUAL) {
    1215         if (!out2->image) {
    1216             out2->image = psImageAlloc(numCols, numRows, PS_TYPE_F32);
    1217         }
    1218         if (ro2->variance) {
    1219             if (!out2->variance) {
    1220                 out2->variance = psImageAlloc(numCols, numRows, PS_TYPE_F32);
    1221             }
    1222             psImageInit(out2->variance, 0.0);
    1223         }
    1224     }
    12251205    psImage *convMask = NULL;           // Convolved mask image (common to inputs 1 and 2)
    12261206    if (subMask) {
    12271207        if (kernels->mode == PM_SUBTRACTION_MODE_1 || kernels->mode == PM_SUBTRACTION_MODE_DUAL) {
    1228             if (!out1->mask) {
    1229                 out1->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
    1230             }
    1231             psImageInit(out1->mask, 0);
    12321208            convMask = out1->mask;
    12331209        }
    12341210        if (kernels->mode == PM_SUBTRACTION_MODE_2 || kernels->mode == PM_SUBTRACTION_MODE_DUAL) {
    1235             if (!out2->mask) {
    1236                 out2->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
    1237             }
    1238             psImageInit(out2->mask, 0);
    12391211            if (!convMask) {
    12401212                convMask = out2->mask;
     
    12561228
    12571229    // Get region for convolution: [xMin:xMax,yMin:yMax]
    1258     int xMin = size, xMax = numCols - size;
    1259     int yMin = size, yMax = numRows - size;
     1230    int xMin = kernels->xMin + size, xMax = kernels->xMax - size;
     1231    int yMin = kernels->yMin + size, yMax = kernels->yMax - size;
    12601232    if (region) {
    12611233        xMin = PS_MAX(region->x0, xMin);
Note: See TracChangeset for help on using the changeset viewer.