IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 2, 2009, 12:04:51 PM (16 years ago)
Author:
Paul Price
Message:

Merging Gene's work on adding a window function to the stamps. I'd been thinking about something like this for a while, so glad someone's done it. It's got visualisation turned on though.

Location:
branches/pap/psModules/src/imcombine
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/pap/psModules/src/imcombine

  • branches/pap/psModules/src/imcombine/pmSubtractionEquation.c

    r26035 r26321  
    1818
    1919#define USE_WEIGHT                      // Include weight (1/variance) in equation?
     20#define USE_WINDOW                      // Include weight (1/variance) in equation?
    2021
    2122
     
    3031                                  const psKernel *reference, // Reference image (convolution source)
    3132                                  const psKernel *weight,  // Weight image
     33                                  const psKernel *window,  // Window image
    3234                                  const psArray *convolutions,         // Convolutions for each kernel
    3335                                  const pmSubtractionKernels *kernels, // Kernels
     
    7678#ifdef USE_WEIGHT
    7779                    cc *= weight->kernel[y][x];
     80#endif
     81#ifdef USE_WINDOW
     82                    if (window) {
     83                        cc *= window->kernel[y][x];
     84                    }
    7885#endif
    7986                    sumCC += cc;
     
    107114                rc *= wtVal;
    108115                c *= wtVal;
     116#endif
     117#ifdef USE_WINDOW
     118                if (window) {
     119                    float winVal = window->kernel[y][x];
     120                    ic *= winVal;
     121                    rc *= winVal;
     122                    c  *= winVal;
     123                }
    109124#endif
    110125                sumIC += ic;
     
    144159            ref *= wtVal;
    145160            one *= wtVal;
     161#endif
     162#ifdef USE_WINDOW
     163            if (window) {
     164                float  winVal = window->kernel[y][x];
     165                rr      *= winVal;
     166                ir      *= winVal;
     167                in      *= winVal;
     168                ref *= winVal;
     169                one *= winVal;
     170            }
    146171#endif
    147172            sumRR += rr;
     
    603628#endif
    604629
     630    // XXX visualize the set of convolved stamps
     631
    605632    psImage *polyValues = p_pmSubtractionPolynomial(NULL, spatialOrder,
    606633                                                    stamp->xNorm, stamp->yNorm); // Polynomial terms
     
    620647      case PM_SUBTRACTION_MODE_1:
    621648        status = calculateMatrixVector(stamp->matrix1, stamp->vector1, stamp->image2, stamp->image1,
    622                                        stamp->weight, stamp->convolutions1, kernels, polyValues,
    623                                       footprint);
     649                                       stamp->weight, stamps->window, stamp->convolutions1, kernels,
     650                                       polyValues, footprint);
    624651        break;
    625652      case PM_SUBTRACTION_MODE_2:
    626653        status = calculateMatrixVector(stamp->matrix1, stamp->vector1, stamp->image1, stamp->image2,
    627                                        stamp->weight, stamp->convolutions2, kernels, polyValues,
    628                                       footprint);
     654                                       stamp->weight, stamps->window, stamp->convolutions2, kernels,
     655                                       polyValues, footprint);
    629656        break;
    630657      case PM_SUBTRACTION_MODE_DUAL:
     
    11471174    double devNorm = 1.0 / (double)numPixels; // Normalisation for deviations
    11481175    int numKernels = kernels->num;      // Number of kernels
     1176    double norm = NAN;
    11491177
    11501178    psImage *polyValues = NULL;         // Polynomial values
    11511179    psKernel *residual = psKernelAlloc(-footprint, footprint, -footprint, footprint); // Residual image
     1180
     1181    // set up holding images for the visualization
     1182    pmSubtractionVisualShowFitInit (stamps);
    11521183
    11531184    for (int i = 0; i < stamps->num; i++) {
     
    11601191        // Calculate coefficients of the kernel basis functions
    11611192        polyValues = p_pmSubtractionPolynomial(polyValues, kernels->spatialOrder, stamp->xNorm, stamp->yNorm);
    1162         double norm = p_pmSubtractionSolutionNorm(kernels); // Normalisation
     1193        norm = p_pmSubtractionSolutionNorm(kernels); // Normalisation
    11631194        double background = p_pmSubtractionSolutionBackground(kernels, polyValues);// Difference in background
    11641195
     
    12141245                }
    12151246            }
     1247
     1248            // XXX visualize the target, source, convolution and residual
     1249            pmSubtractionVisualShowFitAddStamp (target, source, residual, background, norm, i);
     1250
    12161251            for (int y = - footprint; y <= footprint; y++) {
    12171252                for (int x = - footprint; x <= footprint; x++) {
     
    13001335        }
    13011336#endif
    1302 
     1337   
    13031338    }
    13041339    psFree(residual);
    13051340    psFree(polyValues);
    13061341
     1342    psLogMsg("psModules.imcombine", PS_LOG_INFO, "normalization: %f", norm);
     1343    pmSubtractionVisualShowFit();
     1344    pmSubtractionVisualPlotFit(kernels);
     1345
    13071346    return deviations;
    13081347}
Note: See TracChangeset for help on using the changeset viewer.