IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28151


Ignore:
Timestamp:
May 27, 2010, 7:01:38 PM (16 years ago)
Author:
Paul Price
Message:

In case there's already some covariance....

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/imageops/psImageCovariance.c

    r28149 r28151  
    571571
    572572    psKernel *out = psKernelAlloc(xMinOut, xMaxOut, yMinOut, yMaxOut); // Output covariance
    573     double sum = 0.0;                                                  // Sum of covariance
     573    double outSum = 0.0;                                               // Sum of covariance
    574574    for (int y = yMinOut; y <= yMaxOut; y++) {
    575575        float yIn = y * scale + 0.5 - yMinIn + 1; // Position on input image (not the kernel)
     
    581581                return false;
    582582            }
    583             sum += out->kernel[y][x] = value;
     583            outSum += out->kernel[y][x] = value;
    584584        }
    585585    }
    586586    psFree(interp);
    587587
    588     float norm = 1.0 / PS_SQR(scale) / sum; // Renormalisation for covariance (to remove errors in interp.)
     588    double inSum = 0.0;                 // Sum of covariance
     589    for (int y = yMinIn; y <= yMaxIn; y++) {
     590        for (int x = xMinIn; x <= xMaxIn; x++) {
     591            inSum += in->kernel[y][x];
     592        }
     593    }
     594
     595    float norm = inSum / PS_SQR(scale) / outSum; // Renormalisation (to remove errors in interp.)
    589596    for (int y = yMinOut; y <= yMaxOut; y++) {
    590597        for (int x = xMinOut; x <= xMaxOut; x++) {
Note: See TracChangeset for help on using the changeset viewer.