Changeset 25898
- Timestamp:
- Oct 19, 2009, 2:55:12 PM (17 years ago)
- Location:
- branches/pap/psModules/src/imcombine
- Files:
-
- 2 edited
-
pmSubtraction.c (modified) (6 diffs)
-
pmSubtractionKernels.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap/psModules/src/imcombine/pmSubtraction.c
r25841 r25898 65 65 return out; 66 66 } 67 68 // Contribute to an image of the solved kernel component for ISIS 69 static void solvedKernelISIS(psKernel *kernel, // Kernel, updated 70 const pmSubtractionKernels *kernels, // Kernel basis functions 71 float value, // Normalisation value for basis function 72 int index // Index of basis function of interest 73 ) 74 { 75 int size = kernels->size; // Kernel half-size 76 psArray *preCalc = kernels->preCalc->data[index]; // Precalculated values 77 #if 0 78 psVector *xKernel = preCalc->data[0]; // Kernel in x 79 psVector *yKernel = preCalc->data[1]; // Kernel in y 80 // Iterating over the kernel 81 for (int y = 0, v = -size; v <= size; y++, v++) { 82 float yValue = value * yKernel->data.F32[y]; 83 for (int x = 0, u = -size; u <= size; x++, u++) { 84 kernel->kernel[v][u] += yValue * xKernel->data.F32[x]; 85 } 86 } 87 // Photometric scaling for even kernels only 88 if (kernels->u->data.S32[i] % 2 == 0 && kernels->v->data.S32[i] % 2 == 0) { 89 kernel->kernel[0][0] -= value; 90 } 91 #else 92 psKernel *k = preCalc->data[2]; // Kernel image 93 for (int v = -size; v <= size; v++) { 94 for (int u = -size; u <= size; u++) { 95 kernel->kernel[v][u] += value * k->kernel[v][u]; 96 } 97 } 98 #endif 99 100 return; 101 } 102 67 103 68 104 // Generate an image of the solved kernel … … 116 152 case PM_SUBTRACTION_KERNEL_GUNK: { 117 153 if (i < kernels->inner) { 118 // Using pre-calculated function 119 psKernel *preCalc = kernels->preCalc->data[i]; // Precalculated values 120 // Iterating over the kernel 121 for (int v = -size; v <= size; v++) { 122 for (int u = -size; u <= size; u++) { 123 kernel->kernel[v][u] += preCalc->kernel[v][u] * value; 124 // Photometric scaling is built into the preCalc kernel --- no subtraction! 125 } 126 } 154 solvedKernelISIS(kernel, kernels, value, i); 127 155 } else { 128 156 // Using delta function … … 135 163 } 136 164 case PM_SUBTRACTION_KERNEL_ISIS: { 137 psArray *preCalc = kernels->preCalc->data[i]; // Precalculated values 138 #if 0 139 psVector *xKernel = preCalc->data[0]; // Kernel in x 140 psVector *yKernel = preCalc->data[1]; // Kernel in y 141 // Iterating over the kernel 142 for (int y = 0, v = -size; v <= size; y++, v++) { 143 float yValue = value * yKernel->data.F32[y]; 144 for (int x = 0, u = -size; u <= size; x++, u++) { 145 kernel->kernel[v][u] += yValue * xKernel->data.F32[x]; 146 } 147 } 148 // Photometric scaling for even kernels only 149 if (kernels->u->data.S32[i] % 2 == 0 && kernels->v->data.S32[i] % 2 == 0) { 150 kernel->kernel[0][0] -= value; 151 } 152 #else 153 psKernel *k = preCalc->data[2]; // Kernel image 154 for (int v = -size; v <= size; v++) { 155 for (int u = -size; u <= size; u++) { 156 kernel->kernel[v][u] += value * k->kernel[v][u]; 157 } 158 } 159 #endif 165 solvedKernelISIS(kernel, kernels, value, i); 160 166 break; 161 167 } … … 446 452 447 453 return sys; 454 } 455 456 // Convolve a stamp using an ISIS kernel basis function 457 static psKernel *convolveStampISIS(const psKernel *image, // Image to convolve 458 const pmSubtractionKernels *kernels, // Kernel basis functions 459 int index, // Index of basis function of interest 460 int footprint // Half-size of stamp 461 ) 462 { 463 psArray *preCalc = kernels->preCalc->data[index]; // Precalculated data 464 #if 1 465 // Convolving using separable convolution 466 psVector *xKernel = preCalc->data[0]; // Kernel in x 467 psVector *yKernel = preCalc->data[1]; // Kernel in y 468 int size = kernels->size; // Size of kernel 469 470 // Convolve in x 471 // Need to convolve a bit more than the footprint, for the y convolution 472 int yMin = -size - footprint, yMax = size + footprint; // Range for y 473 psKernel *temp = psKernelAlloc(yMin, yMax, 474 -footprint, footprint); // Temporary convolution; NOTE: wrong way! 475 for (int y = yMin; y <= yMax; y++) { 476 for (int x = -footprint; x <= footprint; x++) { 477 float value = 0.0; // Value of convolved pixel 478 int uMin = x - size, uMax = x + size; // Range for u 479 psF32 *xKernelData = &xKernel->data.F32[xKernel->n - 1]; // Kernel values 480 psF32 *imageData = &image->kernel[y][uMin]; // Image values 481 for (int u = uMin; u <= uMax; u++, xKernelData--, imageData++) { 482 value += *xKernelData * *imageData; 483 } 484 temp->kernel[x][y] = value; // NOTE: putting in wrong way! 485 } 486 } 487 488 // Convolve in y 489 psKernel *convolved = psKernelAlloc(-footprint, footprint, -footprint, footprint);// Convolved image 490 for (int x = -footprint; x <= footprint; x++) { 491 for (int y = -footprint; y <= footprint; y++) { 492 float value = 0.0; // Value of convolved pixel 493 int vMin = y - size, vMax = y + size; // Range for v 494 psF32 *yKernelData = &yKernel->data.F32[yKernel->n - 1]; // Kernel values 495 psF32 *imageData = &temp->kernel[x][vMin]; // Image values; NOTE: wrong way! 496 for (int v = vMin; v <= vMax; v++, yKernelData--, imageData++) { 497 value += *yKernelData * *imageData; 498 } 499 convolved->kernel[y][x] = value; 500 } 501 } 502 psFree(temp); 503 504 // Photometric scaling for even kernels only 505 if (kernels->u->data.S32[index] % 2 == 0 && kernels->v->data.S32[index] % 2 == 0) { 506 convolveSub(convolved, image, footprint); 507 } 508 return convolved; 509 #else 510 // Convolving using precalculated kernel 511 return p_pmSubtractionConvolveStampPrecalc(image, preCalc->data[2]); 512 #endif 448 513 } 449 514 … … 599 664 if (index < kernels->inner) { 600 665 // Photometric scaling is already built in to the precalculated kernel 601 return p_pmSubtractionConvolveStampPrecalc(image, kernels->preCalc->data[index]);666 return convolveStampISIS(image, kernels, index, footprint); 602 667 } 603 668 // Using delta function … … 609 674 } 610 675 case PM_SUBTRACTION_KERNEL_ISIS: { 611 psArray *preCalc = kernels->preCalc->data[index]; // Precalculated values 612 #if 1 613 psVector *xKernel = preCalc->data[0]; // Kernel in x 614 psVector *yKernel = preCalc->data[1]; // Kernel in y 615 int size = kernels->size; // Size of kernel 616 617 // Convolve in x 618 // Need to convolve a bit more than the footprint, for the y convolution 619 int yMin = -size - footprint, yMax = size + footprint; // Range for y 620 psKernel *temp = psKernelAlloc(yMin, yMax, 621 -footprint, footprint); // Temporary convolution; NOTE: wrong way! 622 for (int y = yMin; y <= yMax; y++) { 623 for (int x = -footprint; x <= footprint; x++) { 624 float value = 0.0; // Value of convolved pixel 625 int uMin = x - size, uMax = x + size; // Range for u 626 psF32 *xKernelData = &xKernel->data.F32[xKernel->n - 1]; // Kernel values 627 psF32 *imageData = &image->kernel[y][uMin]; // Image values 628 for (int u = uMin; u <= uMax; u++, xKernelData--, imageData++) { 629 value += *xKernelData * *imageData; 630 } 631 temp->kernel[x][y] = value; // NOTE: putting in wrong way! 632 } 633 } 634 635 // Convolve in y 636 psKernel *convolved = psKernelAlloc(-footprint, footprint, -footprint, footprint);// Convolved image 637 for (int x = -footprint; x <= footprint; x++) { 638 for (int y = -footprint; y <= footprint; y++) { 639 float value = 0.0; // Value of convolved pixel 640 int vMin = y - size, vMax = y + size; // Range for v 641 psF32 *yKernelData = &yKernel->data.F32[yKernel->n - 1]; // Kernel values 642 psF32 *imageData = &temp->kernel[x][vMin]; // Image values; NOTE: wrong way! 643 for (int v = vMin; v <= vMax; v++, yKernelData--, imageData++) { 644 value += *yKernelData * *imageData; 645 } 646 convolved->kernel[y][x] = value; 647 } 648 } 649 psFree(temp); 650 651 // Photometric scaling for even kernels only 652 if (kernels->u->data.S32[index] % 2 == 0 && kernels->v->data.S32[index] % 2 == 0) { 653 convolveSub(convolved, image, footprint); 654 } 655 return convolved; 656 #else 657 return p_pmSubtractionConvolveStampPrecalc(image, preCalc->data[2]); 658 #endif 659 676 return convolveStampISIS(image, kernels, index, footprint); 660 677 } 661 678 case PM_SUBTRACTION_KERNEL_RINGS: { -
branches/pap/psModules/src/imcombine/pmSubtractionKernels.c
r25861 r25898 81 81 kernels->penalties = psVectorRealloc(kernels->penalties, start + numNew); 82 82 kernels->inner = start; 83 kernels->num += numNew; 83 84 84 85 // Generate a set of kernels for each (u,v) … … 99 100 } 100 101 } 102 103 kernels->widths->n = start + numNew; 104 kernels->u->n = start + numNew; 105 kernels->v->n = start + numNew; 106 kernels->preCalc->n = start + numNew; 107 kernels->penalties->n = start + numNew; 101 108 102 109 return true; … … 471 478 PS_ASSERT_INT_LESS_THAN(inner, size, NULL); 472 479 473 // XXX GUNK doesn't seem to work --- doesn't add the POIS components, or at least, they're not noticed474 475 480 pmSubtractionKernels *kernels = p_pmSubtractionKernelsRawISIS(size, spatialOrder, fwhms, orders, 476 481 penalty, mode); // Kernels 482 kernels->type = PM_SUBTRACTION_KERNEL_GUNK; 477 483 psStringPrepend(&kernels->description, "GUNK="); 478 484 psStringAppend(&kernels->description, "+POIS(%d,%d)", inner, spatialOrder);
Note:
See TracChangeset
for help on using the changeset viewer.
