Changeset 15305 for trunk/psModules/src/imcombine/pmSubtraction.c
- Timestamp:
- Oct 12, 2007, 1:00:37 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/imcombine/pmSubtraction.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtraction.c
r14870 r15305 4 4 * @author GLG, MHPCC 5 5 * 6 * @version $Revision: 1.6 2$ $Name: not supported by cvs2svn $7 * @date $Date: 2007- 09-17 21:40:22$6 * @version $Revision: 1.63 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-10-12 23:00:36 $ 8 8 * 9 9 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii … … 459 459 460 460 psImage *pmSubtractionMask(const psImage *refMask, const psImage *inMask, psMaskType maskVal, 461 int size, int footprint )461 int size, int footprint, float badFrac) 462 462 { 463 463 PS_ASSERT_IMAGE_NON_NULL(refMask, NULL); … … 470 470 PS_ASSERT_INT_NONNEGATIVE(size, NULL); 471 471 PS_ASSERT_INT_NONNEGATIVE(footprint, NULL); 472 if (isfinite(badFrac)) { 473 PS_ASSERT_FLOAT_LARGER_THAN(badFrac, 0.0, NULL); 474 PS_ASSERT_FLOAT_LESS_THAN_OR_EQUAL(badFrac, 1.0, NULL); 475 } 472 476 473 477 // Size of the images … … 475 479 int numRows = refMask->numRows; 476 480 481 // Dereference inputs for convenience 482 psMaskType **inData = NULL; 483 if (inMask) { 484 inData = inMask->data.PS_TYPE_MASK_DATA; 485 } 486 psMaskType **refData = refMask->data.PS_TYPE_MASK_DATA; 487 488 // First, a pass through to determine the fraction of bad pixels 489 if (isfinite(badFrac) && badFrac != 1.0) { 490 int numBad = 0; // Number of bad pixels 491 for (int y = 0; y < numRows; y++) { 492 for (int x = 0; x < numCols; x++) { 493 if (inData && inData[y][x] & maskVal) { 494 numBad++; 495 continue; 496 } 497 if (refData[y][x] & maskVal) { 498 numBad++; 499 } 500 } 501 } 502 if (numBad > badFrac * numCols * numRows) { 503 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Fraction of bad pixels (%d/%d) exceeds limit (%f)\n", 504 numBad, numCols * numRows, badFrac); 505 return NULL; 506 } 507 } 508 477 509 // Worried about the masks for bad pixels and bad stamps colliding, so make our own mask 478 510 psImage *mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK); // The global mask 479 511 psImageInit(mask, 0); 480 481 // Dereference for convenience 482 psMaskType **maskData = mask->data.PS_TYPE_MASK_DATA; 483 psMaskType **inData = NULL; 484 if (inMask) { 485 inData = inMask->data.PS_TYPE_MASK_DATA; 486 } 487 psMaskType **refData = refMask->data.PS_TYPE_MASK_DATA; 512 psMaskType **maskData = mask->data.PS_TYPE_MASK_DATA; // Dereference for convenience 488 513 489 514 // Block out a border around the edge of the image … … 510 535 } 511 536 } 537 538 // XXX Could do something smarter here --- we will get images that are predominantly masked (where the 539 // skycell isn't overlapped by a large fraction by the observation), so that convolving around every bad 540 // pixel is wasting time. As a first cut, I've put in a check on the fraction of bad pixels, but we could 541 // imagine looking for the edge of big regions and convolving just at the edge. 512 542 513 543 // Mask the bad pixels, and around them
Note:
See TracChangeset
for help on using the changeset viewer.
