Index: /trunk/psLib/test/image/tst_psImageManip.c
===================================================================
--- /trunk/psLib/test/image/tst_psImageManip.c	(revision 1925)
+++ /trunk/psLib/test/image/tst_psImageManip.c	(revision 1926)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-29 00:28:21 $
+ *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-29 19:50:43 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -860,5 +860,8 @@
     psImage* out = NULL;
     psImage* out2 = NULL;
+    psImage* out3 = NULL;
+    psImage* mask = NULL;
     psImage* meanTruth = NULL;
+    psImage* meanTruthWMask = NULL;
     psImage* maxTruth = NULL;
     psStats stats;
@@ -875,13 +878,23 @@
     #define testRebinType(DATATYPE)  \
     in = psImageAlloc(16,16,PS_TYPE_##DATATYPE); \
+    mask = psImageAlloc(16,16,PS_TYPE_U8); \
     meanTruth = psImageAlloc(4,4,PS_TYPE_F32); \
+    meanTruthWMask = psImageAlloc(4,4,PS_TYPE_F32); \
     maxTruth = psImageAlloc(6,6,PS_TYPE_F32); \
     memset(meanTruth->data.F32[0],0,sizeof(psF32)*4*4); \
+    memset(meanTruthWMask->data.F32[0],0,sizeof(psF32)*4*4); \
     memset(maxTruth->data.F32[0],0,sizeof(psF32)*6*6); \
     for (int row = 0; row<16; row++) { \
         ps##DATATYPE* inRow = in->data.DATATYPE[row]; \
         psF32* meanTruthRow = meanTruth->data.F32[row/4]; \
+        psF32* meanTruthWMaskRow = meanTruthWMask->data.F32[row/4]; \
         psF32* maxTruthRow = maxTruth->data.F32[row/3]; \
+        psU8* maskRow = mask->data.U8[row]; \
         for (int col = 0; col<16; col++) { \
+            if(col != 15) { \
+                maskRow[col] = 0; \
+            } else { \
+                maskRow[col] = 1; \
+            } \
             inRow[col] = row + col; \
             meanTruthRow[col/4] += row + col; \
@@ -889,10 +902,19 @@
                 maxTruthRow[col/3] = row+col; \
             } \
+            if(maskRow[col] == 0 ) { \
+                meanTruthWMaskRow[col/4] += row + col; \
+            } \
         } \
     } \
     for (int row = 0; row<4; row++) { \
         psF32* meanTruthRow = meanTruth->data.F32[row]; \
+        psF32* meanTruthWMaskRow = meanTruthWMask->data.F32[row]; \
         for (int col = 0; col<4; col++) { \
             meanTruthRow[col] /= 16; \
+            if ( col == 3 ) { \
+                meanTruthWMaskRow[col] /= 12; \
+            } else { \
+                meanTruthWMaskRow[col] /= 16; \
+            } \
         } \
     } \
@@ -921,4 +943,18 @@
         } \
     } \
+    stats.options = PS_STAT_SAMPLE_MEAN; \
+    out3 = psImageRebin(NULL,in,mask,1,4,&stats); \
+    for (int row = 0; row<4; row++) { \
+        ps##DATATYPE* outRow = out3->data.DATATYPE[row]; \
+        psF32* truthRow = meanTruthWMask->data.F32[row]; \
+        for ( int col = 0; col<4; col++) { \
+            if(abs((int)outRow[col]-(int)truthRow[col]) > FLT_EPSILON) { \
+                psError(__func__,"psImageRebin with mask didn't produce the proper mean " \
+                        "result at (%d,%d) [%f vs %f].", \
+                        col,row,outRow[col],truthRow[col]); \
+                return 3; \
+            } \
+        } \
+    } \
     stats.options = PS_STAT_MAX; \
     out2 = psImageRebin(out,in,NULL,0,3,&stats); \
@@ -951,5 +987,8 @@
     psFree(in); \
     psFree(out); \
+    psFree(out3); \
+    psFree(mask); \
     psFree(meanTruth); \
+    psFree(meanTruthWMask); \
     psFree(maxTruth);
 
@@ -961,6 +1000,7 @@
     // Verify the returned psImage structure is null and program execution
     // doesn't stop, if the input image type is not supported.
-    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");
+    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for unsupported type.");
     in = psImageAlloc(16,16,PS_TYPE_U8);
+    mask = psImageAlloc(16,16,PS_TYPE_F32);
     stats.options = PS_STAT_SAMPLE_MEAN;
     out = psImageRebin(NULL,in,NULL,0,4,&stats);
@@ -970,4 +1010,14 @@
         return 14;
     }
+    // Verify the returned psImage structure is null and program execution
+    // doesn't stop, if the mask type is not U8
+    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for invallid mask type.");
+    out = psImageRebin(NULL,in,mask,1,4,&stats);
+    if(out != NULL) {
+        psError(__func__,"psImageRebin return an image eventhough the "
+                "mask is not the correct type.");
+        return 17;
+    }
+    psFree(mask);
     psFree(in);
 
@@ -986,5 +1036,5 @@
     // doesn't stop, if the input parameter scale is less than or equal to zero.
     in = psImageAlloc(16, 16, PS_TYPE_F32);
-    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");
+    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for scale < 0.");
     out2 = psImageRebin(NULL,in,NULL,0,0,&stats);
 
@@ -997,5 +1047,5 @@
     // Verify the returned psImage structure is null and program execution
     // doesn't stop, if the input parameter stats is null.
-    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");
+    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for stats null.");
     out2 = psImageRebin(NULL,in,NULL,0,1,NULL);
 
@@ -1010,5 +1060,5 @@
     // is zero or any value which doesn't correspond to a valid statistical
     // method.
-    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");
+    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for stats options 0.");
     stats.options = 0;
     out2 = psImageRebin(NULL,in,NULL,0,1,&stats);
@@ -1020,5 +1070,5 @@
     }
 
-    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");
+    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for stat options use range.");
     stats.options = PS_STAT_USE_RANGE;
     out2 = psImageRebin(NULL,in,NULL,0,1,&stats);
@@ -1033,5 +1083,5 @@
     // doesn't stop, if the input parameter psStats structure member options
     // specifies more than one valid statistical method.
-    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");
+    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for stats with multiple options.");
     stats.options = PS_STAT_SAMPLE_MEAN + PS_STAT_MAX;
     out2 = psImageRebin(NULL,in,NULL,0,1,&stats);
Index: /trunk/psLib/test/image/verified/tst_psImageManip.stderr
===================================================================
--- /trunk/psLib/test/image/verified/tst_psImageManip.stderr	(revision 1925)
+++ /trunk/psLib/test/image/verified/tst_psImageManip.stderr	(revision 1926)
@@ -125,5 +125,5 @@
     Following should error as overlay isn't within image boundaries
 <DATE><TIME>|<HOST>|E|psLib.image.psImageOverlaySection
-    Specified subset range, [32:<LINENO>,64:<LINENO>], lies outside psImage's boundaries, [0:<LINENO>,0:<LINENO>].
+    Specified subset range, [32:<LINENO>,64:<LINENO>], is invalid or outside input psImage's boundaries, [0:<LINENO>,0:<LINENO>].
 <DATE><TIME>|<HOST>|I|testImageOverlay
     Following should error as overlay is NULL
@@ -160,27 +160,31 @@
 
 <DATE><TIME>|<HOST>|I|testImageRebin
-    Following should be an error.
+    Following should be an error for unsupported type.
 <DATE><TIME>|<HOST>|E|psLib.image.psImageRebin
     Specified psImage type, psU8, is not supported.
-<DATE><TIME>|<HOST>|E|psLib.image.psImageRebin
-    Can not operate on a NULL psImage.
-<DATE><TIME>|<HOST>|I|testImageRebin
-    Following should be an error.
+<DATE><TIME>|<HOST>|I|testImageRebin
+    Following should be an error for invallid mask type.
+<DATE><TIME>|<HOST>|E|psLib.image.psImageRebin
+    Input psImage mask type, psF32, is not the supported mask datatype of psU8.
+<DATE><TIME>|<HOST>|E|psLib.image.psImageRebin
+    Can not operate on a NULL psImage.
+<DATE><TIME>|<HOST>|I|testImageRebin
+    Following should be an error for scale < 0.
 <DATE><TIME>|<HOST>|E|psLib.image.psImageRebin
     Specified scale value, 0, must be a positive value.
 <DATE><TIME>|<HOST>|I|testImageRebin
-    Following should be an error.
+    Following should be an error for stats null.
 <DATE><TIME>|<HOST>|E|psLib.image.psImageRebin
     Specified statistic can not be NULL.
 <DATE><TIME>|<HOST>|I|testImageRebin
-    Following should be an error.
+    Following should be an error for stats options 0.
 <DATE><TIME>|<HOST>|E|psLib.image.psImageRebin
     Specified statistic option, 0, is not valid.  Must specify one and only one statistic type.
 <DATE><TIME>|<HOST>|I|testImageRebin
-    Following should be an error.
+    Following should be an error for stat options use range.
 <DATE><TIME>|<HOST>|E|psLib.image.psImageRebin
     Specified statistic option, 8192, is not valid.  Must specify one and only one statistic type.
 <DATE><TIME>|<HOST>|I|testImageRebin
-    Following should be an error.
+    Following should be an error for stats with multiple options.
 <DATE><TIME>|<HOST>|E|psLib.image.psImageRebin
     Specified statistic option, 2049, is not valid.  Must specify one and only one statistic type.
