Index: trunk/psModules/src/objects/pmFootprintArrayGrow.c
===================================================================
--- trunk/psModules/src/objects/pmFootprintArrayGrow.c	(revision 18828)
+++ trunk/psModules/src/objects/pmFootprintArrayGrow.c	(revision 18867)
@@ -3,6 +3,6 @@
  * @author RHL, Princeton & IfA; EAM, IfA
  *
- * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-08-01 00:00:17 $
+ * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2008-08-02 01:29:09 $
  * Copyright 2006 Institute for Astronomy, University of Hawaii
  */
@@ -26,11 +26,11 @@
  */
 psArray *pmFootprintArrayGrow(const psArray *footprints, // footprints to grow
-			      int r) {	// how much to grow each footprint
+                              int r) {  // how much to grow each footprint
     assert (footprints->n == 0 || pmFootprintTest(footprints->data[0]));
 
     psTimerStart ("grow");
 
-    if (footprints->n == 0) {		// we don't know the size of the footprint's region
-	return psArrayAlloc(0);
+    if (footprints->n == 0) {           // we don't know the size of the footprint's region
+        return psArrayAlloc(0);
     }
     /*
@@ -41,21 +41,28 @@
     psLogMsg ("psphot", PS_LOG_DETAIL, "set footprint array IDs: %f sec\n", psTimerMark ("grow"));
 
+#if 1
+    // Use a separable convolution: should be faster
+    idImage = (psImage*)psBinaryOp(idImage, idImage, "MAX", psScalarAlloc(1, PS_TYPE_S32));
+    psImage *maskImage = psImageCopy(NULL, idImage, PS_TYPE_MASK);
+    psImage *grownIdImage = psImageConvolveMask(NULL, maskImage, 0xff, 0xff, -1, 1, -1, 1);
+    psFree(maskImage);
+#else
     if (r <= 0) {
-	r = 1;				// r == 1 => no grow
+        r = 1;                          // r == 1 => no grow
     }
     psKernel *circle = psKernelAlloc(-r, r, -r, r);
     assert (circle->image->numRows == 2*r + 1 && circle->image->numCols == circle->image->numRows);
     for (int i = 0; i <= r; i++) {
-	for (int j = 0; j <= r; j++) {
-	    if (i*i + j*j <= r*r) {
-		circle->kernel[i][j] = 
-		    circle->kernel[i][-j] = 
-		    circle->kernel[-i][j] = 
-		    circle->kernel[-i][-j] = 1;
-	    }
-	}
+        for (int j = 0; j <= r; j++) {
+            if (i*i + j*j <= r*r) {
+                circle->kernel[i][j] =
+                    circle->kernel[i][-j] =
+                    circle->kernel[-i][j] =
+                    circle->kernel[-i][-j] = 1;
+            }
+        }
     }
 
-# if (USE_FFTS_TO_CONVOLVE)    
+# if (USE_FFTS_TO_CONVOLVE)
     psImage *f32ImageIn = psImageCopy (NULL, idImage, PS_TYPE_F32);
     psImage *f32ImageOut = psImageConvolveFFT(NULL, f32ImageIn, NULL, 0, circle);
@@ -63,10 +70,13 @@
     psFree (f32ImageIn);
     psFree (f32ImageOut);
-# else
+#else
     psImage *grownIdImage = psImageConvolveDirect(NULL, idImage, circle); // Here's the actual grow step
-# endif
+#endif // USE_FFTS_TO_CONVOLVE
+    psFree(circle);
+#endif // Don't bother at all
+
+    psFree(idImage);
 
     psLogMsg ("psphot", PS_LOG_DETAIL, "convolved with grow disc: %f sec\n", psTimerMark ("grow"));
-    psFree(circle);	
 
     psArray *grown = pmFootprintsFind(grownIdImage, 0.5, 1); // and here we rebuild the grown footprints
@@ -74,5 +84,4 @@
 
     assert (grown != NULL);
-    psFree(idImage); 
     psFree(grownIdImage);
 
@@ -88,5 +97,5 @@
 
     return grown;
-    
+
 }
 
