Changeset 10248
- Timestamp:
- Nov 28, 2006, 3:26:53 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/imcombine/pmReadoutCombine.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmReadoutCombine.c
r9730 r10248 32 32 params->iter = 1; 33 33 params->rej = INFINITY; 34 params->weights = false; 34 35 35 36 return params; … … 77 78 int xSize = 0, ySize = 0; // The size of the output image 78 79 79 bool haveWeights = false; // Do we have weight images?80 80 bool valid = false; // Do we have a single valid input? 81 81 for (long i = 0; i < inputs->n; i++) { … … 97 97 } 98 98 99 if (readout->weight) { 100 if (valid && !haveWeights) { 101 psLogMsg(__func__, PS_LOG_WARN, "Readout %ld has a weight map, but others don't --- " 102 "weights ignored.\n", i); 103 } else { 104 haveWeights = true; 105 } 106 } else if (haveWeights) { 107 psLogMsg(__func__, PS_LOG_WARN, "Readout %ld doesn't have a weight map, but others do --- " 108 "weights ignored.\n", i); 109 haveWeights = false; 110 } 99 if (params->weights && !readout->weight) { 100 psError(PS_ERR_UNEXPECTED_NULL, true, 101 "Rejection based on weights requested, but no weights supplied for image %ld.\n", i); 102 return false; 103 } 104 111 105 valid = true; 112 106 … … 160 154 161 155 psStatsOptions combineStdev = 0; // Statistics option for weights 162 if ( haveWeights) {156 if (params->weights) { 163 157 164 158 if (!output->weight) { … … 207 201 208 202 psVector *weights = NULL; // Stack of weights 203 psVector *errors = NULL; // Stack of errors (sqrt of variance/weights), for psVectorStats 209 204 psF32 *weightsData = NULL; // Dereference weights 210 if ( haveWeights) {205 if (params->weights) { 211 206 weights = psVectorAlloc(inputs->n, PS_TYPE_F32); // Stack of weights 212 207 weightsData = weights->data.F32; … … 272 267 #endif 273 268 pixelsData[r] = image->data.F32[yIn][xIn]; 269 if (params->weights) { 270 weightsData[r] = readout->weight->data.F32[yIn][xIn]; 271 } 272 274 273 if (zero) { 275 274 pixelsData[r] -= zero->data.F32[r]; … … 277 276 if (scale) { 278 277 pixelsData[r] *= invScale->data.F32[r]; 278 if (params->weights) { 279 weightsData[r] *= invScale->data.F32[r] * invScale->data.F32[r]; 280 } 279 281 } 280 282 … … 319 321 } 320 322 323 if (params->weights) { 324 errors = (psVector*)psUnaryOp(errors, weights, "sqrt"); 325 } 326 321 327 // Combination 322 psVectorStats(stats, pixels, weights, mask, 1);328 psVectorStats(stats, pixels, errors, mask, 1); 323 329 outputImage[yOut][xOut] = psStatsGetValue(stats, params->combine); 324 if ( haveWeights) {330 if (params->weights) { 325 331 float stdev = psStatsGetValue(stats, combineStdev); 326 332 outputWeight[yOut][xOut] = PS_SQR(stdev); // Variance … … 337 343 psFree(mask); 338 344 psFree(weights); 345 psFree(errors); 339 346 psFree(stats); 340 347 psFree(invScale);
Note:
See TracChangeset
for help on using the changeset viewer.
