Index: trunk/psLib/test/image/tst_psImageStats02.c
===================================================================
--- trunk/psLib/test/image/tst_psImageStats02.c	(revision 1078)
+++ trunk/psLib/test/image/tst_psImageStats02.c	(revision 1365)
@@ -1,11 +1,11 @@
 /*****************************************************************************
-    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.
- 
-    NOTE: After you debug, set CHEBY_X_DIM != CHEBY_Y_DIM.
-    Also, uses non-square images.
- *****************************************************************************/
+   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.
+
+   NOTE: After you debug, set CHEBY_X_DIM != CHEBY_Y_DIM.
+   Also, uses non-square images.
+*****************************************************************************/
 #include <stdio.h>
 #include "pslib.h"
@@ -19,103 +19,103 @@
 #define CHEBY_X_DIM 8
 #define CHEBY_Y_DIM 8
-#define THRESHOLD 1.0
+#define THRESHOLD 10
 int main()
 {
-    psStats *myStats    = NULL;
-    psImage *tmpImage   = NULL;
-    psImage *outImage   = NULL;
+    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();
+    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] = 4.0;
-            tmpImage->data.F32[i][j] = (float) (i + j);
-            tmpImage->data.F32[i][j] = (float) (i + j) + (4.0 * (float) i);
-            outImage->data.F32[i][j] = 0.0;
+    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 ] = 4.0;
+                    tmpImage->data.F32[ i ][ j ] = ( float ) ( i + j );
+                    tmpImage->data.F32[ i ][ j ] = ( float ) ( i + j ) + ( 4.0 * ( float ) i );
+                    outImage->data.F32[ i ][ j ] = 0.0;
+                }
         }
-    }
-    my2DPoly = psPolynomial2DAlloc(CHEBY_X_DIM, CHEBY_Y_DIM);
+    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);
-    for (i=0;i<CHEBY_X_DIM;i++) {
-        for (j=0;j<CHEBY_Y_DIM;j++) {
-            printf("Cheby Polynomial (%d, %d) coefficient is %f\n", i, j, my2DPoly->coeff[i][j]);
+    printPositiveTestHeader( stdout,
+                             "psImageStats functions",
+                             "Calculate Chebyshev Polynomials, no mask" );
+                             
+    my2DPoly = psImageFitPolynomial( tmpImage, my2DPoly );
+    for ( i = 0;i < CHEBY_X_DIM;i++ ) {
+            for ( j = 0;j < CHEBY_Y_DIM;j++ ) {
+                    printf( "Cheby Polynomial (%d, %d) coefficient is %.2f\n", i, j, my2DPoly->coeff[ i ][ j ] );
+                }
         }
-    }
-
-    psMemCheckCorruption(1);
-    printFooter(stdout,
-                "psImageStats functions",
-                "Calculate Chebyshev Polynomials, no mask",
-                testStatus);
+        
+    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("pixel[%d][%d] is (%f, %f)\n", i, j,
-            //                     tmpImage->data.F32[i][j],
-            //                     outImage->data.F32[i][j]);
-            if (fabs(outImage->data.F32[i][j] - tmpImage->data.F32[i][j]) > THRESHOLD) {
-                printf("Pixel (%d, %d) is %f, should be %f\n", i, j,
-                       outImage->data.F32[i][j],
-                       tmpImage->data.F32[i][j]);
-            }
-
+    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("pixel[%d][%d] is (%f, %f)\n", i, j,
+                    //                     tmpImage->data.F32[i][j],
+                    //                     outImage->data.F32[i][j]);
+                    if ( fabs( outImage->data.F32[ i ][ j ] - tmpImage->data.F32[ i ][ j ] ) > THRESHOLD ) {
+                            printf( "Pixel (%d, %d) is %.2f, should be %.2f\n", i, j,
+                                    outImage->data.F32[ i ][ j ],
+                                    tmpImage->data.F32[ i ][ j ] );
+                        }
+                        
+                }
         }
-    }
-
-    psMemCheckCorruption(1);
-    printFooter(stdout,
-                "psImageStats functions",
-                "Calculate Chebyshev Polynomials, no mask",
-                testStatus);
-
+        
+    psMemCheckCorruption( 1 );
+    printFooter( stdout,
+                 "psImageStats functions",
+                 "Calculate Chebyshev Polynomials, no mask",
+                 testStatus );
+                 
     /*************************************************************************/
     /*  Deallocate data structures                                   */
     /*************************************************************************/
-    printPositiveTestHeader(stdout,
-                            "psImageStats functions",
-                            "Deallocate the psStats/psImage structure.");
-    psFree(myStats);
-    psFree(tmpImage);
-    psFree(outImage);
-    psFree(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);
+    printPositiveTestHeader( stdout,
+                             "psImageStats functions",
+                             "Deallocate the psStats/psImage structure." );
+    psFree( myStats );
+    psFree( tmpImage );
+    psFree( outImage );
+    psFree( 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 );
 }
