Changeset 14455 for trunk/psModules/src/imcombine/pmSubtractionStamps.c
- Timestamp:
- Aug 9, 2007, 10:25:52 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtractionStamps.c
r14342 r14455 42 42 43 43 psArray *pmSubtractionFindStamps(psArray *stamps, const psImage *image, const psImage *subMask, 44 float threshold, float spacing)44 const psRegion *region, float threshold, float spacing) 45 45 { 46 46 PS_ASSERT_IMAGE_NON_NULL(image, NULL); … … 52 52 } 53 53 PS_ASSERT_FLOAT_LARGER_THAN(spacing, 0.0, NULL); 54 if (region) { 55 if (psRegionIsNaN(*region)) { 56 psString string = psRegionToString(*region); 57 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Input region (%s) contains NAN values", string); 58 psFree(string); 59 return false; 60 } 61 if (region->x0 < 0 || region->x1 > image->numCols || 62 region->y0 < 0 || region->y1 > image->numRows) { 63 psString string = psRegionToString(*region); 64 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Input region (%s) does not fit in image (%dx%d)", 65 string, image->numCols, image->numRows); 66 psFree(string); 67 return false; 68 } 69 } 54 70 55 // Size of image 56 int numRows = image->numRows; 57 int numCols = image->numCols; 71 int numRows = image->numRows, numCols = image->numCols; // Size of image 72 73 // Get region in which to find stamps: [xMin:xMax,yMin:yMax] 74 int xMin = 0, xMax = numCols, yMin = 0, yMax = numRows; 75 if (region) { 76 xMin = PS_MAX(region->x0, xMin); 77 xMax = PS_MIN(region->x1, xMax); 78 yMin = PS_MAX(region->y0, yMin); 79 yMax = PS_MIN(region->y1, yMax); 80 } 81 int xSize = xMax - xMin, ySize = yMax - yMin; // Size of region of interest 58 82 59 83 // Number of stamps 60 int xNumStamps = numCols/ spacing + 1;61 int yNumStamps = numRows/ spacing + 1;84 int xNumStamps = xSize / spacing + 1; 85 int yNumStamps = ySize / spacing + 1; 62 86 63 87 int numFound = 0; // Number of stamps found … … 92 116 93 117 // Bounds of region to search for stamp 94 int y Min = j * numRows/ (yNumStamps + 1);95 int y Max = (j + 1) * numRows/ (yNumStamps + 1) - 1;96 int x Min = i * numCols/ (xNumStamps + 1);97 int x Max = (i + 1) * numCols/ (xNumStamps + 1) - 1;98 assert(y Max < image->numRows && xMax < image->numCols && yMin >= 0 && xMin>= 0);118 int yStart = yMin + j * ySize / (yNumStamps + 1); 119 int yStop = yMin + (j + 1) * ySize / (yNumStamps + 1) - 1; 120 int xStart = xMin + i * xSize / (xNumStamps + 1); 121 int xStop = xMin + (i + 1) * xSize / (xNumStamps + 1) - 1; 122 assert(yStop < numRows && xStop < numCols && yStart >= 0 && xStart >= 0); 99 123 100 for (int y = y Min; y <= yMax; y++) {101 for (int x = x Min; x <= xMax; x++) {124 for (int y = yStart; y <= yStop ; y++) { 125 for (int x = xStart; x <= xStop ; x++) { 102 126 if ((!subMask || !(subMask->data.PS_TYPE_MASK_DATA[y][x] & 103 127 (PM_SUBTRACTION_MASK_BORDER | PM_SUBTRACTION_MASK_FOOTPRINT |
Note:
See TracChangeset
for help on using the changeset viewer.
