Index: trunk/ppImage/src/ppImageOptions.c
===================================================================
--- trunk/ppImage/src/ppImageOptions.c	(revision 5976)
+++ trunk/ppImage/src/ppImageOptions.c	(revision 6064)
@@ -17,9 +17,9 @@
     options->doAstrom = false;          // Astrometry
     // Overscan options
-    options->overscanBins = 1;          // Number of pixels per bin for overscan
-    options->overscanStats = NULL;      // Statistics for overscan
-    options->overscanFit = NULL;        // Overscan fit (polynomial or spline)
-    options->overscanFitType = PM_FIT_NONE; // Fit type for overscan
-    options->overscanMode = PM_OVERSCAN_NONE; // Axis for overscan
+    options->overscan = NULL;           // Overscan options
+    bool overscanSingle = false;        // A single value for entire overscan?
+    pmFit overscanFit = PM_FIT_NONE;    // Fit type for overscan
+    int overscanOrder = 0;              // Order for overscan fit
+    psStats *overscanStats = NULL;      // Statistics for overscan
     // Non-linearity options
     options->nonLinearType = 0;         // Type of non-linearity data (vector, string or metadata)
@@ -28,4 +28,5 @@
     // Various others
     options->imageLoadDepth = PP_LOAD_NONE; // No load depth specified yet
+
 
     bool mdStatus = false;              // Result of MD lookup
@@ -122,43 +123,36 @@
     // XXX EAM : we should abort on invalid options. default options?
     if (psMetadataLookupBool(NULL, config->recipe, "OVERSCAN")) {
-        // XXX EAM : does 'overscanMode = NONE' mean doOverscan = false?
         options->doOverscan = true;
-        psString mode = psMetadataLookupStr(NULL, config->recipe, "OVERSCAN.MODE");
-        if (! strcasecmp(mode, "INDIVIDUAL")) {
-            options->overscanMode = PM_OVERSCAN_EDGE;
-        } else if (! strcasecmp(mode, "ALL")) {
-            options->overscanMode = PM_OVERSCAN_ALL;
-        } else if (strcasecmp(mode, "NONE")) {
-            psLogMsg(__func__, PS_LOG_WARN, "OVERSCAN.MODE (%s) is not one of NONE, INDIVIDUAL, or ALL:"
-                     " assuming NONE.\n", mode);
-        }
+
+        // Do the overscan as a single value?
+        overscanSingle = psMetadataLookupBool(NULL, config->recipe, "OVERSCAN.SINGLE");
+
+        // How do we fit it?
         psString fit = psMetadataLookupStr(NULL, config->recipe, "OVERSCAN.FIT");
         if (! strcasecmp(fit, "POLYNOMIAL")) {
-            options->overscanFitType = PM_FIT_POLYNOMIAL;
-            int order = psMetadataLookupS32(NULL, config->recipe, "OVERSCAN.ORDER"); // Order of polynomial fit
-            options->overscanFit = psPolynomial1DAlloc(order, PS_POLYNOMIAL_ORD);
+            overscanFit = PM_FIT_POLY_ORD;
+            overscanOrder = psMetadataLookupS32(NULL, config->recipe, "OVERSCAN.ORDER");
+        } else if (! strcasecmp(fit, "CHEBYSHEV")) {
+            overscanFit = PM_FIT_POLY_CHEBY;
+            overscanOrder = psMetadataLookupS32(NULL, config->recipe, "OVERSCAN.ORDER");
         } else if (! strcasecmp(fit, "SPLINE")) {
-            options->overscanFit = NULL;
-            options->overscanFitType = PM_FIT_SPLINE;
-            // int order = psMetadataLookupS32(NULL, config->recipe, "OVERSCAN.ORDER"); // Order of polynomial fit
-            // XXX : not in psLib yet : options->overscanFit = psSpline1DAlloc();
+            overscanFit = PM_FIT_SPLINE;
         } else if (strcasecmp(fit, "NONE")) {
             psLogMsg(__func__, PS_LOG_WARN, "OVERSCAN.FIT (%s) is not one of NONE, POLYNOMIAL, or SPLINE:"
                      " assuming NONE.\n", fit);
         }
-        options->overscanBins = psMetadataLookupS32(NULL, config->recipe, "OVERSCAN.BIN");
-        if (options->overscanBins <= 0) {
-            psErrorStackPrint(stderr, "OVERSCAN.BIN (%d) is non-positive --- assuming 1.\n", options->overscanBins);
-            options->overscanBins = 1;
-        }
+
         psString stat = psMetadataLookupStr(NULL, config->recipe, "OVERSCAN.STAT");
         if (! strcasecmp(stat, "MEAN")) {
-            options->overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
+            overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
         } else if (! strcasecmp(stat, "MEDIAN")) {
-            options->overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN);
+            overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN);
         } else {
             psErrorStackPrint(stderr, "OVERSCAN.STAT (%s) is not one of MEAN, MEDIAN: assuming MEAN\n", stat);
-            options->overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
+            overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
         }
+
+        // Fill in the options
+        options->overscan = pmOverscanOptionsAlloc(overscanSingle, overscanFit, overscanOrder, overscanStats);
     }
 
