- Timestamp:
- Jan 28, 2010, 5:32:15 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/pap/psModules/src/imcombine/pmSubtractionEquation.c
r26703 r26717 229 229 const psArray *convolutions1, // Convolutions of image 1 for each kernel 230 230 const psArray *convolutions2, // Convolutions of image 2 for each kernel 231 const psKernel *normConv, // Normalisation, convolved 231 232 const pmSubtractionKernels *kernels, // Kernels 232 233 const psImage *polyValues, // Spatial polynomial values … … 370 371 double sumB = 0.0; // Sum of B products (for matrix, background) 371 372 double sumI2 = 0.0; // Sum of I_2 (for vector, background) 373 374 double sumAN = 0.0; // Matrix: A*norm 375 double sumBN = 0.0; // Matrix: B*norm 376 372 377 for (int y = - footprint; y <= footprint; y++) { 373 378 for (int x = - footprint; x <= footprint; x++) { 374 379 double a = iConv1->kernel[y][x]; 375 380 double b = iConv2->kernel[y][x]; 381 double n = normConv->kernel[y][x]; 376 382 float i1 = image1->kernel[y][x]; 377 383 float i2 = image2->kernel[y][x]; … … 381 387 double ai1 = a * i1; 382 388 double bi1 = b * i1; 389 390 double an = a * n; 391 double bn = b * n; 383 392 384 393 if (weight) { … … 391 400 b *= wtVal; 392 401 i2 *= wtVal; 402 403 an *= wtVal; 404 bn *= wtVal; 393 405 } 394 406 if (window) { … … 401 413 b *= wtVal; 402 414 i2 *= wtVal; 415 416 an *= wtVal; 417 bn *= wtVal; 403 418 } 404 419 sumAI2 += ai2; … … 409 424 sumB += b; 410 425 sumI2 += i2; 426 427 sumAN += an; 428 sumBN += bn; 411 429 } 412 430 } … … 420 438 double b = sumB * poly[iTerm]; 421 439 440 double an = sumAN * poly[iTerm]; 441 double bn = sumBN * poly[iTerm]; 442 422 443 if ((mode & PM_SUBTRACTION_EQUATION_NORM) && (mode & PM_SUBTRACTION_EQUATION_KERNELS)) { 423 matrix->data.F64[iIndex][normIndex] = ai1; 424 matrix->data.F64[normIndex][iIndex] = ai1; 425 matrix->data.F64[iIndex + numParams][normIndex] = bi1; 426 matrix->data.F64[normIndex][iIndex + numParams] = bi1; 444 // matrix->data.F64[iIndex][normIndex] = ai1; 445 // matrix->data.F64[normIndex][iIndex] = ai1; 446 // matrix->data.F64[iIndex + numParams][normIndex] = bi1; 447 // matrix->data.F64[normIndex][iIndex + numParams] = bi1; 448 matrix->data.F64[iIndex][normIndex] = an; 449 matrix->data.F64[normIndex][iIndex] = an; 450 matrix->data.F64[iIndex + numParams][normIndex] = bn; 451 matrix->data.F64[normIndex][iIndex + numParams] = bn; 427 452 } 428 453 if ((mode & PM_SUBTRACTION_EQUATION_BG) && (mode & PM_SUBTRACTION_EQUATION_KERNELS)) { … … 453 478 double sumI1I2 = 0.0; // Sum of I_1.I_2 (for vector, normalisation) 454 479 double normI1 = 0.0, normI2 = 0.0; // Sum of I_1 and I_2 within the normalisation window 480 481 double sumN = 0.0; // Matrix: bg*norm 482 double sumN2 = 0.0; // Matrix: norm*norm 483 double sumNI2 = 0.0; // Vector: I2*norm 484 455 485 for (int y = - footprint; y <= footprint; y++) { 456 486 for (int x = - footprint; x <= footprint; x++) { … … 461 491 double one = 1.0; 462 492 double i1i2 = i1 * i2; 493 494 double n = normConv->kernel[y][x]; 495 double n2 = n * n; 496 double ni2 = n * i2; 463 497 464 498 if (PS_SQR(x) + PS_SQR(y) <= PS_SQR(normWindow)) { … … 474 508 i2 *= wtVal; 475 509 i1i2 *= wtVal; 510 511 n *= wtVal; 512 n2 *= wtVal; 513 ni2 *= wtVal; 476 514 } 477 515 if (window) { … … 482 520 i2 *= wtVal; 483 521 i1i2 *= wtVal; 522 523 n *= wtVal; 524 n2 *= wtVal; 525 ni2 *= wtVal; 484 526 } 485 527 sumI1 += i1; … … 488 530 sumI2 += i2; 489 531 sumI1I2 += i1i2; 532 533 sumN += n; 534 sumN2 += n2; 535 sumNI2 += ni2; 490 536 } 491 537 } … … 496 542 497 543 if (mode & PM_SUBTRACTION_EQUATION_NORM) { 498 matrix->data.F64[normIndex][normIndex] = sumI1I1; 499 vector->data.F64[normIndex] = sumI1I2; 544 // matrix->data.F64[normIndex][normIndex] = sumI1I1; 545 // vector->data.F64[normIndex] = sumI1I2; 546 matrix->data.F64[normIndex][normIndex] = sumN2; 547 vector->data.F64[normIndex] = sumNI2; 548 500 549 } 501 550 if (mode & PM_SUBTRACTION_EQUATION_BG) { … … 504 553 } 505 554 if ((mode & PM_SUBTRACTION_EQUATION_NORM) && (mode & PM_SUBTRACTION_EQUATION_BG)) { 506 matrix->data.F64[bgIndex][normIndex] = sumI1; 507 matrix->data.F64[normIndex][bgIndex] = sumI1; 555 // matrix->data.F64[bgIndex][normIndex] = sumI1; 556 // matrix->data.F64[normIndex][bgIndex] = sumI1; 557 matrix->data.F64[bgIndex][normIndex] = sumN; 558 matrix->data.F64[normIndex][bgIndex] = sumN; 508 559 } 509 560 return true; … … 729 780 stamp->image1, stamp->image2, 730 781 weight, window, stamp->convolutions1, stamp->convolutions2, 731 kernels, polyValues, footprint, stamps->normWindow, mode); 782 stamp->normConv, kernels, polyValues, footprint, 783 stamps->normWindow, mode); 732 784 break; 733 785 default:
Note:
See TracChangeset
for help on using the changeset viewer.
