Index: /trunk/psModules/src/detrend/pmBias.c
===================================================================
--- /trunk/psModules/src/detrend/pmBias.c	(revision 13919)
+++ /trunk/psModules/src/detrend/pmBias.c	(revision 13920)
@@ -17,4 +17,7 @@
 #include "pmBias.h"
 
+#define SMOOTH_NSIGMA 4.0               // Number of Gaussian sigma the smoothing kernel extends
+
+
 static void overscanOptionsFree(pmOverscanOptions *options)
 {
@@ -24,5 +27,6 @@
 }
 
-pmOverscanOptions *pmOverscanOptionsAlloc(bool single, pmFit fitType, unsigned int order, psStats *stat)
+pmOverscanOptions *pmOverscanOptionsAlloc(bool single, pmFit fitType, unsigned int order, psStats *stat,
+                                          int boxcar, float gauss)
 {
     pmOverscanOptions *opts = psAlloc(sizeof(pmOverscanOptions));
@@ -34,4 +38,8 @@
     opts->order = order;
     opts->stat = psMemIncrRefCounter(stat);
+
+    // Smoothing
+    opts->boxcar = boxcar;
+    opts->gauss = gauss;
 
     // Outputs
@@ -151,4 +159,19 @@
             mask->data.U8[i] = 1;
         }
+    }
+
+    // Smooth the reduced vector
+    if (overscanOpts->boxcar > 0) {
+        psVector *smoothed = psVectorBoxcar(NULL, reduced, overscanOpts->boxcar); // Smoothed vector
+        psFree(reduced);
+        reduced = smoothed;
+    }
+    if (isfinite(overscanOpts->gauss) && overscanOpts->gauss > 0) {
+        if (overscanOpts->boxcar > 0) {
+            psWarning("Gaussian smoothing the boxcar smoothed overscan --- you asked for it.");
+        }
+        psVector *smoothed = psVectorSmooth(NULL, reduced, overscanOpts->gauss, SMOOTH_NSIGMA);
+        psFree(reduced);
+        reduced = smoothed;
     }
 
Index: /trunk/psModules/src/detrend/pmBias.h
===================================================================
--- /trunk/psModules/src/detrend/pmBias.h	(revision 13919)
+++ /trunk/psModules/src/detrend/pmBias.h	(revision 13920)
@@ -5,6 +5,6 @@
  * @author Paul Price, IfA
  *
- * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-06-14 02:03:29 $
+ * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2007-06-20 20:45:00 $
  * Copyright 2004--2006 Institute for Astronomy, University of Hawaii
  */
@@ -34,11 +34,13 @@
 {
     // Inputs
-    bool single;                ///< Reduce all overscan regions to a single value?
-    pmFit fitType;              ///< Type of fit to overscan
-    unsigned int order;         ///< Order of polynomial, or number of spline pieces
-    psStats *stat;              ///< Statistic to use when reducing the minor direction
+    bool single;                        ///< Reduce all overscan regions to a single value?
+    pmFit fitType;                      ///< Type of fit to overscan
+    unsigned int order;                 ///< Order of polynomial, or number of spline pieces
+    psStats *stat;                      ///< Statistic to use when reducing the minor direction
+    int boxcar;                         ///< Boxcar smoothing radius
+    float gauss;                        ///< Gaussian smoothing sigma
     // Outputs
-    psPolynomial1D *poly;       ///< Result of polynomial fit
-    psSpline1D *spline;         ///< Result of spline fit
+    psPolynomial1D *poly;               ///< Result of polynomial fit
+    psSpline1D *spline;                 ///< Result of spline fit
 }
 pmOverscanOptions;
@@ -46,7 +48,9 @@
 /// Allocator for overscan options
 pmOverscanOptions *pmOverscanOptionsAlloc(bool single, ///< Reduce all overscan regions to a single value?
-        pmFit fitType, ///< Type of fit to overscan
-        unsigned int order, ///< Order of polynomial, or number of splines
-        psStats *stat ///< Statistic to use
+                                          pmFit fitType, ///< Type of fit to overscan
+                                          unsigned int order, ///< Order of polynomial, or number of splines
+                                          psStats *stat, ///< Statistic to use
+                                          int boxcar, ///< Boxcar smoothing radius
+                                          float gauss ///< Gaussian smoothing sigma
                                          );
 
