Index: trunk/psModules/src/imcombine/pmStackReject.c
===================================================================
--- trunk/psModules/src/imcombine/pmStackReject.c	(revision 27307)
+++ trunk/psModules/src/imcombine/pmStackReject.c	(revision 27319)
@@ -10,4 +10,6 @@
 #include "pmSubtractionThreads.h"
 #include "pmSubtractionKernels.h"
+
+#include "pmStackReject.h"
 
 #define PIXEL_LIST_BUFFER 100           // Number of pixels to add to list at a time
@@ -115,6 +117,6 @@
 
 
-psPixels *pmStackReject(const psPixels *in, int numCols, int numRows, float threshold, float poorFrac,
-                        int stride, const psArray *subRegions, const psArray *subKernels)
+psPixels *pmStackReject(const psPixels *in, int numCols, int numRows, float threshold, int stride,
+                        const psArray *subRegions, const psArray *subKernels)
 {
     PS_ASSERT_PIXELS_NON_NULL(in, NULL);
@@ -223,6 +225,17 @@
     psTrace("psModules.imcombine", 7, "Found %ld bad pixels", bad->n);
 
-    // Now, grow the mask to include everything that touches a bad pixel in the convolution
-    psImage *source = psPixelsToMask(NULL, bad, psRegionSet(0, numCols - 1, 0, numRows - 1),
+    return bad;
+}
+
+
+psPixels *pmStackRejectGrow(const psPixels *in, int numCols, int numRows, float poorFrac,
+                            const psArray *subRegions, const psArray *subKernels)
+{
+    PS_ASSERT_PIXELS_NON_NULL(in, NULL);
+    PS_ASSERT_ARRAY_NON_NULL(subRegions, NULL);
+    PS_ASSERT_ARRAY_NON_NULL(subKernels, NULL);
+    PS_ASSERT_ARRAYS_SIZE_EQUAL(subRegions, subKernels, NULL);
+
+    psImage *source = psPixelsToMask(NULL, in, psRegionSet(0, numCols - 1, 0, numRows - 1),
                                      PM_STACK_MASK_BAD); // Mask image to grow
 
@@ -243,5 +256,5 @@
     bool oldThreads = psImageConvolveSetThreads(false); // Old value of threading for psImageColvolve
 
-    psImage *target = psImageRecycle(convolved, numCols, numRows, PS_TYPE_IMAGE_MASK); // Grown image
+    psImage *target = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); // Grown image
     psImageInit(target, 0);
     for (int i = 0; i < subRegions->n; i++) {
@@ -326,5 +339,5 @@
 
     psFree(source);
-    bad = psPixelsFromMask(bad, target, PM_STACK_MASK_ALL);
+    psPixels *bad = psPixelsFromMask(NULL, target, PM_STACK_MASK_ALL); // All bad pixels
     psFree(target);
     psTrace("psModules.imcombine", 7, "Total %ld bad pixels", bad->n);
