Changeset 16479 for trunk/psModules/src/imcombine/pmSubtraction.c
- Timestamp:
- Feb 14, 2008, 1:33:09 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/imcombine/pmSubtraction.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtraction.c
r16476 r16479 4 4 * @author GLG, MHPCC 5 5 * 6 * @version $Revision: 1. 79$ $Name: not supported by cvs2svn $7 * @date $Date: 2008-02-14 23: 18:34$6 * @version $Revision: 1.80 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2008-02-14 23:33:09 $ 8 8 * 9 9 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii … … 50 50 51 51 // Take the square of the normal kernel 52 double sumNormal = 0.0, sumVariance = 0.0; // Sum of the normal and variance kernels 52 53 for (int v = yMin; v <= yMax; v++) { 53 54 for (int u = xMin; u <= xMax; u++) { 54 out->kernel[v][u] = PS_SQR(normalKernel->kernel[v][u]); 55 } 56 } 55 float value = normalKernel->kernel[v][u]; // Value of interest 56 float value2 = PS_SQR(value); // Value squared 57 sumNormal += value; 58 sumVariance += value2; 59 out->kernel[v][u] = value2; 60 } 61 } 62 63 // Normalise so that the sum of the variance kernel is the square of the sum of the normal kernel 64 // This is required to keep the relative scaling between the image and the weight map 65 psBinaryOp(out->image, out->image, "*", psScalarAlloc(PS_SQR(sumNormal) / sumVariance, PS_TYPE_F32)); 57 66 58 67 return out; … … 681 690 PS_ASSERT_IMAGE_TYPE(out1->weight, PS_TYPE_F32, false); 682 691 } 683 if (region && psRegionIsNaN(*region)) { 684 psString string = psRegionToString(*region); 685 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Input region (%s) contains NAN values", string); 686 psFree(string); 687 return false; 692 if (region) { 693 if (psRegionIsNaN(*region)) { 694 psString string = psRegionToString(*region); 695 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Input region (%s) contains NAN values", string); 696 psFree(string); 697 return false; 698 } 699 if (region->x0 < 0 || region->x1 > ro1->image->numCols || 700 region->y0 < 0 || region->y1 > ro1->image->numRows) { 701 psString string = psRegionToString(*region); 702 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Input region (%s) does not fit in image (%dx%d)", 703 string, ro1->image->numCols, ro1->image->numRows); 704 psFree(string); 705 return false; 706 } 688 707 } 689 708 … … 705 724 706 725 int numCols = ro1->image->numCols, numRows = ro1->image->numRows; // Image dimensions 707 int x0 = ro1->col0, y0 = ro1->row0; // Image offset708 726 709 727 psImage *convImage1 = out1->image; // Convolved image … … 762 780 yMax = PS_MIN(region->y1, yMax); 763 781 } 764 765 // Size to use when calculating normalised coordinates (different from actual size when convolving766 // subimage)767 int xNormSize = (kernels->numCols > 0 ? kernels->numCols : numCols);768 int yNormSize = (kernels->numRows > 0 ? kernels->numRows : numRows);769 782 770 783 psMaskType maskSource; // Mask these pixels when convolving … … 794 807 for (int j = yMin; j < yMax; j += fullSize) { 795 808 int ySubMax = PS_MIN(j + fullSize, yMax); // Range for subregion of interest 796 float yNorm = 2.0 * (float)(j + y0 + size + 1 - yNormSize/2.0) / 797 (float)yNormSize; // Normalised coordinate 809 float yNorm = 2.0 * (float)(j + size + 1 - numRows/2.0) / (float)numRows; // Normalised coordinate 798 810 for (int i = xMin; i < xMax; i += fullSize) { 799 811 int xSubMax = PS_MIN(i + fullSize, xMax); // Range for subregion of interest 800 float xNorm = 2.0 * (float)(i + x0 + size + 1 - xNormSize/2.0) / 801 (float)xNormSize; // Normalised coordinate 812 float xNorm = 2.0 * (float)(i + size + 1 - numCols/2.0) / (float)numCols; // Normalised coordinate 802 813 803 814 // Only generate polynomial values every kernel footprint, since we have already assumed
Note:
See TracChangeset
for help on using the changeset viewer.
