Changeset 14195 for trunk/psModules/src/imcombine/pmSubtractionStamps.c
- Timestamp:
- Jul 13, 2007, 10:28:28 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtractionStamps.c
r14106 r14195 6 6 #include <pslib.h> 7 7 8 #include "pmSubtraction.h" 8 9 #include "pmSubtractionStamps.h" 9 10 … … 40 41 41 42 42 psArray *pmSubtractionFindStamps(psArray *stamps, const psImage *image, const psImage *mask, 43 psMaskType maskVal, psMaskType used, float threshold, 44 float spacing, int border) 43 psArray *pmSubtractionFindStamps(psArray *stamps, const psImage *image, const psImage *subMask, 44 float threshold, float spacing) 45 45 { 46 46 PS_ASSERT_IMAGE_NON_NULL(image, NULL); 47 47 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; 48 if (subMask) { 49 PS_ASSERT_IMAGE_NON_NULL(subMask, NULL); 50 PS_ASSERT_IMAGES_SIZE_EQUAL(image, subMask, NULL); 51 PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_MASK, NULL); 56 52 } 57 53 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 54 62 maskVal |= used; // Make sure we don't get stamps we've 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 55 // Size of image 56 int numRows = image->numRows; 57 int numCols = image->numCols; 58 59 // Number of stamps 60 int xNumStamps = numCols / spacing + 1; 61 int yNumStamps = numRows / spacing + 1; 65 62 66 63 if (stamps) { … … 78 75 } 79 76 } 80 // Footprint of image81 int numRows = image->numRows;82 int numCols = image->numCols;83 77 84 78 for (int j = 0, index = 0; j < yNumStamps; j++) { … … 96 90 97 91 // 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); 92 int yMin = j * numRows / (yNumStamps + 1); 93 int yMax = (j + 1) * numRows / (yNumStamps + 1) - 1; 94 int xMin = i * numCols / (xNumStamps + 1); 95 int xMax = (i + 1) * numCols / (xNumStamps + 1) - 1; 96 assert(yMax < image->numRows && xMax < image->numCols && 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 if (mask) { 110 // Check kernel footprint for bad pixels 111 if (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) { 112 ok = false; 113 } else { 114 for (int v = -border; v <= border && ok; v++) { 115 for (int u = -border; u <= border && ok; u++) { 116 if (mask->data.PS_TYPE_MASK_DATA[y + v][x + u] & maskVal) { 117 ok = false; 118 #if 0 119 // Mark it so we don't have to look so hard next time 120 mask->data.PS_TYPE_MASK_DATA[y][x] |= maskVal; 121 #endif 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.
