Index: /trunk/psModules/src/imcombine/pmSubtraction.c
===================================================================
--- /trunk/psModules/src/imcombine/pmSubtraction.c	(revision 19270)
+++ /trunk/psModules/src/imcombine/pmSubtraction.c	(revision 19271)
@@ -369,10 +369,12 @@
 
         if (box > 0) {
+            int colMin = region.x0, colMax = region.x1, rowMin = region.y0, rowMax = region.y1; // Bounds
+
             bool threaded = pmSubtractionThreaded(); // Are we running threaded?
             if (threaded) {
                 psMutexLock(subMask);
             }
-            psImage *image = psImageSubset(subMask, psRegionSet(region.x0 + xMin, region.x1 + xMax,
-                                                                region.y0 + yMin, region.y1 + yMax));
+            psImage *image = psImageSubset(subMask, psRegionSet(colMin - box, colMax + box,
+                                                                rowMin - box, rowMax + box));
             if (threaded) {
                 psMutexUnlock(subMask);
@@ -390,6 +392,7 @@
             }
 
-            int colMin = region.x0, colMax = region.x1, rowMin = region.y0, rowMax = region.y1; // Bounds
             int numBytes = (colMax - colMin) * PSELEMTYPE_SIZEOF(PS_TYPE_MASK); // Number of bytes to copy
+            psAssert(convolved->numCols - 2 * box == colMax - colMin, "Bad number of columns");
+            psAssert(convolved->numRows - 2 * box == rowMax - rowMin, "Bad number of rows");
 
             // Since we're copying back into the source, we need to lock
@@ -397,7 +400,7 @@
                 psMutexLock(subMask);
             }
-            for (int yTarget = rowMin, ySource = -yMin; yTarget < rowMax; yTarget++, ySource++) {
+            for (int yTarget = rowMin, ySource = box; yTarget < rowMax; yTarget++, ySource++) {
                 memcpy(&subMask->data.PS_TYPE_MASK_DATA[yTarget][colMin],
-                       &convolved->data.PS_TYPE_MASK_DATA[ySource][-xMin], numBytes);
+                       &convolved->data.PS_TYPE_MASK_DATA[ySource][box], numBytes);
             }
             if (threaded) {
