Changeset 26035 for trunk/psModules/src/imcombine/pmSubtractionEquation.c
- Timestamp:
- Nov 4, 2009, 4:52:05 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtractionEquation.c
r26031 r26035 17 17 //#define TESTING // TESTING output for debugging; may not work with threads! 18 18 19 #define USE_ VARIANCE // Include variancein equation?19 #define USE_WEIGHT // Include weight (1/variance) in equation? 20 20 21 21 … … 29 29 const psKernel *input, // Input image (target) 30 30 const psKernel *reference, // Reference image (convolution source) 31 const psKernel * variance, // Varianceimage31 const psKernel *weight, // Weight image 32 32 const psArray *convolutions, // Convolutions for each kernel 33 33 const pmSubtractionKernels *kernels, // Kernels … … 74 74 for (int x = - footprint; x <= footprint; x++) { 75 75 double cc = iConv->kernel[y][x] * jConv->kernel[y][x]; 76 #ifdef USE_ VARIANCE77 cc /= variance->kernel[y][x];76 #ifdef USE_WEIGHT 77 cc *= weight->kernel[y][x]; 78 78 #endif 79 79 sumCC += cc; … … 102 102 double rc = ref * conv; 103 103 double c = conv; 104 #ifdef USE_ VARIANCE105 float varVal = 1.0 / variance->kernel[y][x];106 ic *= varVal;107 rc *= varVal;108 c *= varVal;104 #ifdef USE_WEIGHT 105 float wtVal = weight->kernel[y][x]; 106 ic *= wtVal; 107 rc *= wtVal; 108 c *= wtVal; 109 109 #endif 110 110 sumIC += ic; … … 137 137 double rr = PS_SQR(ref); 138 138 double one = 1.0; 139 #ifdef USE_ VARIANCE140 float varVal = 1.0 / variance->kernel[y][x];141 rr *= varVal;142 ir *= varVal;143 in *= varVal;144 ref *= varVal;145 one *= varVal;139 #ifdef USE_WEIGHT 140 float wtVal = weight->kernel[y][x]; 141 rr *= wtVal; 142 ir *= wtVal; 143 in *= wtVal; 144 ref *= wtVal; 145 one *= wtVal; 146 146 #endif 147 147 sumRR += rr; … … 169 169 const psKernel *image1, // Image 1 170 170 const psKernel *image2, // Image 2 171 const psKernel * variance, // Varianceimage171 const psKernel *weight, // Weight image 172 172 const psArray *convolutions1, // Convolutions of image 1 for each kernel 173 173 const psArray *convolutions2, // Convolutions of image 2 for each kernel … … 227 227 double bb = iConv2->kernel[y][x] * jConv2->kernel[y][x]; 228 228 double ab = iConv1->kernel[y][x] * jConv2->kernel[y][x]; 229 #ifdef USE_VARIANCE 230 aa /= variance->kernel[y][x]; 231 bb /= variance->kernel[y][x]; 232 ab /= variance->kernel[y][x]; 229 #ifdef USE_WEIGHT 230 float wtVal = weight->kernel[y][x]; 231 aa *= wtVal; 232 bb *= wtVal; 233 ab *= wtVal; 233 234 #endif 234 235 sumAA += aa; … … 258 259 for (int x = - footprint; x <= footprint; x++) { 259 260 double ab = iConv1->kernel[y][x] * jConv2->kernel[y][x]; 260 #ifdef USE_ VARIANCE261 ab /= variance->kernel[y][x];261 #ifdef USE_WEIGHT 262 ab *= weight->kernel[y][x]; 262 263 #endif 263 264 sumAB += ab; … … 295 296 double i1i2 = i1 * i2; 296 297 297 #ifdef USE_ VARIANCE298 float varVal = 1.0 / variance->kernel[y][x];299 ai2 *= varVal;300 bi2 *= varVal;301 ai1 *= varVal;302 bi1 *= varVal;303 i1i2 *= varVal;304 a *= varVal;305 b *= varVal;306 i2 *= varVal;298 #ifdef USE_WEIGHT 299 float wtVal = weight->kernel[y][x]; 300 ai2 *= wtVal; 301 bi2 *= wtVal; 302 ai1 *= wtVal; 303 bi1 *= wtVal; 304 i1i2 *= wtVal; 305 a *= wtVal; 306 b *= wtVal; 307 i2 *= wtVal; 307 308 #endif 308 309 … … 351 352 double i1i2 = i1 * i2; 352 353 353 #ifdef USE_ VARIANCE354 float varVal = 1.0 / variance->kernel[y][x];355 i1 *= varVal;356 i1i1 *= varVal;357 one *= varVal;358 i2 *= varVal;359 i1i2 *= varVal;354 #ifdef USE_WEIGHT 355 float wtVal = weight->kernel[y][x]; 356 i1 *= wtVal; 357 i1i1 *= wtVal; 358 one *= wtVal; 359 i2 *= wtVal; 360 i1i2 *= wtVal; 360 361 #endif 361 362 … … 619 620 case PM_SUBTRACTION_MODE_1: 620 621 status = calculateMatrixVector(stamp->matrix1, stamp->vector1, stamp->image2, stamp->image1, 621 stamp-> variance, stamp->convolutions1, kernels, polyValues,622 stamp->weight, stamp->convolutions1, kernels, polyValues, 622 623 footprint); 623 624 break; 624 625 case PM_SUBTRACTION_MODE_2: 625 626 status = calculateMatrixVector(stamp->matrix1, stamp->vector1, stamp->image1, stamp->image2, 626 stamp-> variance, stamp->convolutions2, kernels, polyValues,627 stamp->weight, stamp->convolutions2, kernels, polyValues, 627 628 footprint); 628 629 break; … … 639 640 #endif 640 641 status = calculateDualMatrixVector(stamp->matrix1, stamp->vector1, stamp->matrix2, stamp->vector2, 641 stamp->matrixX, stamp->image1, stamp->image2, stamp-> variance,642 stamp->matrixX, stamp->image1, stamp->image2, stamp->weight, 642 643 stamp->convolutions1, stamp->convolutions2, kernels, polyValues, 643 644 footprint); … … 1163 1164 1164 1165 // Calculate residuals 1165 psKernel * variance = stamp->variance; // Variancepostage stamp1166 psKernel *weight = stamp->weight; // Weight postage stamp 1166 1167 psImageInit(residual->image, 0.0); 1167 1168 if (kernels->mode != PM_SUBTRACTION_MODE_DUAL) { … … 1247 1248 for (int y = - footprint; y <= footprint; y++) { 1248 1249 for (int x = - footprint; x <= footprint; x++) { 1249 double dev = PS_SQR(residual->kernel[y][x]) / variance->kernel[y][x];1250 double dev = PS_SQR(residual->kernel[y][x]) * weight->kernel[y][x]; 1250 1251 deviation += dev; 1251 1252 #ifdef TESTING … … 1290 1291 psFitsClose(fits); 1291 1292 } 1292 if (stamp-> variance) {1293 if (stamp->weight) { 1293 1294 psString filename = NULL; 1294 psStringAppend(&filename, "stamp_ variance_%03d.fits", i);1295 psStringAppend(&filename, "stamp_weight_%03d.fits", i); 1295 1296 psFits *fits = psFitsOpen(filename, "w"); 1296 1297 psFree(filename); 1297 psFitsWriteImage(fits, NULL, stamp-> variance->image, 0, NULL);1298 psFitsWriteImage(fits, NULL, stamp->weight->image, 0, NULL); 1298 1299 psFitsClose(fits); 1299 1300 }
Note:
See TracChangeset
for help on using the changeset viewer.
