Changeset 14524
- Timestamp:
- Aug 15, 2007, 4:57:34 PM (19 years ago)
- Location:
- trunk/psModules/src/imcombine
- Files:
-
- 2 edited
-
pmSubtraction.c (modified) (6 diffs)
-
pmSubtraction.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtraction.c
r14515 r14524 4 4 * @author GLG, MHPCC 5 5 * 6 * @version $Revision: 1.3 8$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-08-16 0 0:32:43$6 * @version $Revision: 1.39 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-08-16 02:57:34 $ 8 8 * 9 9 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii … … 644 644 645 645 646 int pmSubtractionRejectStamps(psArray *stamps, const psImage *refImage, psImage *inImage, 647 psImage *subMask, const psVector *solution, int footprint, float sigmaRej, 648 const pmSubtractionKernels *kernels) 646 int pmSubtractionRejectStamps(psArray *stamps, psImage *subMask, const psVector *solution, 647 int footprint, float sigmaRej, const pmSubtractionKernels *kernels) 649 648 { 650 649 PS_ASSERT_ARRAY_NON_NULL(stamps, -1); 651 PS_ASSERT_IMAGE_NON_EMPTY(refImage, -1);652 PS_ASSERT_IMAGE_TYPE(refImage, PS_TYPE_F32, -1);653 PS_ASSERT_IMAGE_NON_EMPTY(inImage, -1);654 PS_ASSERT_IMAGE_TYPE(inImage, PS_TYPE_F32, -1);655 PS_ASSERT_IMAGES_SIZE_EQUAL(refImage, inImage, -1);656 650 PS_ASSERT_IMAGE_NON_EMPTY(subMask, -1); 657 651 PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_MASK, -1); 658 PS_ASSERT_IMAGES_SIZE_EQUAL(refImage, subMask, -1);659 652 PS_ASSERT_VECTOR_NON_NULL(solution, -1); 660 653 PS_ASSERT_VECTOR_TYPE(solution, PS_TYPE_F64, -1); … … 670 663 int numStamps = 0; // Number of used stamps 671 664 { 672 int numCols = refImage->numCols, numRows = refImage->numRows; // Image dimensions673 665 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); // Statistics 674 psImage *convolvedStamp = psImageAlloc(2 * footprint + 1, 2 * footprint + 1, 675 PS_TYPE_F32); // Convolved image of stamp 666 psKernel *convolution = psKernelAlloc(-footprint, footprint, -footprint, footprint); // Convolution 676 667 psKernel *kernelImage = NULL; // The kernel, with which to convolve the stamps 677 668 float background = solution->data.F64[solution->n-1]; // The difference in background … … 683 674 continue; 684 675 } 685 int xStamp = stamp->x, yStamp = stamp->y; // Coordinates of stamp 686 687 float xNorm = 2.0 * (float)(stamp->x - numCols/2.0) / (float)numCols; // Normalised x coord688 float yNorm = 2.0 * (float)(stamp->y - numRows/2.0) / (float)numRows; // Normalised y coord 689 ps Image *polyValues = spatialPolyValues(kernels->spatialOrder, xNorm, yNorm); // Polynomial terms676 677 psImage *polyValues = spatialPolyValues(kernels->spatialOrder, stamp->xNorm, 678 stamp->yNorm); // Polynomial terms 679 680 psKernel *reference = stamp->reference; // Reference postage stamp 690 681 691 682 kernelImage = solvedKernel(kernelImage, solution, kernels, polyValues, false); 692 for (int y = yStamp - footprint, j = 0; y <= yStamp + footprint; y++, j++) {693 for (int x = xStamp - footprint, i = 0; x <= xStamp + footprint; x++, i++) {694 convol vedStamp->data.F32[j][i] = background;683 for (int y = - footprint; y <= footprint; y++) { 684 for (int x = - footprint; x <= footprint; x++) { 685 convolution->kernel[y][x] = background; 695 686 for (int v = -size; v <= size; v++) { 696 687 for (int u = -size; u <= size; u++) { 697 convol vedStamp->data.F32[j][i] += kernelImage->kernel[v][u] *698 ref Image->data.F32[y + v][x + u];688 convolution->kernel[y][x] += kernelImage->kernel[v][u] * 689 reference->kernel[y + v][x + u]; 699 690 } 700 691 } 701 692 } 702 693 } 703 704 694 psFree(polyValues); 705 695 706 psRegion region = psRegionSet(xStamp - footprint, xStamp + footprint + 1, 707 yStamp - footprint, yStamp + footprint + 1); // Region of interest 708 psImage *inStamp = psImageSubset(inImage, region); // Image of stamp 709 assert(inStamp->numCols == convolvedStamp->numCols && 710 inStamp->numRows == convolvedStamp->numRows); 696 psImage *convolvedStamp = convolution->image; // Image of the convolution 697 psImage *input = stamp->input->image; // Input image postage stamp 698 699 // Region of interest 700 psRegion region = psRegionSet(input->col0 + size, input->col0 + size + 2 * footprint + 1, 701 input->row0 + size, input->row0 + size + 2 * footprint + 1); 702 703 psImage *inStamp = psImageSubset(stamp->input->image, region); // Image of stamp 704 assert(convolvedStamp->numCols == inStamp->numCols && 705 convolvedStamp->numRows == inStamp->numRows); 711 706 (void)psBinaryOp(convolvedStamp, inStamp, "-", convolvedStamp); 712 707 (void)psBinaryOp(convolvedStamp, convolvedStamp, "*", convolvedStamp); … … 717 712 "Unable to calculate statistics on normalised residual image of stamp."); 718 713 psFree(deviations); 719 psFree(convol vedStamp);714 psFree(convolution); 720 715 psFree(stats); 721 716 return -1; … … 729 724 730 725 psFree(kernelImage); 731 psFree(convol vedStamp);726 psFree(convolution); 732 727 psFree(stats); 733 728 } -
trunk/psModules/src/imcombine/pmSubtraction.h
r14515 r14524 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-08-16 0 0:32:43$8 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-08-16 02:57:34 $ 10 10 * Copyright 2004-207 Institute for Astronomy, University of Hawaii 11 11 */ … … 51 51 /// Reject stamps 52 52 int pmSubtractionRejectStamps(psArray *stamps, ///< Array of stamps to check for rejection 53 const psImage *refImage, ///< Reference image54 psImage *inImage, ///< Input image55 53 psImage *subMask, ///< Subtraction mask 56 54 const psVector *solution, ///< Solution vector
Note:
See TracChangeset
for help on using the changeset viewer.
