Changeset 18182
- Timestamp:
- Jun 18, 2008, 3:59:59 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/imcombine/pmStack.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmStack.c
r17679 r18182 8 8 * @author GLG, MHPCC 9 9 * 10 * @version $Revision: 1.3 1$ $Name: not supported by cvs2svn $11 * @date $Date: 2008-0 5-14 22:22:28$10 * @version $Revision: 1.32 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2008-06-19 01:59:59 $ 12 12 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii 13 13 * … … 216 216 const psArray *inputs, // Stack data 217 217 const psVector *weights, // Global (single value) weights for data, or NULL 218 const psVector *varFactors, // Variance factors for data 218 219 const psVector *reject, // Indices of pixels to reject, or NULL 219 220 int x, int y, // Coordinates of interest; frame of output image … … 233 234 assert(numIter >= 0); 234 235 assert(buffer); 236 assert(varFactors); 235 237 assert((useVariance && variance) || !useVariance); 236 238 … … 339 341 psVectorInit(pixelMasks, 0); 340 342 if (useVariance) { 341 // Convert to rejection limits 343 // Convert to rejection limits --- saves doing it later. 344 // Using squared rejection limit because it's cheaper than sqrts 345 rej *= rej; 342 346 for (int i = 0; i < num; i++) { 343 pixelVariances->data.F32[i] = rej * sqrtf(pixelVariances->data.F32[i]); 347 pixelVariances->data.F32[i] = rej * pixelVariances->data.F32[i] * 348 varFactors->data.F32[i]; 344 349 } 345 350 } … … 364 369 } 365 370 371 // Mask a pixel for inspection 372 #define MASK_PIXEL_FOR_INSPECTION() \ 373 pixelMasks->data.PS_TYPE_MASK_DATA[j] = 0xff; \ 374 combineInspect(inputs, x, y, pixelSources->data.U16[j]); \ 375 numClipped++; \ 376 totalClipped++; 377 366 378 for (int j = 0; j < num; j++) { 367 379 if (pixelMasks->data.PS_TYPE_MASK_DATA[j]) { … … 369 381 } 370 382 float diff = fabsf(pixelData->data.F32[j] - median); // Difference from expected 371 if (diff > (useVariance ? pixelVariances->data.F32[i] : limit)) { 372 pixelMasks->data.PS_TYPE_MASK_DATA[j] = 0xff; 373 combineInspect(inputs, x, y, pixelSources->data.U16[j]); 374 numClipped++; 375 totalClipped++; 383 if (useVariance) { 384 // Comparing squares --- cheaper than lots of sqrts 385 if (PS_SQR(diff) > pixelVariances->data.F32[i]) { 386 MASK_PIXEL_FOR_INSPECTION(); 387 } 388 } else if (diff > limit) { 389 MASK_PIXEL_FOR_INSPECTION(); 376 390 } 377 391 } … … 561 575 } 562 576 577 psVector *varFactors = psVectorAlloc(num, PS_TYPE_F32); // Variance factors for each image 563 578 psVector *weights = psVectorAlloc(num, PS_TYPE_F32); // Relative weighting for each image 564 579 psArray *stack = psArrayAlloc(num); // Stack of readouts … … 571 586 weights->data.F32[i] = data->weight; 572 587 stack->data[i] = psMemIncrRefCounter(data->readout); 588 // Variance factor 589 float vf = psMetadataLookupF32(NULL, data->readout->parent->concepts, "CELL.VARFACTOR"); // Var factor 590 if (!isfinite(vf)) { 591 psWarning("Non-finite CELL.VARFACTOR for image %d --- setting to unity.", i); 592 vf = 1.0; 593 } 594 varFactors->data.F32[i] = vf; 573 595 } 574 596 … … 618 640 for (int x = minInputCols; x < maxInputCols; x++) { 619 641 psVector *reject = pixelMapQuery(pixelMap, x, y); // Inspect these images closely 620 combinePixels(combinedImage, combinedMask, combinedVariance, input, weights, reject, x, y,621 maskVal, bad, numIter, rej, useVariance, safe, buffer);642 combinePixels(combinedImage, combinedMask, combinedVariance, input, weights, varFactors, 643 reject, x, y, maskVal, bad, numIter, rej, useVariance, safe, buffer); 622 644 } 623 645 } … … 631 653 } 632 654 psVector *reject = pixelMapQuery(pixelMap, x, y); // Inspect these images closely 633 combinePixels(combinedImage, combinedMask, combinedVariance, input, weights, reject, x, y,634 maskVal, bad, numIter, rej, useVariance, safe, buffer);655 combinePixels(combinedImage, combinedMask, combinedVariance, input, weights, varFactors, 656 reject, x, y, maskVal, bad, numIter, rej, useVariance, safe, buffer); 635 657 } 636 658 } … … 658 680 for (int y = minInputRows; y < maxInputRows; y++) { 659 681 for (int x = minInputCols; x < maxInputCols; x++) { 660 combinePixels(combinedImage, combinedMask, combinedVariance, input, weights, NULL, x, y,661 maskVal, bad, numIter, rej, useVariance, safe, buffer);682 combinePixels(combinedImage, combinedMask, combinedVariance, input, weights, varFactors, 683 NULL, x, y, maskVal, bad, numIter, rej, useVariance, safe, buffer); 662 684 } 663 685 }
Note:
See TracChangeset
for help on using the changeset viewer.
