Changeset 28866 for branches/eam_branches/ipp-20100621/psModules/src/imcombine/pmSubtractionEquation.c
- Timestamp:
- Aug 9, 2010, 8:27:57 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100621/psModules/src/imcombine/pmSubtractionEquation.c
r28405 r28866 38 38 const psImage *polyValues, // Spatial polynomial values 39 39 int footprint, // (Half-)Size of stamp 40 int normWindow, // Window (half-)size for normalisation measurement 40 int normWindow1, // Window (half-)size for normalisation measurement 41 int normWindow2, // Window (half-)size for normalisation measurement 41 42 const pmSubtractionEquationCalculationMode mode 42 43 ) … … 184 185 double one = 1.0; 185 186 186 if (PS_SQR(x) + PS_SQR(y) <= PS_SQR(normWindow )) {187 if (PS_SQR(x) + PS_SQR(y) <= PS_SQR(normWindow1)) { 187 188 normI1 += ref; 189 } 190 if (PS_SQR(x) + PS_SQR(y) <= PS_SQR(normWindow2)) { 188 191 normI2 += in; 189 192 } … … 214 217 215 218 *norm = normI2 / normI1; 219 220 fprintf (stderr, "normValue: %f %f %f\n", normI1, normI2, *norm); 216 221 217 222 if (mode & PM_SUBTRACTION_EQUATION_NORM) { … … 262 267 const psImage *polyValues, // Spatial polynomial values 263 268 int footprint, // (Half-)Size of stamp 264 int normWindow, // Window (half-)size for normalisation measurement 269 int normWindow1, // Window (half-)size for normalisation measurement 270 int normWindow2, // Window (half-)size for normalisation measurement 265 271 const pmSubtractionEquationCalculationMode mode 266 272 ) … … 492 498 double i1i2 = i1 * i2; 493 499 494 if (PS_SQR(x) + PS_SQR(y) <= PS_SQR(normWindow )) {500 if (PS_SQR(x) + PS_SQR(y) <= PS_SQR(normWindow1)) { 495 501 normI1 += i1; 502 } 503 if (PS_SQR(x) + PS_SQR(y) <= PS_SQR(normWindow2)) { 496 504 normI2 += i2; 497 505 } … … 522 530 523 531 *norm = normI2 / normI1; 532 fprintf (stderr, "normValue: %f %f %f\n", normI1, normI2, *norm); 524 533 525 534 if (mode & PM_SUBTRACTION_EQUATION_NORM) { … … 559 568 // Add in penalty term to least-squares vector 560 569 bool calculatePenalty(psImage *matrix, // Matrix to which to add in penalty term 561 psVector *vector, // Vector to which to add in penalty term562 const pmSubtractionKernels *kernels, // Kernel parameters563 float norm // Normalisation564 )570 psVector *vector, // Vector to which to add in penalty term 571 const pmSubtractionKernels *kernels, // Kernel parameters 572 float norm // Normalisation 573 ) 565 574 { 566 575 if (kernels->penalty == 0.0) { … … 568 577 } 569 578 570 psVector *penalties = kernels->penalties; // Penalties for each kernel component 579 psVector *penalties1 = kernels->penalties1; // Penalties for each kernel component (input) 580 psVector *penalties2 = kernels->penalties2; // Penalties for each kernel component (ref) 581 571 582 int spatialOrder = kernels->spatialOrder; // Order of spatial variations 572 583 int numKernels = kernels->num; // Number of kernel components … … 588 599 for (int xOrder = 0; xOrder <= spatialOrder - yOrder; xOrder++, index += numKernels) { 589 600 // Contribution to chi^2: a_i^2 P_i 590 psAssert(isfinite(penalties->data.F32[i]), "Invalid penalty"); 591 matrix->data.F64[index][index] += norm * penalties->data.F32[i]; 601 psAssert(isfinite(penalties1->data.F32[i]), "Invalid penalty"); 602 fprintf (stderr, "penalty: %f + %f (%f * %f)\n", matrix->data.F64[index][index], norm * penalties1->data.F32[i], norm, penalties1->data.F32[i]); 603 matrix->data.F64[index][index] += norm * penalties1->data.F32[i]; 592 604 if (kernels->mode == PM_SUBTRACTION_MODE_DUAL) { 593 matrix->data.F64[index + numParams + 2][index + numParams + 2] += norm * penalties->data.F32[i]; 605 fprintf (stderr, "penalty: %f + %f (%f * %f)\n", matrix->data.F64[index + numParams + 2][index + numParams + 2], norm * penalties2->data.F32[i], norm, penalties2->data.F32[i]); 606 matrix->data.F64[index + numParams + 2][index + numParams + 2] += norm * penalties2->data.F32[i]; 594 607 // matrix[i][i] is ~ (k_i * I_1)(k_i * I_1) 595 608 // penalties scale with second moments … … 682 695 683 696 pmSubtractionStampList *stamps = job->args->data[0]; // List of stamps 684 constpmSubtractionKernels *kernels = job->args->data[1]; // Kernels697 pmSubtractionKernels *kernels = job->args->data[1]; // Kernels 685 698 int index = PS_SCALAR_VALUE(job->args->data[2], S32); // Stamp index 686 699 pmSubtractionEquationCalculationMode mode = PS_SCALAR_VALUE(job->args->data[3], S32); // calculation model … … 689 702 } 690 703 691 bool pmSubtractionCalculateEquationStamp(pmSubtractionStampList *stamps, constpmSubtractionKernels *kernels,704 bool pmSubtractionCalculateEquationStamp(pmSubtractionStampList *stamps, pmSubtractionKernels *kernels, 692 705 int index, const pmSubtractionEquationCalculationMode mode) 693 706 { … … 778 791 status = calculateMatrixVector(stamp->matrix, stamp->vector, &stamp->norm, stamp->image2, stamp->image1, 779 792 weight, window, stamp->convolutions1, kernels, 780 polyValues, footprint, stamps->normWindow , mode);793 polyValues, footprint, stamps->normWindow1, stamps->normWindow2, mode); 781 794 break; 782 795 case PM_SUBTRACTION_MODE_2: 783 796 status = calculateMatrixVector(stamp->matrix, stamp->vector, &stamp->norm, stamp->image1, stamp->image2, 784 797 weight, window, stamp->convolutions2, kernels, 785 polyValues, footprint, stamps->normWindow , mode);798 polyValues, footprint, stamps->normWindow2, stamps->normWindow1, mode); 786 799 break; 787 800 case PM_SUBTRACTION_MODE_DUAL: … … 789 802 stamp->image1, stamp->image2, 790 803 weight, window, stamp->convolutions1, stamp->convolutions2, 791 kernels, polyValues, footprint, stamps->normWindow , mode);804 kernels, polyValues, footprint, stamps->normWindow1, stamps->normWindow2, mode); 792 805 break; 793 806 default: … … 830 843 } 831 844 832 bool pmSubtractionCalculateEquation(pmSubtractionStampList *stamps, constpmSubtractionKernels *kernels,845 bool pmSubtractionCalculateEquation(pmSubtractionStampList *stamps, pmSubtractionKernels *kernels, 833 846 const pmSubtractionEquationCalculationMode mode) 834 847 { … … 996 1009 } 997 1010 1011 // double normValue = 1.0; 998 1012 double normValue = stats->robustMedian; 999 1013 // double bgValue = 0.0; … … 1023 1037 } 1024 1038 # endif 1039 1040 #if (1) 1041 for (int i = 0; i < solution->n; i++) { 1042 fprintf(stderr, "Single solution %d: %lf\n", i, solution->data.F64[i]); 1043 } 1044 #endif 1025 1045 1026 1046 if (!kernels->solution1) { … … 1096 1116 1097 1117 int normIndex = PM_SUBTRACTION_INDEX_NORM(kernels); // Index for normalisation 1098 calculatePenalty(sumMatrix, sumVector, kernels, sumMatrix->data.F64[normIndex][normIndex] / 1000 .0);1118 calculatePenalty(sumMatrix, sumVector, kernels, sumMatrix->data.F64[normIndex][normIndex] / 10000.0); 1099 1119 #endif 1100 1120 … … 1177 1197 1178 1198 1179 #if def TESTING1199 #if (1) 1180 1200 for (int i = 0; i < solution->n; i++) { 1181 1201 fprintf(stderr, "Dual solution %d: %lf\n", i, solution->data.F64[i]);
Note:
See TracChangeset
for help on using the changeset viewer.
