IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 2, 2010, 6:13:37 PM (17 years ago)
Author:
eugene
Message:

adding window to dual convolution; fixing normalization for deconvolved-hermitians

File:
1 edited

Legend:

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

    r26470 r26502  
    1515#include "pmSubtractionVisual.h"
    1616
    17 //#define TESTING                         // TESTING output for debugging; may not work with threads!
     17// #define TESTING                         // TESTING output for debugging; may not work with threads!
    1818
    1919#define USE_WEIGHT                      // Include weight (1/variance) in equation?
    20 #define USE_WINDOW                      // Include weight (1/variance) in equation?
     20// #define USE_WINDOW                      // Include weight (1/variance) in equation?
    2121
    2222
     
    157157            if (mode & PM_SUBTRACTION_EQUATION_KERNELS) {
    158158                vector->data.F64[iIndex] = sumIC * poly[iTerm];
    159                 if (!(mode & PM_SUBTRACTION_EQUATION_NORM)) {
     159                // XXX TEST for Hermitians: do not calculate A - norm*B - \sum(k x B),
     160                // instead, calculate A - \sum(k x B), with full hermitians
     161                if (0 && !(mode & PM_SUBTRACTION_EQUATION_NORM)) {
    160162                    // subtract norm * sumRC * poly[iTerm]
    161163                    psAssert (kernels->solution1, "programming error: define solution first!");
     
    228230                                      const psKernel *image2, // Image 2
    229231                                      const psKernel *weight,  // Weight image
     232                                      const psKernel *window,  // Window image
    230233                                      const psArray *convolutions1, // Convolutions of image 1 for each kernel
    231234                                      const psArray *convolutions2, // Convolutions of image 2 for each kernel
     
    291294                        ab *= wtVal;
    292295                    }
     296                    if (window) {
     297                        float wtVal = window->kernel[y][x];
     298                        aa *= wtVal;
     299                        bb *= wtVal;
     300                        ab *= wtVal;
     301                    }
    293302                    sumAA += aa;
    294303                    sumBB += bb;
     
    319328                    if (weight) {
    320329                        ab *= weight->kernel[y][x];
     330                    }
     331                    if (window) {
     332                        ab *= window->kernel[y][x];
    321333                    }
    322334                    sumAB += ab;
     
    365377                    i2 *= wtVal;
    366378                }
     379                if (window) {
     380                    float wtVal = window->kernel[y][x];
     381                    ai2 *= wtVal;
     382                    bi2 *= wtVal;
     383                    ai1 *= wtVal;
     384                    bi1 *= wtVal;
     385                    i1i2 *= wtVal;
     386                    a *= wtVal;
     387                    b *= wtVal;
     388                    i2 *= wtVal;
     389                }
    367390                sumAI2 += ai2;
    368391                sumBI2 += bi2;
     
    411434            if (weight) {
    412435                float wtVal = weight->kernel[y][x];
     436                i1 *= wtVal;
     437                i1i1 *= wtVal;
     438                one *= wtVal;
     439                i2 *= wtVal;
     440                i1i2 *= wtVal;
     441            }
     442            if (window) {
     443                float wtVal = window->kernel[y][x];
    413444                i1 *= wtVal;
    414445                i1i1 *= wtVal;
     
    516547            for (int xOrder = 0; xOrder <= spatialOrder - yOrder; xOrder++, index += numKernels) {
    517548                // Contribution to chi^2: a_i^2 P_i
     549                if (!isfinite(penalties->data.F32[i])) {
     550                    psAbort ("invalid penalty");
     551                }
    518552                matrix->data.F64[index][index] -= norm * penalties->data.F32[i];
    519553            }
     
    702736        break;
    703737      case PM_SUBTRACTION_MODE_DUAL:
    704         psAbort ("dual is disabled: need to add window and calculation mode");
    705738        if (new) {
    706739            stamp->matrix2 = psImageAlloc(numKernels * numSpatial, numKernels * numSpatial, PS_TYPE_F64);
     
    714747#endif
    715748        status = calculateDualMatrixVector(stamp->matrix1, stamp->vector1, stamp->matrix2, stamp->vector2,
    716                                            stamp->matrixX, stamp->image1, stamp->image2, weight,
     749                                           stamp->matrixX, stamp->image1, stamp->image2, weight, window,
    717750                                           stamp->convolutions1, stamp->convolutions2, kernels, polyValues,
    718751                                           footprint);
     
    15871620                }
    15881621            }
     1622
     1623            // XXX visualize the target, source, convolution and residual
     1624            pmSubtractionVisualShowFitAddStamp (image2, image1, residual, background, norm, i);
     1625
    15891626            for (int y = - footprint; y <= footprint; y++) {
    15901627                for (int x = - footprint; x <= footprint; x++) {
Note: See TracChangeset for help on using the changeset viewer.