IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 20, 2008, 10:00:01 AM (18 years ago)
Author:
Paul Price
Message:

Adding penalties for large kernel components.

File:
1 edited

Legend:

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

    r17825 r18239  
    382382}
    383383
     384
     385// Add in penalty term to least-squares vector
     386static bool calculatePenalty(int numPixels, // Number of pixels; for normalisation
     387                             psVector *vector, // Vector to which to add in penalty term
     388                             const pmSubtractionKernels *kernels // Kernel parameters
     389    )
     390{
     391    if (kernels->penalty == 0.0) {
     392        return true;
     393    }
     394
     395    float penalty = numPixels * kernels->penalty; // Penalty value
     396    psVector *penalties = kernels->penalties; // Penalties for each kernel component
     397    int spatialOrder = kernels->spatialOrder; // Order of spatial variations
     398    int numKernels = kernels->num; // Number of kernel components
     399    for (int i = 0; i < numKernels; i++) {
     400        for (int yOrder = 0, index = i; yOrder <= spatialOrder; yOrder++) {
     401            for (int xOrder = 0; xOrder <= spatialOrder - yOrder; xOrder++, index += numKernels) {
     402                vector->data.F64[index] -= penalty * penalties->data.F32[i];
     403            }
     404        }
     405    }
     406
     407    return true;
     408}
     409
    384410//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    385411// Semi-public functions
    386 // XXX EAM these cannot be inline :: talk to Josh
     412// XXX We might like to define these functions as "extern inline" but gcc currently doesn't handle this in c99
     413// mode.  See http://gcc.gnu.org/ml/gcc/2006-11/msg00006.html
    387414//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    388415
     
    675702        psVectorInit(sumVector, 0.0);
    676703        psImageInit(sumMatrix, 0.0);
     704        int numStamps = 0;              // Number of good stamps
    677705        for (int i = 0; i < stamps->num; i++) {
    678706            pmSubtractionStamp *stamp = stamps->stamps->data[i]; // Stamp of interest
     
    680708                (void)psBinaryOp(sumMatrix, sumMatrix, "+", stamp->matrix1);
    681709                (void)psBinaryOp(sumVector, sumVector, "+", stamp->vector1);
    682             }
    683         }
     710                numStamps++;
     711            }
     712        }
     713        calculatePenalty(numStamps * PS_SQR(2 * stamps->footprint + 1), sumVector, kernels);
    684714
    685715        psVector *permutation = NULL;       // Permutation vector, required for LU decomposition
     
    716746        psVectorInit(sumVector2, 0.0);
    717747
     748        int numStamps = 0;              // Number of good stamps
    718749        for (int i = 0; i < stamps->num; i++) {
    719750            pmSubtractionStamp *stamp = stamps->stamps->data[i]; // Stamp of interest
     
    724755                (void)psBinaryOp(sumVector1, sumVector1, "+", stamp->vector1);
    725756                (void)psBinaryOp(sumVector2, sumVector2, "+", stamp->vector2);
    726             }
    727         }
     757                numStamps++;
     758            }
     759        }
     760        calculatePenalty(numStamps * PS_SQR(2 * stamps->footprint + 1), sumVector1, kernels);
     761        calculatePenalty(numStamps * PS_SQR(2 * stamps->footprint + 1), sumVector2, kernels);
    728762
    729763#if 0
Note: See TracChangeset for help on using the changeset viewer.