Index: /trunk/psLib/src/dataManip/psConstants.h
===================================================================
--- /trunk/psLib/src/dataManip/psConstants.h	(revision 2292)
+++ /trunk/psLib/src/dataManip/psConstants.h	(revision 2293)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-11-06 00:44:56 $
+ *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-06 00:56:28 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -318,4 +318,13 @@
 }
 
+#define PS_IMAGE_CHECK_SIZE_EQUAL(NAME1, NAME2, RVAL) \
+if ((NAME1->numCols != NAME2->numCols) || \
+        (NAME1->numRows != NAME2->numRows)) { \
+    psError(PS_ERR_BAD_PARAMETER_SIZE, true, \
+            "Unallowable operation: psImages %s and %s are not the same size.", \
+            #NAME1, #NAME2); \
+    return(RVAL); \
+}
+
 
 
Index: /trunk/psLib/src/image/psImageStats.c
===================================================================
--- /trunk/psLib/src/image/psImageStats.c	(revision 2292)
+++ /trunk/psLib/src/image/psImageStats.c	(revision 2293)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.52 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-11-06 00:45:13 $
+ *  @version $Revision: 1.53 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-06 00:56:29 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -34,5 +34,10 @@
 /// This routine must determine the various statistics for the image.
 /*****************************************************************************
-XXX: verify that image/mask have the correct types, and sizes.
+psImageStats(stats, in, mask, maskVal): this routine simply calls the
+psVectorStats() routine, which does the actual statistical calculation.  In
+order to do so, we create dummy psVectors and set their "data" pointer to that
+of the input psImages.
+ 
+XXX: use static psVectors
  *****************************************************************************/
 psStats* psImageStats(psStats* stats,
@@ -41,12 +46,17 @@
                       psS32 maskVal)
 {
+    psVector *junkData = NULL;
+    psVector *junkMask = NULL;
+
     PS_PTR_CHECK_NULL(stats, NULL);
     PS_INT_CHECK_ZERO(stats->options, NULL);
     PS_IMAGE_CHECK_NULL(in, NULL)
-    psVector* junkData = NULL;
-    psVector* junkMask = NULL;
+    if (mask != NULL) {
+        PS_IMAGE_CHECK_TYPE(mask, PS_TYPE_U8, NULL);
+        PS_IMAGE_CHECK_SIZE_EQUAL(in, mask, NULL);
+    }
 
     // stuff the image data into a psVector struct.
-    junkData = psAlloc(sizeof(psVector));
+    junkData = (psVector *) psAlloc(sizeof(psVector));
     junkData->type = in->type;
     junkData->nalloc = in->numRows * in->numCols;
@@ -55,13 +65,4 @@
 
     if (mask != NULL) {
-        if (mask->type.type != PS_TYPE_MASK) {
-            char* typeStr;
-            PS_TYPE_NAME(typeStr,mask->type.type);
-            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
-                    PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE,
-                    typeStr, PS_TYPE_MASK_NAME);
-            psFree(junkData);
-            return NULL;
-        }
         // stuff the mask data into a psVector struct.
         junkMask = psAlloc(sizeof(psVector));
@@ -92,4 +93,5 @@
     if (mask != NULL) {
         PS_IMAGE_CHECK_TYPE(mask, PS_TYPE_U8, NULL);
+        PS_IMAGE_CHECK_SIZE_EQUAL(in, mask, NULL);
     }
     psVector* junkData = NULL;
@@ -137,21 +139,4 @@
         tmp = (M_PI * (tmp - 0.5)) / ((double)n);
         scalingFactors[i] = cos(tmp);
-    }
-
-    return (scalingFactors);
-}
-
-psVector *VeccalcScaleFactors(psVector *scalingFactors, psS32 n)
-{
-    PS_VECTOR_CHECK_NULL(scalingFactors, NULL);
-    PS_VECTOR_CHECK_TYPE(scalingFactors, PS_TYPE_F64, NULL);
-    PS_INT_CHECK_NON_NEGATIVE(n, NULL);
-    psS32 i = 0;
-    double tmp = 0.0;
-
-    for (i = 0; i < n; i++) {
-        tmp = (double)(n - i);
-        tmp = (M_PI * (tmp - 0.5)) / ((double)n);
-        scalingFactors->data.F64[i] = cos(tmp);
     }
 
Index: /trunk/psLib/src/imageops/psImageStats.c
===================================================================
--- /trunk/psLib/src/imageops/psImageStats.c	(revision 2292)
+++ /trunk/psLib/src/imageops/psImageStats.c	(revision 2293)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.52 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-11-06 00:45:13 $
+ *  @version $Revision: 1.53 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-06 00:56:29 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -34,5 +34,10 @@
 /// This routine must determine the various statistics for the image.
 /*****************************************************************************
-XXX: verify that image/mask have the correct types, and sizes.
+psImageStats(stats, in, mask, maskVal): this routine simply calls the
+psVectorStats() routine, which does the actual statistical calculation.  In
+order to do so, we create dummy psVectors and set their "data" pointer to that
+of the input psImages.
+ 
+XXX: use static psVectors
  *****************************************************************************/
 psStats* psImageStats(psStats* stats,
@@ -41,12 +46,17 @@
                       psS32 maskVal)
 {
+    psVector *junkData = NULL;
+    psVector *junkMask = NULL;
+
     PS_PTR_CHECK_NULL(stats, NULL);
     PS_INT_CHECK_ZERO(stats->options, NULL);
     PS_IMAGE_CHECK_NULL(in, NULL)
-    psVector* junkData = NULL;
-    psVector* junkMask = NULL;
+    if (mask != NULL) {
+        PS_IMAGE_CHECK_TYPE(mask, PS_TYPE_U8, NULL);
+        PS_IMAGE_CHECK_SIZE_EQUAL(in, mask, NULL);
+    }
 
     // stuff the image data into a psVector struct.
-    junkData = psAlloc(sizeof(psVector));
+    junkData = (psVector *) psAlloc(sizeof(psVector));
     junkData->type = in->type;
     junkData->nalloc = in->numRows * in->numCols;
@@ -55,13 +65,4 @@
 
     if (mask != NULL) {
-        if (mask->type.type != PS_TYPE_MASK) {
-            char* typeStr;
-            PS_TYPE_NAME(typeStr,mask->type.type);
-            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
-                    PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE,
-                    typeStr, PS_TYPE_MASK_NAME);
-            psFree(junkData);
-            return NULL;
-        }
         // stuff the mask data into a psVector struct.
         junkMask = psAlloc(sizeof(psVector));
@@ -92,4 +93,5 @@
     if (mask != NULL) {
         PS_IMAGE_CHECK_TYPE(mask, PS_TYPE_U8, NULL);
+        PS_IMAGE_CHECK_SIZE_EQUAL(in, mask, NULL);
     }
     psVector* junkData = NULL;
@@ -137,21 +139,4 @@
         tmp = (M_PI * (tmp - 0.5)) / ((double)n);
         scalingFactors[i] = cos(tmp);
-    }
-
-    return (scalingFactors);
-}
-
-psVector *VeccalcScaleFactors(psVector *scalingFactors, psS32 n)
-{
-    PS_VECTOR_CHECK_NULL(scalingFactors, NULL);
-    PS_VECTOR_CHECK_TYPE(scalingFactors, PS_TYPE_F64, NULL);
-    PS_INT_CHECK_NON_NEGATIVE(n, NULL);
-    psS32 i = 0;
-    double tmp = 0.0;
-
-    for (i = 0; i < n; i++) {
-        tmp = (double)(n - i);
-        tmp = (M_PI * (tmp - 0.5)) / ((double)n);
-        scalingFactors->data.F64[i] = cos(tmp);
     }
 
Index: /trunk/psLib/src/math/psConstants.h
===================================================================
--- /trunk/psLib/src/math/psConstants.h	(revision 2292)
+++ /trunk/psLib/src/math/psConstants.h	(revision 2293)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-11-06 00:44:56 $
+ *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-06 00:56:28 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -318,4 +318,13 @@
 }
 
+#define PS_IMAGE_CHECK_SIZE_EQUAL(NAME1, NAME2, RVAL) \
+if ((NAME1->numCols != NAME2->numCols) || \
+        (NAME1->numRows != NAME2->numRows)) { \
+    psError(PS_ERR_BAD_PARAMETER_SIZE, true, \
+            "Unallowable operation: psImages %s and %s are not the same size.", \
+            #NAME1, #NAME2); \
+    return(RVAL); \
+}
+
 
 
