IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 10, 2010, 6:28:51 PM (16 years ago)
Author:
watersc1
Message:

Skycell Summary and stack Association stuff should be finished. I'll merge and do final tests on monday.

Location:
branches/czw_branch/20100519
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20100519

  • branches/czw_branch/20100519/psLib/src/imageops/psImageCovariance.c

    r28006 r28304  
    571571
    572572    psKernel *out = psKernelAlloc(xMinOut, xMaxOut, yMinOut, yMaxOut); // Output covariance
     573    double outSum = 0.0;                                               // Sum of covariance
    573574    for (int y = yMinOut; y <= yMaxOut; y++) {
    574575        float yIn = y * scale + 0.5 - yMinIn + 1; // Position on input image (not the kernel)
    575576        for (int x = xMinOut; x <= xMaxOut; x++) {
    576577            float xIn = x * scale + 0.5 - xMinIn + 1; // Position on input (not the kernel)
     578
    577579            double value;                                     // Value on output
    578580            if (!psImageInterpolate(&value, NULL, NULL, xIn, yIn, interp)) {
     
    580582                return false;
    581583            }
    582             out->kernel[y][x] = value;
    583         }
    584     }
    585 
     584            outSum += out->kernel[y][x] = value;
     585        }
     586    }
    586587    psFree(interp);
     588
     589    // Problem: the interpolation has introduced power into the covariance matrix that shouldn't be there.  We
     590    // can't scale the sum of the matrix because that would throw off the central value and affect the noise
     591    // calculation for this image.  But we can't scale just by the central value because that would throw off
     592    // the noise calculation for convolutions of this image.  We choose to scale by the sum of the non-central
     593    // elements.  This is almost having the best of both worlds.
     594
     595    double inSum = 0.0;                 // Sum of covariance
     596    for (int y = yMinIn; y <= yMaxIn; y++) {
     597        for (int x = xMinIn; x <= xMaxIn; x++) {
     598            inSum += in->kernel[y][x];
     599        }
     600    }
     601
     602    float norm = (inSum - in->kernel[0][0]) / (outSum - out->kernel[0][0]) / PS_SQR(scale); // Renormalisation
     603    for (int y = yMinOut; y <= yMaxOut; y++) {
     604        for (int x = xMinOut; x <= xMaxOut; x++) {
     605            if (x != 0 && y != 0) {
     606                out->kernel[y][x] *= norm;
     607            }
     608        }
     609    }
    587610
    588611    return out;
Note: See TracChangeset for help on using the changeset viewer.