Index: /trunk/psphot/src/psphotFindPeaks.c
===================================================================
--- /trunk/psphot/src/psphotFindPeaks.c	(revision 7435)
+++ /trunk/psphot/src/psphotFindPeaks.c	(revision 7436)
@@ -8,4 +8,5 @@
     float SIGMA;
     float threshold;
+    float value;
 
     // smooth the image and weight map
@@ -15,4 +16,6 @@
     NSIGMA = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_NSIGMA");
 
+    // XXX we are somewhat doing the wrong thing here with the mask.
+    // it would be better to smooth the image using the mask information
     psImage *smooth_im = psImageCopy (NULL, readout->image, PS_TYPE_F32);
     psImageSmooth (smooth_im, SIGMA, NSIGMA);
@@ -23,4 +26,6 @@
     psLogMsg ("psphot", 4, "smooth weight: %f sec\n", psTimerMark ("psphot"));
 
+    psImage *mask = readout->mask;
+
     // psphotSaveImage (NULL, smooth_im, "imsmooth.fits");
     // psphotSaveImage (NULL, smooth_wt, "wtsmooth.fits");
@@ -29,6 +34,9 @@
     for (int j = 0; j < smooth_im->numRows; j++) {
 	for (int i = 0; i < smooth_im->numCols; i++) {
+	    value = smooth_im->data.F32[j][i];
+	    smooth_im->data.F32[j][i] = 0.0;
+	    if (mask->data.U8[j][i]) continue;
 	    if (smooth_wt->data.F32[j][i] <= 0) continue;
-	    smooth_im->data.F32[j][i] = PS_SQR(smooth_im->data.F32[j][i]) / smooth_wt->data.F32[j][i];
+	    smooth_im->data.F32[j][i] = PS_SQR(value) / smooth_wt->data.F32[j][i];
 	}
     }
