Changeset 26893 for trunk/psModules/src/imcombine/pmSubtractionMask.c
- Timestamp:
- Feb 10, 2010, 7:34:39 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/imcombine/pmSubtractionMask.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtractionMask.c
r24257 r26893 38 38 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 39 39 40 psImage *pmSubtractionMask(const psImage *mask1, const psImage *mask2, psImageMaskType maskVal, 41 int size, int footprint, float badFrac, pmSubtractionMode mode) 42 { 43 PS_ASSERT_IMAGE_NON_NULL(mask1, NULL); 44 PS_ASSERT_IMAGE_TYPE(mask1, PS_TYPE_IMAGE_MASK, NULL); 45 if (mask2) { 46 PS_ASSERT_IMAGE_NON_NULL(mask2, NULL); 47 PS_ASSERT_IMAGE_TYPE(mask2, PS_TYPE_IMAGE_MASK, NULL); 48 PS_ASSERT_IMAGES_SIZE_EQUAL(mask2, mask1, NULL); 49 } 40 psImage *pmSubtractionMask(psRegion *bounds, const pmReadout *ro1, const pmReadout *ro2, 41 psImageMaskType maskVal, int size, int footprint, float badFrac, 42 pmSubtractionMode mode) 43 { 44 PM_ASSERT_READOUT_NON_NULL(ro1, NULL); 45 PM_ASSERT_READOUT_IMAGE(ro1, NULL); 46 PM_ASSERT_READOUT_MASK(ro1, NULL); 47 PM_ASSERT_READOUT_NON_NULL(ro2, NULL); 48 PM_ASSERT_READOUT_IMAGE(ro2, NULL); 49 PM_ASSERT_READOUT_MASK(ro2, NULL); 50 PS_ASSERT_IMAGES_SIZE_EQUAL(ro1->image, ro2->image, NULL); 50 51 PS_ASSERT_INT_NONNEGATIVE(size, NULL); 51 52 PS_ASSERT_INT_NONNEGATIVE(footprint, NULL); … … 55 56 } 56 57 57 int numCols = mask1->numCols, numRows = mask1->numRows; // Size of the images58 int numCols = ro1->image->numCols, numRows = ro1->image->numRows; // Size of the images 58 59 59 60 // Dereference inputs for convenience 60 psImageMaskType **data1 = mask1->data.PS_TYPE_IMAGE_MASK_DATA; 61 psImageMaskType **data2 = NULL; 62 if (mask2) { 63 data2 = mask2->data.PS_TYPE_IMAGE_MASK_DATA; 64 } 61 psF32 **imageData1 = ro1->image->data.F32, **imageData2 = ro2->image->data.F32; 62 psImageMaskType **maskData1 = ro1->mask->data.PS_TYPE_IMAGE_MASK_DATA, 63 **maskData2 = ro2->mask->data.PS_TYPE_IMAGE_MASK_DATA; 65 64 66 65 // First, a pass through to determine the fraction of bad pixels 67 if (isfinite(badFrac) && badFrac != 1.0) { 66 if (bounds || (isfinite(badFrac) && badFrac != 1.0)) { 67 int xMin = numCols, xMax = 0, yMin = numRows, yMax = 0; // Bounds of good pixels 68 68 int numBad = 0; // Number of bad pixels 69 69 for (int y = 0; y < numRows; y++) { 70 70 for (int x = 0; x < numCols; x++) { 71 if ( data1[y][x] & maskVal) {71 if ((maskData1[y][x] & maskVal) || !isfinite(imageData1[y][x])) { 72 72 numBad++; 73 73 continue; 74 74 } 75 if ( data2 && data2[y][x] & maskVal) {75 if ((maskData2[y][x] & maskVal) || !isfinite(imageData2[y][x])) { 76 76 numBad++; 77 continue; 77 78 } 78 } 79 } 80 if (numBad > badFrac * numCols * numRows) { 79 xMin = PS_MIN(xMin, x); 80 xMax = PS_MAX(xMax, x); 81 yMin = PS_MIN(yMin, y); 82 yMax = PS_MAX(yMax, y); 83 } 84 } 85 if (bounds) { 86 bounds->x0 = xMin; 87 bounds->x1 = xMax; 88 bounds->y0 = yMin; 89 bounds->y1 = yMax; 90 } 91 if (isfinite(badFrac) && badFrac != 1.0 && numBad > badFrac * numCols * numRows) { 81 92 psError(PM_ERR_SMALL_AREA, true, 82 93 "Fraction of bad pixels (%d/%d=%f) exceeds limit (%f)\n", … … 117 128 for (int y = 0; y < numRows; y++) { 118 129 for (int x = 0; x < numCols; x++) { 119 if ( data1[y][x] & maskVal) {130 if (maskData1[y][x] & maskVal) { 120 131 maskData[y][x] |= PM_SUBTRACTION_MASK_BAD_1; 121 132 } 122 if ( data2 && data2[y][x] & maskVal) {133 if (maskData2[y][x] & maskVal) { 123 134 maskData[y][x] |= PM_SUBTRACTION_MASK_BAD_2; 124 135 }
Note:
See TracChangeset
for help on using the changeset viewer.
