Changeset 26035 for trunk/psModules/src/imcombine/pmSubtractionParams.c
- Timestamp:
- Nov 4, 2009, 4:52:05 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtractionParams.c
r21363 r26035 71 71 double *sumII, // Sum of I(x)^2/sigma(x)^2 72 72 double *sumIC, // Sum of I(x)conv(x)/sigma(x)^2 73 const pmSubtractionStamp *stamp, // Stamp with variance73 const pmSubtractionStamp *stamp, // Stamp 74 74 const psKernel *target, // Target stamp 75 75 int kernelIndex, // Index for kernel component … … 78 78 ) 79 79 { 80 psKernel * variance = stamp->variance; // Variance, sigma(x)^280 psKernel *weight = stamp->weight; // Weight image 81 81 psKernel *convolution = selectConvolution(stamp, kernelIndex, mode); // Convolution of interest 82 82 83 83 for (int y = -footprint; y <= footprint; y++) { 84 84 psF32 *in = &target->kernel[y][-footprint]; // Dereference input 85 psF32 *wt = & variance->kernel[y][-footprint]; // Dereference variance85 psF32 *wt = &weight->kernel[y][-footprint]; // Dereference weight 86 86 psF32 *conv = &convolution->kernel[y][-footprint]; // Dereference convolution 87 87 for (int x = -footprint; x <= footprint; x++, in++, wt++, conv++) { 88 double temp = *in /*wt; // Temporary product88 double temp = *in * *wt; // Temporary product 89 89 *sumI += temp; 90 90 *sumII += *in * temp; … … 98 98 static void accumulateConvolutions(double *sumC, // Sum of conv(x)/sigma(x)^2 99 99 double *sumCC, // Sum of conv(x)^2/sigma(x)^2 100 const pmSubtractionStamp *stamp, // Stamp with input and variance100 const pmSubtractionStamp *stamp, // Stamp with input and weight 101 101 int kernelIndex, // Index for kernel component 102 102 int footprint, // Size of region of interest … … 104 104 ) 105 105 { 106 psKernel * variance = stamp->variance; // Variance, sigma(x)^2106 psKernel *weight = stamp->weight; // Weight image 107 107 psKernel *convolution = selectConvolution(stamp, kernelIndex, mode); // Convolution of interest 108 108 109 109 for (int y = -footprint; y <= footprint; y++) { 110 psF32 *wt = & variance->kernel[y][-footprint]; // Dereference variance110 psF32 *wt = &weight->kernel[y][-footprint]; // Dereference weight 111 111 psF32 *conv = &convolution->kernel[y][-footprint]; // Dereference convolution 112 112 for (int x = -footprint; x <= footprint; x++, wt++, conv++) { 113 double convNoise = *conv /*wt; // Temporary product113 double convNoise = *conv * *wt; // Temporary product 114 114 *sumC += convNoise; 115 115 *sumCC += *conv * convNoise; … … 120 120 121 121 static double accumulateChi2(const psKernel *target, // Target stamp 122 pmSubtractionStamp *stamp, // Stamp with variance122 pmSubtractionStamp *stamp, // Stamp with weight 123 123 int kernelIndex, // Index for kernel component 124 124 double coeff, // Coefficient of convolution … … 129 129 { 130 130 double chi2 = 0.0; 131 psKernel * variance = stamp->variance; // Variance, sigma(x)^2131 psKernel *weight = stamp->weight; // Weight image 132 132 psKernel *convolution = selectConvolution(stamp, kernelIndex, mode); // Convolution of interest 133 133 134 134 for (int y = -footprint; y <= footprint; y++) { 135 135 psF32 *in = &target->kernel[y][-footprint]; // Dereference input 136 psF32 *wt = & variance->kernel[y][-footprint]; // Dereference variance136 psF32 *wt = &weight->kernel[y][-footprint]; // Dereference weight 137 137 psF32 *conv = &convolution->kernel[y][-footprint]; // Dereference convolution 138 138 for (int x = -footprint; x <= footprint; x++, in++, wt++, conv++) { 139 chi2 += PS_SQR(*in - bg - coeff * *conv) /*wt;139 chi2 += PS_SQR(*in - bg - coeff * *conv) * *wt; 140 140 } 141 141 } … … 146 146 // Return the initial value of chi^2 147 147 static double initialChi2(const psKernel *target, // Target stamp 148 const pmSubtractionStamp *stamp, // Stamp with variance148 const pmSubtractionStamp *stamp, // Stamp 149 149 int footprint, // Size of convolution 150 150 pmSubtractionMode mode // Mode of subtraction 151 151 ) 152 152 { 153 psKernel * variance = stamp->variance; // Variance map153 psKernel *weight = stamp->weight; // Weight image 154 154 psKernel *source; // Source stamp 155 155 switch (mode) { … … 167 167 for (int y = -footprint; y <= footprint; y++) { 168 168 psF32 *in = &target->kernel[y][-footprint]; // Dereference input 169 psF32 *wt = & variance->kernel[y][-footprint]; // Dereference variance169 psF32 *wt = &weight->kernel[y][-footprint]; // Dereference weight 170 170 psF32 *ref = &source->kernel[y][-footprint]; // Derference reference 171 171 for (int x = -footprint; x <= footprint; x++, in++, wt++, ref++) { 172 172 float diff = *in - *ref; // Temporary value 173 chi2 += PS_SQR(diff) /*wt;173 chi2 += PS_SQR(diff) * *wt; 174 174 } 175 175 } … … 180 180 // Subtract a convolution from the input 181 181 static void subtractConvolution(psKernel *target, // Target stamp 182 const pmSubtractionStamp *stamp, // Stamp with variance182 const pmSubtractionStamp *stamp, // Stamp 183 183 int kernelIndex, // Index for kernel component 184 184 float coeff, // Coefficient of subtraction … … 288 288 289 289 // This sum is invariant to the kernel 290 psKernel * variance = stamp->variance; // Variance map for stamp290 psKernel *weight = stamp->weight; // Weight image 291 291 for (int v = -footprint; v <= footprint; v++) { 292 psF32 *wt = & variance->kernel[v][-footprint]; // Dereference variance map292 psF32 *wt = &weight->kernel[v][-footprint]; // Dereference weight 293 293 for (int u = -footprint; u <= footprint; u++, wt++) { 294 sum1 += 1.0 /*wt;294 sum1 += 1.0 * *wt; 295 295 } 296 296 }
Note:
See TracChangeset
for help on using the changeset viewer.
