Changeset 15325 for trunk/psModules/src/imcombine/pmSubtraction.c
- Timestamp:
- Oct 16, 2007, 4:45:40 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/imcombine/pmSubtraction.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtraction.c
r15319 r15325 4 4 * @author GLG, MHPCC 5 5 * 6 * @version $Revision: 1.6 4$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-10-1 6 21:38:24$6 * @version $Revision: 1.65 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-10-17 02:45:40 $ 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, float badFrac )461 int size, int footprint, float badFrac, bool useFFT) 462 462 { 463 463 PS_ASSERT_IMAGE_NON_NULL(refMask, NULL); … … 540 540 // skycell isn't overlapped by a large fraction by the observation), so that convolving around every bad 541 541 // pixel is wasting time. As a first cut, I've put in a check on the fraction of bad pixels, but we could 542 // imagine looking for the edge of big regions and convolving just at the edge. 543 544 // Mask the bad pixels, and around them 542 // imagine looking for the edge of big regions and convolving just at the edge. As a second cut, allow 543 // use of FFT convolution. 544 545 545 for (int y = 0; y < numRows; y++) { 546 546 for (int x = 0; x < numCols; x++) { 547 547 if (inData && inData[y][x] & maskVal) { 548 548 maskData[y][x] |= PM_SUBTRACTION_MASK_INPUT; 549 // Block out the entire stamp footprint around this pixel550 for (int v = PS_MAX(y - footprint, 0); v <= PS_MIN(y + footprint, numRows - 1); v++) {551 for (int u = PS_MAX(x - footprint, 0); u <= PS_MIN(x + footprint, numCols - 1); u++) {552 maskData[v][u] |= PM_SUBTRACTION_MASK_FOOTPRINT;553 }554 }555 549 } 556 550 if (refData[y][x] & maskVal) { 557 551 maskData[y][x] |= PM_SUBTRACTION_MASK_REF; 558 559 // We want to block out with the CONVOLVE mask anything that would be bad if we convolved with 560 // this bad pixel (within 'size'). Then we want to block out with the FOOTPRINT mask 561 // everything within a footprint's distance of those (within 'footprint'). 562 563 // Bottom stripe 564 for (int v = PS_MAX(y - footprint - size, 0); v < y - size; v++) { 565 for (int u = PS_MAX(x - footprint - size, 0); 566 u <= PS_MIN(x + footprint + size, numCols - 1); u++) { 567 maskData[v][u] |= PM_SUBTRACTION_MASK_FOOTPRINT; 568 } 569 } 570 // Middle 571 for (int v = PS_MAX(y - size, 0); v <= PS_MIN(y + size, numRows - 1); v++) { 572 // Left side 573 for (int u = PS_MAX(x - footprint - size, 0); u < x - size; u++) { 574 maskData[v][u] |= PM_SUBTRACTION_MASK_FOOTPRINT; 575 } 576 // Centre 577 for (int u = PS_MAX(x - size, 0); u <= PS_MIN(x + size, numCols - 1); u++) { 578 maskData[v][u] |= PM_SUBTRACTION_MASK_FOOTPRINT | PM_SUBTRACTION_MASK_CONVOLVE; 579 } 580 // Right side 581 for (int u = x + size + 1; u <= PS_MIN(x + footprint + size, numCols - 1); u++) { 582 maskData[v][u] |= PM_SUBTRACTION_MASK_FOOTPRINT; 583 } 584 } 585 // Top stripe 586 for (int v = y + size + 1; v <= PS_MIN(y + footprint + size, numRows - 1); v++) { 587 for (int u = PS_MAX(x - footprint - size, 0); 588 u <= PS_MIN(x + footprint + size, numCols - 1); u++) { 589 maskData[v][u] |= PM_SUBTRACTION_MASK_FOOTPRINT; 590 } 591 } 592 } 552 } 553 } 554 } 555 556 // Block out the entire stamp footprint around bad input pixels. 557 558 // We want to block out with the CONVOLVE mask anything that would be bad if we convolved with a bad 559 // reference pixel (within 'size'). Then we want to block out with the FOOTPRINT mask everything within a 560 // footprint's distance of those (within 'footprint'). 561 562 if (useFFT) { 563 if (!psImageConvolveMaskFFT(mask, mask, PM_SUBTRACTION_MASK_INPUT, PM_SUBTRACTION_MASK_FOOTPRINT, 564 -footprint, footprint, -footprint, footprint, 0.5)) { 565 psError(PS_ERR_UNKNOWN, false, "Unable to convolve bad input pixels."); 566 psFree(mask); 567 return NULL; 568 } 569 if (!psImageConvolveMaskFFT(mask, mask, PM_SUBTRACTION_MASK_REF, PM_SUBTRACTION_MASK_CONVOLVE, 570 -size, size, -size, size, 0.5)) { 571 psError(PS_ERR_UNKNOWN, false, "Unable to convolve bad reference pixels."); 572 psFree(mask); 573 return NULL; 574 } 575 if (!psImageConvolveMaskFFT(mask, mask, PM_SUBTRACTION_MASK_CONVOLVE, PM_SUBTRACTION_MASK_FOOTPRINT, 576 -footprint, footprint, -footprint, footprint, 0.5)) { 577 psError(PS_ERR_UNKNOWN, false, "Unable to reconvolve bad reference pixels."); 578 psFree(mask); 579 return NULL; 580 } 581 } else { 582 if (!psImageConvolveMaskDirect(mask, mask, PM_SUBTRACTION_MASK_INPUT, PM_SUBTRACTION_MASK_FOOTPRINT, 583 -footprint, footprint, -footprint, footprint)) { 584 psError(PS_ERR_UNKNOWN, false, "Unable to convolve bad input pixels."); 585 psFree(mask); 586 return NULL; 587 } 588 if (!psImageConvolveMaskDirect(mask, mask, PM_SUBTRACTION_MASK_REF, PM_SUBTRACTION_MASK_CONVOLVE, 589 -size, size, -size, size)) { 590 psError(PS_ERR_UNKNOWN, false, "Unable to convolve bad reference pixels."); 591 psFree(mask); 592 return NULL; 593 } 594 if (!psImageConvolveMaskDirect(mask, mask, PM_SUBTRACTION_MASK_CONVOLVE, 595 PM_SUBTRACTION_MASK_FOOTPRINT, 596 -footprint, footprint, -footprint, footprint)) { 597 psError(PS_ERR_UNKNOWN, false, "Unable to reconvolve bad reference pixels."); 598 psFree(mask); 599 return NULL; 593 600 } 594 601 }
Note:
See TracChangeset
for help on using the changeset viewer.
