Index: trunk/psphot/src/psphotSignificanceImage.c
===================================================================
--- trunk/psphot/src/psphotSignificanceImage.c	(revision 20177)
+++ trunk/psphot/src/psphotSignificanceImage.c	(revision 20213)
@@ -15,4 +15,10 @@
     // XXX we can a) choose fft to convolve if needed and b) multithread fftw
 
+    float minGauss = psMetadataLookupF32(NULL, recipe, "PEAKS_MIN_GAUSS"); // Minimum valid fraction of kernel
+    if (!isfinite(minGauss)) {
+        psWarning("PEAKS_MIN_GAUSS is not set in recipe; using default value");
+        minGauss = 0.5;
+    }
+
     bool status_x, status_y;
     float FWHM_X = psMetadataLookupF32 (&status_x, recipe, "FWHM_X");
@@ -26,17 +32,18 @@
       // if we do not know the FWHM, use the guess smoothing kernel supplied.
       // it is a configuration error if these are not supplied
-      SIGMA_SMTH  = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_SIGMA"); 
+      SIGMA_SMTH  = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_SIGMA");
       PS_ASSERT (status, NULL);
-      NSIGMA_SMTH = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_NSIGMA"); 
+      NSIGMA_SMTH = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_NSIGMA");
       PS_ASSERT (status, NULL);
       guess = true;
     }
     // record the actual smoothing sigma
-    psMetadataAddF32  (recipe, PS_LIST_TAIL, "SIGMA_SMOOTH", PS_META_REPLACE, "Smoothing sigma for detections", SIGMA_SMTH);
+    psMetadataAddF32(recipe, PS_LIST_TAIL, "SIGMA_SMOOTH", PS_META_REPLACE, "Smoothing sigma for detections",
+                     SIGMA_SMTH);
 
     // smooth the image, applying the mask as we go
-    psImage *smooth_im = psImageCopy (NULL, readout->image, PS_TYPE_F32);
-    psImageSmoothMaskF32 (smooth_im, readout->mask, maskVal, SIGMA_SMTH, NSIGMA_SMTH);
-    psLogMsg ("psphot", PS_LOG_MINUTIA, "smooth image: %f sec\n", psTimerMark ("smooth"));
+    psImage *smooth_im = psImageCopy(NULL, readout->image, PS_TYPE_F32);
+    psImageSmoothMask(smooth_im, smooth_im, readout->mask, maskVal, SIGMA_SMTH, NSIGMA_SMTH, minGauss);
+    psLogMsg("psphot", PS_LOG_MINUTIA, "smooth image: %f sec\n", psTimerMark("smooth"));
 
     // Smooth the weight, applying the mask as we go.  The variance is smoothed by the PSF^2,
@@ -47,7 +54,8 @@
     // measurements based on apertures comparable to or larger than the smoothing kernel, the
     // effective per-pixel variance is maintained.
-    psImage *smooth_wt = psImageCopy (NULL, readout->weight, PS_TYPE_F32);
-    psImageSmoothMaskF32 (smooth_wt, readout->mask, maskVal, SIGMA_SMTH/sqrt(2), NSIGMA_SMTH);
-    psLogMsg ("psphot", PS_LOG_MINUTIA, "smooth weight: %f sec\n", psTimerMark ("smooth"));
+    psImage *smooth_wt = psImageCopy(NULL, readout->weight, PS_TYPE_F32);
+    psImageSmoothMask(smooth_wt, smooth_wt, readout->mask, maskVal, SIGMA_SMTH * M_SQRT1_2,
+                      NSIGMA_SMTH, minGauss);
+    psLogMsg("psphot", PS_LOG_MINUTIA, "smooth weight: %f sec\n", psTimerMark("smooth"));
 
     psImage *mask = readout->mask;
@@ -58,7 +66,7 @@
         char name[64];
         sprintf (name, "imsmooth.v%d.fits", pass);
-        psphotSaveImage (NULL, smooth_im, name);
+        psphotSaveImage(NULL, smooth_im, name);
         sprintf (name, "wtsmooth.v%d.fits", pass);
-        psphotSaveImage (NULL, smooth_wt, name);
+        psphotSaveImage(NULL, smooth_wt, name);
     }
 
@@ -67,5 +75,5 @@
     // sigma_s^2.  Ideally, we are choosing sigma_s = sigma_r, in which case sigma_o^2 = 2
     // sigma_s^2.  If we do not know the input image PSF size (initial detection stage), then
-    // we are assuming that sigma_r = sigma_s.  
+    // we are assuming that sigma_r = sigma_s.
 
     // Build the significance image on top of smooth_im.  We need to correct the ratio im/wt by
@@ -93,6 +101,7 @@
     // record the effective area and significance scaling factor
     float effArea = 8.0 * M_PI * PS_SQR(SIGMA_SMTH);
-    psMetadataAddF32  (recipe, PS_LIST_TAIL, "EFFECTIVE_AREA", PS_META_REPLACE, "Effective Area", effArea);
-    psMetadataAddF32  (recipe, PS_LIST_TAIL, "SIGNIFICANCE_SCALE_FACTOR", PS_META_REPLACE, "Signicance scale factor", factor);
+    psMetadataAddF32(recipe, PS_LIST_TAIL, "EFFECTIVE_AREA", PS_META_REPLACE, "Effective Area", effArea);
+    psMetadataAddF32(recipe, PS_LIST_TAIL, "SIGNIFICANCE_SCALE_FACTOR", PS_META_REPLACE,
+                     "Signicance scale factor", factor);
 
     // XXX multithread this if needed
@@ -107,5 +116,5 @@
         }
     }
-    psLogMsg ("psphot", PS_LOG_INFO, "built smoothed signficance image: %f sec\n", psTimerMark ("smooth"));
+    psLogMsg ("psphot", PS_LOG_INFO, "built smoothed signficance image: %f sec\n", psTimerMark("smooth"));
 
     // optionally save example images under trace
@@ -117,5 +126,5 @@
     }
 
-    psFree (smooth_wt);
+    psFree(smooth_wt);
     return smooth_im;
 }
