Index: /trunk/psModules/src/imcombine/pmSubtractionStamps.c
===================================================================
--- /trunk/psModules/src/imcombine/pmSubtractionStamps.c	(revision 13364)
+++ /trunk/psModules/src/imcombine/pmSubtractionStamps.c	(revision 13365)
@@ -42,5 +42,5 @@
 psArray *pmSubtractionFindStamps(psArray *stamps, const psImage *image, const psImage *mask,
                                  psMaskType maskVal, psMaskType used, float threshold,
-                                 float spacing, int footprint)
+                                 float spacing, int border)
 {
     PS_ASSERT_IMAGE_NON_NULL(image, NULL);
@@ -56,10 +56,10 @@
     }
     PS_ASSERT_FLOAT_LARGER_THAN(spacing, 0.0, NULL);
-    PS_ASSERT_INT_NONNEGATIVE(footprint, NULL);
-    PS_ASSERT_INT_LARGER_THAN(image->numCols, (2 * footprint), NULL);
-    PS_ASSERT_INT_LARGER_THAN(image->numRows, (2 * footprint), NULL);
+    PS_ASSERT_INT_NONNEGATIVE(border, NULL);
+    PS_ASSERT_INT_LARGER_THAN(image->numCols, 2 * border, NULL);
+    PS_ASSERT_INT_LARGER_THAN(image->numRows, 2 * border, NULL);
 
-    int xNumStamps = image->numCols / spacing + 1; // Number of stamps in x dimension
-    int yNumStamps = image->numRows / spacing + 1; // Number of stamps in y dimension
+    int xNumStamps = (image->numCols - 2 * border) / spacing + 1; // Number of stamps in x
+    int yNumStamps = (image->numRows - 2 * border) / spacing + 1; // Number of stamps in y
 
     if (stamps) {
@@ -95,9 +95,10 @@
 
                 // Bounds of region to search for stamp
-                int yMin = footprint + j * (numRows - 2.0 * footprint) / yNumStamps;
-                int yMax = footprint + (j + 1) * (numRows - 2.0 * footprint) / yNumStamps - 1;
-                int xMin = footprint + i * (numCols - 2.0 * footprint) / xNumStamps;
-                int xMax = footprint + (i + 1) * (numCols - 2.0 * footprint) / xNumStamps - 1;
-                assert(yMax < image->numRows && xMax < image->numCols && yMin >= 0 && xMin >= 0);
+                int yMin = border + j * (numRows - border) / (yNumStamps + 1);
+                int yMax = border + (j + 1) * (numRows - border) / (yNumStamps + 1) - 1;
+                int xMin = border + i * (numCols - border) / (xNumStamps + 1);
+                int xMax = border + (i + 1) * (numCols - border) / (xNumStamps + 1) - 1;
+                assert(yMax < image->numRows - border && xMax < image->numCols - border &&
+                       yMin >= border && xMin >= border);
 
                 for (int y = yMin; y <= yMax ; y++) {
@@ -107,11 +108,15 @@
                             if (mask) {
                                 // Check kernel footprint for bad pixels
-                                if (mask->data.U8[y][x] & maskVal) {
+                                if (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
                                     ok = false;
                                 } else {
-                                    for (int v = -footprint; v <= footprint && ok; v++) {
-                                        for (int u = -footprint; u <= footprint && ok; u++) {
-                                            if (mask->data.U8[y][x] & maskVal) {
+                                    for (int v = -border; v <= border && ok; v++) {
+                                        for (int u = -border; u <= border && ok; u++) {
+                                            if (mask->data.PS_TYPE_MASK_DATA[y + v][x + u] & maskVal) {
                                                 ok = false;
+#if 0
+                                                // Mark it so we don't have to look so hard next time
+                                                mask->data.PS_TYPE_MASK_DATA[y][x] |= maskVal;
+#endif
                                             }
                                         }
Index: /trunk/psModules/src/imcombine/pmSubtractionStamps.h
===================================================================
--- /trunk/psModules/src/imcombine/pmSubtractionStamps.h	(revision 13364)
+++ /trunk/psModules/src/imcombine/pmSubtractionStamps.h	(revision 13365)
@@ -30,5 +30,5 @@
                                  float threshold, ///< Threshold for stamps in the image
                                  float spacing, ///< Rough spacing for stamps
-                                 int footprint ///< Half-size of stamp footprint
+                                 int border ///< Size of border around image; no stamps in border
     );
 
