Changeset 14106 for trunk/psModules/src/imcombine/pmSubtractionStamps.c
- Timestamp:
- Jul 10, 2007, 1:54:26 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtractionStamps.c
r13735 r14106 6 6 #include <pslib.h> 7 7 8 #include "pmSubtraction.h"9 8 #include "pmSubtractionStamps.h" 10 9 … … 40 39 } 41 40 42 psArray *pmSubtractionFindStamps(psArray *stamps, const psImage *image, const psImage *subMask, 43 float threshold, float spacing) 41 42 psArray *pmSubtractionFindStamps(psArray *stamps, const psImage *image, const psImage *mask, 43 psMaskType maskVal, psMaskType used, float threshold, 44 float spacing, int border) 44 45 { 45 46 PS_ASSERT_IMAGE_NON_NULL(image, NULL); 46 47 PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, 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); 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; 51 56 } 52 57 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); 53 61 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; 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 61 65 62 66 if (stamps) { … … 74 78 } 75 79 } 80 // Footprint of image 81 int numRows = image->numRows; 82 int numCols = image->numCols; 76 83 77 84 for (int j = 0, index = 0; j < yNumStamps; j++) { … … 89 96 90 97 // Bounds of region to search for stamp 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);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); 97 104 98 105 for (int y = yMin; y <= yMax ; y++) { 99 106 for (int x = xMin; x <= xMax ; x++) { 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; 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 } 107 133 } 108 134 }
Note:
See TracChangeset
for help on using the changeset viewer.
