Changeset 23849
- Timestamp:
- Apr 14, 2009, 8:53:51 AM (17 years ago)
- Location:
- trunk/psModules/src/imcombine
- Files:
-
- 4 edited
-
pmSubtractionMask.c (modified) (2 diffs)
-
pmSubtractionMatch.c (modified) (2 diffs)
-
pmSubtractionStamps.c (modified) (14 diffs)
-
pmSubtractionStamps.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtractionMask.c
r21183 r23849 139 139 bool oldThreads = psImageConvolveSetThreads(true); // Old value of threading for psImageConvolve 140 140 141 if (!psImageConvolveMask(mask, mask, PM_SUBTRACTION_MASK_BAD_1, 142 PM_SUBTRACTION_MASK_CONVOLVE_1, 141 if (!psImageConvolveMask(mask, mask, PM_SUBTRACTION_MASK_BAD_1, PM_SUBTRACTION_MASK_CONVOLVE_1, 143 142 -size, size, -size, size)) { 144 143 psError(PS_ERR_UNKNOWN, false, "Unable to convolve bad pixels from mask 1."); … … 146 145 return NULL; 147 146 } 148 if (!psImageConvolveMask(mask, mask, PM_SUBTRACTION_MASK_BAD_2, 149 PM_SUBTRACTION_MASK_CONVOLVE_2, 147 if (!psImageConvolveMask(mask, mask, PM_SUBTRACTION_MASK_BAD_2, PM_SUBTRACTION_MASK_CONVOLVE_2, 150 148 -size, size, -size, size)) { 151 149 psError(PS_ERR_UNKNOWN, false, "Unable to convolve bad pixels from mask 2."); -
trunk/psModules/src/imcombine/pmSubtractionMatch.c
r23740 r23849 72 72 { 73 73 psTrace("psModules.imcombine", 3, "Finding stamps...\n"); 74 *stamps = pmSubtractionStampsFind(*stamps, ro1->image, subMask, region, threshold, footprint,74 *stamps = pmSubtractionStampsFind(*stamps, ro1->image, subMask, region, threshold, size, footprint, 75 75 stampSpacing, mode); 76 76 if (!*stamps) { … … 419 419 420 420 if (sources) { 421 stamps = pmSubtractionStampsSetFromSources(sources, ro1->image, subMask, region, footprint,422 stampSpacing, subMode);421 stamps = pmSubtractionStampsSetFromSources(sources, ro1->image, subMask, region, size, 422 footprint, stampSpacing, subMode); 423 423 } else if (stampsName && strlen(stampsName) > 0) { 424 stamps = pmSubtractionStampsSetFromFile(stampsName, ro1->image, subMask, region, footprint,425 stampSpacing, subMode);424 stamps = pmSubtractionStampsSetFromFile(stampsName, ro1->image, subMask, region, size, 425 footprint, stampSpacing, subMode); 426 426 } 427 427 -
trunk/psModules/src/imcombine/pmSubtractionStamps.c
r23839 r23849 80 80 // Is this position unmasked? 81 81 static bool checkStampMask(int x, int y, // Coordinates of stamp 82 int numCols, int numRows, // Size of image 82 83 const psImage *mask, // Mask 83 84 pmSubtractionMode mode, // Mode for subtraction 84 int footprint // Footprint to check for Bad Stuff 85 int footprint, // Size of stamp 86 int border // Size of border 85 87 ) 86 88 { 89 // Check the footprint bounds 90 if (x < border || x >= numCols - border || y < border || y >= numRows - border) { 91 if (mask) { 92 goto BAD_STAMP; 93 } 94 return false; 95 } 96 87 97 if (!mask) { 88 98 return true; 89 99 } 90 100 91 bool clean = true; // Is the footprint clean?92 int numCols = mask->numCols, numRows = mask->numRows; // Size of image93 94 int xMin = PS_MAX(x - footprint, 0), xMax = PS_MIN(x + footprint, numCols - 1); // Bounds in x95 int yMin = PS_MAX(y - footprint, 0), yMax = PS_MIN(y + footprint, numRows - 1); // Bounds in y96 97 // Check the footprint bounds98 if (x < footprint || x >= numCols - footprint || y < footprint || y >= numRows - footprint) {99 clean = false;100 goto CHECK_STAMP_MASK_DONE;101 102 }103 104 101 // Determine mask value 105 psImageMaskType maskVal = PM_SUBTRACTION_MASK_BORDER | PM_SUBTRACTION_MASK_BAD_1 | PM_SUBTRACTION_MASK_BAD_2; 102 psImageMaskType maskVal = PM_SUBTRACTION_MASK_BAD_1 | PM_SUBTRACTION_MASK_BAD_2 | 103 PM_SUBTRACTION_MASK_BORDER; // Mask value to check for 106 104 switch (mode) { 107 105 case PM_SUBTRACTION_MODE_1: 108 maskVal |= PM_SUBTRACTION_MASK_CONVOLVE_1 ;106 maskVal |= PM_SUBTRACTION_MASK_CONVOLVE_1 | PM_SUBTRACTION_MASK_CONVOLVE_BAD_1; 109 107 break; 110 108 case PM_SUBTRACTION_MODE_2: 111 maskVal |= PM_SUBTRACTION_MASK_CONVOLVE_2 ;109 maskVal |= PM_SUBTRACTION_MASK_CONVOLVE_2 | PM_SUBTRACTION_MASK_CONVOLVE_BAD_2; 112 110 break; 113 111 case PM_SUBTRACTION_MODE_UNSURE: 114 112 case PM_SUBTRACTION_MODE_DUAL: 115 maskVal |= PM_SUBTRACTION_MASK_CONVOLVE_1 | PM_SUBTRACTION_MASK_CONVOLVE_2; 113 maskVal |= PM_SUBTRACTION_MASK_CONVOLVE_1 | PM_SUBTRACTION_MASK_CONVOLVE_BAD_1 | 114 PM_SUBTRACTION_MASK_CONVOLVE_2 | PM_SUBTRACTION_MASK_CONVOLVE_BAD_2; 116 115 break; 117 116 default: … … 119 118 } 120 119 121 // Check the immediate pixel 122 if (clean && (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & (maskVal | PM_SUBTRACTION_MASK_REJ))) { 123 goto CHECK_STAMP_MASK_DONE; 124 clean = false; 120 // Check the central pixel 121 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & (maskVal | PM_SUBTRACTION_MASK_REJ)) { 122 goto BAD_STAMP; 125 123 } 126 124 127 125 // Check the footprint 128 if (clean) { 129 for (int j = yMin; j <= yMax; j++) { 130 for (int i = xMin; i <= xMax; i++) { 131 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] & maskVal) { 132 clean = false; 133 goto CHECK_STAMP_MASK_DONE; 134 } 126 int xMin = PS_MAX(x - footprint, 0), xMax = PS_MIN(x + footprint, numCols - 1); // Bounds in x 127 int yMin = PS_MAX(y - footprint, 0), yMax = PS_MIN(y + footprint, numRows - 1); // Bounds in y 128 for (int j = yMin; j <= yMax; j++) { 129 for (int i = xMin; i <= xMax; i++) { 130 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] & maskVal) { 131 goto BAD_STAMP; 135 132 } 136 133 } 137 134 } 138 135 139 CHECK_STAMP_MASK_DONE: 140 if (!clean) { 141 // Mask the footprint, so we don't select something near it again 142 for (int j = yMin; j <= yMax; j++) { 143 for (int i = xMin; i <= xMax; i++) { 144 mask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= PM_SUBTRACTION_MASK_REJ; 145 } 146 } 147 } 148 149 return clean; 136 return true; 137 138 BAD_STAMP: 139 // Stamp is bad, so mark it as such so we don't find it again 140 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= PM_SUBTRACTION_MASK_REJ; 141 return false; 150 142 } 151 143 … … 279 271 pmSubtractionStampList *pmSubtractionStampsFind(pmSubtractionStampList *stamps, const psImage *image, 280 272 const psImage *subMask, const psRegion *region, 281 float threshold, int footprint, float spacing,273 float threshold, int size, int footprint, float spacing, 282 274 pmSubtractionMode mode) 283 275 { … … 289 281 PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_IMAGE_MASK, NULL); 290 282 } 283 PS_ASSERT_INT_POSITIVE(size, NULL); 291 284 PS_ASSERT_INT_NONNEGATIVE(footprint, NULL); 292 285 PS_ASSERT_FLOAT_LARGER_THAN(spacing, 0.0, NULL); … … 309 302 310 303 int numRows = image->numRows, numCols = image->numCols; // Size of image 304 int border = size + footprint; // Border size 311 305 312 306 if (!stamps) { … … 367 361 for (int x = subRegion->x0; x <= subRegion->x1; x++) { 368 362 if (image->data.F32[y][x] > fluxStamp && 369 checkStampMask(x, y, subMask, mode, footprint)) {363 checkStampMask(x, y, numCols, numRows, subMask, mode, footprint, border)) { 370 364 fluxStamp = image->data.F32[y][x]; 371 365 xStamp = x; … … 419 413 pmSubtractionStampList *pmSubtractionStampsSet(const psVector *x, const psVector *y, 420 414 const psImage *image, const psImage *subMask, 421 const psRegion *region, int footprint, float spacing,422 pmSubtractionMode mode)415 const psRegion *region, int size, int footprint, 416 float spacing, pmSubtractionMode mode) 423 417 424 418 { … … 432 426 PS_ASSERT_IMAGE_NON_NULL(subMask, NULL); 433 427 PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_IMAGE_MASK, NULL); 434 if (image) { 435 PS_ASSERT_IMAGE_NON_NULL(image, NULL); 436 PS_ASSERT_IMAGES_SIZE_EQUAL(image, subMask, NULL); 437 } 438 } 428 PS_ASSERT_IMAGES_SIZE_EQUAL(image, subMask, NULL); 429 } 430 PS_ASSERT_INT_POSITIVE(size, NULL); 431 PS_ASSERT_INT_POSITIVE(footprint, NULL); 439 432 PS_ASSERT_FLOAT_LARGER_THAN(spacing, 0.0, NULL); 440 433 … … 443 436 region, footprint, spacing); // Stamp list 444 437 int numStamps = stamps->num; // Number of stamps 438 int numCols = image->numCols, numRows = image->numRows; // Size of image 439 int border = footprint + size; // Border size 445 440 446 441 psString ds9name = NULL; // Filename for ds9 region file … … 471 466 continue; 472 467 } 473 if (!checkStampMask(xPix, yPix, subMask, mode, footprint)) {468 if (!checkStampMask(xPix, yPix, numCols, numRows, subMask, mode, footprint, border)) { 474 469 // Not a good stamp 475 470 psTrace("psModules.imcombine", 9, "Rejecting input stamp (%d,%d) because bad mask", … … 613 608 pmSubtractionStampList *pmSubtractionStampsSetFromSources(const psArray *sources, const psImage *image, 614 609 const psImage *subMask, const psRegion *region, 615 int footprint, float spacing,610 int size, int footprint, float spacing, 616 611 pmSubtractionMode mode) 617 612 { … … 642 637 y->n = numOut; 643 638 644 pmSubtractionStampList *stamps = pmSubtractionStampsSet(x, y, image, subMask, region, 639 pmSubtractionStampList *stamps = pmSubtractionStampsSet(x, y, image, subMask, region, size, 645 640 footprint, spacing, mode); // Stamps to return 646 641 psFree(x); … … 657 652 pmSubtractionStampList *pmSubtractionStampsSetFromFile(const char *filename, const psImage *image, 658 653 const psImage *subMask, const psRegion *region, 659 int footprint, float spacing, pmSubtractionMode mode) 654 int size, int footprint, float spacing, 655 pmSubtractionMode mode) 660 656 { 661 657 PS_ASSERT_STRING_NON_EMPTY(filename, NULL); … … 673 669 psBinaryOp(y, y, "-", psScalarAlloc(1.0, PS_TYPE_F32)); 674 670 675 pmSubtractionStampList *stamps = pmSubtractionStampsSet(x, y, image, subMask, region, footprint,671 pmSubtractionStampList *stamps = pmSubtractionStampsSet(x, y, image, subMask, region, size, footprint, 676 672 spacing, mode); 677 673 psFree(data); -
trunk/psModules/src/imcombine/pmSubtractionStamps.h
r23839 r23849 78 78 const psRegion *region, ///< Region to search, or NULL 79 79 float threshold, ///< Threshold for stamps in the image 80 int size, ///< Kernel half-size 80 81 int footprint, ///< Half-size for stamps 81 82 float spacing, ///< Rough spacing for stamps … … 89 90 const psImage *mask, ///< Mask, or NULL 90 91 const psRegion *region, ///< Region to search, or NULL 92 int size, ///< Kernel half-size 91 93 int footprint, ///< Half-size for stamps 92 94 float spacing, ///< Rough spacing for stamps … … 100 102 const psImage *subMask, ///< Mask, or NULL 101 103 const psRegion *region, ///< Region to search, or NULL 104 int size, ///< Kernel half-size 102 105 int footprint, ///< Half-size for stamps 103 106 float spacing, ///< Rough spacing for stamps … … 111 114 const psImage *subMask, ///< Mask, or NULL 112 115 const psRegion *region, ///< Region to search, or NULL 116 int size, ///< Kernel half-size 113 117 int footprint, ///< Half-size for stamps 114 118 float spacing, ///< Rough spacing for stamps
Note:
See TracChangeset
for help on using the changeset viewer.
