Index: /trunk/psphot/src/psphotFindPeaks.c
===================================================================
--- /trunk/psphot/src/psphotFindPeaks.c	(revision 13011)
+++ /trunk/psphot/src/psphotFindPeaks.c	(revision 13012)
@@ -2,5 +2,7 @@
 
 // In this function, we smooth the image, then search for the peaks 
-psArray *psphotFindPeaks (pmReadout *readout, psMetadata *recipe, int pass) {
+psArray *psphotFindPeaks (pmReadout *readout, psMetadata *recipe,
+			  bool returnFootprints,
+			  const int pass) {
 
     float SIGMA_SMTH, NSIGMA_SMTH, NSIGMA_PEAK;
@@ -110,7 +112,4 @@
     }
 
-    psFree (smooth_im);
-    psFree (smooth_wt);
-
     // optional dump of all peak data
     char *output = psMetadataLookupStr (&status, recipe, "PEAKS_OUTPUT_FILE");
@@ -119,5 +118,58 @@
     }
     psLogMsg ("psphot", PS_LOG_INFO, "%ld peaks: %f sec\n", peaks->n, psTimerMark ("psphot"));
+    //
+    // If they asked us to return a set of pmFootprints, not a raw pmPeak list,
+    // go ahead and find the footprints, and assign them their peaks.
+    //
+    // N.b. We're not culling this list; call pmFootprintCullPeaks if you
+    // want to do that
+    //
+    if (returnFootprints) {	// We want an array of pmFootprint, not pmPeak
+	int npixMin = psMetadataLookupS32(&status, recipe, "FOOTPRINT_NPIXMIN");
+	if (!status) {
+	    npixMin = 1;
+	}
+	float FOOTPRINT_NSIGMA_LIMIT =
+	    psMetadataLookupS32(&status, recipe,
+				(pass == 1) ? "FOOTPRINT_NSIGMA_LIMIT" : "FOOTPRINT_NSIGMA_LIMIT_2");
+	if (!status) {
+	    FOOTPRINT_NSIGMA_LIMIT = NSIGMA_PEAK;
+	}
+	threshold = PS_SQR(FOOTPRINT_NSIGMA_LIMIT)/effArea;
+
+	psArray *footprints = pmFindFootprints(smooth_im, threshold, npixMin);
+	pmPeaksAssignToFootprints(footprints, peaks);
+
+	psFree(peaks);
+	peaks = footprints;		// well, you know what I mean
+    }
+
+    psFree (smooth_im);
+    psFree (smooth_wt);
 
     return (peaks);
 }
+
+
+/************************************************************************************************************/
+/*
+ * Cull a set of peaks contained in a psArray of pmFootprints
+ */
+psErrorCode
+psphotCullPeaks(const pmReadout *readout, 
+		const psMetadata *recipe,
+		psArray *footprints) { // array of pmFootprints
+    bool status = false;
+    float nsigma_delta = psMetadataLookupF32(&status, recipe, "FOOTPRINT_CULL_NSIGMA_DELTA");
+    if (!status) {
+	nsigma_delta = 0; // min. 
+    }
+    float nsigma_min = psMetadataLookupF32(&status, recipe, "FOOTPRINT_CULL_NSIGMA_MIN");
+    if (!status) {
+	nsigma_min = 0;
+    }
+    const float skyStdev = psMetadataLookupF32(NULL, recipe, "SKY_STDEV");
+
+    return pmFootprintArrayCullPeaks(readout->image, readout->weight, footprints,
+				     nsigma_delta, nsigma_min*skyStdev);
+}
Index: /trunk/psphot/src/psphotReadout.c
===================================================================
--- /trunk/psphot/src/psphotReadout.c	(revision 13011)
+++ /trunk/psphot/src/psphotReadout.c	(revision 13012)
@@ -20,4 +20,7 @@
     PS_ASSERT_PTR_NON_NULL (breakPt, false);
 
+    // Use the new pmFootprints approach?
+    const bool useFootprints = psMetadataLookupBool(NULL, recipe, "USE_FOOTPRINTS");
+
     // generate mask & weight images if they don't already exit
     if (!pmReadoutGenerateMaskWeight (readout, true)) {
@@ -58,5 +61,13 @@
 
     // find the peaks in the image
-    psArray *peaks = psphotFindPeaks (readout, recipe, 1);
+    psArray *peaks;
+    if (useFootprints) {
+       psArray *footprints = psphotFindPeaks (readout, recipe, useFootprints, 1);
+       peaks = pmFootprintArrayToPeaks(footprints);
+       psFree(footprints);
+    } else {
+       peaks = psphotFindPeaks (readout, recipe, useFootprints, 1);
+    }
+
     if (!peaks) {
 	psLogMsg ("psphot", 3, "unable to find peaks in this image");
@@ -146,5 +157,16 @@
 
     // find the peaks in the image
-    psArray *newPeaks = psphotFindPeaks (readout, recipe, 2);
+    psArray *newPeaks;
+    if (useFootprints) {
+       psArray *newFootprints = psphotFindPeaks (readout, recipe, useFootprints, 2);
+
+       psphotCullPeaks(readout, recipe, newFootprints);
+
+       newPeaks = pmFootprintArrayToPeaks(newFootprints);
+
+       psFree(newFootprints);
+    } else {
+       newPeaks = psphotFindPeaks(readout, recipe, useFootprints, 2);
+    }
 
     // remove noise for subtracted objects
@@ -186,5 +208,5 @@
 
     // calculate source magnitudes
-    pmReadout *background = psphotSelectBackground (config, view);
+    pmReadout *background = psphotSelectBackground (config, view, false);
     psphotMagnitudes(sources, recipe, psf, background);
 
