Index: trunk/psLib/test/image/tst_psImageStats00.c
===================================================================
--- trunk/psLib/test/image/tst_psImageStats00.c	(revision 887)
+++ trunk/psLib/test/image/tst_psImageStats00.c	(revision 887)
@@ -0,0 +1,113 @@
+/*****************************************************************************
+    This routine must ensure that the psHistogram structure is correctly
+    allocated and populated by the psImageHistogram() function.
+ *****************************************************************************/
+#include <stdio.h>
+#include "pslib.h"
+#include "psTest.h"
+#include "psMemory.h"
+#include "psImage.h"
+#include "psImageStats.h"
+#define NUM_BINS 20
+#define IMAGE_SIZE 20
+
+int main()
+{
+    psHistogram *myHist = NULL;
+    psImage *tmpImage   = NULL;
+    psImage *tmpMask    = NULL;
+    int testStatus      = true;
+    int memLeaks        = 0;
+    int i               = 0;
+    int j               = 0;
+    int currentId       = 0;
+
+    currentId       = psMemGetId();
+    /*************************************************************************/
+    /*  Allocate and initialize data structures                      */
+    /*************************************************************************/
+    tmpImage = psImageAlloc(IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32);
+    for (i=0;i<IMAGE_SIZE;i++) {
+        for (j=0;j<IMAGE_SIZE;j++) {
+            tmpImage->data.F32[i][j] = (float) (i + j);
+        }
+    }
+    tmpMask = psImageAlloc(IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_U8);
+    for (i=0;i<IMAGE_SIZE;i++) {
+        for (j=0;j<IMAGE_SIZE;j++) {
+            if ((i > (IMAGE_SIZE/2)) &&
+                    (j > (IMAGE_SIZE/2))) {
+                tmpMask->data.U8[i][j] = 1;
+            } else {
+                tmpMask->data.U8[i][j] = 0;
+            }
+        }
+    }
+    /*************************************************************************/
+    /*  Calculate Histogram with no mask                             */
+    /*************************************************************************/
+    printPositiveTestHeader(stdout,
+                            "psImageStats functions",
+                            "Calculate Histogram, no mask");
+
+    myHist = psHistogramAlloc(0.0, (float) (2 * IMAGE_SIZE), NUM_BINS);
+    myHist = psImageHistogram(myHist, tmpImage, NULL, 0);
+    for (i=0;i<NUM_BINS;i++) {
+        printf("Bin number %d bounds: (%f - %f) data (%d)\n", i,
+               myHist->bounds->data.F32[i],
+               myHist->bounds->data.F32[i+1],
+               myHist->nums->data.S32[i]);
+    }
+    psHistogramFree(myHist);
+
+    psMemCheckCorruption(1);
+    printFooter(stdout,
+                "psImageStats functions",
+                "Calculate Histogram, no mask",
+                testStatus);
+
+    /*************************************************************************/
+    /*  Calculate Histogram with mask                                */
+    /*************************************************************************/
+    printPositiveTestHeader(stdout,
+                            "psImageStats functions",
+                            "Calculate Histogram with mask");
+
+    myHist = psHistogramAlloc(0.0, (float) (2 * IMAGE_SIZE), NUM_BINS);
+    myHist = psImageHistogram(myHist, tmpImage, tmpMask, 1);
+    for (i=0;i<NUM_BINS;i++) {
+        printf("Bin number %d bounds: (%f - %f) data (%d)\n", i,
+               myHist->bounds->data.F32[i],
+               myHist->bounds->data.F32[i+1],
+               myHist->nums->data.S32[i]);
+    }
+
+    psMemCheckCorruption(1);
+    printFooter(stdout,
+                "psImageStats functions",
+                "Calculate Histogram with mask",
+                testStatus);
+
+    /*************************************************************************/
+    /*  Deallocate data structures                                   */
+    /*************************************************************************/
+    printPositiveTestHeader(stdout,
+                            "psImageStats functions",
+                            "Deallocate the psHistogram/psImage structure.");
+    psHistogramFree(myHist);
+    psImageFree(tmpImage);
+    psImageFree(tmpMask);
+
+    psMemCheckCorruption(1);
+    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+
+    printFooter(stdout,
+                "psImageStats functions",
+                "Deallocate the psHistogram/psImage structure.",
+                testStatus);
+
+    return (!testStatus);
+}
Index: trunk/psLib/test/image/tst_psImageStats01.c
===================================================================
--- trunk/psLib/test/image/tst_psImageStats01.c	(revision 887)
+++ trunk/psLib/test/image/tst_psImageStats01.c	(revision 887)
@@ -0,0 +1,106 @@
+/*****************************************************************************
+    This routine must ensure that the psImageStats() routine can correctly
+    call the psVectorStats() routine.  Since the psVectorStats() will be
+    thouroughly tested elsewhere, we will only test psImageStats() with
+    the PS_STAT_SAMPLE_MEAN here.
+ *****************************************************************************/
+#include <stdio.h>
+#include "pslib.h"
+#include "psTest.h"
+#include "psMemory.h"
+#include "psImage.h"
+#include "psImageStats.h"
+#define NUM_BINS 20
+#define IMAGE_SIZE 512
+
+int main()
+{
+    psStats *myStats    = NULL;
+    psImage *tmpImage   = NULL;
+    psImage *tmpMask    = NULL;
+    int testStatus      = true;
+    int memLeaks        = 0;
+    int i               = 0;
+    int j               = 0;
+    int currentId       = 0;
+
+    currentId       = psMemGetId();
+    /*************************************************************************/
+    /*  Allocate and initialize data structures                      */
+    /*************************************************************************/
+    tmpImage = psImageAlloc(IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32);
+    for (i=0;i<IMAGE_SIZE;i++) {
+        for (j=0;j<IMAGE_SIZE;j++) {
+            tmpImage->data.F32[i][j] = (float) (i + j);
+        }
+    }
+    tmpMask = psImageAlloc(IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_U8);
+    for (i=0;i<IMAGE_SIZE;i++) {
+        for (j=0;j<IMAGE_SIZE;j++) {
+            if ((i > (IMAGE_SIZE/2)) &&
+                    (j > (IMAGE_SIZE/2))) {
+                tmpMask->data.U8[i][j] = 1;
+            } else {
+                tmpMask->data.U8[i][j] = 0;
+            }
+        }
+    }
+
+    myStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
+    /*************************************************************************/
+    /*  Calculate Sample Mean with no mask                           */
+    /*************************************************************************/
+    printPositiveTestHeader(stdout,
+                            "psImageStats functions",
+                            "Calculate Sample Mean, no mask");
+
+    myStats = psImageStats(myStats, tmpImage, NULL, 0);
+    printf("The sample mean was %f\n", myStats->sampleMean);
+
+    psMemCheckCorruption(1);
+
+    printFooter(stdout,
+                "psImageStats functions",
+                "Calculate Sample Mean, no mask",
+                testStatus);
+
+    /*************************************************************************/
+    /*  Calculate Sample Mean with mask                              */
+    /*************************************************************************/
+    printPositiveTestHeader(stdout,
+                            "psImageStats functions",
+                            "Calculate Sample Mean with mask");
+
+    myStats = psImageStats(myStats, tmpImage, tmpMask, 1);
+    printf("The sample mean was %f\n", myStats->sampleMean);
+
+    psMemCheckCorruption(1);
+
+    printFooter(stdout,
+                "psImageStats functions",
+                "Calculate Sample Mean with mask",
+                testStatus);
+
+    /*************************************************************************/
+    /*  Deallocate data structures                                   */
+    /*************************************************************************/
+    printPositiveTestHeader(stdout,
+                            "psImageStats functions",
+                            "Deallocate the psStats/psImage structure.");
+    psStatsFree(myStats);
+    psImageFree(tmpImage);
+    psImageFree(tmpMask);
+
+    psMemCheckCorruption(1);
+    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+
+    printFooter(stdout,
+                "psImageStats functions",
+                "Deallocate the psStats/psImage structure.",
+                testStatus);
+
+    return (!testStatus);
+}
Index: trunk/psLib/test/image/tst_psImageStats02.c
===================================================================
--- trunk/psLib/test/image/tst_psImageStats02.c	(revision 887)
+++ trunk/psLib/test/image/tst_psImageStats02.c	(revision 887)
@@ -0,0 +1,108 @@
+/*****************************************************************************
+    This routine must ensure that the psImageStats() routine can correctly
+    call the psVectorStats() routine.  Since the psVectorStats() will be
+    thouroughly tested elsewhere, we will only test psImageStats() with
+    the PS_STAT_SAMPLE_MEAN here.
+ *****************************************************************************/
+#include <stdio.h>
+#include "pslib.h"
+#include "psTest.h"
+#include "psMemory.h"
+#include "psImage.h"
+#include "psImageStats.h"
+#define NUM_BINS 20
+#define IMAGE_SIZE 10
+#define CHEBY_X_DIM 5
+#define CHEBY_Y_DIM 3
+
+int main()
+{
+    psStats *myStats    = NULL;
+    psImage *tmpImage   = NULL;
+    psImage *outImage   = NULL;
+    psPolynomial2D *my2DPoly = NULL;
+    int testStatus      = true;
+    int memLeaks        = 0;
+    int i               = 0;
+    int j               = 0;
+    int rc              = 0;
+    int currentId       = 0;
+
+    currentId       = psMemGetId();
+    /*************************************************************************/
+    /*  Allocate and initialize data structures                      */
+    /*************************************************************************/
+    tmpImage = psImageAlloc(IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32);
+    outImage = psImageAlloc(IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32);
+    for (i=0;i<IMAGE_SIZE;i++) {
+        for (j=0;j<IMAGE_SIZE;j++) {
+            tmpImage->data.F32[i][j] = (float) (i + j);
+            outImage->data.F32[i][j] = 0.0;
+        }
+    }
+    for (i=0;i<IMAGE_SIZE;i++) {
+        for (j=0;j<IMAGE_SIZE;j++) {
+            printf("(%f, %f)\n", tmpImage->data.F32[i][j],
+                   outImage->data.F32[i][j]);
+        }
+    }
+    my2DPoly = psPolynomial2DAlloc(CHEBY_X_DIM, CHEBY_Y_DIM);
+    /*************************************************************************/
+    /*  Calculate Chebyshev Polynomials, no mask                     */
+    /*************************************************************************/
+    printPositiveTestHeader(stdout,
+                            "psImageStats functions",
+                            "Calculate Chebyshev Polynomials, no mask");
+
+    my2DPoly = psImageFitPolynomial(tmpImage, my2DPoly);
+
+    psMemCheckCorruption(1);
+    printFooter(stdout,
+                "psImageStats functions",
+                "Calculate Chebyshev Polynomials, no mask",
+                testStatus);
+    /*************************************************************************/
+    /*  Evaluate Chebyshev Polynomials, no mask                      */
+    /*************************************************************************/
+    printPositiveTestHeader(stdout,
+                            "psImageStats functions",
+                            "Calculate Chebyshev Polynomials, no mask");
+
+    rc = psImageEvalPolynomial(outImage, my2DPoly);
+    for (i=0;i<IMAGE_SIZE;i++) {
+        for (j=0;j<IMAGE_SIZE;j++) {
+            printf("(%f, %f)\n", tmpImage->data.F32[i][j],
+                   outImage->data.F32[i][j]);
+        }
+    }
+
+    psMemCheckCorruption(1);
+    printFooter(stdout,
+                "psImageStats functions",
+                "Calculate Chebyshev Polynomials, no mask",
+                testStatus);
+
+    /*************************************************************************/
+    /*  Deallocate data structures                                   */
+    /*************************************************************************/
+    printPositiveTestHeader(stdout,
+                            "psImageStats functions",
+                            "Deallocate the psStats/psImage structure.");
+    psStatsFree(myStats);
+    psImageFree(tmpImage);
+    psImageFree(outImage);
+    psPolynomial2DFree(my2DPoly);
+
+    psMemCheckCorruption(1);
+    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+
+    printFooter(stdout,
+                "psImageStats functions",
+                "Deallocate the psStats/psImage structure.",
+                testStatus);
+
+    return (!testStatus);
+}
