IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

Problem: the interpolation has introduced power into the covariance
matrix that shouldn't be there. We can't scale the sum of the matrix
because that would throw off the central value and affect the noise
calculation for this image. But we can't scale just by the central
value because that would throw off the noise calculation for
convolutions of this image. We choose to scale by the sum of the
non-central elements. This is almost having the best of both worlds.

File:
1 edited

Legend:

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

    r28151 r28152  
    576576        for (int x = xMinOut; x <= xMaxOut; x++) {
    577577            float xIn = x * scale + 0.5 - xMinIn + 1; // Position on input (not the kernel)
     578
    578579            double value;                                     // Value on output
    579580            if (!psImageInterpolate(&value, NULL, NULL, xIn, yIn, interp)) {
     
    586587    psFree(interp);
    587588
     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
    588595    double inSum = 0.0;                 // Sum of covariance
    589596    for (int y = yMinIn; y <= yMaxIn; y++) {
     
    593600    }
    594601
    595     float norm = inSum / PS_SQR(scale) / outSum; // Renormalisation (to remove errors in interp.)
     602    float norm = (inSum - in->kernel[0][0]) / (outSum - out->kernel[0][0]) / PS_SQR(scale); // Renormalisation
    596603    for (int y = yMinOut; y <= yMaxOut; y++) {
    597604        for (int x = xMinOut; x <= xMaxOut; x++) {
    598             out->kernel[y][x] *= norm;
     605            if (x != 0 && y != 0) {
     606                out->kernel[y][x] *= norm;
     607            }
    599608        }
    600609    }
Note: See TracChangeset for help on using the changeset viewer.