IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25903


Ignore:
Timestamp:
Oct 20, 2009, 5:47:50 PM (17 years ago)
Author:
Paul Price
Message:

Don't think the (sum k_ij)2 should be in the variance kernel normalisation (following r21428).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/pap/psModules/src/imcombine/pmSubtraction.c

    r25898 r25903  
    2929#define PIXEL_LIST_BUFFER 100           // Number of entries to add to pixel list at a time
    3030#define MIN_SAMPLE_STATS    7           // Minimum number to use sample statistics; otherwise use quartiles
     31//#define USE_SYS_ERR                   // Use systematic error image?
    3132
    3233//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    3637// Generate the kernel to apply to the variance from the normal kernel
    3738static psKernel *varianceKernel(psKernel *out, // Output kernel
    38                                 psKernel *normalKernel // Normal kernel
     39                                const psKernel *normalKernel // Normal kernel
    3940                                )
    4041{
     
    4849
    4950    // Take the square of the normal kernel
    50     double sumNormal = 0.0, sumVariance = 0.0; // Sum of the normal and variance kernels
     51    double sumVariance = 0.0; // Sum of the variance kernels
    5152    for (int v = yMin; v <= yMax; v++) {
    5253        for (int u = xMin; u <= xMax; u++) {
    53             float value = normalKernel->kernel[v][u]; // Value of interest
    54             float value2 = PS_SQR(value); // Value squared
    55             sumNormal += value;
    56             sumVariance += value2;
    57             out->kernel[v][u] = value2;
     54            sumVariance += out->kernel[v][u] = PS_SQR(normalKernel->kernel[v][u]);
    5855        }
    5956    }
     
    432429}
    433430
     431#ifdef USE_SYS_ERR
    434432// Generate an image that can be used to track systematic errors
    435433static psImage *subtractionSysErrImage(const psImage *image, // Image from which to make sys err image
     
    453451    return sys;
    454452}
     453#endif
    455454
    456455// Convolve a stamp using an ISIS kernel basis function
     
    11901189        if (!out1->image) {
    11911190            out1->image = psImageAlloc(numCols, numRows, PS_TYPE_F32);
    1192             // XXX if (threaded) {
    1193             // XXX     psMutexInit(out1->image);
    1194             // XXX }
    11951191        }
    11961192        if (ro1->variance) {
    11971193            if (!out1->variance) {
    11981194                out1->variance = psImageAlloc(numCols, numRows, PS_TYPE_F32);
    1199                 // XXX if (threaded) {
    1200                 // XXX     psMutexInit(out1->variance);
    1201                 // XXX }
    12021195            }
    12031196            psImageInit(out1->variance, 0.0);
     
    12071200        if (!out2->image) {
    12081201            out2->image = psImageAlloc(numCols, numRows, PS_TYPE_F32);
    1209             // XXX if (threaded) {
    1210             // XXX     psMutexInit(out2->image);
    1211             // XXX }
    12121202        }
    12131203        if (ro2->variance) {
    12141204            if (!out2->variance) {
    12151205                out2->variance = psImageAlloc(numCols, numRows, PS_TYPE_F32);
    1216                 // XXX if (threaded) {
    1217                 // XXX     psMutexInit(out2->variance);
    1218                 // XXX }
    12191206            }
    12201207            psImageInit(out2->variance, 0.0);
     
    12231210    psImage *convMask = NULL;           // Convolved mask image (common to inputs 1 and 2)
    12241211    if (subMask) {
    1225         // XXX if (threaded) {
    1226         // XXX     psMutexInit(subMask);
    1227         // XXX }
    12281212        if (kernels->mode == PM_SUBTRACTION_MODE_1 || kernels->mode == PM_SUBTRACTION_MODE_DUAL) {
    12291213            if (!out1->mask) {
     
    12491233
    12501234    psImage *sys1 = NULL, *sys2 = NULL; // Systematic error images
     1235#ifdef USE_SYS_ERR
    12511236    if (kernels->mode == PM_SUBTRACTION_MODE_1 || kernels->mode == PM_SUBTRACTION_MODE_DUAL) {
    12521237        sys1 = subtractionSysErrImage(ro1->image, sysError);
    1253         // XXX if (threaded && sys1) {
    1254         // XXX     psMutexInit(sys1);
    1255         // XXX }
    12561238    }
    12571239    if (kernels->mode == PM_SUBTRACTION_MODE_2 || kernels->mode == PM_SUBTRACTION_MODE_DUAL) {
    12581240        sys2 = subtractionSysErrImage(ro2->image, sysError);
    1259         // XXX if (threaded && sys2) {
    1260         // XXX     psMutexInit(sys2);
    1261         // XXX }
    1262     }
     1241    }
     1242#endif
    12631243
    12641244    int size = kernels->size;           // Half-size of kernel
     
    13091289                psArrayAdd(args, 1, (pmReadout*)ro1); // Casting away const
    13101290                psArrayAdd(args, 1, (pmReadout*)ro2); // Casting away const
    1311                 // Since adding to the array can impact the reference count, we need to lock
    1312                 // XXX if (sys1) {
    1313                 // XXX     psMutexLock(sys1);
    1314                 // XXX }
    13151291                psArrayAdd(args, 1, sys1);
    1316                 // XXX if (sys1) {
    1317                 // XXX     psMutexUnlock(sys1);
    1318                 // XXX }
    1319                 // XXX if (sys2) {
    1320                 // XXX     psMutexLock(sys2);
    1321                 // XXX }
    13221292                psArrayAdd(args, 1, sys2);
    1323                 // XXX if (sys2) {
    1324                 // XXX     psMutexUnlock(sys2);
    1325                 // XXX }
    1326                 // XXX if (subMask) {
    1327                 // XXX     psMutexLock(subMask);
    1328                 // XXX }
    13291293                psArrayAdd(args, 1, subMask);
    1330                 // XXX if (subMask) {
    1331                 // XXX     psMutexUnlock(subMask);
    1332                 // XXX }
    13331294                PS_ARRAY_ADD_SCALAR(args, maskBad, PS_TYPE_IMAGE_MASK);
    13341295                PS_ARRAY_ADD_SCALAR(args, maskPoor, PS_TYPE_IMAGE_MASK);
     
    13691330            psFree(job);
    13701331        }
    1371 
    1372         // XXX if (subMask) {
    1373         // XXX     psMutexDestroy(subMask);
    1374         // XXX }
    1375         // XXX if (sys1) {
    1376         // XXX     psMutexDestroy(sys1);
    1377         // XXX }
    1378         // XXX if (sys2) {
    1379         // XXX     psMutexDestroy(sys2);
    1380         // XXX }
    13811332    }
    13821333    psImageConvolveSetThreads(oldThreads);
Note: See TracChangeset for help on using the changeset viewer.