IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 22, 2010, 11:07:49 AM (16 years ago)
Author:
Paul Price
Message:

Based on simulation and real data, the sum of the covariance kernel is not important. What is important is weighting the covariance average by the mean variances.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/pap/ppSub/src/ppSubReadoutSubtract.c

    r27709 r27727  
    4949    outRO->image = (psImage*)psBinaryOp(outRO->image, minuend->image, "-", subtrahend->image);
    5050    outRO->mask = (psImage*)psBinaryOp(outRO->mask, minuend->mask, "|", subtrahend->mask);
    51 
    52     // Combining the variance is not straight-forward.  The problem is, we're representing the variance by a
    53     // variance map and a covariance pseudo-matrix, and we cannot simply add them and get the correct result,
    54     // because they don't combine nicely.  It's like we want dD = aA + bB, but the upper- and lower-case
    55     // variables can't be merged.  Our solution is to pull the normalisation of the covariance pseudo-matrices
    56     // into the variance map, sum the scaled variance maps and (weighted) average the covariance
    57     // pseudo-matrices.  It's not perfectly correct, but it's gotta be good enough.
     51    outRO->variance = (psImage*)psBinaryOp(outRO->variance, minuend->variance, "+", subtrahend->variance);
    5852
    5953    // Measure the variance scales
     
    6963    psFree(rng);
    7064
    71     // Measure and apply the covariance scales
    72     float minuendSum = psImageCovarianceSum(minuend->covariance); // Sum of covariance for minuend
    73     float subtrahendSum = psImageCovarianceSum(subtrahend->covariance); // Sum of covariance for subtrahend
    74     psBinaryOp(minuend->covariance->image, minuend->covariance->image, "/",
    75                psScalarAlloc(minuendSum, PS_TYPE_F32));
    76     psBinaryOp(subtrahend->covariance->image, subtrahend->covariance->image, "/",
    77                psScalarAlloc(subtrahendSum, PS_TYPE_F32));
    78 
    79     // Combine the scaled covariances
     65    // Combine the covariances
     66    // These are weighted by the appropriate mean variance.  This is probably not perfectly correct, but it
     67    // does seem to reproduce the correct magnitude limit in psphot.
    8068    psArray *covars = psArrayAlloc(2);  // Covariance pseudo-matrices
    8169    psVector *covarWeights = psVectorAlloc(2, PS_TYPE_F32); // Weights for covariances
    8270    covars->data[0] = psMemIncrRefCounter(minuend->covariance);
    8371    covars->data[1] = psMemIncrRefCounter(subtrahend->covariance);
    84     covarWeights->data.F32[0] = minuendSum * minuendVar;
    85     covarWeights->data.F32[1] = subtrahendSum * subtrahendVar;
     72    covarWeights->data.F32[0] = minuendVar;
     73    covarWeights->data.F32[1] = subtrahendVar;
    8674    outRO->covariance = psImageCovarianceAverageWeighted(covars, covarWeights);
    8775    psFree(covars);
    8876    psFree(covarWeights);
    8977
    90     // Restore the scales, in case someone cares to look at the noise in the convolved images
    91     psBinaryOp(minuend->covariance->image, minuend->covariance->image, "*",
    92                psScalarAlloc(minuendSum, PS_TYPE_F32));
    93     psBinaryOp(subtrahend->covariance->image, subtrahend->covariance->image, "*",
    94                psScalarAlloc(subtrahendSum, PS_TYPE_F32));
    95 
    96     // Combine the variance maps
    97     int numCols = outRO->image->numCols, numRows = outRO->image->numRows; // Size of image
    98     psImage *outVar = outRO->variance = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Output variance map
    99     psImage *minuendVariance = minuend->variance, *subtrahendVariance = subtrahend->variance; // Variance maps
    100     for (int y = 0; y < numRows; y++) {
    101         for (int x = 0; x < numCols; x++) {
    102             outVar->data.F32[y][x] = minuendVariance->data.F32[y][x] * minuendSum +
    103                 subtrahendVariance->data.F32[y][x] * subtrahendSum;
    104         }
    105     }
    10678    psImageCovarianceTransfer(outRO->variance, outRO->covariance);
    10779
Note: See TracChangeset for help on using the changeset viewer.