IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 27, 2010, 4:04:37 PM (16 years ago)
Author:
Paul Price
Message:

After scaling, must renormalise covariance to remove errors in interpolation.

File:
1 edited

Legend:

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

    r28006 r28149  
    571571
    572572    psKernel *out = psKernelAlloc(xMinOut, xMaxOut, yMinOut, yMaxOut); // Output covariance
     573    double sum = 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)
     
    580581                return false;
    581582            }
    582             out->kernel[y][x] = value;
    583         }
    584     }
    585 
     583            sum += out->kernel[y][x] = value;
     584        }
     585    }
    586586    psFree(interp);
     587
     588    float norm = 1.0 / PS_SQR(scale) / sum; // Renormalisation for covariance (to remove errors in interp.)
     589    for (int y = yMinOut; y <= yMaxOut; y++) {
     590        for (int x = xMinOut; x <= xMaxOut; x++) {
     591            out->kernel[y][x] *= norm;
     592        }
     593    }
    587594
    588595    return out;
Note: See TracChangeset for help on using the changeset viewer.