IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21282


Ignore:
Timestamp:
Feb 4, 2009, 10:24:33 AM (17 years ago)
Author:
Paul Price
Message:

Calculate covariance matrix for output.

Location:
branches/pap_branch_20090128/pswarp/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/pap_branch_20090128/pswarp/src/pswarp.h

    r20307 r21282  
    1919#define PSWARP_ANALYSIS_VARFACTOR "PSWARP.VARFACTOR" // Name for variance factor in analysis metadata
    2020#define PSWARP_ANALYSIS_GOODPIX   "PSWARP.GOODPIX" // Name for number of good pixels in analysis metadata
     21#define PSWARP_ANALYSIS_COVARIANCES "PSWARP.COVARIANCES" // Name for covariance matrices on analysis MD
    2122
    2223// a single pswarpMap converts coordinates from one image to a second image
     
    5354    long goodPixels;                    // Number of good pixels
    5455    int xMin, xMax, yMin, yMax;         // Bounds of tile
     56    psKernel *covariance;               // Covariance matrix
    5557} pswarpTransformTileArgs;
    5658
  • branches/pap_branch_20090128/pswarp/src/pswarpLoop.c

    r21235 r21282  
    273273    }
    274274
     275    // Set covariance matrix for output
     276    {
     277        psList *covariances = psMetadataLookupPtr(&mdok, output->analysis,
     278                                                  PSWARP_ANALYSIS_COVARIANCES); // Covariance matrices
     279        psAssert(covariances, "Should be there");
     280        psArray *covars = psListToArray(covariances); // Array of covariance matrices
     281        output->covariance = psImageCovarianceAverage(covars);
     282        psFree(covars);
     283        psMetadataRemoveKey(output->analysis, PSWARP_ANALYSIS_COVARIANCES);
     284    }
     285
    275286    if (!pmConceptsAverageCells(outCell, cells, NULL, NULL, false)) {
    276287        psError(PS_ERR_UNKNOWN, false, "Unable to average cell concepts.");
  • branches/pap_branch_20090128/pswarp/src/pswarpTransformReadout.c

    r21235 r21282  
    2626    psImageMaskType maskBad  = pmConfigMaskGet("BAD.WARP", config);
    2727    psAssert(mdok, "MASK.INPUT was not defined");
     28
     29    if (!input->covariance) {
     30        input->covariance = psImageCovarianceNone();
     31    }
    2832
    2933    int nThreads = psMetadataLookupS32(&mdok, config->arguments, "NTHREADS"); // Number of threads
     
    122126    int xMin = output->image->numCols, xMax = 0, yMin = output->image->numRows, yMax = 0; // Bounds
    123127    int goodPixels = 0;                 // total number of good pixels across all tiles
     128    psList *covariances = psMetadataLookupPtr(&mdok, output->analysis,
     129                                              PSWARP_ANALYSIS_COVARIANCES); // Collection of covar. matrices
     130    if (!covariances) {
     131        covariances = psListAlloc(NULL);
     132        psMetadataAddList(output->analysis, PS_LIST_TAIL, PSWARP_ANALYSIS_COVARIANCES, 0,
     133                          "Collection of covariance matrices", covariances);
     134    }
    124135    while ((job = psThreadJobGetDone()) != NULL) {
    125136        if (job->args->n < 1) {
     
    133144            yMin = PS_MIN(args->yMin, yMin);
    134145            yMax = PS_MAX(args->yMax, yMax);
     146            if (args->covariance) {
     147                psListAdd(covariances, PS_LIST_TAIL, args->covariance);
     148            }
    135149        }
    136150        psFree(job);
  • branches/pap_branch_20090128/pswarp/src/pswarpTransformTile.c

    r21235 r21282  
    88    psFree(args->interp);
    99    psFree(args->region);
     10    psFree(args->covariance);
    1011    return;
    1112}
     
    3031    args->yMin = PS_MAX_S32;
    3132    args->yMax = PS_MIN_S32;
     33    args->covariance = NULL;
    3234
    3335    return args;
     
    104106    }
    105107
     108    if (goodPixels > 0) {
     109        float xOut = 0.5 * (xMin + xMax), yOut = 0.5 * (yMin + yMax); // Position of interest on output
     110        double xIn, yIn;                // Position of interest on input
     111        pswarpMapApply(&xIn, &yIn, map, xOut + 0.5, yOut + 0.5);
     112        // XXX Why are we subtracting the *output* col0,row0 from the *input* coordinates?
     113        // I expect these are zero, so that it makes no difference, but it's distracting.
     114        xIn -= outCol0;
     115        yIn -= outRow0;
     116        psKernel *kernel = psImageInterpolationKernel(xIn, yIn, args->interp->mode); // Interpolation kernel
     117        args->covariance = psImageCovarianceCalculate(kernel, args->output->covariance);
     118        psFree(kernel);
     119    }
     120
    106121    args->goodPixels = goodPixels;
    107122    args->xMin = xMin;
Note: See TracChangeset for help on using the changeset viewer.