Index: trunk/psphot/src/psphotFindDetections.c
===================================================================
--- trunk/psphot/src/psphotFindDetections.c	(revision 33761)
+++ trunk/psphot/src/psphotFindDetections.c	(revision 33889)
@@ -48,4 +48,5 @@
     // Use the new pmFootprints approach?
     const bool useFootprints = psMetadataLookupBool(NULL, recipe, "USE_FOOTPRINTS");
+    const bool footprintsUseUnsubtracted = psMetadataLookupBool(NULL, recipe, "FOOTPRINT_USE_UNSUBTRACTED");
 
     pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
@@ -64,4 +65,5 @@
     }
 
+    bool replaceSourcesForFootprints = false;
     if (firstPass) {
         pass = 1;
@@ -70,4 +72,6 @@
     } else {
         pass = 2;
+        // XXX change this to a recipe value
+        replaceSourcesForFootprints = footprintsUseUnsubtracted;    
         NSIGMA_PEAK = psMetadataLookupF32 (&status, recipe, "PEAKS_NSIGMA_LIMIT_2"); PS_ASSERT (status, NULL);
         NMAX = 0; // unlimited number of peaks in final pass: allow a limit (PEAKS_NMAX_2) ?
@@ -116,5 +120,16 @@
     // optionally merge peaks into footprints
     if (useFootprints) {
+        if (replaceSourcesForFootprints) {
+            psphotAddOrSubNoiseReadout(config, view, filerule, index, recipe, false);
+            psphotReplaceAllSourcesReadout (config, view, filerule, index, recipe, false);
+            psFree (significance);
+            significance = psphotSignificanceImage (readout, recipe, maskVal);
+        }
+
 	psphotFindFootprints (detections, significance, readout, recipe, threshold, pass, maskVal);
+
+        if (replaceSourcesForFootprints) {
+            psphotRemoveAllSourcesReadout (config, view, filerule, index, recipe, false);
+        }
     }
 
