Changeset 16607 for trunk/psModules/src/imcombine/pmSubtraction.c
- Timestamp:
- Feb 22, 2008, 9:50:56 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/imcombine/pmSubtraction.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtraction.c
r16604 r16607 4 4 * @author GLG, MHPCC 5 5 * 6 * @version $Revision: 1.82 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2008-02-22 19:50:56 $ 8 * 6 9 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii 7 10 * … … 47 50 48 51 // Take the square of the normal kernel 49 double sumNormal = 0.0, sumVariance = 0.0; // Sum of the normal and variance kernels50 52 for (int v = yMin; v <= yMax; v++) { 51 53 for (int u = xMin; u <= xMax; u++) { 52 float value = normalKernel->kernel[v][u]; // Value of interest 53 float value2 = PS_SQR(value); // Value squared 54 sumNormal += value; 55 sumVariance += value2; 56 out->kernel[v][u] = value2; 57 } 58 } 59 60 // Normalise so that the sum of the variance kernel is the square of the sum of the normal kernel 61 // This is required to keep the relative scaling between the image and the weight map 62 psBinaryOp(out->image, out->image, "*", psScalarAlloc(PS_SQR(sumNormal) / sumVariance, PS_TYPE_F32)); 54 out->kernel[v][u] = PS_SQR(normalKernel->kernel[v][u]); 55 } 56 } 63 57 64 58 return out; … … 687 681 PS_ASSERT_IMAGE_TYPE(out1->weight, PS_TYPE_F32, false); 688 682 } 689 if (region) { 690 if (psRegionIsNaN(*region)) { 691 psString string = psRegionToString(*region); 692 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Input region (%s) contains NAN values", string); 693 psFree(string); 694 return false; 695 } 696 if (region->x0 < 0 || region->x1 > ro1->image->numCols || 697 region->y0 < 0 || region->y1 > ro1->image->numRows) { 698 psString string = psRegionToString(*region); 699 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Input region (%s) does not fit in image (%dx%d)", 700 string, ro1->image->numCols, ro1->image->numRows); 701 psFree(string); 702 return false; 703 } 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; 704 688 } 705 689 … … 776 760 yMax = PS_MIN(region->y1, yMax); 777 761 } 762 763 // Size to use when calculating normalised coordinates (different from actual size when convolving 764 // subimage) 765 int xNormSize = (kernels->numCols > 0 ? kernels->numCols : numCols); 766 int yNormSize = (kernels->numRows > 0 ? kernels->numRows : numRows); 778 767 779 768 psMaskType maskSource; // Mask these pixels when convolving … … 803 792 for (int j = yMin; j < yMax; j += fullSize) { 804 793 int ySubMax = PS_MIN(j + fullSize, yMax); // Range for subregion of interest 805 float yNorm = 2.0 * (float)(j + size + 1 - numRows/2.0) / (float)numRows; // Normalised coordinate 794 float yNorm = 2.0 * (float)(j + y0 + size + 1 - yNormSize/2.0) / 795 (float)yNormSize; // Normalised coordinate 806 796 for (int i = xMin; i < xMax; i += fullSize) { 807 797 int xSubMax = PS_MIN(i + fullSize, xMax); // Range for subregion of interest 808 float xNorm = 2.0 * (float)(i + size + 1 - numCols/2.0) / (float)numCols; // Normalised coordinate 798 float xNorm = 2.0 * (float)(i + x0 + size + 1 - xNormSize/2.0) / 799 (float)xNormSize; // Normalised coordinate 809 800 810 801 // Only generate polynomial values every kernel footprint, since we have already assumed
Note:
See TracChangeset
for help on using the changeset viewer.
