IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30305


Ignore:
Timestamp:
Jan 19, 2011, 3:23:09 PM (15 years ago)
Author:
eugene
Message:

back to using weighted fits so the chisq and penalty is generally sensible; adjust the chisq-based score using the sum-square of the smoothing kernel -- this automatically accounts for larger output images

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101205/psModules/src/imcombine/pmSubtractionEquation.c

    r30289 r30305  
    1818
    1919//# define TESTING                         // TESTING output for debugging; may not work with threads!
    20 //# define USE_WEIGHT                      // Include weight (1/variance) in equation?
     20# define USE_WEIGHT                      // Include weight (1/variance) in equation?
    2121# define USE_WINDOW                      // window to avoid neighbor contamination
    2222
     
    15891589    float momentValue = stats->sampleMean;
    15901590
    1591     // XXX this is probably wrong : I want to score against higher moments **compared with the raw momements**
    1592     // score : chisq * dMoments * modeFactor
    1593     float modeFactor = kernels->mode == PM_SUBTRACTION_MODE_DUAL ? 2.0 : 1.0;
    1594     float orderFactor = 0.5*(kernels->spatialOrder + 1) * (kernels->spatialOrder + 2);
    1595     float score = chisqValue * momentValue * modeFactor * orderFactor;
    1596 
    1597     fprintf (stderr, "chisq: %f, moment: %f, score: %f\n", chisqValue, momentValue, score);
     1591    double sumKernel1 = 0.0, sumKernel2 = 0.0; // Sum of the kernel
     1592
     1593    // calculate the variance contribution from this smoothing kernel
     1594    psKernel *modelKernel = pmSubtractionKernel(kernels, 0.0, 0.0, false);
     1595    for (int y = modelKernel->yMin; y <= modelKernel->yMax; y++) {
     1596        for (int x = modelKernel->xMin; x <= modelKernel->xMax; x++) {
     1597            if (!isfinite(modelKernel->kernel[y][x])) {
     1598                psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Non-finite covariance matrix element in kernel at %d,%d", x, y);
     1599                return NULL;
     1600            }
     1601            sumKernel1 += PS_SQR(modelKernel->kernel[y][x]);
     1602        }
     1603    }
     1604    psFree (modelKernel);
     1605
     1606    if (kernels->mode == PM_SUBTRACTION_MODE_DUAL) {
     1607        psKernel *modelKernel = pmSubtractionKernel(kernels, 0.0, 0.0, true);
     1608        for (int y = modelKernel->yMin; y <= modelKernel->yMax; y++) {
     1609            for (int x = modelKernel->xMin; x <= modelKernel->xMax; x++) {
     1610                if (!isfinite(modelKernel->kernel[y][x])) {
     1611                    psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Non-finite covariance matrix element in kernel at %d,%d", x, y);
     1612                    return NULL;
     1613                }
     1614                sumKernel2 += PS_SQR(modelKernel->kernel[y][x]);
     1615            }
     1616        }
     1617        psFree (modelKernel);
     1618    } else {
     1619        sumKernel2 = 1.0;
     1620    }
     1621
     1622    // if we modify the chisq value by the (sumKernel1 + sumKernel2), we account for the
     1623    // smoothing coming from larger kernels adding additional spatial fit terms should be
     1624    // penalized by increasing the score somewhat.  the 0.01 value is not well-chosen.
     1625    float orderFactor = 0.01 * kernels->spatialOrder;
     1626    float score = 2.0 * chisqValue / (sumKernel1 + sumKernel2) + orderFactor;
     1627    psLogMsg("psModules.imcombine", PS_LOG_INFO, "chisq: %6.3f, moment: %6.3f, sumKernel_1: %6.3f, sumKernel_2, score: %6.3f: %6.3f\n", chisqValue, momentValue, sumKernel1, sumKernel2, score);
    15981628
    15991629    // save this result if it is the first or the best (skip if bestMatch is NULL)
     
    16141644        }
    16151645        if (keep) {
    1616             fprintf (stderr, "keeping order: %d, mode: %d, score: %f\n", kernels->spatialOrder, kernels->mode, score);
     1646            psLogMsg("psModules.imcombine", PS_LOG_INFO, "keeping order: %d, mode: %d, score: %f\n", kernels->spatialOrder, kernels->mode, score);
    16171647            match->score        = score;
    16181648            match->spatialOrder = kernels->spatialOrder;
Note: See TracChangeset for help on using the changeset viewer.