Index: trunk/psLib/src/imageops/psImageStats.c
===================================================================
--- trunk/psLib/src/imageops/psImageStats.c	(revision 796)
+++ trunk/psLib/src/imageops/psImageStats.c	(revision 797)
@@ -15,28 +15,55 @@
 #include "psImage.h"
 #include "psFunctions.h"
-
 #include "float.h"
 #include <math.h>
+
 /// This routine must determine the various statistics for the image.
-psStats *
-
-psImageGetStats(const psImage *input,
-                psStats *stats)
-{
-    psVector *junk=NULL;
-    psStats *stats2= NULL;
-
-    junk = psVectorAlloc(input->numRows * input->numCols, input->type.type);
-    stats2 = psVectorStats(stats, junk, NULL, 0xffffffff);
-    psVectorFree(junk);
-
-    return(stats2);
-}
-
-psHistogram *
-psImageHistogram(psHistogram *hist,
-                 const psImage *input)
-{
-    return(hist);
+psStats *psImageStats(psStats *stats,
+                      psImage *in,
+                      psImage *mask,
+                      int maskVal)
+{
+    psVector *junkData=NULL;
+    psVector *junkMask=NULL;
+
+    junkData = psVectorAlloc(in->numRows * in->numCols, in->type.type);
+    junkMask = psVectorAlloc(mask->numRows * mask->numCols, mask->type.type);
+
+    // GUS: figure out mask types
+    junkData->vec.f = (float *) in->data.F32;
+    junkMask->vec.f = (float *) mask->data.F32;
+    stats = psVectorStats(stats, junkData, junkMask, maskVal);
+
+    psVectorFree(junkData);
+    psVectorFree(junkMask);
+
+    return(stats);
+}
+
+/*****************************************************************************
+    NOTE: We assume that the psHistogram structure out has already been
+    allocated and initialized.
+ *****************************************************************************/
+psHistogram *psImageHistogram(psHistogram *out,
+                              psImage *in,
+                              psImage *mask,
+                              int maskVal)
+{
+    psVector *junkData=NULL;
+    psVector *junkMask=NULL;
+
+    junkData = psVectorAlloc(in->numRows * in->numCols, in->type.type);
+    junkMask = psVectorAlloc(mask->numRows * mask->numCols, mask->type.type);
+
+    // GUS: figure out mask types
+    junkData->vec.f = (float *) in->data.F32;
+    junkMask->vec.f = (float *) mask->data.F32;
+
+    out = psHistogramVector(out, junkData, junkMask, maskVal);
+
+    psVectorFree(junkData);
+    psVectorFree(junkMask);
+
+    return(out);
 }
 
Index: trunk/psLib/src/imageops/psImageStats.h
===================================================================
--- trunk/psLib/src/imageops/psImageStats.h	(revision 796)
+++ trunk/psLib/src/imageops/psImageStats.h	(revision 797)
@@ -7,14 +7,14 @@
 
 /// This routine must determine the various statistics for the image.
-psStats *
-psImageGetStats(const psImage *input,   ///< image (or subimage) to calculate stats
-                psStats *stats          ///< defines statistics to be calculated & target
-               );
+psStats *psImageStats(psStats *stats, ///< defines statistics to be calculated
+                      psImage *in,    ///< image (or subimage) to calculate stats
+                      psImage *mask,  ///< mask data for image (NULL ok)
+                      int maskVal);   ///< mask Mask for mask
 
-/// Construct a histogram from an image (or subimage).
-psHistogram *
-psImageHistogram(psHistogram *hist,     ///< input histogram description & target
-                 const psImage *input   ///< determine histogram of this image
-                );
+
+psHistogram *psImageHistogram(psHistogram *out,  ///< input histogram description & target
+                              psImage *in,       ///< Image data to be histogramed.
+                              psImage *mask,     ///< mask data for image (NULL ok)
+                              int maskVal);      ///< mask Mask for mask
 
 /// Fit a 2-D polynomial surface to an image.
