Changeset 13735 for trunk/psModules/src/imcombine/pmSubtractionStamps.c
- Timestamp:
- Jun 8, 2007, 3:04:02 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtractionStamps.c
r13510 r13735 6 6 #include <pslib.h> 7 7 8 #include "pmSubtraction.h" 8 9 #include "pmSubtractionStamps.h" 9 10 … … 39 40 } 40 41 41 42 psArray *pmSubtractionFindStamps(psArray *stamps, const psImage *image, const psImage *mask, 43 psMaskType maskVal, psMaskType used, float threshold, 44 float spacing, int border) 42 psArray *pmSubtractionFindStamps(psArray *stamps, const psImage *image, const psImage *subMask, 43 float threshold, float spacing) 45 44 { 46 45 PS_ASSERT_IMAGE_NON_NULL(image, NULL); 47 46 PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, NULL); 48 if (mask) { 49 PS_ASSERT_IMAGE_NON_NULL(mask, NULL); 50 PS_ASSERT_IMAGES_SIZE_EQUAL(image, mask, NULL); 51 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL); 52 } 53 if (used == 0) { 54 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "The mask value for used stamps cannot be zero."); 55 return NULL; 47 if (subMask) { 48 PS_ASSERT_IMAGE_NON_NULL(subMask, NULL); 49 PS_ASSERT_IMAGES_SIZE_EQUAL(image, subMask, NULL); 50 PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_MASK, NULL); 56 51 } 57 52 PS_ASSERT_FLOAT_LARGER_THAN(spacing, 0.0, NULL); 58 PS_ASSERT_INT_NONNEGATIVE(border, NULL);59 PS_ASSERT_INT_LARGER_THAN(image->numCols, 2 * border, NULL);60 PS_ASSERT_INT_LARGER_THAN(image->numRows, 2 * border, NULL);61 53 62 psMaskType badCentral = maskVal | used; // For central pixel of stamp, don't get a stamp already used 63 int xNumStamps = (image->numCols - 2 * border) / spacing + 1; // Number of stamps in x 64 int yNumStamps = (image->numRows - 2 * border) / spacing + 1; // Number of stamps in y 54 // Size of image 55 int numRows = image->numRows; 56 int numCols = image->numCols; 57 58 // Number of stamps 59 int xNumStamps = numCols / spacing + 1; 60 int yNumStamps = numRows / spacing + 1; 65 61 66 62 if (stamps) { … … 78 74 } 79 75 } 80 // Footprint of image81 int numRows = image->numRows;82 int numCols = image->numCols;83 76 84 77 for (int j = 0, index = 0; j < yNumStamps; j++) { … … 96 89 97 90 // Bounds of region to search for stamp 98 int yMin = border + j * (numRows - border)/ (yNumStamps + 1);99 int yMax = border + (j + 1) * (numRows - border)/ (yNumStamps + 1) - 1;100 int xMin = border + i * (numCols - border)/ (xNumStamps + 1);101 int xMax = border + (i + 1) * (numCols - border)/ (xNumStamps + 1) - 1;102 assert(yMax < image->numRows - border && xMax < image->numCols - border&&103 yMin >= border && xMin >= border);91 int yMin = j * numRows / (yNumStamps + 1); 92 int yMax = (j + 1) * numRows / (yNumStamps + 1) - 1; 93 int xMin = i * numCols / (xNumStamps + 1); 94 int xMax = (i + 1) * numCols / (xNumStamps + 1) - 1; 95 assert(yMax < image->numRows && xMax < image->numCols && 96 yMin >= 0 && xMin >= 0); 104 97 105 98 for (int y = yMin; y <= yMax ; y++) { 106 99 for (int x = xMin; x <= xMax ; x++) { 107 if (image->data.F32[y][x] > fluxBest) { 108 bool ok = true; 109 // Check kernel footprint for bad pixels 110 if (mask && (mask->data.PS_TYPE_MASK_DATA[y][x] & badCentral)) { 111 ok = false; 112 } else { 113 for (int v = -border; v <= border && ok; v++) { 114 for (int u = -border; u <= border && ok; u++) { 115 if ((mask && 116 (mask->data.PS_TYPE_MASK_DATA[y + v][x + u] & maskVal)) || 117 !isfinite(image->data.F32[y + v][x + u])) { 118 ok = false; 119 if (mask) { 120 // Mark it so we don't have to look so hard next time 121 mask->data.PS_TYPE_MASK_DATA[y][x] |= used; 122 } 123 } 124 } 125 } 126 } 127 128 if (ok) { 129 fluxBest = image->data.F32[y][x]; 130 xBest = x; 131 yBest = y; 132 } 100 if ((!subMask || !(subMask->data.PS_TYPE_MASK_DATA[y][x] & 101 (PM_SUBTRACTION_MASK_BORDER | PM_SUBTRACTION_MASK_FOOTPRINT | 102 PM_SUBTRACTION_MASK_REJ))) && 103 image->data.F32[y][x] > fluxBest) { 104 fluxBest = image->data.F32[y][x]; 105 xBest = x; 106 yBest = y; 133 107 } 134 108 }
Note:
See TracChangeset
for help on using the changeset viewer.
