IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28150 for trunk/psModules


Ignore:
Timestamp:
May 27, 2010, 5:54:44 PM (16 years ago)
Author:
Paul Price
Message:

Use a range of positions on the image to calculate the covariance
pseudo-matrices. This makes the noise model more robust against
kernel (spatial) variations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/imcombine/pmSubtraction.c

    r27086 r28150  
    3232#define MIN_SAMPLE_STATS    7           // Minimum number to use sample statistics; otherwise use quartiles
    3333#define USE_KERNEL_ERR                  // Use kernel error image?
     34#define NUM_COVAR_POS 5                 // Number of positions for covariance calculation
    3435
    3536//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    13281329    // This can be fairly involved, so we only do it for a single instance
    13291330    // Enable threads for covariance calculation, since we're not threading on top of it.
     1331    float position[NUM_COVAR_POS] = { -1.0, -0.5, 0.0, +0.5, +1.0 }; // Positions for covariance calculations
    13301332    oldThreads = psImageCovarianceSetThreads(true);
    13311333    if (kernels->mode == PM_SUBTRACTION_MODE_1 || kernels->mode == PM_SUBTRACTION_MODE_DUAL) {
    1332         psKernel *kernel = pmSubtractionKernel(kernels, 0.0, 0.0, false); // Convolution kernel
    1333         psKernelTruncate(kernel, covarFrac);
    1334         out1->covariance = psImageCovarianceCalculate(kernel, ro1->covariance);
    1335         psFree(kernel);
     1334        psArray *covars = psArrayAlloc(PS_SQR(NUM_COVAR_POS)); // Covariances
     1335        for (int y = 0, i = 0; y < NUM_COVAR_POS; y++) {
     1336            for (int x = 0; x < NUM_COVAR_POS; x++, i++) {
     1337                psKernel *kernel = pmSubtractionKernel(kernels, position[x], position[y],
     1338                                                       false); // Convolution kernel
     1339                psKernelTruncate(kernel, covarFrac);
     1340                covars->data[i] = psImageCovarianceCalculate(kernel, ro1->covariance);
     1341                psFree(kernel);
     1342            }
     1343        }
     1344        out1->covariance = psImageCovarianceAverage(covars);
     1345        psFree(covars);
    13361346    }
    13371347    if (kernels->mode == PM_SUBTRACTION_MODE_2 || kernels->mode == PM_SUBTRACTION_MODE_DUAL) {
    1338         psKernel *kernel = pmSubtractionKernel(kernels, 0.0, 0.0,
    1339                                                kernels->mode == PM_SUBTRACTION_MODE_DUAL); // Conv. kernel
    1340         psKernelTruncate(kernel, covarFrac);
    1341         out2->covariance = psImageCovarianceCalculate(kernel, ro2->covariance);
    1342         psFree(kernel);
     1348        psArray *covars = psArrayAlloc(PS_SQR(NUM_COVAR_POS)); // Covariances
     1349        for (int y = 0, i = 0; y < NUM_COVAR_POS; y++) {
     1350            for (int x = 0; x < NUM_COVAR_POS; x++, i++) {
     1351                psKernel *kernel = pmSubtractionKernel(kernels, position[x], position[y],
     1352                                                       kernels->mode == PM_SUBTRACTION_MODE_DUAL); // Convolution kernel
     1353                psKernelTruncate(kernel, covarFrac);
     1354                covars->data[i] = psImageCovarianceCalculate(kernel, ro2->covariance);
     1355                psFree(kernel);
     1356            }
     1357        }
     1358        out2->covariance = psImageCovarianceAverage(covars);
     1359        psFree(covars);
    13431360    }
    13441361    psImageCovarianceSetThreads(oldThreads);
Note: See TracChangeset for help on using the changeset viewer.