- Timestamp:
- Jun 20, 2008, 10:00:01 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/pap_branch_080617/psModules/src/imcombine/pmSubtractionEquation.c
r17825 r18239 382 382 } 383 383 384 385 // Add in penalty term to least-squares vector 386 static 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 384 410 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 385 411 // 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 387 414 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 388 415 … … 675 702 psVectorInit(sumVector, 0.0); 676 703 psImageInit(sumMatrix, 0.0); 704 int numStamps = 0; // Number of good stamps 677 705 for (int i = 0; i < stamps->num; i++) { 678 706 pmSubtractionStamp *stamp = stamps->stamps->data[i]; // Stamp of interest … … 680 708 (void)psBinaryOp(sumMatrix, sumMatrix, "+", stamp->matrix1); 681 709 (void)psBinaryOp(sumVector, sumVector, "+", stamp->vector1); 682 } 683 } 710 numStamps++; 711 } 712 } 713 calculatePenalty(numStamps * PS_SQR(2 * stamps->footprint + 1), sumVector, kernels); 684 714 685 715 psVector *permutation = NULL; // Permutation vector, required for LU decomposition … … 716 746 psVectorInit(sumVector2, 0.0); 717 747 748 int numStamps = 0; // Number of good stamps 718 749 for (int i = 0; i < stamps->num; i++) { 719 750 pmSubtractionStamp *stamp = stamps->stamps->data[i]; // Stamp of interest … … 724 755 (void)psBinaryOp(sumVector1, sumVector1, "+", stamp->vector1); 725 756 (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); 728 762 729 763 #if 0
Note:
See TracChangeset
for help on using the changeset viewer.
