Index: /trunk/psModules/src/imcombine/pmSubtractionEquation.c
===================================================================
--- /trunk/psModules/src/imcombine/pmSubtractionEquation.c	(revision 24292)
+++ /trunk/psModules/src/imcombine/pmSubtractionEquation.c	(revision 24293)
@@ -16,4 +16,6 @@
 
 //#define TESTING
+
+#define USE_VARIANCE                    // Include variance in equation?
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -31,5 +33,9 @@
     for (int y = - footprint; y <= footprint; y++) {
         for (int x = - footprint; x <= footprint; x++) {
-            sum += image1->kernel[y][x] * image2->kernel[y][x] / 1.0; // variance->kernel[y][x];
+            double value = image1->kernel[y][x] * image2->kernel[y][x];
+#ifdef USE_VARIANCE
+            value /= variance->kernel[y][x];
+#endif
+            sum += value;
         }
     }
@@ -195,5 +201,9 @@
             for (int y = - footprint; y <= footprint; y++) {
                 for (int x = - footprint; x <= footprint; x++) {
-                    sumC += conv->kernel[y][x] / 1.0; // variance->kernel[y][x];
+                    double value = conv->kernel[y][x];
+#ifdef USE_VARIANCE
+                    value /= variance->kernel[y][x];
+#endif
+                    sumC += value;
                 }
             }
@@ -218,5 +228,8 @@
         for (int y = - footprint; y <= footprint; y++) {
             for (int x = - footprint; x <= footprint; x++) {
-                double invNoise2 = 1.0 / 1.0; // variance->kernel[y][x];
+                double invNoise2 = 1.0;
+#ifdef USE_VARIANCE
+                invNoise2 /= variance->kernel[y][x];
+#endif
                 double value = input->kernel[y][x] * invNoise2;
                 sumI += value;
@@ -277,5 +290,9 @@
         for (int y = - footprint; y <= footprint; y++) {
             for (int x = - footprint; x <= footprint; x++) {
-                sumTC += target->kernel[y][x] * conv->kernel[y][x] / 1.0; // variance->kernel[y][x];
+                double value = target->kernel[y][x] * conv->kernel[y][x];
+#ifdef USE_VARIANCE
+                value /= variance->kernel[y][x];
+#endif
+                sumTC += value;
             }
         }
@@ -297,5 +314,8 @@
         for (int y = - footprint; y <= footprint; y++) {
             for (int x = - footprint; x <= footprint; x++) {
-                float value = target->kernel[y][x] / 1.0; // variance->kernel[y][x];
+                double value = target->kernel[y][x];
+#ifdef USE_VARIANCE
+                value /= variance->kernel[y][x];
+#endif
                 sumIT += value * input->kernel[y][x];
                 sumT += value;
@@ -366,5 +386,9 @@
         for (int y = - footprint; y <= footprint; y++) {
             for (int x = - footprint; x <= footprint; x++) {
-                sumC += conv->kernel[y][x] / 1.0; // variance->kernel[y][x];
+                double value = conv->kernel[y][x];
+#ifdef USE_VARIANCE
+                value /= variance->kernel[y][x];
+#endif
+                sumC += value;
             }
         }
