Index: trunk/psModules/src/detrend/pmSubtractSky.c
===================================================================
--- trunk/psModules/src/detrend/pmSubtractSky.c	(revision 7769)
+++ trunk/psModules/src/detrend/pmSubtractSky.c	(revision 8004)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-06-30 23:59:49 $
+ *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-07-28 03:21:19 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -90,5 +90,5 @@
 requirements change and we might need a custom reBin function.
  *****************************************************************************/
-/*
+#if 0
 static psImage *binImage(psImage *origImage,
                          int binFactor,
@@ -96,5 +96,5 @@
 {
     psTrace("SubtractSky.binImage", 4, "Calling binImage(%d)\n", binFactor);
- 
+
     if (binFactor <= 0) {
         psLogMsg(__func__, PS_LOG_WARN,
@@ -105,9 +105,9 @@
         return(origImage);
     }
- 
+
     psVector *binVector = psVectorAlloc(binFactor * binFactor, PS_TYPE_F32);
     psVector *binMask = psVectorAlloc(binFactor * binFactor, PS_TYPE_U8);
     psStats *myStats = psStatsAlloc(statOptions);
- 
+
     for (psS32 row = 0; row < origImage->numRows ; row+=binFactor) {
         for (psS32 col = 0; col < origImage->numCols ; col+=binFactor) {
@@ -134,5 +134,5 @@
             psF64 statValue;
             psBool rc = p_psGetStatValue(rc1, &statValue);
- 
+
             if (rc == true) {
                 origImage->data.F32[row][col] = (psF32) statValue;
@@ -147,9 +147,9 @@
     psFree(binMask);
     psFree(myStats);
- 
+
     psTrace("SubtractSky.binImage", 4, "Exiting binImage(%d)\n", binFactor);
     return(origImage);
 }
-*/
+#endif
 
 /******************************************************************************
@@ -601,29 +601,11 @@
     } else {
         // Determine the mean and standard deviation of the binned image.
-        psF64 binnedMean;
-        psF64 binnedStdev;
-        psStats *myStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
-        psStats *rc =  psImageStats(myStats, binnedImage, NULL, 0);
-        if (rc == NULL) {
-            psError(PS_ERR_UNKNOWN, false, "psImageStats(): could not perform requested statistical operation.  Returning in image.\n");
-            return(in);
-        }
-        if (false == p_psGetStatValue(rc, &binnedMean)) {
-            psError(PS_ERR_UNKNOWN, false, "p_psGetStatValue(): could not determine requested statistical operation.  Returning in image.\n");
-            return(in);
-        }
-        psTrace(".psModule.pmSubtractSky", 6,
-                "binned Mean is %f\n", binnedMean);
-
-        myStats->options = PS_STAT_SAMPLE_STDEV;
-        rc =  psImageStats(myStats, binnedImage, NULL, 0);
-        if (rc == NULL) {
-            psError(PS_ERR_UNKNOWN, false, "psImageStats(): could not perform requested statistical operation.  Returning in image.\n");
-            return(in);
-        }
-        if (false == p_psGetStatValue(myStats, &binnedStdev)) {
-            psError(PS_ERR_UNKNOWN, false, "p_psGetStatValue(): could not determine requested statistical operation.  Returning in image.\n");
-            return(in);
-        }
+        psStats *myStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV);
+        if (!psImageStats(myStats, binnedImage, NULL, 0)) {
+            psError(PS_ERR_UNEXPECTED_NULL, false, "Couldn't get statistics for image.\n");
+            return NULL;
+        }
+        psF64 binnedMean = myStats->sampleMean;
+        psF64 binnedStdev = myStats->sampleStdev;
         psFree(myStats);
         psTrace(".psModule.pmSubtractSky", 6,
