Changeset 15305
- Timestamp:
- Oct 12, 2007, 1:00:37 PM (19 years ago)
- Location:
- trunk/psModules/src/imcombine
- Files:
-
- 4 edited
-
pmSubtraction.c (modified) (5 diffs)
-
pmSubtraction.h (modified) (2 diffs)
-
pmSubtractionMatch.c (modified) (3 diffs)
-
pmSubtractionMatch.h (modified) (1 diff)
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 -
trunk/psModules/src/imcombine/pmSubtraction.h
r14801 r15305 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.1 7$ $Name: not supported by cvs2svn $9 * @date $Date: 2007- 09-10 20:10:05$8 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-10-12 23:00:37 $ 10 10 * 11 11 * Copyright 2004-207 Institute for Astronomy, University of Hawaii … … 37 37 psMaskType maskVal, ///< Value to mask out 38 38 int size, ///< Half-size of the kernel (pmSubtractionKernels.size) 39 int footprint ///< Half-size of the kernel footprint 39 int footprint, ///< Half-size of the kernel footprint 40 float badFrac ///< Maximum fraction of bad input pixels to accept 40 41 ); 41 42 -
trunk/psModules/src/imcombine/pmSubtractionMatch.c
r15285 r15305 98 98 int inner, int ringsOrder, int binning, bool optimum, const psVector *optFWHMs, 99 99 int optOrder, float optThreshold, int iter, float rej, psMaskType maskBad, 100 psMaskType maskBlank )100 psMaskType maskBlank, float badFrac) 101 101 { 102 102 PS_ASSERT_PTR_NON_NULL(convolved, false); … … 165 165 // Don't care about maskBad 166 166 // Don't care about maskBlank 167 if (isfinite(badFrac)) { 168 PS_ASSERT_FLOAT_LARGER_THAN(badFrac, 0.0, NULL); 169 PS_ASSERT_FLOAT_LESS_THAN_OR_EQUAL(badFrac, 1.0, NULL); 170 } 167 171 168 172 // If the stamp footprint is smaller than the kernel size, then we won't get much signal in the outer … … 219 223 memCheck("start"); 220 224 221 subMask = pmSubtractionMask(reference->mask, inMask, maskBad, size, footprint); 225 subMask = pmSubtractionMask(reference->mask, inMask, maskBad, size, footprint, badFrac); 226 if (subMask) { 227 psError(PS_ERR_UNKNOWN, false, "Unable to generate subtraction mask."); 228 return false; 229 } 222 230 223 231 memCheck("mask"); -
trunk/psModules/src/imcombine/pmSubtractionMatch.h
r14805 r15305 37 37 float rej, ///< Rejection threshold 38 38 psMaskType maskBad, ///< Value to mask 39 psMaskType maskBlank ///< Mask for blank region 39 psMaskType maskBlank, ///< Mask for blank region 40 float badFrac ///< Maximum fraction of bad input pixels to accept 40 41 ); 41 42
Note:
See TracChangeset
for help on using the changeset viewer.
