IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25899


Ignore:
Timestamp:
Oct 19, 2009, 3:29:47 PM (17 years ago)
Author:
Paul Price
Message:

Need to mask out all spatial orders of a parameter.

File:
1 edited

Legend:

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

    r25897 r25899  
    968968
    969969        psVector *solution = NULL;                       // Solution to equation!
    970         psVector *mask = psVectorAlloc(numParams + numParams2, PS_TYPE_U8); // Mask of parameters
    971         psVectorInit(mask, 0);
    972970        {
    973971            solution = psMatrixSolveSVD(solution, sumMatrix, sumVector);
     
    976974                psFree(sumMatrix);
    977975                psFree(sumVector);
    978                 psFree(mask);
    979976                return NULL;
    980977            }
    981978
     979            int numSpatial = PM_SUBTRACTION_POLYTERMS(kernels->spatialOrder); // Number of spatial variations
     980            int numKernels = kernels->num; // Number of kernel basis functions
     981
    982982            // Remove a kernel basis for image 1 from the equation
    983 #define MASK_BASIS_1(INDEX) \
    984             { \
    985                 for (int k = 0; k < numParams2; k++) { \
    986                     sumMatrix1->data.F64[k][INDEX] = 0.0; \
    987                     sumMatrix1->data.F64[INDEX][k] = 0.0; \
    988                     sumMatrixX->data.F64[k][INDEX] = 0.0; \
    989                 } \
    990                 sumMatrix1->data.F64[bgIndex][INDEX] = 0.0; \
    991                 sumMatrix1->data.F64[INDEX][bgIndex] = 0.0; \
    992                 sumMatrix1->data.F64[normIndex][INDEX] = 0.0; \
    993                 sumMatrix1->data.F64[INDEX][normIndex] = 0.0; \
    994                 sumMatrix1->data.F64[INDEX][INDEX] = 1.0; \
    995                 sumVector1->data.F64[INDEX] = 0.0; \
    996                 mask->data.U8[INDEX] = 0xFF; \
     983#define MASK_BASIS_1(INDEX)                                             \
     984            {                                                           \
     985                for (int j = 0, index = INDEX; j < numSpatial; j++, index += numKernels) { \
     986                    for (int k = 0; k < numParams2; k++) {              \
     987                        sumMatrix1->data.F64[k][index] = 0.0;           \
     988                        sumMatrix1->data.F64[index][k] = 0.0;           \
     989                        sumMatrixX->data.F64[k][index] = 0.0;           \
     990                    }                                                   \
     991                    sumMatrix1->data.F64[bgIndex][index] = 0.0;         \
     992                    sumMatrix1->data.F64[index][bgIndex] = 0.0;         \
     993                    sumMatrix1->data.F64[normIndex][index] = 0.0;       \
     994                    sumMatrix1->data.F64[index][normIndex] = 0.0;       \
     995                    sumMatrix1->data.F64[index][index] = 1.0;           \
     996                    sumVector1->data.F64[index] = 0.0;                  \
     997                }                                                       \
    997998            }
    998999
    9991000            // Remove a kernel basis for image 2 from the equation
    1000 #define MASK_BASIS_2(INDEX) \
    1001             { \
    1002                 for (int k = 0; k < numParams2; k++) { \
    1003                     sumMatrix2->data.F64[k][j] = 0.0; \
    1004                     sumMatrix2->data.F64[j][k] = 0.0; \
    1005                     sumMatrixX->data.F64[j][k] = 0.0; \
    1006                 } \
    1007                 sumMatrix2->data.F64[INDEX][INDEX] = 1.0; \
    1008                 sumMatrixX->data.F64[j][normIndex] = 0.0; \
    1009                 sumMatrixX->data.F64[j][bgIndex] = 0.0; \
    1010                 sumVector2->data.F64[j] = 0.0; \
    1011                 mask->data.U8[numParams + j] = 0xFF; \
     1001#define MASK_BASIS_2(INDEX)                                             \
     1002            {                                                           \
     1003                for (int j = 0, index = INDEX; j < numSpatial; j++, index += numKernels) { \
     1004                    for (int k = 0; k < numParams2; k++) {              \
     1005                        sumMatrix2->data.F64[k][index] = 0.0;           \
     1006                        sumMatrix2->data.F64[index][k] = 0.0;           \
     1007                        sumMatrixX->data.F64[index][k] = 0.0;           \
     1008                    }                                                   \
     1009                    sumMatrix2->data.F64[index][index] = 1.0;           \
     1010                    sumMatrixX->data.F64[index][normIndex] = 0.0;       \
     1011                    sumMatrixX->data.F64[index][bgIndex] = 0.0;         \
     1012                    sumVector2->data.F64[index] = 0.0;                  \
     1013                }                                                       \
    10121014            }
    10131015
     
    10161018            double norm = solution->data.F64[normIndex];        // Normalisation
    10171019            double thresh = norm * TOL;                         // Threshold for low parameters
    1018             for (int j = 0; j < numParams2; j++) {
    1019                 double param1 = solution->data.F64[j],
    1020                     param2 = solution->data.F64[numParams + j]; // Parameters of interest
     1020            for (int i = 0; i < numKernels; i++) {
     1021                // Getting 0th order parameter value.  In the presence of spatial variation, the actual value
     1022                // of the parameter will vary over the image.  We are in effect getting the value in the
     1023                // centre of the image.  If we use different polynomial functions (e.g., Chebyshev), we may
     1024                // have to change this to properly determine the value of the parameter at the centre.
     1025                double param1 = solution->data.F64[i],
     1026                    param2 = solution->data.F64[numParams + i]; // Parameters of interest
     1027                bool mask1 = false, mask2 = false;              // Masked the parameter?
    10211028                if (fabs(param1) < thresh) {
    1022                     psTrace("psModules.imcombine", 7, "Parameter %d: 1 below threshold\n", j);
    1023                     MASK_BASIS_1(j);
     1029                    psTrace("psModules.imcombine", 7, "Parameter %d: 1 below threshold\n", i);
     1030                    MASK_BASIS_1(i);
     1031                    mask1 = true;
    10241032                }
    10251033                if (fabs(param2) < thresh) {
    1026                     psTrace("psModules.imcombine", 7, "Parameter %d: 2 below threshold\n", j);
    1027                     MASK_BASIS_2(j);
    1028                 }
    1029 
    1030                 if (!mask->data.U8[j] && !mask->data.U8[numParams + j]) {
     1034                    psTrace("psModules.imcombine", 7, "Parameter %d: 2 below threshold\n", i);
     1035                    MASK_BASIS_2(i);
     1036                    mask2 = true;
     1037                }
     1038
     1039                if (!mask1 && !mask2) {
    10311040                    if (fabs(param1) < fabs(param2)) {
    1032                         psTrace("psModules.imcombine", 7, "Parameter %d: 1 < 2\n", j);
    1033                         MASK_BASIS_1(j);
     1041                        psTrace("psModules.imcombine", 7, "Parameter %d: 1 < 2\n", i);
     1042                        MASK_BASIS_1(i);
    10341043                    } else {
    1035                         psTrace("psModules.imcombine", 7, "Parameter %d: 2 < 1\n", j);
    1036                         MASK_BASIS_2(j);
     1044                        psTrace("psModules.imcombine", 7, "Parameter %d: 2 < 1\n", i);
     1045                        MASK_BASIS_2(i);
    10371046                    }
    10381047                }
     
    10661075            psFree(sumMatrix);
    10671076            psFree(sumVector);
    1068             psFree(mask);
    10691077            return NULL;
    10701078        }
    1071 
    1072 #if 0
    1073         for (int i = 0; i < num; i++) {
    1074             if (mask->data.U8[i]) {
    1075                 solution->data.F64[i] = 0.0;
    1076             }
    1077         }
    1078 #endif
    1079         psFree(mask);
    10801079
    10811080        psFree(sumMatrix1);
Note: See TracChangeset for help on using the changeset viewer.