IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 12, 2007, 4:43:55 PM (19 years ago)
Author:
Paul Price
Message:

Need to normalise the variance kernel so that the sum is unity ---
just like the image kernel. Otherwise, the noise can be significantly
underestimated.

File:
1 edited

Legend:

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

    r13651 r14826  
    77 *  @author Paul Price, IfA
    88 *
    9  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2007-06-05 22:04:28 $
     9 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2007-09-13 02:43:55 $
    1111 *
    1212 *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
     
    312312        #define KERNEL_VARIANCE_CASE(TYPE) \
    313313            case PS_TYPE_##TYPE: { \
     314                double sumKernel2 = 0.0; /* Sum of kernel squares */ \
    314315                for (int j = 0, yPix = yCentral - (yNum - 1) / 2; j < yNum; j++, yPix++) { \
    315316                    for (int i = 0, xPix = xCentral - (xNum - 1) / 2; i < xNum; i++, xPix++) { \
    316                         *varianceValue += PS_SQR(kernel[j][i]) * variance->data.TYPE[yPix][xPix]; \
     317                        double kernel2 = PS_SQR(kernel[j][i]); /* Kernel squared */ \
     318                        sumKernel2 += kernel2; \
     319                        *varianceValue += kernel2 * variance->data.TYPE[yPix][xPix]; \
    317320                    } \
    318321                } \
     322                *varianceValue /= sumKernel2; /* Normalise so that sum of kernel squares is unity */ \
    319323                break; \
    320324            }
     
    378382// Interpolation engine for separable interpolation kernels (either for good reasons or for practical reasons)
    379383static psImageInterpolateStatus interpolateSeparate(double *imageValue, double *varianceValue,
    380                                                psMaskType *maskValue, float x, float y,
    381                                                const psImageInterpolateOptions *options)
     384                                                    psMaskType *maskValue, float x, float y,
     385                                                    const psImageInterpolateOptions *options)
    382386{
    383387    // Parameters have been checked by psImageInterpolate()
     
    542546        #define SEPARATE_VARIANCE_CASE(TYPE) \
    543547          case PS_TYPE_##TYPE: { \
     548            double ySumKernel2 = 0.0; /* Sum of kernel squared in y */ \
    544549            for (int j = 0, yPix = yCentral - (yNum - 1) / 2; j < yNum; j++, yPix++) { \
    545550                double xInterpValue = 0.0; /* Interpolation in x */ \
     551                double xSumKernel2 = 0.0; /* Sum of kernel squared in x */ \
    546552                for (int i = 0, xPix = xCentral - (xNum - 1) / 2; i < xNum; i++, xPix++) { \
    547                     xInterpValue += PS_SQR(xKernel[i]) * variance->data.TYPE[yPix][xPix]; \
     553                    double kernel2 = PS_SQR(xKernel[i]); /* Kernel squared */ \
     554                    xSumKernel2 += kernel2; \
     555                    xInterpValue += kernel2 * variance->data.TYPE[yPix][xPix]; \
    548556                } \
    549                 *varianceValue += xInterpValue * PS_SQR(yKernel[j]); /* Interpolating in y */ \
     557                double kernel2 = PS_SQR(yKernel[j]); /* Kernel squared */ \
     558                ySumKernel2 += xSumKernel2 * kernel2; \
     559                *varianceValue += xInterpValue * kernel2; /* Interpolating in y */ \
    550560            } \
     561            *varianceValue /= ySumKernel2; /* Normalise so that sum of kernel squares is unity */ \
    551562            break; \
    552563          }
Note: See TracChangeset for help on using the changeset viewer.