- Timestamp:
- Jun 27, 2008, 1:56:41 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080620/psModules/src/imcombine/pmSubtractionMatch.c
r18202 r18350 117 117 pmSubtractionKernelsType type, int size, int spatialOrder, 118 118 const psVector *isisWidths, const psVector *isisOrders, 119 int inner, int ringsOrder, int binning, bool optimum, const psVector *optFWHMs, 120 int optOrder, float optThreshold, int iter, float rej, psMaskType maskBad, 121 psMaskType maskBlank, float badFrac, pmSubtractionMode mode) 119 int inner, int ringsOrder, int binning, float penalty, 120 bool optimum, const psVector *optFWHMs, int optOrder, float optThreshold, 121 int iter, float rej, psMaskType maskBad, psMaskType maskBlank, 122 float badFrac, pmSubtractionMode mode) 122 123 { 123 124 if (mode != PM_SUBTRACTION_MODE_2) { … … 320 321 if (optimum && (type == PM_SUBTRACTION_KERNEL_ISIS || type == PM_SUBTRACTION_KERNEL_GUNK)) { 321 322 kernels = pmSubtractionKernelsOptimumISIS(type, size, inner, spatialOrder, optFWHMs, optOrder, 322 stamps, footprint, optThreshold, mode);323 stamps, footprint, optThreshold, penalty, mode); 323 324 if (!kernels) { 324 325 psErrorClear(); … … 329 330 // Not an ISIS/GUNK kernel, or the optimum kernel search failed 330 331 kernels = pmSubtractionKernelsGenerate(type, size, spatialOrder, isisWidths, isisOrders, 331 inner, binning, ringsOrder, mode);332 inner, binning, ringsOrder, penalty, mode); 332 333 } 333 334 … … 450 451 // Generate image with convolution kernels 451 452 int fullSize = 2 * size + 1 + 1; // Full size of kernel 452 psImage *convKernels = psImageAlloc(5 * fullSize - 1, 5 * fullSize - 1, PS_TYPE_F32); 453 int imageSize = (2 * KERNEL_MOSAIC + 1) * fullSize; 454 psImage *convKernels = psImageAlloc((mode == PM_SUBTRACTION_MODE_DUAL ? 2 : 1) * 455 imageSize - 1 + 456 (mode == PM_SUBTRACTION_MODE_DUAL ? 4 : 0), 457 imageSize - 1, PS_TYPE_F32); 453 458 psImageInit(convKernels, NAN); 454 459 for (int j = -KERNEL_MOSAIC; j <= KERNEL_MOSAIC; j++) { … … 471 476 } 472 477 psFree(kernel); 478 479 if (mode == PM_SUBTRACTION_MODE_DUAL) { 480 kernel = pmSubtractionKernelImage(kernels, (float)i / (float)KERNEL_MOSAIC, 481 (float)j / (float)KERNEL_MOSAIC, 482 true); // Image of the kernel 483 if (!kernel) { 484 psError(PS_ERR_UNKNOWN, false, "Unable to generate kernel image."); 485 psFree(convKernels); 486 goto MATCH_ERROR; 487 } 488 489 if (psImageOverlaySection(convKernels, kernel, 490 (2 * KERNEL_MOSAIC + 1 + i + KERNEL_MOSAIC) * fullSize + 491 4, 492 (j + KERNEL_MOSAIC) * fullSize, "=") == 0) { 493 psError(PS_ERR_UNKNOWN, false, "Unable to overlay kernel image."); 494 psFree(kernel); 495 psFree(convKernels); 496 goto MATCH_ERROR; 497 } 498 psFree(kernel); 499 } 500 473 501 } 474 502 } … … 509 537 goto MATCH_ERROR; 510 538 } 539 540 // Set the variance factors 541 switch (mode) { 542 case PM_SUBTRACTION_MODE_1: { 543 recordVarianceFactor(conv1, pmSubtractionVarianceFactor(kernels, 0.5, 0.5, false), 544 region); 545 break; 546 } 547 case PM_SUBTRACTION_MODE_2: 548 recordVarianceFactor(conv1, pmSubtractionVarianceFactor(kernels, 0.5, 0.5, false), 549 region); 550 break; 551 case PM_SUBTRACTION_MODE_DUAL: 552 recordVarianceFactor(conv1, pmSubtractionVarianceFactor(kernels, 0.5, 0.5, false), 553 region); 554 recordVarianceFactor(conv2, pmSubtractionVarianceFactor(kernels, 0.5, 0.5, true), 555 region); 556 break; 557 default: 558 psAbort("Should never reach here."); 559 } 560 511 561 psFree(kernels); 512 562 kernels = NULL; … … 526 576 conv2->parent->parent->data_exists = true; 527 577 } 528 }529 530 531 // Set the variance factors532 float xMid = 0.5 * (region ? (region->x0 + region->x1) : numCols); // Average x position533 float yMid = 0.5 * (region ? (region->y0 + region->y1) : numRows); // Average y position534 switch (mode) {535 case PM_SUBTRACTION_MODE_1: {536 recordVarianceFactor(conv1, pmSubtractionVarianceFactor(kernels, xMid, yMid, false),537 region);538 break;539 }540 case PM_SUBTRACTION_MODE_2:541 recordVarianceFactor(conv1, pmSubtractionVarianceFactor(kernels, xMid, yMid, false),542 region);543 break;544 case PM_SUBTRACTION_MODE_DUAL:545 recordVarianceFactor(conv1, pmSubtractionVarianceFactor(kernels, xMid, yMid, false),546 region);547 recordVarianceFactor(conv2, pmSubtractionVarianceFactor(kernels, xMid, yMid, true),548 region);549 break;550 default:551 psAbort("Should never reach here.");552 578 } 553 579 }
Note:
See TracChangeset
for help on using the changeset viewer.
