Changeset 14318
- Timestamp:
- Jul 19, 2007, 11:26:12 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/imcombine/pmSubtraction.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtraction.c
r14314 r14318 4 4 * @author GLG, MHPCC 5 5 * 6 * @version $Revision: 1.2 7$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-07-19 03:36:06$6 * @version $Revision: 1.28 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-07-19 21:26:12 $ 8 8 * 9 9 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii … … 25 25 #include "pmSubtraction.h" 26 26 27 //#define USE_FUNCTIONS_INSTEAD_OF_MACROS // Can I pass the address of a static inline function?27 #define USE_FUNCTIONS_INSTEAD_OF_MACROS // Can I pass the address of a static inline function? 28 28 29 29 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// … … 851 851 } 852 852 853 int numKernels = solution->n - 1; // Number of kernel basis functions 854 855 // Measure 853 // Measure deviations 856 854 psVector *deviations = psVectorAlloc(stamps->n, PS_TYPE_F32); // Mean deviation for stamps 857 855 double totalSquareDev = 0.0; // Total square deviation from zero … … 859 857 { 860 858 int numCols = refImage->numCols, numRows = refImage->numRows; // Image dimensions 861 862 859 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); // Statistics 863 864 // Convolved image of stamp 865 psImage *convolvedStamp = psImageAlloc(2 * footprint + 1, 2 * footprint + 1, PS_TYPE_F32); 860 psImage *convolvedStamp = psImageAlloc(2 * footprint + 1, 2 * footprint + 1, 861 PS_TYPE_F32); // Convolved image of stamp 862 psKernel *kernelImage = NULL; // The kernel, with which to convolve the stamps 863 float background = solution->data.F64[solution->n-1]; // The difference in background 864 int size = kernels->size; // Half-size of the kernel 866 865 867 866 for (int i = 0; i < stamps->n; i++) { … … 871 870 } 872 871 int xStamp = stamp->x, yStamp = stamp->y; // Coordinates of stamp 873 psImageInit(convolvedStamp, 0.0);874 872 875 873 // Precalulate polynomial values … … 878 876 2.0 * (float)(stamp->y - numRows/2.0) / (float)numRows); 879 877 880 for (int y = - footprint; y <= footprint; y++) {881 for (int x = footprint; x <= footprint; x++) {882 for (int k = 0; k < numKernels; k++) {883 878 #ifdef USE_FUNCTIONS_INSTEAD_OF_MACROS 884 convolvedStamp->data.F32[y + footprint][x + footprint] += 885 convolvePixel(kernels, k, xStamp + x, yStamp + y, refImage, polyValues, 886 imageWeighting); 879 kernelImage = solvedKernel(kernelImage, solution, kernels, polyValues, imageWeighting); 887 880 #else 888 CONVOLVE_PIXEL(convolvedStamp->data.F32[y + footprint][x + footprint], kernels, 889 k, xStamp + x, yStamp + y, refImage, polyValues, imageWeighting); 881 SOLVED_KERNEL(kernelImage, solution, kernels, polyValues, imageWeighting); 890 882 #endif 883 for (int y = yStamp - footprint, j = 0; y <= yStamp + footprint; y++, j++) { 884 for (int x = xStamp - footprint, i = 0; x <= xStamp + footprint; x++, i++) { 885 convolvedStamp->data.F32[j][i] = background; 886 for (int v = -size; v <= size; v++) { 887 for (int u = -size; u <= size; u++) { 888 convolvedStamp->data.F32[j][i] += kernelImage->kernel[v][u] * 889 refImage->data.F32[y + v][x + u]; 890 } 891 891 } 892 892 } 893 893 } 894 894 895 psFree(polyValues); 895 896 … … 900 901 inStamp->numRows == convolvedStamp->numRows); 901 902 (void)psBinaryOp(convolvedStamp, inStamp, "-", convolvedStamp); 903 (void)psBinaryOp(convolvedStamp, convolvedStamp, "*", convolvedStamp); 902 904 (void)psBinaryOp(convolvedStamp, convolvedStamp, "/", inStamp); 903 905 psFree(inStamp); 904 (void)psBinaryOp(convolvedStamp, convolvedStamp, "*", convolvedStamp);905 906 if (!psImageStats(stats, convolvedStamp, NULL, 0)) { 906 907 psError(PS_ERR_UNKNOWN, false, … … 911 912 return -1; 912 913 } 913 deviations->data.F32[i] = stats->sampleMean; 914 deviations->data.F32[i] = sqrt(stats->sampleMean / 2.0); 915 psTrace("psModules.imcombine", 1, "Deviation for stamp %d: %f\n", i, deviations->data.F32[i]); 914 916 totalSquareDev += PS_SQR(deviations->data.F32[i]); 915 917 numStamps++; 916 918 } 917 919 920 psFree(kernelImage); 918 921 psFree(convolvedStamp); 919 922 psFree(stats); 920 923 } 921 924 922 float limit = sigmaRej * sqrt(totalSquareDev / (numStamps - 1)); // Limit on maximum deviation 925 float limit = sigmaRej * sqrt(totalSquareDev / numStamps); // Limit on maximum deviation 926 psTrace("psModules.imcombine", 1, "Deviation limit: %f\n", limit); 923 927 924 928 int numRejected = 0;
Note:
See TracChangeset
for help on using the changeset viewer.
