Index: trunk/psLib/src/imageops/psImageGeomManip.c
===================================================================
--- trunk/psLib/src/imageops/psImageGeomManip.c	(revision 7991)
+++ trunk/psLib/src/imageops/psImageGeomManip.c	(revision 7999)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-06-30 02:20:06 $
+ *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-07-28 00:44:05 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -48,5 +48,4 @@
     psMaskType* maskData = NULL;
     psStats* myStats;
-    double statVal;
 
     if (in == NULL) {
@@ -72,5 +71,6 @@
     }
 
-    if (p_psGetStatValue(stats, &statVal) == false) {
+    psStatsOptions statistic = psStatsSingleOption(stats->options); // Statistics option to use
+    if (statistic == 0) {
         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
                 PS_ERRORTEXT_psImage_BAD_STAT,
@@ -108,19 +108,19 @@
     out = psImageRecycle(out, outCols, outRows, in->type.type);
 
-    #define PS_IMAGE_REBIN_CASE(type) \
-case PS_TYPE_##type: { \
-        ps##type* outRowData; \
-        ps##type* vecData = vec->data.type; \
-        psMaskType* inRowMask = NULL; \
+    #define PS_IMAGE_REBIN_CASE(TYPE) \
+case PS_TYPE_##TYPE: { \
+        ps##TYPE *outRowData; \
+        ps##TYPE *vecData = vec->data.TYPE; \
+        psMaskType *inRowMask = NULL; \
         for (psS32 row = 0; row < outRows; row++) { \
-            outRowData = out->data.type[row]; \
-            psS32 inCurrentRow = row*scale; \
-            psS32 inNextRow = (row+1)*scale; \
+            outRowData = out->data.TYPE[row]; \
+            psS32 inCurrentRow = row * scale; \
+            psS32 inNextRow = (row + 1) * scale; \
             for (psS32 col = 0; col < outCols; col++) { \
-                psS32 inCurrentCol = col*scale; \
-                psS32 inNextCol = (col+1)*scale; \
+                psS32 inCurrentCol = col * scale; \
+                psS32 inNextCol = (col + 1) * scale; \
                 psS32 n = 0; \
                 for (psS32 inRow = inCurrentRow; inRow < inNextRow && inRow < inRows; inRow++) { \
-                    ps##type* inRowData = in->data.type[inRow]; \
+                    ps##TYPE* inRowData = in->data.TYPE[inRow]; \
                     if (mask != NULL) { \
                         inRowMask = mask->data.PS_TYPE_MASK_DATA[inRow]; \
@@ -134,7 +134,6 @@
                 } \
                 vec->n = n; \
-                myStats = psVectorStats(myStats,vec,NULL,maskVec,maskVal); \
-                p_psGetStatValue(myStats,&statVal); \
-                outRowData[col] = (ps##type)statVal; \
+                myStats = psVectorStats(myStats, vec, NULL, maskVec, maskVal); \
+                outRowData[col] = (ps##TYPE)psStatsGetValue(myStats, statistic); \
             } \
         } \
Index: trunk/psLib/src/imageops/psImagePixelExtract.c
===================================================================
--- trunk/psLib/src/imageops/psImagePixelExtract.c	(revision 7991)
+++ trunk/psLib/src/imageops/psImagePixelExtract.c	(revision 7999)
@@ -8,6 +8,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-05-16 23:12:20 $
+ *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-07-28 00:44:05 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -210,5 +210,4 @@
                        const psStats* stats)
 {
-    double statVal;
     psStats* myStats;
     psElemType type;
@@ -375,7 +374,7 @@
     }
 
-    // verify that the stats struct specifies a
-    // single stats operation
-    if (p_psGetStatValue(stats, &statVal) == false) {
+    // verify that the stats struct specifies a single stats operation
+    psStatsOptions statistic = psStatsSingleOption(stats->options);
+    if (statistic == 0) {
         psError(PS_ERR_BAD_PARAMETER_VALUE, false,
                 PS_ERRORTEXT_psImage_BAD_STAT,stats->options);
@@ -439,6 +438,5 @@
                 } \
                 myStats = psVectorStats(myStats,imgVec,NULL,maskVec,maskVal); \
-                (void)p_psGetStatValue(myStats,&statVal); \
-                *outData = statVal; \
+                *outData = psStatsGetValue(myStats, statistic); \
                 if (outPosition != NULL) { \
                     outPosition->x = c; \
@@ -520,6 +518,5 @@
             }
             myStats = psVectorStats(myStats, imgVec, NULL, maskVec, maskVal);
-            (void)p_psGetStatValue(myStats, &statVal);  // we know it works cause we tested it above
-            *outData = statVal;
+            *outData = psStatsGetValue(myStats, statistic);
             if (outPosition != NULL) {
                 outPosition->y = r;
@@ -741,6 +738,4 @@
                            const psStats* stats)
 {
-    double statVal;
-
     /* check the parameters */
 
@@ -808,7 +803,7 @@
     }
 
-    // verify that the stats struct specifies a
-    // single stats operation
-    if (p_psGetStatValue(stats, &statVal) == false) {
+    // verify that the stats struct specifies a single stats operation
+    psStatsOptions statistic = psStatsSingleOption(stats->options);
+    if (statistic == 0) {
         psError(PS_ERR_BAD_PARAMETER_VALUE, false,
                 PS_ERRORTEXT_psImage_BAD_STAT,
@@ -914,6 +909,5 @@
     for (psS32 r = 0; r < numOut; r++) {
         myStats = psVectorStats(myStats,buffer[r], NULL, bufferMask[r],maskVal);
-        (void)p_psGetStatValue(myStats,&statVal);
-        outData[r] = statVal;
+        outData[r] = psStatsGetValue(myStats, statistic);
     }
 
Index: trunk/psLib/src/math/psStats.c
===================================================================
--- trunk/psLib/src/math/psStats.c	(revision 7991)
+++ trunk/psLib/src/math/psStats.c	(revision 7999)
@@ -16,6 +16,6 @@
  * use ->min and ->max (PS_STAT_USE_RANGE)
  *
- *  @version $Revision: 1.181 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-07-27 03:51:13 $
+ *  @version $Revision: 1.182 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-07-28 00:44:05 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -34,4 +34,5 @@
 /*****************************************************************************/
 #include "psMemory.h"
+#include "psAbort.h"
 #include "psImage.h"
 #include "psVector.h"
@@ -80,64 +81,4 @@
 
 // None
-
-/*****************************************************************************/
-/* FUNCTION IMPLEMENTATION - LOCAL                                           */
-/*****************************************************************************/
-
-psBool p_psGetStatValue(const psStats* stats, psF64 *value)
-{
-    psTrace(__func__, 4, "---- %s() begin ----\n", __func__);
-    //    switch (stats->options & ~(PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE | PS_STAT_ROBUST_FOR_SAMPLE)) {
-    switch (stats->options & ~(PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE)) {
-    case PS_STAT_SAMPLE_MEAN:
-        *value = stats->sampleMean;
-        psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);
-        return true;
-
-    case PS_STAT_SAMPLE_MEDIAN:
-        *value = stats->sampleMedian;
-        psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);
-        return true;
-
-    case PS_STAT_SAMPLE_STDEV:
-        *value = stats->sampleStdev;
-        psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);
-        return true;
-
-    case PS_STAT_ROBUST_MEDIAN:
-        *value = stats->robustMedian;
-        psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);
-        return true;
-
-    case PS_STAT_ROBUST_STDEV:
-        *value = stats->robustStdev;
-        psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);
-        return true;
-
-    case PS_STAT_CLIPPED_MEAN:
-        *value = stats->clippedMean;
-        psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);
-        return true;
-
-    case PS_STAT_CLIPPED_STDEV:
-        *value = stats->clippedStdev;
-        psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);
-        return true;
-
-    case PS_STAT_MAX:
-        *value = stats->max;
-        psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);
-        return true;
-
-    case PS_STAT_MIN:
-        *value = stats->min;
-        psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);
-        return true;
-
-    default:
-        psTrace(__func__, 4, "---- %s(false) end ----\n", __func__);
-        return false;
-    }
-}
 
 /******************************************************************************
@@ -2211,2 +2152,64 @@
     return psStatsOptionToString(stats->options);
 }
+
+inline psStatsOptions psStatsSingleOption(psStatsOptions option)
+{
+    switch (option & ~(PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE)) {
+    case PS_STAT_SAMPLE_MEAN:
+    case PS_STAT_SAMPLE_MEDIAN:
+    case PS_STAT_SAMPLE_STDEV:
+    case PS_STAT_SAMPLE_QUARTILE:
+    case PS_STAT_ROBUST_MEDIAN:
+    case PS_STAT_ROBUST_STDEV:
+    case PS_STAT_ROBUST_QUARTILE:
+    case PS_STAT_FITTED_MEAN:
+    case PS_STAT_FITTED_STDEV:
+    case PS_STAT_CLIPPED_MEAN:
+    case PS_STAT_CLIPPED_STDEV:
+    case PS_STAT_MAX:
+    case PS_STAT_MIN:
+        return option & ~(PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE);
+    default:
+        return 0;
+    }
+    psAbort(__func__, "Should never get here.\n");
+    return 0;
+}
+
+inline double psStatsGetValue(const psStats *stats, psStatsOptions option)
+{
+    // We could call psStatsSingle to check, but it would be a waste since we effectively do it anyway
+    switch (option & ~(PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE)) {
+    case PS_STAT_SAMPLE_MEAN:
+        return stats->sampleMean;
+    case PS_STAT_SAMPLE_MEDIAN:
+        return stats->sampleMedian;
+    case PS_STAT_SAMPLE_STDEV:
+        return stats->sampleStdev;
+    case PS_STAT_ROBUST_MEDIAN:
+        return stats->robustMedian;
+    case PS_STAT_ROBUST_STDEV:
+        return stats->robustStdev;
+    case PS_STAT_FITTED_MEAN:
+        return stats->fittedMean;
+    case PS_STAT_FITTED_STDEV:
+        return stats->fittedStdev;
+    case PS_STAT_CLIPPED_MEAN:
+        return stats->clippedMean;
+    case PS_STAT_CLIPPED_STDEV:
+        return stats->clippedStdev;
+    case PS_STAT_MAX:
+        return stats->max;
+    case PS_STAT_MIN:
+        return stats->min;
+    case PS_STAT_SAMPLE_QUARTILE:
+    case PS_STAT_ROBUST_QUARTILE:
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Cannot return a single quartile value; "
+                "get them yourself.\n");
+        return NAN;
+    default:
+        return NAN;
+    }
+    psAbort(__func__, "Should never get here.\n");
+    return NAN;
+}
Index: trunk/psLib/src/math/psStats.h
===================================================================
--- trunk/psLib/src/math/psStats.h	(revision 7991)
+++ trunk/psLib/src/math/psStats.h	(revision 7999)
@@ -14,6 +14,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.54 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-07-27 03:51:13 $
+ *  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-07-28 00:44:05 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -190,16 +190,4 @@
 );
 
-/** Extracts the statistic value specified by stats->options.
- *
- *  @return psBool    If more than one statistic result is set in stats->options,
- *                    false is returned and the value parameter is not set,
- *                    otherwise true is returned.
- */
-psBool p_psGetStatValue(
-    const psStats* stats, ///< the statistic struct to operate on
-
-    psF64 *value ///< if return is true, this is set to the specified statistic value by stats->options
-);
-
 
 // Get the statistics option from a string
@@ -211,5 +199,8 @@
 // Generate a string of statistics options from a psStats
 psString psStatsToString(const psStats *stats);
-
+// Is only a single statistics option set?
+inline psStatsOptions psStatsSingleOption(psStatsOptions option);
+// Return a particular stats value
+inline double psStatsGetValue(const psStats *stats, psStatsOptions option);
 
 /// @}
