IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 28, 2010, 5:32:15 PM (16 years ago)
Author:
Paul Price
Message:

Attempting to use a wide function for the normalisation component, rather than delta-function.

File:
1 edited

Legend:

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

    r26703 r26717  
    229229                                      const psArray *convolutions1, // Convolutions of image 1 for each kernel
    230230                                      const psArray *convolutions2, // Convolutions of image 2 for each kernel
     231                                      const psKernel *normConv,     // Normalisation, convolved
    231232                                      const pmSubtractionKernels *kernels, // Kernels
    232233                                      const psImage *polyValues, // Spatial polynomial values
     
    370371        double sumB = 0.0;              // Sum of B products (for matrix, background)
    371372        double sumI2 = 0.0;             // Sum of I_2 (for vector, background)
     373
     374        double sumAN = 0.0;             // Matrix: A*norm
     375        double sumBN = 0.0;             // Matrix: B*norm
     376
    372377        for (int y = - footprint; y <= footprint; y++) {
    373378            for (int x = - footprint; x <= footprint; x++) {
    374379                double a = iConv1->kernel[y][x];
    375380                double b = iConv2->kernel[y][x];
     381                double n = normConv->kernel[y][x];
    376382                float i1 = image1->kernel[y][x];
    377383                float i2 = image2->kernel[y][x];
     
    381387                double ai1 = a * i1;
    382388                double bi1 = b * i1;
     389
     390                double an = a * n;
     391                double bn = b * n;
    383392
    384393                if (weight) {
     
    391400                    b *= wtVal;
    392401                    i2 *= wtVal;
     402
     403                    an *= wtVal;
     404                    bn *= wtVal;
    393405                }
    394406                if (window) {
     
    401413                    b *= wtVal;
    402414                    i2 *= wtVal;
     415
     416                    an *= wtVal;
     417                    bn *= wtVal;
    403418                }
    404419                sumAI2 += ai2;
     
    409424                sumB += b;
    410425                sumI2 += i2;
     426
     427                sumAN += an;
     428                sumBN += bn;
    411429            }
    412430        }
     
    420438            double b   = sumB * poly[iTerm];
    421439
     440            double an  = sumAN * poly[iTerm];
     441            double bn  = sumBN * poly[iTerm];
     442
    422443            if ((mode & PM_SUBTRACTION_EQUATION_NORM) && (mode & PM_SUBTRACTION_EQUATION_KERNELS)) {
    423                 matrix->data.F64[iIndex][normIndex] = ai1;
    424                 matrix->data.F64[normIndex][iIndex] = ai1;
    425                 matrix->data.F64[iIndex + numParams][normIndex] = bi1;
    426                 matrix->data.F64[normIndex][iIndex + numParams] = bi1;
     444//                matrix->data.F64[iIndex][normIndex] = ai1;
     445//                matrix->data.F64[normIndex][iIndex] = ai1;
     446//                matrix->data.F64[iIndex + numParams][normIndex] = bi1;
     447//                matrix->data.F64[normIndex][iIndex + numParams] = bi1;
     448                matrix->data.F64[iIndex][normIndex] = an;
     449                matrix->data.F64[normIndex][iIndex] = an;
     450                matrix->data.F64[iIndex + numParams][normIndex] = bn;
     451                matrix->data.F64[normIndex][iIndex + numParams] = bn;
    427452            }
    428453            if ((mode & PM_SUBTRACTION_EQUATION_BG) && (mode & PM_SUBTRACTION_EQUATION_KERNELS)) {
     
    453478    double sumI1I2 = 0.0;               // Sum of I_1.I_2 (for vector, normalisation)
    454479    double normI1 = 0.0, normI2 = 0.0;  // Sum of I_1 and I_2 within the normalisation window
     480
     481    double sumN = 0.0;              // Matrix: bg*norm
     482    double sumN2 = 0.0;             // Matrix: norm*norm
     483    double sumNI2 = 0.0;            // Vector: I2*norm
     484
    455485    for (int y = - footprint; y <= footprint; y++) {
    456486        for (int x = - footprint; x <= footprint; x++) {
     
    461491            double one = 1.0;
    462492            double i1i2 = i1 * i2;
     493
     494            double n = normConv->kernel[y][x];
     495            double n2 = n * n;
     496            double ni2 = n * i2;
    463497
    464498            if (PS_SQR(x) + PS_SQR(y) <= PS_SQR(normWindow)) {
     
    474508                i2 *= wtVal;
    475509                i1i2 *= wtVal;
     510
     511                n *= wtVal;
     512                n2 *= wtVal;
     513                ni2 *= wtVal;
    476514            }
    477515            if (window) {
     
    482520                i2 *= wtVal;
    483521                i1i2 *= wtVal;
     522
     523                n *= wtVal;
     524                n2 *= wtVal;
     525                ni2 *= wtVal;
    484526            }
    485527            sumI1 += i1;
     
    488530            sumI2 += i2;
    489531            sumI1I2 += i1i2;
     532
     533            sumN += n;
     534            sumN2 += n2;
     535            sumNI2 += ni2;
    490536        }
    491537    }
     
    496542
    497543    if (mode & PM_SUBTRACTION_EQUATION_NORM) {
    498         matrix->data.F64[normIndex][normIndex] = sumI1I1;
    499         vector->data.F64[normIndex] = sumI1I2;
     544//        matrix->data.F64[normIndex][normIndex] = sumI1I1;
     545//        vector->data.F64[normIndex] = sumI1I2;
     546        matrix->data.F64[normIndex][normIndex] = sumN2;
     547        vector->data.F64[normIndex] = sumNI2;
     548
    500549    }
    501550    if (mode & PM_SUBTRACTION_EQUATION_BG) {
     
    504553    }
    505554    if ((mode & PM_SUBTRACTION_EQUATION_NORM) && (mode & PM_SUBTRACTION_EQUATION_BG)) {
    506         matrix->data.F64[bgIndex][normIndex] = sumI1;
    507         matrix->data.F64[normIndex][bgIndex] = sumI1;
     555//        matrix->data.F64[bgIndex][normIndex] = sumI1;
     556//        matrix->data.F64[normIndex][bgIndex] = sumI1;
     557        matrix->data.F64[bgIndex][normIndex] = sumN;
     558        matrix->data.F64[normIndex][bgIndex] = sumN;
    508559    }
    509560    return true;
     
    729780                                           stamp->image1, stamp->image2,
    730781                                           weight, window, stamp->convolutions1, stamp->convolutions2,
    731                                            kernels, polyValues, footprint, stamps->normWindow, mode);
     782                                           stamp->normConv, kernels, polyValues, footprint,
     783                                           stamps->normWindow, mode);
    732784        break;
    733785      default:
Note: See TracChangeset for help on using the changeset viewer.