Index: trunk/ppMerge/src/ppMerge.c
===================================================================
--- trunk/ppMerge/src/ppMerge.c	(revision 9463)
+++ trunk/ppMerge/src/ppMerge.c	(revision 9996)
@@ -14,4 +14,5 @@
 #include "ppMergeCombine.h"
 #include "ppMergeScaleZero.h"
+#include "ppMergeMask.h"
 
 //#include "ppMem.h"
@@ -45,11 +46,17 @@
     }
 
-    // Measure the background in each image
     psImage *scale = NULL;              // The scalings
     psImage *zero = NULL;               // The zeros
-    ppMergeScaleZero(&scale, &zero, data, options, config);
 
-    // Do the combination and write
-    ppMergeCombine(scale, zero, data, options, config);
+    if (options->mask) {
+        // Generate a mask
+        ppMergeMask(data, options, config);
+    } else {
+        // Measure the background in each image
+        ppMergeScaleZero(&scale, &zero, data, options, config);
+
+        // Do the combination and write
+        ppMergeCombine(scale, zero, data, options, config);
+    }
 
     // Output the statistics
