Changeset 27412 for branches/pap_stack/psModules/src/imcombine/pmStack.c
- Timestamp:
- Mar 23, 2010, 1:54:27 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/pap_stack/psModules/src/imcombine/pmStack.c
r27400 r27412 34 34 35 35 36 //#define TESTING // Enable test output37 //#define TEST_X 843-1 // x coordinate to examine38 //#define TEST_Y 813-1 // y coordinate to examine39 //#define TEST_RADIUS 0 // Radius to examine36 #define TESTING // Enable test output 37 #define TEST_X 843-1 // x coordinate to examine 38 #define TEST_Y 813-1 // y coordinate to examine 39 #define TEST_RADIUS 0 // Radius to examine 40 40 41 41 … … 129 129 float sumExp = 0.0; // Sum of the exposure time 130 130 float sumExpWeight = 0.0; // Sum of the exposure time multiplied by the global weights 131 int numGood = 0; // Number of good exposures 131 132 for (int i = 0; i < values->n; i++) { 132 133 sumValueWeight += values->data.F32[i] * weights->data.F32[i]; … … 138 139 sumExp += exps->data.F32[i]; 139 140 sumExpWeight += exps->data.F32[i] * weights->data.F32[i]; 141 numGood++; 140 142 } 141 143 } … … 153 155 } 154 156 if (expWeight) { 155 *expWeight = sumExpWeight / sumWeight;157 *expWeight = sumExpWeight; 156 158 } 157 159 return true; … … 391 393 int x, int y, // Coordinates of interest; frame of output image 392 394 psImageMaskType bad, // Value for bad pixels 393 bool safe // Safe combination? 395 bool safe, // Safe combination? 396 float invTotalWeight // Inverse of total weight for all inputs 394 397 ) 395 398 { … … 423 426 if (exp) { 424 427 expValue = pixelExps->data.F32[0]; 428 expWeightValue = pixelExps->data.F32[0]; 425 429 } 426 430 maskValue = 0; … … 490 494 } 491 495 if (expweight) { 492 expweight->data.F32[y][x] = expWeightValue ;496 expweight->data.F32[y][x] = expWeightValue * invTotalWeight; 493 497 } 494 498 … … 1024 1028 psVector *exps = psVectorAlloc(num, PS_TYPE_F32); // Exposure times for each image 1025 1029 psArray *stack = psArrayAlloc(num); // Stack of readouts 1030 float totalExpWeight = 0.0; // Total value of all weighted exposure times 1031 float totalExp = 0.0; // Total exposure time 1026 1032 for (int i = 0; i < num; i++) { 1027 1033 pmStackData *data = input->data[i]; // Stack data for this input … … 1033 1039 weights->data.F32[i] = data->weight; 1034 1040 exps->data.F32[i] = data->exp; 1041 totalExp += exps->data.F32[i]; 1042 totalExpWeight += exps->data.F32[i] * weights->data.F32[i]; 1035 1043 pmReadout *ro = data->readout; // Readout of interest 1036 1044 stack->data[i] = psMemIncrRefCounter(ro); … … 1051 1059 } 1052 1060 } 1061 totalExpWeight = totalExp / totalExpWeight; // Convert to inverse 1053 1062 1054 1063 int minInputCols, maxInputCols, minInputRows, maxInputRows; // Smallest and largest values to combine … … 1095 1104 } 1096 1105 1097 psImage *exp = NULL, *expnum = NULL ; // Exposure map and exposure number1106 psImage *exp = NULL, *expnum = NULL, *expweight = NULL; // Exposure map and exposure number 1098 1107 if (expmaps) { 1099 1108 if (!expmaps->image) { … … 1106 1115 } 1107 1116 expnum = expmaps->mask; 1117 1118 if (!expmaps->variance) { 1119 expmaps->variance = psImageAlloc(numCols, numRows, PS_TYPE_F32); 1120 } 1121 expweight = expmaps->variance; 1108 1122 } 1109 1123 … … 1145 1159 combineExtract(&num, &suspect, buffer, combinedImage, combinedMask, combinedVariance, 1146 1160 input, weights, exps, addVariance, reject, x, y, maskVal, maskSuspect); 1147 combinePixels(combinedImage, combinedMask, combinedVariance, exp, expnum, NULL,1148 num, buffer, x, y, bad, safe );1161 combinePixels(combinedImage, combinedMask, combinedVariance, exp, expnum, expweight, 1162 num, buffer, x, y, bad, safe, totalExpWeight); 1149 1163 1150 1164 if (iter > 0) {
Note:
See TracChangeset
for help on using the changeset viewer.
