IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 23, 2008, 12:41:08 PM (18 years ago)
Author:
Paul Price
Message:

Merging in dual-convolution development branch.

File:
1 edited

Legend:

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

    r17825 r18287  
    3030    for (int y = - footprint; y <= footprint; y++) {
    3131        for (int x = - footprint; x <= footprint; x++) {
    32             sum += image1->kernel[y][x] * image2->kernel[y][x] / weight->kernel[y][x];
     32            sum += image1->kernel[y][x] * image2->kernel[y][x] / 1.0; // weight->kernel[y][x];
    3333        }
    3434    }
     
    194194            for (int y = - footprint; y <= footprint; y++) {
    195195                for (int x = - footprint; x <= footprint; x++) {
    196                     sumC += conv->kernel[y][x] / weight->kernel[y][x];
     196                    sumC += conv->kernel[y][x] / 1.0; // weight->kernel[y][x];
    197197                }
    198198            }
     
    217217        for (int y = - footprint; y <= footprint; y++) {
    218218            for (int x = - footprint; x <= footprint; x++) {
    219                 double invNoise2 = 1.0 / weight->kernel[y][x];
     219                double invNoise2 = 1.0 / 1.0; // weight->kernel[y][x];
    220220                double value = input->kernel[y][x] * invNoise2;
    221221                sumI += value;
     
    276276        for (int y = - footprint; y <= footprint; y++) {
    277277            for (int x = - footprint; x <= footprint; x++) {
    278                     sumTC += target->kernel[y][x] * conv->kernel[y][x] / weight->kernel[y][x];
     278                sumTC += target->kernel[y][x] * conv->kernel[y][x] / 1.0; // weight->kernel[y][x];
    279279            }
    280280        }
     
    296296        for (int y = - footprint; y <= footprint; y++) {
    297297            for (int x = - footprint; x <= footprint; x++) {
    298                 float value = target->kernel[y][x] / weight->kernel[y][x];
     298                float value = target->kernel[y][x] / 1.0; // weight->kernel[y][x];
    299299                sumIT += value * input->kernel[y][x];
    300300                sumT += value;
     
    365365        for (int y = - footprint; y <= footprint; y++) {
    366366            for (int x = - footprint; x <= footprint; x++) {
    367                 sumC += conv->kernel[y][x] / weight->kernel[y][x];
     367                sumC += conv->kernel[y][x] / 1.0; // weight->kernel[y][x];
    368368            }
    369369        }
     
    382382}
    383383
     384
     385// Add in penalty term to least-squares vector
     386static bool calculatePenalty(psVector *vector, // Vector to which to add in penalty term
     387                             const pmSubtractionKernels *kernels // Kernel parameters
     388    )
     389{
     390    if (kernels->penalty == 0.0) {
     391        return true;
     392    }
     393
     394    psVector *penalties = kernels->penalties; // Penalties for each kernel component
     395    int spatialOrder = kernels->spatialOrder; // Order of spatial variations
     396    int numKernels = kernels->num; // Number of kernel components
     397    for (int i = 0; i < numKernels; i++) {
     398        for (int yOrder = 0, index = i; yOrder <= spatialOrder; yOrder++) {
     399            for (int xOrder = 0; xOrder <= spatialOrder - yOrder; xOrder++, index += numKernels) {
     400                vector->data.F64[index] -= penalties->data.F32[i];
     401            }
     402        }
     403    }
     404
     405    return true;
     406}
     407
    384408//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    385409// Semi-public functions
    386 // XXX EAM these cannot be inline :: talk to Josh
     410// XXX We might like to define these functions as "extern inline" but gcc currently doesn't handle this in c99
     411// mode.  See http://gcc.gnu.org/ml/gcc/2006-11/msg00006.html
    387412//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    388413
     
    675700        psVectorInit(sumVector, 0.0);
    676701        psImageInit(sumMatrix, 0.0);
     702        int numStamps = 0;              // Number of good stamps
    677703        for (int i = 0; i < stamps->num; i++) {
    678704            pmSubtractionStamp *stamp = stamps->stamps->data[i]; // Stamp of interest
     
    680706                (void)psBinaryOp(sumMatrix, sumMatrix, "+", stamp->matrix1);
    681707                (void)psBinaryOp(sumVector, sumVector, "+", stamp->vector1);
    682             }
    683         }
     708                numStamps++;
     709            }
     710        }
     711        calculatePenalty(sumVector, kernels);
    684712
    685713        psVector *permutation = NULL;       // Permutation vector, required for LU decomposition
     
    716744        psVectorInit(sumVector2, 0.0);
    717745
     746        int numStamps = 0;              // Number of good stamps
    718747        for (int i = 0; i < stamps->num; i++) {
    719748            pmSubtractionStamp *stamp = stamps->stamps->data[i]; // Stamp of interest
     
    724753                (void)psBinaryOp(sumVector1, sumVector1, "+", stamp->vector1);
    725754                (void)psBinaryOp(sumVector2, sumVector2, "+", stamp->vector2);
    726             }
    727         }
     755                numStamps++;
     756            }
     757        }
     758        calculatePenalty(sumVector1, kernels);
     759        calculatePenalty(sumVector2, kernels);
    728760
    729761#if 0
     
    778810        psImage *F = (psImage*)psBinaryOp(NULL, CtBiC, "-", A);
    779811        assert(F->numRows == numParams && F->numCols == numParams);
    780         float det = NAN;
     812        float det = 0.0;
    781813        psImage *Fi = psMatrixInvert(NULL, F, &det);
    782814        assert(Fi->numRows == numParams && Fi->numCols == numParams);
Note: See TracChangeset for help on using the changeset viewer.