IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21291


Ignore:
Timestamp:
Feb 4, 2009, 12:09:30 PM (17 years ago)
Author:
Paul Price
Message:

I think this is a better expression for the size of the covariance
matrix --- it's symmetric, and I haven't encountered any SEGVs yet...

File:
1 edited

Legend:

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

    r21288 r21291  
    4646    // covariance matrix and another kernel.  This means that the resultant covariance matrix has twice the
    4747    // size of the kernel plus the size of the input covariance matrix.
    48 
    49     // Covariance matrix for output
    50     psKernel *out = psKernelAlloc(2 * kernel->xMin + covar->xMin, 2 * kernel->xMax + covar->xMax,
    51                                   2 * kernel->yMin + covar->yMin, 2 * kernel->yMax + covar->yMax);
     48    int xMin = kernel->xMin - kernel->xMax + covar->xMin, xMax = kernel->xMax - kernel->xMin + covar->xMax;
     49    int yMin = kernel->yMin - kernel->yMax + covar->yMin, yMax = kernel->yMax - kernel->yMin + covar->yMax;
     50    psKernel *out = psKernelAlloc(xMin, xMax, yMin, yMax); // Covariance matrix for output
    5251
    5352    // Need to go:
     
    6665
    6766    double total = 0.0;                 // Total covariance
    68     for (int y = out->yMin; y <= out->yMax; y++) {
     67    for (int y = yMin; y <= yMax; y++) {
    6968        // Range for v
    7069        int vMin = PS_MAX(kernel->yMin + covar->yMin, y + kernel->yMin);
    7170        int vMax = PS_MIN(kernel->yMax + covar->yMax, y + kernel->yMax);
    72         for (int x = out->xMin; x <= out->xMax; x++) {
     71        for (int x = xMin; x <= xMax; x++) {
    7372            // Range for u
    7473            int uMin = PS_MAX(kernel->xMin + covar->xMin, x + kernel->xMin);
Note: See TracChangeset for help on using the changeset viewer.