Index: trunk/psModules/src/pmSubtractBias.c
===================================================================
--- trunk/psModules/src/pmSubtractBias.c	(revision 1899)
+++ trunk/psModules/src/pmSubtractBias.c	(revision 1901)
@@ -8,6 +8,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-24 23:47:21 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-25 21:03:05 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -18,7 +18,4 @@
 #endif
 
-#include<stdio.h>
-#include<math.h>
-#include "pslib.h"
 #include "pmSubtractBias.h"
 
@@ -57,4 +54,5 @@
             (in->image)->data.F32[i][j]-=
                 (bias->image)->data.F32[i+in->row0-bias->row0][j+in->col0-bias->col0];
+
             ((in->mask)->data.U8[i][j])|=
                 (bias->mask)->data.U8[i+in->row0-bias->row0][j+in->col0-bias->col0];
@@ -146,5 +144,5 @@
 /******************************************************************************
 ScaleOverscanVector(): this routine takes as input an arbitrary vector,
-creates anew vector of length n, and fills the new vector with the
+creates a new vector of length n, and fills the new vector with the
 interpolated values of the old vector.  The type of interpolation is:
     PM_FIT_POLYNOMIAL: fit a polynomial to the entire input vector data.
@@ -159,4 +157,8 @@
                               pmFit fit)
 {
+    if (n == overscanVector) {
+        return(overscanVector);
+    }
+
     psVector *newVec = psVectorAlloc(n, PS_TYPE_F32);
     psPolynomial1D *myPoly;
@@ -166,15 +168,25 @@
 
     if (fit == PM_FIT_POLYNOMIAL) {
+        // Fit a polynomial to the old overscan vector.
         myPoly = (psPolynomial1D *) fitSpec;
         myPoly = psVectorFitPolynomial1D(myPoly, NULL, overscanVector, NULL);
+
+        // For each element of the new vector, convert the x-ordinate to that
+        // of the old vector, use the fitted polynomial to determine the
+        // interpolated value at that point, and set the new vector.
         for (i=0;i<n;i++) {
-            x = (((float) i) / ((float) n)) * ((float) overscanVector->n);
+            x = ((float) i) * ((float) overscanVector->n) / ((float) n);
             newVec->data.F32[i] = psPolynomial1DEval(x, myPoly);
         }
     } else if (fit == PM_FIT_SPLINE) {
+        // Fit a spline to the old overscan vector.
         mySpline = (psSpline1D *) fitSpec;
         mySpline = psVectorFitSpline1D(mySpline, NULL, overscanVector, NULL);
+
+        // For each element of the new vector, convert the x-ordinate to that
+        // of the old vector, use the fitted polynomial to determine the
+        // interpolated value at that point, and set the new vector.
         for (i=0;i<n;i++) {
-            x = (((float) i) / ((float) n)) * ((float) overscanVector->n);
+            x = ((float) i) * ((float) overscanVector->n) / ((float) n);
             newVec->data.F32[i] = psSpline1DEval(mySpline, x);
         }
@@ -254,4 +266,5 @@
 
     // XXX: How to use multiple overscans?  Currently, only the first is used.
+
     if ((overScanAxis == PM_OVERSCAN_ROWS) || (overScanAxis == PM_OVERSCAN_COLUMNS)) {
         myOverscanImage = (psImage *) ((overscans->head)->data);
@@ -271,5 +284,5 @@
                         tmpRow->data.F32[j] = myOverscanImage->data.F32[i][j];
                     }
-                    stat = psVectorStats(stat, tmpRow, NULL, 0xffffffff);
+                    stat = psVectorStats(stat, tmpRow, NULL, 0);
                     p_psGetStatValue(stat, &statValue);
                     overscanVector->data.F32[i] = statValue;
@@ -295,9 +308,9 @@
                         tmpRow->data.F32[j] = myOverscanImage->data.F32[i][j];
                     }
-                    stat = psVectorStats(stat, tmpRow, NULL, 0xffffffff);
+                    stat = psVectorStats(stat, tmpRow, NULL, 0);
                     p_psGetStatValue(stat, &statValue);
                     overscanVector->data.F32[i] = statValue;
                 }
-                //                tmpOverscan = tmpOverscan->next;
+                // tmpOverscan = tmpOverscan->next;
                 tmpOverscan = NULL;
             }
@@ -306,4 +319,7 @@
         }
 
+        //
+        // Re-bin the overscan vector (change its length).
+        //
         if ((nBin > 0) && (nBin < overscanVector->n)) {
             numBins = 1+((overscanVector->n)/nBin);
@@ -327,4 +343,5 @@
 
             }
+
             // Change the effective size of overscanVector.
             overscanVector->n = numBins;
@@ -338,4 +355,7 @@
         }
 
+        //
+        // Fit a polynomial to the overscan vector.
+        //
         if (!((fitSpec == NULL) || (fit == PM_FIT_NONE))) {
             if (fit == PM_FIT_POLYNOMIAL) {
@@ -352,4 +372,7 @@
         }
 
+        //
+        // Subtract overscan vector row-wise from the image.
+        //
         if (overScanAxis == PM_OVERSCAN_ROWS) {
             for (i=0;i<(in->image)->numCols;i++) {
@@ -360,4 +383,7 @@
         }
 
+        //
+        // Subtract overscan vector column-wise from the image.
+        //
         if (overScanAxis == PM_OVERSCAN_COLUMNS) {
             for (i=0;i<(in->image)->numRows;i++) {
Index: trunk/psModules/src/pmSubtractBias.h
===================================================================
--- trunk/psModules/src/pmSubtractBias.h	(revision 1899)
+++ trunk/psModules/src/pmSubtractBias.h	(revision 1901)
@@ -8,6 +8,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-24 22:33:17 $
+ *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-25 21:03:05 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -25,4 +25,6 @@
 #include<math.h>
 #include "pslib.h"
+// XXX: have Desonia do this correctly.
+#include "../../psLib/src/dataManip/psConstants.h"
 
 typedef enum {
