Index: /trunk/psModules/src/imcombine/pmSubtraction.c
===================================================================
--- /trunk/psModules/src/imcombine/pmSubtraction.c	(revision 14866)
+++ /trunk/psModules/src/imcombine/pmSubtraction.c	(revision 14867)
@@ -4,6 +4,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.60 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-09-12 20:21:41 $
+ *  @version $Revision: 1.61 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-09-17 20:58:53 $
  *
  *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
@@ -360,4 +360,5 @@
 static void convolveFFT(psImage *target,// Place the result in here
                         const psImage *image, // Image to convolve
+                        const psImage *mask, // Mask image
                         const psKernel *kernel, // Kernel by which to convolve
                         psRegion region,// Region of interest
@@ -371,10 +372,11 @@
     // Casting away const so psImageSubset can add the child
     psImage *subImage = psImageSubset((psImage*)image, border); // Subimage to convolve
-    psImage *convolved = psImageConvolveFFT(subImage, kernel, 0.0); // Convolution
+    psImage *subMask = psImageSubset((psImage*)mask, border); // Subimage mask
+    psImage *convolved = psImageConvolveFFT(subImage, subMask, PM_SUBTRACTION_MASK_REF,
+                                            kernel, 0.0); // Convolution
     psFree(subImage);
 
     // Now, we have to chop off the borders, and stick it in where it belongs
-    psImage *subConv = psImageSubset(convolved, psRegionSet(size, -size,
-                                                            size, -size)); // Cut off the edges
+    psImage *subConv = psImageSubset(convolved, psRegionSet(size, -size, size, -size)); // Cut off the edges
     psImage *subTarget = psImageSubset(target, region); // Target for this subregion
     if (background != 0.0) {
@@ -443,5 +445,5 @@
     PS_ASSERT_KERNEL_NON_NULL(kernel, NULL);
 
-    psImage *conv = psImageConvolveFFT(image->image, kernel, 0.0); // Convolved image
+    psImage *conv = psImageConvolveFFT(image->image, NULL, 0, kernel, 0.0); // Convolved image
     int x0 = - image->xMin, y0 = - image->yMin; // Position of centre of convolved image
     psKernel *convolved = psKernelAllocFromImage(conv, x0, y0); // Kernel version
@@ -1116,9 +1118,9 @@
                 // Use Fast Fourier Transform to do the convolution
                 // This provides a big speed-up for large kernels
-                convolveFFT(convImage, inImage, kernelImage, psRegionSet(i, xSubMax, j, ySubMax),
+                convolveFFT(convImage, inImage, subMask, kernelImage, psRegionSet(i, xSubMax, j, ySubMax),
                             background, size);
                 if (inWeight) {
-                    convolveFFT(convWeight, inWeight, kernelWeight, psRegionSet(i, xSubMax, j, ySubMax),
-                                0.0, size);
+                    convolveFFT(convWeight, inWeight, subMask, kernelWeight,
+                                psRegionSet(i, xSubMax, j, ySubMax), 0.0, size);
                 }
             } else {
