Changeset 30305
- Timestamp:
- Jan 19, 2011, 3:23:09 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20101205/psModules/src/imcombine/pmSubtractionEquation.c
r30289 r30305 18 18 19 19 //# 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? 21 21 # define USE_WINDOW // window to avoid neighbor contamination 22 22 … … 1589 1589 float momentValue = stats->sampleMean; 1590 1590 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); 1598 1628 1599 1629 // save this result if it is the first or the best (skip if bestMatch is NULL) … … 1614 1644 } 1615 1645 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); 1617 1647 match->score = score; 1618 1648 match->spatialOrder = kernels->spatialOrder;
Note:
See TracChangeset
for help on using the changeset viewer.
