Index: trunk/psModules/src/imcombine/pmSubtraction.c
===================================================================
--- trunk/psModules/src/imcombine/pmSubtraction.c	(revision 14812)
+++ trunk/psModules/src/imcombine/pmSubtraction.c	(revision 14824)
@@ -4,6 +4,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.59 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-09-10 20:10:05 $
+ *  @version $Revision: 1.60 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-09-12 20:21:41 $
  *
  *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
@@ -86,9 +86,19 @@
 
     // Take the square of the normal kernel
+    double sumNormal = 0.0, sumVariance = 0.0; // Sum of the normal and variance kernels
     for (int v = yMin; v <= yMax; v++) {
         for (int u = xMin; u <= xMax; u++) {
-            kernel->kernel[v][u] = PS_SQR(normalKernel->kernel[v][u]);
-        }
-    }
+            float value = normalKernel->kernel[v][u]; // Value of interest
+            float value2 = PS_SQR(value); // Value squared
+            sumNormal += value;
+            sumVariance += value2;
+            kernel->kernel[v][u] = value2;
+        }
+    }
+
+    // Normalise so that the sum of the variance kernel is the square of the sum of the normal kernel
+    // This is required to keep the relative scaling between the image and the weight map
+    psBinaryOp(kernel->image, kernel->image, "*",
+               psScalarAlloc(PS_SQR(sumNormal) / sumVariance, PS_TYPE_F32));
 
     return kernel;
