- Timestamp:
- Aug 26, 2010, 9:18:39 AM (16 years ago)
- Location:
- branches/sc_branches/trunkTest
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/sc_branches/trunkTest
- Property svn:mergeinfo changed
-
branches/sc_branches/trunkTest/psModules
- Property svn:mergeinfo deleted
-
branches/sc_branches/trunkTest/psModules/src/imcombine/pmSubtractionEquation.c
r28405 r29060 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: (x^%d y^%d fwhm %f) : %f + %f (%f * %f)\n", kernels->u->data.S32[index], kernels->v->data.S32[index], kernels->widths->data.F32[index], 606 matrix->data.F64[index + numParams + 2][index + numParams + 2], norm * penalties2->data.F32[i], norm, penalties2->data.F32[i]); 607 matrix->data.F64[index + numParams + 2][index + numParams + 2] += norm * penalties2->data.F32[i]; 594 608 // matrix[i][i] is ~ (k_i * I_1)(k_i * I_1) 595 609 // penalties scale with second moments … … 682 696 683 697 pmSubtractionStampList *stamps = job->args->data[0]; // List of stamps 684 constpmSubtractionKernels *kernels = job->args->data[1]; // Kernels698 pmSubtractionKernels *kernels = job->args->data[1]; // Kernels 685 699 int index = PS_SCALAR_VALUE(job->args->data[2], S32); // Stamp index 686 700 pmSubtractionEquationCalculationMode mode = PS_SCALAR_VALUE(job->args->data[3], S32); // calculation model … … 689 703 } 690 704 691 bool pmSubtractionCalculateEquationStamp(pmSubtractionStampList *stamps, constpmSubtractionKernels *kernels,705 bool pmSubtractionCalculateEquationStamp(pmSubtractionStampList *stamps, pmSubtractionKernels *kernels, 692 706 int index, const pmSubtractionEquationCalculationMode mode) 693 707 { … … 778 792 status = calculateMatrixVector(stamp->matrix, stamp->vector, &stamp->norm, stamp->image2, stamp->image1, 779 793 weight, window, stamp->convolutions1, kernels, 780 polyValues, footprint, stamps->normWindow , mode);794 polyValues, footprint, stamps->normWindow1, stamps->normWindow2, mode); 781 795 break; 782 796 case PM_SUBTRACTION_MODE_2: 783 797 status = calculateMatrixVector(stamp->matrix, stamp->vector, &stamp->norm, stamp->image1, stamp->image2, 784 798 weight, window, stamp->convolutions2, kernels, 785 polyValues, footprint, stamps->normWindow , mode);799 polyValues, footprint, stamps->normWindow2, stamps->normWindow1, mode); 786 800 break; 787 801 case PM_SUBTRACTION_MODE_DUAL: … … 789 803 stamp->image1, stamp->image2, 790 804 weight, window, stamp->convolutions1, stamp->convolutions2, 791 kernels, polyValues, footprint, stamps->normWindow , mode);805 kernels, polyValues, footprint, stamps->normWindow1, stamps->normWindow2, mode); 792 806 break; 793 807 default: … … 830 844 } 831 845 832 bool pmSubtractionCalculateEquation(pmSubtractionStampList *stamps, constpmSubtractionKernels *kernels,846 bool pmSubtractionCalculateEquation(pmSubtractionStampList *stamps, pmSubtractionKernels *kernels, 833 847 const pmSubtractionEquationCalculationMode mode) 834 848 { … … 996 1010 } 997 1011 1012 // double normValue = 1.0; 998 1013 double normValue = stats->robustMedian; 999 1014 // double bgValue = 0.0; … … 1023 1038 } 1024 1039 # endif 1040 1041 #if (1) 1042 for (int i = 0; i < solution->n; i++) { 1043 fprintf(stderr, "Single solution %d: %lf\n", i, solution->data.F64[i]); 1044 } 1045 #endif 1025 1046 1026 1047 if (!kernels->solution1) { … … 1096 1117 1097 1118 int normIndex = PM_SUBTRACTION_INDEX_NORM(kernels); // Index for normalisation 1098 calculatePenalty(sumMatrix, sumVector, kernels, sumMatrix->data.F64[normIndex][normIndex] / 100 0.0);1119 calculatePenalty(sumMatrix, sumVector, kernels, sumMatrix->data.F64[normIndex][normIndex] / 100.0); 1099 1120 #endif 1100 1121 … … 1177 1198 1178 1199 1179 #if def TESTING1200 #if (1) 1180 1201 for (int i = 0; i < solution->n; i++) { 1181 1202 fprintf(stderr, "Dual solution %d: %lf\n", i, solution->data.F64[i]);
Note:
See TracChangeset
for help on using the changeset viewer.
