Index: trunk/psphot/src/psphotBasicDeblend.c
===================================================================
--- trunk/psphot/src/psphotBasicDeblend.c	(revision 6379)
+++ trunk/psphot/src/psphotBasicDeblend.c	(revision 6427)
@@ -2,5 +2,5 @@
 
 // 2006.02.07 : no leaks
-bool psphotBasicDeblend (psArray *sources, psMetadata *config, psStats *sky) { 
+bool psphotBasicDeblend (psArray *sources, psMetadata *config) { 
 
     int N;
@@ -18,6 +18,4 @@
     float NSIGMA   = psMetadataLookupF32 (&status, config, "DEBLEND_SKY_NSIGMA");
     if (!status) NSIGMA = 5.0;
-
-    float minThreshold = NSIGMA*sky->sampleStdev;
 
     // we need sources spatially-sorted to find overlaps
@@ -83,6 +81,10 @@
 	// generate source contour (1/4 peak counts)
 	// set the threshold based on user inputs
-	threshold = FRACTION * (source->peak->counts - source->moments->Sky) + source->moments->Sky; 
-	threshold = PS_MAX (threshold, minThreshold);
+	
+	// threshold is fraction of the source peak flux
+	// image is background subtracted; source->moments->Sky should always be 0.0
+	threshold = FRACTION * source->moments->Peak;
+	// threshold is no less than NSIGMA above the local median sigma?
+	threshold = PS_MAX (threshold, NSIGMA*source->moments->dSky);
 
 	// generate a basic contour (set of x,y coordinates at-or-below flux level)
