Index: trunk/psLib/src/image/psImage.c
===================================================================
--- trunk/psLib/src/image/psImage.c	(revision 1406)
+++ trunk/psLib/src/image/psImage.c	(revision 1407)
@@ -1,2 +1,3 @@
+
 /** @file  psImage.c
  *
@@ -9,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-08-06 22:34:05 $
+ *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-08-07 00:06:06 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -18,5 +19,7 @@
 
 /******************************************************************************/
+
 /*  INCLUDE FILES                                                             */
+
 /******************************************************************************/
 
@@ -29,53 +32,61 @@
 #include "psImage.h"
 
-static void imageFree(psImage* image);
+static void imageFree(psImage * image);
 
 /*****************************************************************************/
+
 /* FUNCTION IMPLEMENTATION - PUBLIC                                          */
+
 /*****************************************************************************/
 
-psImage *psImageAlloc(unsigned int numCols, unsigned int numRows,
-                      const psElemType type)
+psImage *psImageAlloc(unsigned int numCols, unsigned int numRows, const psElemType type)
 {
     int area = 0;
-    int elementSize = PSELEMTYPE_SIZEOF(type); // element size in bytes
-    int rowSize = numCols*elementSize;  // row size in bytes.
-
-    area = numCols*numRows;
+    int elementSize = PSELEMTYPE_SIZEOF(type);  // element
+
+    // size in
+    // bytes
+    int rowSize = numCols * elementSize;        // row
+
+    // size
+
+    // in bytes.
+
+    area = numCols * numRows;
 
     if (area < 1) {
-        psError(__func__, "Invalid value for number of rows or columns "
-                "(numRows=%d, numCols=%d).", numRows, numCols);
+        psError(__func__,
+                "Invalid value for number of rows or columns " "(numRows=%d, numCols=%d).", numRows, numCols);
         return NULL;
     }
 
-    psImage *image = (psImage *)psAlloc(sizeof(psImage));
-    if(image == NULL) {
-        psAbort(__func__," : Line %d - Failed to allocate memory", __LINE__);
-    }
-
-    p_psMemSetDeallocator(image,(psFreeFcn)imageFree);
-
-    image->data.V = psAlloc(sizeof(void*)*numRows);
-    if(image->data.V == NULL) {
-        psAbort(__func__," : Line %d - Failed to allocate memory", __LINE__);
-    }
-
-
-    image->data.V[0] = psAlloc(area*elementSize);
-    if(image->data.V[0] == NULL) {
-        psAbort(__func__," : Line %d - Failed to allocate memory", __LINE__);
-    }
-
-    for(int i = 1; i < numRows; i++) {
-        image->data.V[i] = (void*)((int8_t*)image->data.V[i-1]+rowSize);
-    }
-
-    *(int*)&image->col0 = 0;
-    *(int*)&image->row0 = 0;
-    *(unsigned int*)&image->numCols = numCols;
-    *(unsigned int*)&image->numRows = numRows;
-    *(psDimen*)&image->type.dimen = PS_DIMEN_IMAGE;
-    *(psElemType*)&image->type.type = type;
+    psImage *image = (psImage *) psAlloc(sizeof(psImage));
+
+    if (image == NULL) {
+        psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
+    }
+
+    p_psMemSetDeallocator(image, (psFreeFcn) imageFree);
+
+    image->data.V = psAlloc(sizeof(void *) * numRows);
+    if (image->data.V == NULL) {
+        psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
+    }
+
+    image->data.V[0] = psAlloc(area * elementSize);
+    if (image->data.V[0] == NULL) {
+        psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
+    }
+
+    for (int i = 1; i < numRows; i++) {
+        image->data.V[i] = (void *)((int8_t *) image->data.V[i - 1] + rowSize);
+    }
+
+    *(int *)&image->col0 = 0;
+    *(int *)&image->row0 = 0;
+    *(unsigned int *)&image->numCols = numCols;
+    *(unsigned int *)&image->numRows = numRows;
+    *(psDimen *) & image->type.dimen = PS_DIMEN_IMAGE;
+    *(psElemType *) & image->type.type = type;
     image->parent = NULL;
     image->nChildren = 0;
@@ -85,5 +96,5 @@
 }
 
-static void imageFree(psImage* image)
+static void imageFree(psImage * image)
 {
     if (image == NULL) {
@@ -92,12 +103,13 @@
 
     if (image->type.type == PS_TYPE_PTR) {
-        // 2-D array of pointers -- must dereference
+        // 2-D array of pointers -- must
+        // dereference
         unsigned int oldNumRows = image->numRows;
         unsigned int oldNumCols = image->numCols;
-        psPTR* rowPtr;
-
-        for(unsigned int row=0;row<oldNumRows;row++) {
+        psPTR *rowPtr;
+
+        for (unsigned int row = 0; row < oldNumRows; row++) {
             rowPtr = image->data.PTR[row];
-            for (unsigned int col=0;col<oldNumCols;col++) {
+            for (unsigned int col = 0; col < oldNumCols; col++) {
                 psMemDecrRefCounter(rowPtr[col]);
             }
@@ -112,31 +124,36 @@
 }
 
-psImage* psImageRecycle(psImage* old,
-                        unsigned int numCols,
-                        unsigned int numRows,
-                        const psElemType type)
+psImage *psImageRecycle(psImage * old, unsigned int numCols, unsigned int numRows, const psElemType type)
 {
-    int elementSize = PSELEMTYPE_SIZEOF(type); // element size in bytes
-    int rowSize = numCols*elementSize;  // row size in bytes.
+    int elementSize = PSELEMTYPE_SIZEOF(type);  // element
+
+    // size in
+    // bytes
+    int rowSize = numCols * elementSize;        // row
+
+    // size
+
+    // in bytes.
 
     if (old == NULL) {
-        old = psImageAlloc(numCols,numRows,type);
+        old = psImageAlloc(numCols, numRows, type);
         return old;
     }
 
     if (old->type.dimen != PS_DIMEN_IMAGE) {
-        psError(__func__,"Can not realloc image because input is not an image.");
+        psError(__func__, "Can not realloc image because input is not an image.");
         return NULL;
     }
 
     if (old->type.type == PS_TYPE_PTR) {
-        // 2-D array of pointers -- must dereference
+        // 2-D array of pointers -- must
+        // dereference
         unsigned int oldNumRows = old->numRows;
         unsigned int oldNumCols = old->numCols;
-        psPTR* rowPtr;
-
-        for(unsigned int row=0;row<oldNumRows;row++) {
+        psPTR *rowPtr;
+
+        for (unsigned int row = 0; row < oldNumRows; row++) {
             rowPtr = old->data.PTR[row];
-            for (unsigned int col=0;col<oldNumCols;col++) {
+            for (unsigned int col = 0; col < oldNumCols; col++) {
                 psMemDecrRefCounter(rowPtr[col]);
                 rowPtr[col] = NULL;
@@ -146,26 +163,24 @@
 
     /* image already the right size/type? */
-    if (numCols == old->numCols && numRows == old->numRows &&
-            type == old->type.type) {
+    if (numCols == old->numCols && numRows == old->numRows && type == old->type.type) {
         return old;
     }
-
     // Resize the image buffer
-    old->data.V[0] = psRealloc(old->data.V[0],numCols * numRows * elementSize);
-    old->data.V = (void**) psRealloc(old->data.V,numRows * sizeof(void*));
+    old->data.V[0] = psRealloc(old->data.V[0], numCols * numRows * elementSize);
+    old->data.V = (void **)psRealloc(old->data.V, numRows * sizeof(void *));
 
     // recreate the row pointers
-    for(int i = 1; i < numRows; i++) {
-        old->data.V[i] = (void*)((int8_t*)old->data.V[i-1]+rowSize);
-    }
-
-    *(unsigned int*)&old->numCols = numCols;
-    *(unsigned int*)&old->numRows = numRows;
-    *(psElemType*)&old->type.type = type;
+    for (int i = 1; i < numRows; i++) {
+        old->data.V[i] = (void *)((int8_t *) old->data.V[i - 1] + rowSize);
+    }
+
+    *(unsigned int *)&old->numCols = numCols;
+    *(unsigned int *)&old->numRows = numRows;
+    *(psElemType *) & old->type.type = type;
 
     return old;
 }
 
-int psImageFreeChildren(psImage* image)
+int psImageFreeChildren(psImage * image)
 {
     int i = 0;
@@ -181,5 +196,5 @@
     children = image->children;
 
-    for(i=0; i<nChildren; i++) {
+    for (i = 0; i < nChildren; i++) {
         if (children[i] != NULL) {
             numFreed++;
@@ -191,5 +206,4 @@
     image->nChildren = 0;
     image->children = NULL;
-
 
     return numFreed;
@@ -202,17 +216,12 @@
 linear interpolation is performed on the image.
  *****************************************************************************/
-psF32 psImagePixelInterpolate(
-    const psImage *input,
-    float x,
-    float y,
-    psF32 unexposedValue,
-    psImageInterpolateMode mode)
+psF32 psImagePixelInterpolate(const psImage * input,
+                              float x, float y, psF32 unexposedValue, psImageInterpolateMode mode)
 {
 
     if (input == NULL) {
-        psError(__func__,"Image can not be NULL.");
+        psError(__func__, "Image can not be NULL.");
         return unexposedValue;
     }
-
     #define PSIMAGE_PIXEL_INTERPOLATE_CASE(TYPE) \
 case PS_TYPE_##TYPE: \
@@ -243,5 +252,5 @@
         PSIMAGE_PIXEL_INTERPOLATE_CASE(C64);
     default:
-        psError(__func__,"Unsupported image datatype (%d)",input->type.type);
+        psError(__func__, "Unsupported image datatype (%d)", input->type.type);
     }
 
@@ -303,5 +312,4 @@
 PSIMAGE_PIXEL_INTERPOLATE_FLAT_COMPLEX(C32)
 PSIMAGE_PIXEL_INTERPOLATE_FLAT_COMPLEX(C64)
-
 #define PSIMAGE_PIXEL_INTERPOLATE_BILINEAR(TYPE) \
 inline psF64 p_psImagePixelInterpolateBILINEAR_##TYPE(const psImage *input, \
@@ -359,5 +367,4 @@
     return(pixel); \
 }
-
 #define PSIMAGE_PIXEL_INTERPOLATE_BILINEAR_COMPLEX(TYPE) \
 inline psC64 p_psImagePixelInterpolateBILINEAR_##TYPE(const psImage *input, \
@@ -428,4 +435,2 @@
 PSIMAGE_PIXEL_INTERPOLATE_BILINEAR_COMPLEX(C32)
 PSIMAGE_PIXEL_INTERPOLATE_BILINEAR_COMPLEX(C64)
-
-
Index: trunk/psLib/src/image/psImage.h
===================================================================
--- trunk/psLib/src/image/psImage.h	(revision 1406)
+++ trunk/psLib/src/image/psImage.h	(revision 1407)
@@ -1,2 +1,3 @@
+
 /** @file  psImage.h
  *
@@ -11,15 +12,15 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-08-06 22:34:05 $
+ *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-08-07 00:06:06 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
-# ifndef PS_IMAGE_H
-# define PS_IMAGE_H
+#ifndef PS_IMAGE_H
+#    define PS_IMAGE_H
 
-#include <complex.h>
+#    include <complex.h>
 
-#include "psType.h"
+#    include "psType.h"
 
 /// @addtogroup Image
@@ -39,36 +40,37 @@
 typedef struct psImage
 {
-    const psType type;                  ///< Image data type and dimension.
-    const unsigned int numCols;         ///< Number of columns in image
-    const unsigned int numRows;         ///< Number of rows in image.
-    const int col0;                     ///< Column position relative to parent.
-    const int row0;                     ///< Row position relative to parent.
+    const psType type;          // /< Image data type and dimension.
+    const unsigned int numCols; // /< Number of columns in image
+    const unsigned int numRows; // /< Number of rows in image.
+    const int col0;             // /< Column position relative to parent.
+    const int row0;             // /< Row position relative to parent.
 
     union {
-        psU8    **U8;                   ///< Unsigned 8-bit integer data.
-        psU16   **U16;                  ///< Unsigned 16-bit integer data.
-        psU32   **U32;                  ///< Unsigned 32-bit integer data.
-        psU64   **U64;                  ///< Unsigned 64-bit integer data.
-        psS8    **S8;                   ///< Signed 8-bit integer data.
-        psS16   **S16;                  ///< Signed 16-bit integer data.
-        psS32   **S32;                  ///< Signed 32-bit integer data.
-        psS64   **S64;                  ///< Signed 64-bit integer data.
-        psF32   **F32;                  ///< Single-precision float data.
-        psF64   **F64;                  ///< Double-precision float data.
-        psC32   **C32;                  ///< Single-precision complex data.
-        psC64   **C64;                  ///< Double-precision complex data.
-        psPTR   **PTR;                  ///< Void pointers.
-        psPTR    *V;                    ///< Pointer to data.
-    } data;                             ///< Union for data types.
-    const struct psImage *parent;       ///< Parent, if a subimage.
-    int nChildren;                      ///< Number of subimages.
-    struct psImage** children;          ///< Children of this region.
+        psU8 **U8;              // /< Unsigned 8-bit integer data.
+        psU16 **U16;            // /< Unsigned 16-bit integer data.
+        psU32 **U32;            // /< Unsigned 32-bit integer data.
+        psU64 **U64;            // /< Unsigned 64-bit integer data.
+        psS8 **S8;              // /< Signed 8-bit integer data.
+        psS16 **S16;            // /< Signed 16-bit integer data.
+        psS32 **S32;            // /< Signed 32-bit integer data.
+        psS64 **S64;            // /< Signed 64-bit integer data.
+        psF32 **F32;            // /< Single-precision float data.
+        psF64 **F64;            // /< Double-precision float data.
+        psC32 **C32;            // /< Single-precision complex data.
+        psC64 **C64;            // /< Double-precision complex data.
+        psPTR **PTR;            // /< Void pointers.
+        psPTR *V;               // /< Pointer to data.
+    } data;                     // /< Union for data types.
+    const struct psImage *parent;       // /< Parent, if a subimage.
+    int nChildren;              // /< Number of subimages.
+    struct psImage **children;  // /< Children of this region.
 }
 psImage;
 
 /*****************************************************************************/
+
 /* FUNCTION PROTOTYPES                                                       */
+
 /*****************************************************************************/
-
 
 /** Create an image of the specified size and type.
@@ -80,9 +82,8 @@
  *
  */
-psImage *psImageAlloc(
-    unsigned int numCols,               ///< Number of rows in image.
-    unsigned int numRows,               ///< Number of columns in image.
-    const psElemType type               ///< Type of data for image.
-);
+psImage *psImageAlloc(unsigned int numCols,     // /< Number of rows in image.
+                      unsigned int numRows,     // /< Number of columns in image.
+                      const psElemType type     // /< Type of data for image.
+                     );
 
 /** Resize a given image to the given size/type.
@@ -91,11 +92,9 @@
  *
  */
-psImage* psImageRecycle(
-    psImage* old,                       ///< the psImage to recycle by resizing image buffer
-    unsigned int numCols,               ///< the desired number of columns in image
-    unsigned int numRows,               ///< the desired number of rows in image
-    const psElemType type               ///< the desired datatype of the image
-);
-
+psImage *psImageRecycle(psImage * old,  // /< the psImage to recycle by resizing image buffer
+                        unsigned int numCols,   // /< the desired number of columns in image
+                        unsigned int numRows,   // /< the desired number of rows in image
+                        const psElemType type   // /< the desired datatype of the image
+                       );
 
 /** Frees all children of a psImage.
@@ -104,18 +103,13 @@
  *
  */
-int psImageFreeChildren(
-    psImage* image
-    /**< psImage in which all children shall be deallocated */
-);
+int psImageFreeChildren(psImage * image
 
-psF32 psImagePixelInterpolate(
-    const psImage *input,
-    float x,
-    float y,
-    psF32 unexposedValue,
-    psImageInterpolateMode mode
-);
+                        /**< psImage in which all children shall be deallocated */
+                       );
 
-#define p_psImagePixelInterpolateFcns(TYPE) \
+psF32 psImagePixelInterpolate(const psImage * input,
+                              float x, float y, psF32 unexposedValue, psImageInterpolateMode mode);
+
+#    define p_psImagePixelInterpolateFcns(TYPE) \
 inline psF64 p_psImagePixelInterpolateFLAT_##TYPE( \
         const psImage *input, \
@@ -131,5 +125,5 @@
                                                      );
 
-#define p_psImagePixelInterpolateComplexFcns(TYPE) \
+#    define p_psImagePixelInterpolateComplexFcns(TYPE) \
 inline psC64 p_psImagePixelInterpolateFLAT_##TYPE( \
         const psImage *input, \
@@ -157,6 +151,4 @@
 p_psImagePixelInterpolateComplexFcns(C32)
 p_psImagePixelInterpolateComplexFcns(C64)
-
 /// @}
-
 #endif
Index: trunk/psLib/src/image/psImageExtraction.c
===================================================================
--- trunk/psLib/src/image/psImageExtraction.c	(revision 1406)
+++ trunk/psLib/src/image/psImageExtraction.c	(revision 1407)
@@ -1,2 +1,3 @@
+
 /** @file  psImageExtraction.c
 *
@@ -9,6 +10,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-08-06 22:34:05 $
+*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-08-07 00:06:06 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -22,72 +23,83 @@
 #include "psError.h"
 
-psImage *psImageSubset( psImage *out, psImage *image, unsigned int numCols,
-                        unsigned int numRows, unsigned int col0,
-                        unsigned int row0 )
+psImage *psImageSubset(psImage * out,
+                       psImage * image,
+                       unsigned int numCols, unsigned int numRows, unsigned int col0, unsigned int row0)
 {
-    unsigned int elementSize;           // size of image element in bytes
-    unsigned int outputRowSize;         // output row size in bytes
-    unsigned int inputColOffset;        // offset in bytes to first subset pixel in input row
-
-    if ( image == NULL || image->data.V == NULL ) {
-        psError( __func__, "Can not subset image because input image or its pixel buffer is NULL." );
-        return NULL;
-    }
-
-    if ( image->type.dimen != PS_DIMEN_IMAGE ) {
-        psError( __func__, "Can not subset image because input image is not an image." );
-        return NULL;
-    }
-
-    if ( numCols < 1 || numRows < 1 ) {
-        psError( __func__, "Can not subset image because number of rows or columns are zero (%dx%d).",
-                 numCols, numRows );
-        return NULL;
-    }
-
-    if ( col0 >= image->numCols || row0 >= image->numRows ) {
-        psError( __func__, "Can not subset image because col0,row0 (%d,%d) is not a valid pixel location.",
-                 col0, row0 );
+    unsigned int elementSize;   // size of image
+
+    // element in
+    // bytes
+    unsigned int outputRowSize; // output row
+
+    // size in bytes
+    unsigned int inputColOffset;        // offset
+
+    // in
+    // bytes
+    // to
+    // first
+    // subset
+
+    // pixel in input row
+
+    if (image == NULL || image->data.V == NULL) {
+        psError(__func__, "Can not subset image because input image or its pixel buffer is NULL.");
+        return NULL;
+    }
+
+    if (image->type.dimen != PS_DIMEN_IMAGE) {
+        psError(__func__, "Can not subset image because input image is not an image.");
+        return NULL;
+    }
+
+    if (numCols < 1 || numRows < 1) {
+        psError(__func__,
+                "Can not subset image because number of rows or columns are zero (%dx%d).", numCols, numRows);
+        return NULL;
+    }
+
+    if (col0 >= image->numCols || row0 >= image->numRows) {
+        psError(__func__,
+                "Can not subset image because col0,row0 (%d,%d) is not a valid pixel location.", col0, row0);
         return NULL;
     }
 
     /* validate subimage size */
-    if ( col0 + numCols >= image->numCols || row0 + numRows >= image->numRows ) {
-        psError( __func__, "Can not subset image outside of image boundaries (size=%dx%d, "
-                 "subset=[%d:%d,%d:%d]).", image->numCols, image->numRows, col0,
-                 col0 + numCols, row0, row0 + numRows );
-        return NULL;
-    }
-
-
-    elementSize = PSELEMTYPE_SIZEOF( image->type.type );
-
-    out = psImageRecycle( out, numCols, numRows, image->type.type );
-
-    // set the parent information into the child output image
-    *( int* ) & out->row0 = row0;
-    *( int* ) & out->col0 = col0;
-    *( psImage** ) & out->parent = ( psImage* ) image;
-
-    // add output image as a child of the input image.
+    if (col0 + numCols >= image->numCols || row0 + numRows >= image->numRows) {
+        psError(__func__,
+                "Can not subset image outside of image boundaries (size=%dx%d, "
+                "subset=[%d:%d,%d:%d]).",
+                image->numCols, image->numRows, col0, col0 + numCols, row0, row0 + numRows);
+        return NULL;
+    }
+
+    elementSize = PSELEMTYPE_SIZEOF(image->type.type);
+
+    out = psImageRecycle(out, numCols, numRows, image->type.type);
+
+    // set the parent information into the child
+    // output image
+    *(int *)&out->row0 = row0;
+    *(int *)&out->col0 = col0;
+    *(psImage **) & out->parent = (psImage *) image;
+
+    // add output image as a child of the input
+    // image.
     image->nChildren++;
-    image->children = ( psImage ** ) psRealloc( image->children,
-                      image->nChildren * sizeof( psImage* ) );
-    image->children[ image->nChildren - 1 ] = out;
+    image->children = (psImage **) psRealloc(image->children, image->nChildren * sizeof(psImage *));
+    image->children[image->nChildren - 1] = out;
 
     inputColOffset = elementSize * col0;
     outputRowSize = elementSize * numCols;
 
-    for ( int row = 0; row < numRows; row++ ) {
-        memcpy( out->data.V[ row ], image->data.U8[ row0 + row ] + inputColOffset,
-                outputRowSize );
-    }
-
-    return ( out );
+    for (int row = 0; row < numRows; row++) {
+        memcpy(out->data.V[row], image->data.U8[row0 + row] + inputColOffset, outputRowSize);
+    }
+
+    return (out);
 }
 
-
-psImage *psImageCopy( psImage* restrict output, const psImage *input,
-                      psElemType type )
+psImage *psImageCopy(psImage * restrict output, const psImage * input, psElemType type)
 {
     psElemType inDatatype;
@@ -97,20 +109,21 @@
     int numCols;
 
-    if ( input == NULL || input->data.V == NULL ) {
-        psError( __func__, "Can not copy image because input image or its pixel buffer is NULL." );
-        psFree( output );
-        return NULL;
-    }
-
-    if ( input == output ) {
-        psError( __func__, "Can not copy image because given input and output "
-                 "parameter reference the same psImage struct." );
-        psFree( output );
-        return NULL;
-    }
-
-    if ( input->type.dimen != PS_DIMEN_IMAGE ) {
-        psError( __func__, "Can not copy image because input image is not actually an image." );
-        psFree( output );
+    if (input == NULL || input->data.V == NULL) {
+        psError(__func__, "Can not copy image because input image or its pixel buffer is NULL.");
+        psFree(output);
+        return NULL;
+    }
+
+    if (input == output) {
+        psError(__func__,
+                "Can not copy image because given input and output "
+                "parameter reference the same psImage struct.");
+        psFree(output);
+        return NULL;
+    }
+
+    if (input->type.dimen != PS_DIMEN_IMAGE) {
+        psError(__func__, "Can not copy image because input image is not actually an image.");
+        psFree(output);
         return NULL;
     }
@@ -120,20 +133,20 @@
     numCols = input->numCols;
     elements = numRows * numCols;
-    elementSize = PSELEMTYPE_SIZEOF( inDatatype );
-
-    if ( inDatatype == PS_TYPE_PTR || type == PS_TYPE_PTR ) {
-        psError( __func__, "Can not copy image to/from a void* matrix" );
-        psFree( output );
-        return NULL;
-    }
-
-    output = psImageRecycle( output, numCols, numRows, type );
-
-    // cover the trival case of copy of the same datatype.
-    if ( type == inDatatype ) {
-        memcpy( output->data.V[ 0 ], input->data.V[ 0 ], elementSize * elements );
+    elementSize = PSELEMTYPE_SIZEOF(inDatatype);
+
+    if (inDatatype == PS_TYPE_PTR || type == PS_TYPE_PTR) {
+        psError(__func__, "Can not copy image to/from a void* matrix");
+        psFree(output);
+        return NULL;
+    }
+
+    output = psImageRecycle(output, numCols, numRows, type);
+
+    // cover the trival case of copy of the same
+    // datatype.
+    if (type == inDatatype) {
+        memcpy(output->data.V[0], input->data.V[0], elementSize * elements);
         return output;
     }
-
     #define PSIMAGE_ELEMENT_COPY(IN,INTYPE,OUT,OUTTYPE,ELEMENTS) { \
         ps##INTYPE *in = IN->data.INTYPE[0]; \
@@ -186,40 +199,40 @@
     }
 
-    switch ( type ) {
+    switch (type) {
     case PS_TYPE_S8:
-        PSIMAGE_COPY_CASE( output, S8 );
+        PSIMAGE_COPY_CASE(output, S8);
         break;
     case PS_TYPE_S16:
-        PSIMAGE_COPY_CASE( output, S16 );
+        PSIMAGE_COPY_CASE(output, S16);
         break;
     case PS_TYPE_S32:
-        PSIMAGE_COPY_CASE( output, S32 );
+        PSIMAGE_COPY_CASE(output, S32);
         break;
     case PS_TYPE_S64:
-        PSIMAGE_COPY_CASE( output, S64 );
+        PSIMAGE_COPY_CASE(output, S64);
         break;
     case PS_TYPE_U8:
-        PSIMAGE_COPY_CASE( output, U8 );
+        PSIMAGE_COPY_CASE(output, U8);
         break;
     case PS_TYPE_U16:
-        PSIMAGE_COPY_CASE( output, U16 );
+        PSIMAGE_COPY_CASE(output, U16);
         break;
     case PS_TYPE_U32:
-        PSIMAGE_COPY_CASE( output, U32 );
+        PSIMAGE_COPY_CASE(output, U32);
         break;
     case PS_TYPE_U64:
-        PSIMAGE_COPY_CASE( output, U64 );
+        PSIMAGE_COPY_CASE(output, U64);
         break;
     case PS_TYPE_F32:
-        PSIMAGE_COPY_CASE( output, F32 );
+        PSIMAGE_COPY_CASE(output, F32);
         break;
     case PS_TYPE_F64:
-        PSIMAGE_COPY_CASE( output, F64 );
+        PSIMAGE_COPY_CASE(output, F64);
         break;
     case PS_TYPE_C32:
-        PSIMAGE_COPY_CASE( output, C32 );
+        PSIMAGE_COPY_CASE(output, C32);
         break;
     case PS_TYPE_C64:
-        PSIMAGE_COPY_CASE( output, C64 );
+        PSIMAGE_COPY_CASE(output, C64);
         break;
     default:
@@ -229,34 +242,31 @@
 }
 
-psVector* psImageSlice( psVector* out,
-                        psVector* slicePositions,
-                        const psImage* restrict in,
-                        const psImage* restrict mask,
-                        unsigned int maskVal,
-                        unsigned int col,
-                        unsigned int row,
-                        unsigned int numCols,
-                        unsigned int numRows,
-                        psImageCutDirection direction,
-                        const psStats* stats )
+psVector *psImageSlice(psVector * out,
+                       psVector * slicePositions,
+                       const psImage * restrict in,
+                       const psImage * restrict mask,
+                       unsigned int maskVal,
+                       unsigned int col,
+                       unsigned int row,
+                       unsigned int numCols,
+                       unsigned int numRows, psImageCutDirection direction, const psStats * stats)
 {
     double statVal;
-    psStats* myStats;
+    psStats *myStats;
     psElemType type;
     int inRows;
     int inCols;
     int delta = 1;
-    psF64* outData;
-
-    if ( in == NULL || in->data.V == NULL ) {
-        psError( __func__, "Input image can not be NULL." );
-        psFree( out );
-        return NULL;
-    }
-
-    if ( numRows == 0 || numCols == 0 ) {
-        psError( __func__, "The specified region contains no data (%dx%d)",
-                 numCols, numRows );
-        psFree( out );
+    psF64 *outData;
+
+    if (in == NULL || in->data.V == NULL) {
+        psError(__func__, "Input image can not be NULL.");
+        psFree(out);
+        return NULL;
+    }
+
+    if (numRows == 0 || numCols == 0) {
+        psError(__func__, "The specified region contains no data (%dx%d)", numCols, numRows);
+        psFree(out);
         return NULL;
     }
@@ -266,71 +276,73 @@
     inCols = in->numCols;
 
-    if ( direction == PS_CUT_X_NEG || direction == PS_CUT_Y_NEG ) {
+    if (direction == PS_CUT_X_NEG || direction == PS_CUT_Y_NEG) {
         delta = -1;
     }
-
-    // if numRows/numCols is negative, invert the problem to give positive
-    // numRows/numCols (and cut in opposite direction).
-    if ( numRows < 0 ) {
+    // if numRows/numCols is negative, invert the
+    // problem to give positive
+    // numRows/numCols (and cut in opposite
+    // direction).
+    if (numRows < 0) {
         numRows = -numRows;
-        row -= ( numRows - 1 );
+        row -= (numRows - 1);
         delta = -delta;
     }
 
-    if ( numCols < 0 ) {
+    if (numCols < 0) {
         numCols = -numCols;
-        col -= ( numCols - 1 );
+        col -= (numCols - 1);
         delta = -delta;
     }
 
-    if ( mask != NULL ) {
-        if ( inRows != mask->numRows || inCols != mask->numCols ) {
-            psError( __func__, "The mask and image dimensions did not match (%dx%d vs %dx%d)",
-                     mask->numCols, mask->numRows, in->numCols, in->numRows );
-            psFree( out );
-        }
-        if ( mask->type.type != PS_TYPE_MASK ) {
-            psError( __func__, "The mask datatype (%d) must be %s.",
-                     mask->type.type, PS_TYPE_MASK_NAME );
-            psFree( out );
-        }
-    }
-
-    if ( row >= inRows || col >= inCols ||
-            col + numCols > in->numCols || row + numRows > in->numRows ) {
-        psError( __func__, "The specified image region (%d,%d to %d,%d) is outside of image area (0,0 to %d,%d).",
-                 col, row, col + numCols - 1, row + numRows - 1, in->numCols - 1, in->numRows - 1 );
-        psFree( out );
-        return NULL;
-    }
-
-    // verify that the stats struct specifies a single stats operation
-    if ( stats == NULL || p_psGetStatValue( stats, &statVal ) == false ) {
-        psError( __func__, "The stat options didn't specify a single supported statistic type." );
-        psFree( out );
-        return NULL;
-    }
-
-    // since stats input is const, I need to create a 'scratch' stats struct
-    myStats = psAlloc( sizeof( psStats ) );
+    if (mask != NULL) {
+        if (inRows != mask->numRows || inCols != mask->numCols) {
+            psError(__func__,
+                    "The mask and image dimensions did not match (%dx%d vs %dx%d)",
+                    mask->numCols, mask->numRows, in->numCols, in->numRows);
+            psFree(out);
+        }
+        if (mask->type.type != PS_TYPE_MASK) {
+            psError(__func__, "The mask datatype (%d) must be %s.", mask->type.type, PS_TYPE_MASK_NAME);
+            psFree(out);
+        }
+    }
+
+    if (row >= inRows || col >= inCols || col + numCols > in->numCols || row + numRows > in->numRows) {
+        psError(__func__,
+                "The specified image region (%d,%d to %d,%d) is outside of image area (0,0 to %d,%d).",
+                col, row, col + numCols - 1, row + numRows - 1, in->numCols - 1, in->numRows - 1);
+        psFree(out);
+        return NULL;
+    }
+    // verify that the stats struct specifies a
+    // single stats operation
+    if (stats == NULL || p_psGetStatValue(stats, &statVal) == false) {
+        psError(__func__, "The stat options didn't specify a single supported statistic type.");
+        psFree(out);
+        return NULL;
+    }
+    // since stats input is const, I need to
+    // create a 'scratch' stats struct
+    myStats = psAlloc(sizeof(psStats));
     *myStats = *stats;
 
-
-
-    if ( direction == PS_CUT_X_POS || direction == PS_CUT_X_NEG ) {
-        psVector * imgVec = psVectorAlloc( numRows, type );
-        psVector* maskVec = NULL;
-        psMaskType* maskData = NULL;
-        psU32* outPosition = NULL;
-
-        // recycle output to make a proper sized/type output structure
-        // n.b. type is double as that is the type given for all stats in psStats.
-        out = psVectorRecycle( out, numCols, PS_TYPE_F64);
+    if (direction == PS_CUT_X_POS || direction == PS_CUT_X_NEG) {
+        psVector *imgVec = psVectorAlloc(numRows, type);
+        psVector *maskVec = NULL;
+        psMaskType *maskData = NULL;
+        psU32 *outPosition = NULL;
+
+        // recycle output to make a proper
+        // sized/type output structure
+        // n.b. type is double as that is the
+        // type given for all stats in
+        // psStats.
+        out = psVectorRecycle(out, numCols, PS_TYPE_F64);
         if (slicePositions != NULL) {
-            slicePositions = psVectorRecycle(slicePositions,numCols,PS_TYPE_U32);
+            slicePositions = psVectorRecycle(slicePositions, numCols, PS_TYPE_U32);
             outPosition = slicePositions->data.U32;
         }
         outData = out->data.F64;
-        if ( delta < 0 ) {
+        if (delta < 0) {
             outData += numCols - 1;
             if (outPosition != NULL) {
@@ -339,8 +351,7 @@
         }
 
-        if ( mask != NULL ) {
-            maskVec = psVectorAlloc( numRows, mask->type.type );
-        }
-
+        if (mask != NULL) {
+            maskVec = psVectorAlloc(numRows, mask->type.type);
+        }
         #define PSIMAGE_CUT_VERTICAL(TYPE) \
     case PS_TYPE_##TYPE: { \
@@ -373,83 +384,108 @@
         }
 
-        switch ( type ) {
-            PSIMAGE_CUT_VERTICAL( U8 );
-            PSIMAGE_CUT_VERTICAL( U16 );
-            PSIMAGE_CUT_VERTICAL( U32 );
-            PSIMAGE_CUT_VERTICAL( U64 );
-            PSIMAGE_CUT_VERTICAL( S8 );
-            PSIMAGE_CUT_VERTICAL( S16 );
-            PSIMAGE_CUT_VERTICAL( S32 );
-            PSIMAGE_CUT_VERTICAL( S64 );
-            PSIMAGE_CUT_VERTICAL( F32 );
-            PSIMAGE_CUT_VERTICAL( F64 );
-            PSIMAGE_CUT_VERTICAL( C32 );
-            PSIMAGE_CUT_VERTICAL( C64 );
+        switch (type) {
+            PSIMAGE_CUT_VERTICAL(U8);
+            PSIMAGE_CUT_VERTICAL(U16);
+            PSIMAGE_CUT_VERTICAL(U32);
+            PSIMAGE_CUT_VERTICAL(U64);
+            PSIMAGE_CUT_VERTICAL(S8);
+            PSIMAGE_CUT_VERTICAL(S16);
+            PSIMAGE_CUT_VERTICAL(S32);
+            PSIMAGE_CUT_VERTICAL(S64);
+            PSIMAGE_CUT_VERTICAL(F32);
+            PSIMAGE_CUT_VERTICAL(F64);
+            PSIMAGE_CUT_VERTICAL(C32);
+            PSIMAGE_CUT_VERTICAL(C64);
         default:
-            psError( __func__, "Unsupported datatype (%d)", type );
-            psFree( out );
+            psError(__func__, "Unsupported datatype (%d)", type);
+            psFree(out);
             out = NULL;
         }
-        psFree( imgVec );
-        psFree( maskVec );
-    } else
-        if ( direction == PS_CUT_Y_POS || direction == PS_CUT_Y_NEG ) { // Cut in Y direction
-            psVector * imgVec = NULL;
-            psVector* maskVec = NULL;
-            int elementSize = PSELEMTYPE_SIZEOF( type );
-            psU32* outPosition = NULL;
-
-            // fill in psVectors to fake out the statistics functions.
-            imgVec = psAlloc( sizeof( psVector ) );
-            imgVec->type = in->type;
-            imgVec->n = imgVec->nalloc = numCols;
-            if ( mask != NULL ) {
-                maskVec = psAlloc( sizeof( psVector ) );
-                maskVec->type = mask->type;
-                maskVec->n = maskVec->nalloc = numCols;
+        psFree(imgVec);
+        psFree(maskVec);
+    } else if (direction == PS_CUT_Y_POS || direction == PS_CUT_Y_NEG) {        // Cut
+        //
+        //
+        //
+        //
+        //
+        //
+        //
+        //
+        //
+        // in
+        // Y
+        // direction
+        psVector *imgVec = NULL;
+        psVector *maskVec = NULL;
+        int elementSize = PSELEMTYPE_SIZEOF(type);
+        psU32 *outPosition = NULL;
+
+        // fill in psVectors to fake out the
+        // statistics functions.
+        imgVec = psAlloc(sizeof(psVector));
+        imgVec->type = in->type;
+        imgVec->n = imgVec->nalloc = numCols;
+        if (mask != NULL) {
+            maskVec = psAlloc(sizeof(psVector));
+            maskVec->type = mask->type;
+            maskVec->n = maskVec->nalloc = numCols;
+        }
+        // recycle output to make a proper
+        // sized/type output structure
+        // n.b. type is double as that is the
+        // type given for all stats in
+        // psStats.
+        out = psVectorRecycle(out, numRows, PS_TYPE_F64);
+        if (slicePositions != NULL) {
+            slicePositions = psVectorRecycle(slicePositions, numRows, PS_TYPE_U32);
+            outPosition = slicePositions->data.U32;
+        }
+        outData = out->data.F64;
+        if (delta < 0) {
+            outData += numRows - 1;
+            if (outPosition != NULL) {
+                outPosition += numRows - 1;
             }
-
-            // recycle output to make a proper sized/type output structure
-            // n.b. type is double as that is the type given for all stats in psStats.
-            out = psVectorRecycle( out, numRows, PS_TYPE_F64 );
-            if (slicePositions != NULL) {
-                slicePositions = psVectorRecycle(slicePositions,numRows,PS_TYPE_U32);
-                outPosition = slicePositions->data.U32;
+        }
+
+        for (int r = 0; r < numRows; r++) {
+            // point the vector struct to the
+            // data to calculate the stats
+            imgVec->data.V = (void *)(in->data.U8[row + r] + col * elementSize);
+            if (maskVec != NULL) {
+                maskVec->data.V = (void *)(mask->data.U8[row + r] + col * sizeof(psMaskType));
             }
-            outData = out->data.F64;
-            if ( delta < 0 ) {
-                outData += numRows - 1;
-                if (outPosition != NULL) {
-                    outPosition += numRows - 1;
-                }
+            myStats = psVectorStats(myStats, imgVec, maskVec, maskVal);
+            (void)p_psGetStatValue(myStats, &statVal);  // we
+            // know
+            // it
+            // works
+            // cause we tested it
+            // above
+            *outData = statVal;
+            if (outPosition != NULL) {
+                *outPosition = row + r;
+                outPosition += delta;
+
             }
-
-            for ( int r = 0;r < numRows;r++ ) {
-                // point the vector struct to the data to calculate the stats
-                imgVec->data.V = ( void* ) ( in->data.U8[ row + r ] + col * elementSize );
-                if ( maskVec != NULL ) {
-                    maskVec->data.V = ( void* ) ( mask->data.U8[ row + r ] + col * sizeof( psMaskType ) );
-                }
-                myStats = psVectorStats( myStats, imgVec, maskVec, maskVal );
-                ( void ) p_psGetStatValue( myStats, &statVal ); // we know it works cause we tested it above
-                *outData = statVal;
-                if (outPosition != NULL) {
-                    *outPosition = row+r;
-                    outPosition += delta;
-                    \
-                }
-                outData += delta;
-            }
-            psFree( imgVec );
-            psFree( maskVec );
-        } else { // don't know what the direction flag is
-            psError( __func__, "Invalid direction flag (%d)", direction );
-            psFree( out );
-            out = NULL;
-        }
-
-    psFree( myStats );
+            outData += delta;
+        }
+        psFree(imgVec);
+        psFree(maskVec);
+    } else {                               // don't
+        // know
+        // what
+        // the
+        // direction
+        // flag
+        // is
+        psError(__func__, "Invalid direction flag (%d)", direction);
+        psFree(out);
+        out = NULL;
+    }
+
+    psFree(myStats);
 
     return out;
 }
-
Index: trunk/psLib/src/image/psImageExtraction.h
===================================================================
--- trunk/psLib/src/image/psImageExtraction.h	(revision 1406)
+++ trunk/psLib/src/image/psImageExtraction.h	(revision 1407)
@@ -1,2 +1,3 @@
+
 /** @file  psImageExtraction.h
 *
@@ -9,6 +10,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-08-06 21:50:13 $
+*  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-08-07 00:06:06 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -16,9 +17,9 @@
 
 #ifndef PSIMAGEEXTRACTION_H
-#define PSIMAGEEXTRACTION_H
+#    define PSIMAGEEXTRACTION_H
 
-#include "psImage.h"
-#include "psVector.h"
-#include "psStats.h"
+#    include "psImage.h"
+#    include "psVector.h"
+#    include "psStats.h"
 
 /// @addtogroup Image
@@ -40,12 +41,11 @@
 *
 */
-psImage *psImageSubset(
-    psImage *out,                         ///< Subimage to return, or NULL.
-    psImage *image,                       ///< Parent image.
-    unsigned int numCols,                 ///< Subimage width (<= image.nCols - col0).
-    unsigned int numRows,                 ///< Subimage height (<= image.nRows - row0).
-    unsigned int col0,                    ///< Subimage col-offset (0 <= col0 < nCol).
-    unsigned int row0                   ///< Subimage row-offset (0 <= row0 < nCol).
-);
+psImage *psImageSubset(psImage * out,   // /< Subimage to return, or NULL.
+                       psImage * image, // /< Parent image.
+                       unsigned int numCols,    // /< Subimage width (<= image.nCols - col0).
+                       unsigned int numRows,    // /< Subimage height (<= image.nRows - row0).
+                       unsigned int col0,       // /< Subimage col-offset (0 <= col0 < nCol).
+                       unsigned int row0        // /< Subimage row-offset (0 <= row0 < nCol).
+                      );
 
 /** Makes a copy of a psImage
@@ -55,52 +55,39 @@
  *
  */
-psImage *psImageCopy(
-    psImage* restrict output,
-    /**< if not NULL, a psImage that could be recycled.  If it can not be used,
-     *   it will be freed via psImageFree
-     */
-    const psImage *input,
-    /**< the psImage to copy */
-    psElemType type
-    /**< the desired datatype of the returned copy */
-);
+psImage *psImageCopy(psImage * restrict output,
 
-psVector* psImageSlice(
-    psVector* out,
-    psVector* slicePositions,
-    const psImage* restrict input,
-    const psImage* restrict mask,
-    unsigned int maskVal,
-    unsigned int col,
-    unsigned int row,
-    unsigned int numCols,
-    unsigned int numRows,
-    psImageCutDirection direction,
-    const psStats* stats
-);
+                     /**< if not NULL, a psImage that could be recycled.  If it can not be used,
+                      *   it will be freed via psImageFree
+                      */
+                     const psImage * input,
 
-psVector* psImageCut(
-    psVector* out,
-    const psImage* input,
-    const psImage* restrict mask,
-    unsigned int maskVal,
-    float startCol,
-    float startRow,
-    float endCol,
-    float endRow,
-    float width,
-    const psStats* stats
-);
+                     /**< the psImage to copy */
+                     psElemType type
 
-psVector* psImageRadialCut(
-    psVector* out,
-    const psImage* input,
-    const psImage* restrict mask,
-    unsigned int maskVal,
-    float centerCol,
-    float centerRow,
-    const psVector* radii,
-    const psStats* stats
-);
+                     /**< the desired datatype of the returned copy */
+                    );
+
+psVector *psImageSlice(psVector * out,
+                       psVector * slicePositions,
+                       const psImage * restrict input,
+                       const psImage * restrict mask,
+                       unsigned int maskVal,
+                       unsigned int col,
+                       unsigned int row,
+                       unsigned int numCols,
+                       unsigned int numRows, psImageCutDirection direction, const psStats * stats);
+
+psVector *psImageCut(psVector * out,
+                     const psImage * input,
+                     const psImage * restrict mask,
+                     unsigned int maskVal,
+                     float startCol,
+                     float startRow, float endCol, float endRow, float width, const psStats * stats);
+
+psVector *psImageRadialCut(psVector * out,
+                           const psImage * input,
+                           const psImage * restrict mask,
+                           unsigned int maskVal,
+                           float centerCol, float centerRow, const psVector * radii, const psStats * stats);
 
 /// @}
Index: trunk/psLib/src/image/psImageIO.c
===================================================================
--- trunk/psLib/src/image/psImageIO.c	(revision 1406)
+++ trunk/psLib/src/image/psImageIO.c	(revision 1407)
@@ -1,2 +1,3 @@
+
 /** @file  psImageIO.c
  *
@@ -7,6 +8,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-08-06 22:34:05 $
+ *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-08-07 00:06:06 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -21,23 +22,25 @@
 #include "psMemory.h"
 
-psImage* psImageReadSection(psImage* output, int col, int row, int numCols,
-                            int numRows, int z, char* extname, int extnum, char* filename)
+psImage *psImageReadSection(psImage * output,
+                            int col,
+                            int row,
+                            int numCols, int numRows, int z, char *extname, int extnum, char *filename)
 {
-    fitsfile    *fptr=NULL;                 /*Pointer to the FITS file*/
-    int         status=0;                   /*CFITSIO file vars*/
-    int         nAxis=0;
-    int         anynull=0;
-    int         bitPix=0;                   /*Pixel type*/
-    long        nAxes[3];
-    long        firstPixel[3];              /* lower-left corner of image subset */
-    long        lastPixel[3];               /* upper-right corner of image subset */
-    long        increment[3];               /* increment for image subset */
-    char        fitsErr[80] = "";           /*CFITSIO error message string */
-    int         hduType = IMAGE_HDU;
-    int         fitsDatatype = 0;
-    int         datatype = 0;
+    fitsfile *fptr = NULL;      /* Pointer to the FITS file */
+    int status = 0;             /* CFITSIO file vars */
+    int nAxis = 0;
+    int anynull = 0;
+    int bitPix = 0;             /* Pixel type */
+    long nAxes[3];
+    long firstPixel[3];         /* lower-left corner of image subset */
+    long lastPixel[3];          /* upper-right corner of image subset */
+    long increment[3];          /* increment for image subset */
+    char fitsErr[80] = "";      /* CFITSIO error message string */
+    int hduType = IMAGE_HDU;
+    int fitsDatatype = 0;
+    int datatype = 0;
 
     if (filename == NULL) {
-        psError(__func__,"Must specify filename; it can not be NULL.");
+        psError(__func__, "Must specify filename; it can not be NULL.");
         psFree(output);
         return NULL;
@@ -47,7 +50,6 @@
     (void)fits_open_file(&fptr, filename, READONLY, &status);
     if (fptr == NULL || status != 0) {
-        fits_get_errstatus(status,fitsErr);
-        psError(__func__,"Could not open file '%s'. (%s)",
-                filename, fitsErr);
+        fits_get_errstatus(status, fitsErr);
+        psError(__func__, "Could not open file '%s'. (%s)", filename, fitsErr);
         psFree(output);
         return NULL;
@@ -56,20 +58,18 @@
     /* find the specified extension */
     if (extname != NULL) {
-        if (fits_movnam_hdu(fptr, hduType, extname, 0,&status) != 0) {
+        if (fits_movnam_hdu(fptr, hduType, extname, 0, &status) != 0) {
             fits_get_errstatus(status, fitsErr);
             status = 0;
             (void)fits_close_file(fptr, &status);
-            psError(__func__,"Could not index to '%s' HDU for file %s. (%s)",
-                    extname, filename, fitsErr);
+            psError(__func__, "Could not index to '%s' HDU for file %s. (%s)", extname, filename, fitsErr);
             psFree(output);
             return NULL;
         }
     } else {
-        if (fits_movabs_hdu(fptr, extnum+1, &hduType, &status) != 0) {
+        if (fits_movabs_hdu(fptr, extnum + 1, &hduType, &status) != 0) {
             fits_get_errstatus(status, fitsErr);
             status = 0;
             (void)fits_close_file(fptr, &status);
-            psError(__func__,"Could not index to HDU #%d for file %s. (%s)",
-                    extnum, filename, fitsErr);
+            psError(__func__, "Could not index to HDU #%d for file %s. (%s)", extnum, filename, fitsErr);
             psFree(output);
             return NULL;
@@ -82,6 +82,5 @@
         status = 0;
         (void)fits_close_file(fptr, &status);
-        psError("Could not determine image data type of '%s'. (%s)",
-                filename, fitsErr);
+        psError("Could not determine image data type of '%s'. (%s)", filename, fitsErr);
         psFree(output);
         return NULL;
@@ -93,6 +92,5 @@
         status = 0;
         (void)fits_close_file(fptr, &status);
-        psError("Could not determine dimensions of '%s'. (%s)",
-                filename,fitsErr);
+        psError("Could not determine dimensions of '%s'. (%s)", filename, fitsErr);
         psFree(output);
         return NULL;
@@ -100,20 +98,18 @@
 
     /* Validate the number of axis */
-    if ( (nAxis < 2) || (nAxis > 3) ) {
-        status=0;
-        (void)fits_close_file(fptr, &status);
-        psError("Dimensions of '%s' are not supported (NAXIS=%i).",
-                filename, nAxis);
-        psFree(output);
-        return NULL;
-    }
-
-    /* Get the Image size from the FITS file  */
-    if ( fits_get_img_size(fptr, nAxis, nAxes, &status) != 0) {
+    if ((nAxis < 2) || (nAxis > 3)) {
+        status = 0;
+        (void)fits_close_file(fptr, &status);
+        psError("Dimensions of '%s' are not supported (NAXIS=%i).", filename, nAxis);
+        psFree(output);
+        return NULL;
+    }
+
+    /* Get the Image size from the FITS file */
+    if (fits_get_img_size(fptr, nAxis, nAxes, &status) != 0) {
         (void)fits_get_errstatus(status, fitsErr);
         status = 0;
         (void)fits_close_file(fptr, &status);
-        psError("Could not determine image size of '%s'. (%s)",
-                filename,fitsErr);
+        psError("Could not determine image size of '%s'. (%s)", filename, fitsErr);
         psFree(output);
         return NULL;
@@ -127,11 +123,11 @@
     }
 
-    firstPixel[0] = col+1;
-    firstPixel[1] = row+1;
-    firstPixel[2] = z+1;
+    firstPixel[0] = col + 1;
+    firstPixel[1] = row + 1;
+    firstPixel[2] = z + 1;
 
     lastPixel[0] = firstPixel[0] + numCols - 1;
     lastPixel[1] = firstPixel[1] + numRows - 1;
-    lastPixel[2] = z+1;
+    lastPixel[2] = z + 1;
 
     increment[0] = 1;
@@ -139,6 +135,8 @@
     increment[2] = 1;
 
-    // turn off the BSCALE/BZERO processing in CFITSIO
-    // (void)fits_set_bscale(fptr, 1.0,0.0,&status);
+    // turn off the BSCALE/BZERO processing in
+    // CFITSIO
+    // (void)fits_set_bscale(fptr,
+    // 1.0,0.0,&status);
 
     switch (bitPix) {
@@ -180,18 +178,17 @@
         break;
     default:
-        psError(__func__,"Unsupported bitpix value (%d) in FITS file %s.",
-                bitPix,filename);
-        psFree(output);
-        return NULL;
-    }
-    output = psImageRecycle(output,numCols,numRows,datatype);
-    if (fits_read_subset(fptr, fitsDatatype, firstPixel, lastPixel, increment,
-                         NULL, output->data.V[0], &anynull, &status) != 0) {
+        psError(__func__, "Unsupported bitpix value (%d) in FITS file %s.", bitPix, filename);
+        psFree(output);
+        return NULL;
+    }
+    output = psImageRecycle(output, numCols, numRows, datatype);
+    if (fits_read_subset
+            (fptr, fitsDatatype, firstPixel,
+             lastPixel, increment, NULL, output->data.V[0], &anynull, &status) != 0) {
         psFree(output);
         (void)fits_get_errstatus(status, fitsErr);
         status = 0;
         (void)fits_close_file(fptr, &status);
-        psError(__func__,"Failed to read image [%s]",
-                filename, fitsErr);
+        psError(__func__, "Failed to read image [%s]", filename, fitsErr);
         return NULL;
     }
@@ -202,28 +199,26 @@
 }
 
-
-bool psImageWriteSection(psImage* input, int col0,int row0,int z,
-                         char* extname, int extnum, char* filename)
+bool psImageWriteSection(psImage * input, int col0, int row0, int z, char *extname, int extnum,
+                         char *filename)
 {
-    int         numCols = 0;
-    int         numRows = 0;
-
-    int         status=0;               /* CFITSIO  status */
-    fitsfile    *fptr=NULL;             /* pointer to the FITS file */
-    long        nAxes[3];               /* Image axis vars */
-    long        firstPixel[3];          /* First Pixel to read */
-    long        lastPixel[3];           /* Last Pixel to read */
-    char        fitsErr[80];            /* FITSIO message string */
-    int         datatype = 0;           /* the datatype of the image */
-    int         bitPix = 0;             /* FITS bitPix value */
-    int         hduType = IMAGE_HDU;    /* the HDU type (image,table, etc.) */
-    double      bscale = 1.0;
-    double      bzero = 0.0;
-    bool        createNewHDU = false;
+    int numCols = 0;
+    int numRows = 0;
+
+    int status = 0;             /* CFITSIO status */
+    fitsfile *fptr = NULL;      /* pointer to the FITS file */
+    long nAxes[3];              /* Image axis vars */
+    long firstPixel[3];         /* First Pixel to read */
+    long lastPixel[3];          /* Last Pixel to read */
+    char fitsErr[80];           /* FITSIO message string */
+    int datatype = 0;           /* the datatype of the image */
+    int bitPix = 0;             /* FITS bitPix value */
+    int hduType = IMAGE_HDU;    /* the HDU type (image,table, etc.) */
+    double bscale = 1.0;
+    double bzero = 0.0;
+    bool createNewHDU = false;
 
     /* need a valid image to write */
-    if(input==NULL) {
-        psError(__func__, "Can not write %s.  Input psImage is NULL.",
-                filename);
+    if (input == NULL) {
+        psError(__func__, "Can not write %s.  Input psImage is NULL.", filename);
         return false;
     }
@@ -244,5 +239,5 @@
     case PS_TYPE_U16:
         bitPix = SHORT_IMG;
-        bzero = -1.0f*INT16_MIN;
+        bzero = -1.0f * INT16_MIN;
         datatype = TUSHORT;
         break;
@@ -253,5 +248,5 @@
     case PS_TYPE_U32:
         bitPix = LONG_IMG;
-        bzero = -1.0f*INT32_MIN;
+        bzero = -1.0f * INT32_MIN;
         datatype = TUINT;
         break;
@@ -269,16 +264,16 @@
         break;
     default:
-        psError(__func__, "psImage datatype (%d) not supported.  File %s not written.",
-                input->type.type,filename);
+        psError(__func__,
+                "psImage datatype (%d) not supported.  File %s not written.", input->type.type, filename);
         return false;
     }
 
     /* Open the FITS file */
-    if (access(filename, F_OK) == 0) { // file exists
+    if (access(filename, F_OK) == 0) {     // file
+        // exists
         (void)fits_open_file(&fptr, filename, READWRITE, &status);
         if (fptr == NULL || status != 0) {
-            fits_get_errstatus(status,fitsErr);
-            psError(__func__,"Could not open file '%s'. FITS error:%s",
-                    filename, fitsErr);
+            fits_get_errstatus(status, fitsErr);
+            psError(__func__, "Could not open file '%s'. FITS error:%s", filename, fitsErr);
             return false;
         }
@@ -286,42 +281,42 @@
         /* find the specified extension */
         if (extname != NULL) {
-            if (fits_movnam_hdu(fptr, hduType, extname, 0,&status) != 0) {
+            if (fits_movnam_hdu(fptr, hduType, extname, 0, &status) != 0) {
                 fits_get_errstatus(status, fitsErr);
                 status = 0;
                 (void)fits_close_file(fptr, &status);
-                psError(__func__,"Could not index to '%s' HDU for file %s. (%s)",
-                        extname, filename, fitsErr);
+                psError(__func__,
+                        "Could not index to '%s' HDU for file %s. (%s)", extname, filename, fitsErr);
                 return false;
             }
         } else {
             int numHDUs = 0;
-            fits_get_num_hdus(fptr,&numHDUs,&status);
+
+            fits_get_num_hdus(fptr, &numHDUs, &status);
             if (numHDUs < extnum) {
                 status = 0;
                 (void)fits_close_file(fptr, &status);
-                psError(__func__,"extnum (%d) must not exceed number of HDUs (%d) by more than one.",
-                        extnum, numHDUs);
+                psError(__func__,
+                        "extnum (%d) must not exceed number of HDUs (%d) by more than one.", extnum, numHDUs);
                 return false;
-            } else
-                if (numHDUs == extnum) {
-                    createNewHDU = true;
-                } else
-                    if (fits_movabs_hdu(fptr, extnum+1, &hduType, &status) != 0) {
-                        fits_get_errstatus(status, fitsErr);
-                        status = 0;
-                        (void)fits_close_file(fptr, &status);
-                        psError(__func__,"Could not index to HDU #%d for file %s. (%s)",
-                                extnum, filename, fitsErr);
-                        return false;
-                    }
-        }
-
-    } else { // file does not exist
-
-        (void)fits_create_file(&fptr,filename,&status);
+            } else if (numHDUs == extnum) {
+                createNewHDU = true;
+            } else if (fits_movabs_hdu(fptr, extnum + 1, &hduType, &status) != 0) {
+                fits_get_errstatus(status, fitsErr);
+                status = 0;
+                (void)fits_close_file(fptr, &status);
+                psError(__func__, "Could not index to HDU #%d for file %s. (%s)", extnum, filename, fitsErr);
+                return false;
+            }
+        }
+
+    } else {                               // file
+        // does
+        // not
+        // exist
+
+        (void)fits_create_file(&fptr, filename, &status);
         if (fptr == NULL || status != 0) {
-            fits_get_errstatus(status,fitsErr);
-            psError(__func__,"Could not create file '%s'. (%s)",
-                    filename, fitsErr);
+            fits_get_errstatus(status, fitsErr);
+            psError(__func__, "Could not create file '%s'. (%s)", filename, fitsErr);
             return false;
         }
@@ -330,21 +325,19 @@
 
     if (createNewHDU) {
-        /*  create the mandatory image keywords */
-        nAxes[0] = col0+numCols;
-        nAxes[1] = row0+numRows;
-        nAxes[2] = z+1;
+        /* create the mandatory image keywords */
+        nAxes[0] = col0 + numCols;
+        nAxes[1] = row0 + numRows;
+        nAxes[2] = z + 1;
         if (fits_create_img(fptr, bitPix, 3, nAxes, &status) != 0) {
             (void)fits_get_errstatus(status, fitsErr);
             status = 0;
             (void)fits_close_file(fptr, &status);
-            psError(__func__,"Could not create image HDU in FITS file '%s'. %s",
-                    filename, fitsErr);
+            psError(__func__, "Could not create image HDU in FITS file '%s'. %s", filename, fitsErr);
             return false;
         }
-
         // set the bscale/bzero
-        fits_write_key_dbl(fptr, "BZERO",bzero,12,"Pixel Value Offset",&status);
-        fits_write_key_dbl(fptr, "BSCALE",bscale,12,"Pixel Value Scale",&status);
-        fits_set_bscale(fptr,bscale,bzero,&status);
+        fits_write_key_dbl(fptr, "BZERO", bzero, 12, "Pixel Value Offset", &status);
+        fits_write_key_dbl(fptr, "BSCALE", bscale, 12, "Pixel Value Scale", &status);
+        fits_set_bscale(fptr, bscale, bzero, &status);
 
         if (extname != NULL) {
@@ -354,6 +347,6 @@
                 status = 0;
                 (void)fits_close_file(fptr, &status);
-                psError(__func__,"Could not create EXTNAME keyword in FITS file '%s'. (%s)",
-                        filename, fitsErr);
+                psError(__func__,
+                        "Could not create EXTNAME keyword in FITS file '%s'. (%s)", filename, fitsErr);
                 return false;
             }
@@ -361,18 +354,17 @@
     }
 
-    firstPixel[0] = col0+1;
-    firstPixel[1] = row0+1;
-    firstPixel[2] = z+1;
+    firstPixel[0] = col0 + 1;
+    firstPixel[1] = row0 + 1;
+    firstPixel[2] = z + 1;
 
     lastPixel[0] = firstPixel[0] + numCols - 1;
     lastPixel[1] = firstPixel[1] + numRows - 1;
-    lastPixel[2] = z+1;
-
-    if ( fits_write_subset(fptr, datatype, firstPixel, lastPixel, input->data.V[0], &status) != 0) {
+    lastPixel[2] = z + 1;
+
+    if (fits_write_subset(fptr, datatype, firstPixel, lastPixel, input->data.V[0], &status) != 0) {
         (void)fits_get_errstatus(status, fitsErr);
         status = 0;
         (void)fits_close_file(fptr, &status);
-        psError(__func__, "Could not write image data to '%s'. (%s)",
-                filename, fitsErr);
+        psError(__func__, "Could not write image data to '%s'. (%s)", filename, fitsErr);
         return false;
     }
Index: trunk/psLib/src/image/psImageIO.h
===================================================================
--- trunk/psLib/src/image/psImageIO.h	(revision 1406)
+++ trunk/psLib/src/image/psImageIO.h	(revision 1407)
@@ -1,2 +1,3 @@
+
 /** @file  psImageIO.h
  *
@@ -9,15 +10,15 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-07-19 22:01:19 $
+ *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-08-07 00:06:06 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
-# ifndef PS_IMAGEIO_H
-# define PS_IMAGEIO_H
+#ifndef PS_IMAGEIO_H
+#    define PS_IMAGEIO_H
 
-#include <stdbool.h>
+#    include <stdbool.h>
 
-#include "psImage.h"
+#    include "psImage.h"
 
 /// @addtogroup ImageIO
@@ -29,28 +30,36 @@
  *                          signifies that a problem had occured.
  */
-psImage* psImageReadSection(
-    psImage* output,
-    /**< the output psImage to recycle, or NULL if new psImage desired */
-    int col0,
-    /**< the column index of the origin to start reading */
-    int row0,
-    /**< the row index of the origin to start reading */
-    int numCols,
-    /**< the number of desired columns to read */
-    int numRows,
-    /**< the number of desired rows to read */
-    int z,
-    /**< the z index to read if file is organized as a 3D image cube. */
-    char* extname,
-    /**< the image extension to read (this should match the EXTNAME keyword in
-     *   the extension If NULL, the extnum parameter is to be used instead
-     */
-    int extnum,
-    /**< the image extension to read (0=PHU, 1=first extension, etc.)  This is
-     *   only used if extname is NULL
-     */
-    char* filename
-    /**< the filename of the FITS image file to read */
-);
+psImage *psImageReadSection(psImage * output,
+
+                            /**< the output psImage to recycle, or NULL if new psImage desired */
+                            int col0,
+
+                            /**< the column index of the origin to start reading */
+                            int row0,
+
+                            /**< the row index of the origin to start reading */
+                            int numCols,
+
+                            /**< the number of desired columns to read */
+                            int numRows,
+
+                            /**< the number of desired rows to read */
+                            int z,
+
+                            /**< the z index to read if file is organized as a 3D image cube. */
+                            char *extname,
+
+                            /**< the image extension to read (this should match the EXTNAME keyword in
+                             *   the extension If NULL, the extnum parameter is to be used instead
+                             */
+                            int extnum,
+
+                            /**< the image extension to read (0=PHU, 1=first extension, etc.)  This is
+                             *   only used if extname is NULL
+                             */
+                            char *filename
+
+                            /**< the filename of the FITS image file to read */
+                           );
 
 /** Read an image or subimage from a FITS file specified by a filename.
@@ -58,24 +67,30 @@
  *  return bool         TRUE is successful, otherwise FALSE.
  */
-bool psImageWriteSection(
-    psImage* input,
-    /**< the psImage to write */
-    int col0,
-    /**< the column index of the origin to start writing */
-    int row0,
-    /**< the row index of the origin to start writing */
-    int z,
-    /**< the z index to start writing */
-    char* extname,
-    /**< the image extension to write (this should match the EXTNAME keyword in
-     *   the extension If NULL, the extnum parameter is to be used instead
-     */
-    int extnum,
-    /**< the image extension to write (0=PHU, 1=first extension, etc.)  This is
-     *   only used if extname is NULL.
-     */
-    char* filename
-    /**< the filename of the FITS image file to write */
-);
+bool psImageWriteSection(psImage * input,
+
+                         /**< the psImage to write */
+                         int col0,
+
+                         /**< the column index of the origin to start writing */
+                         int row0,
+
+                         /**< the row index of the origin to start writing */
+                         int z,
+
+                         /**< the z index to start writing */
+                         char *extname,
+
+                         /**< the image extension to write (this should match the EXTNAME keyword in
+                          *   the extension If NULL, the extnum parameter is to be used instead
+                          */
+                         int extnum,
+
+                         /**< the image extension to write (0=PHU, 1=first extension, etc.)  This is
+                          *   only used if extname is NULL.
+                          */
+                         char *filename
+
+                         /**< the filename of the FITS image file to write */
+                        );
 
 /// @}
Index: trunk/psLib/src/image/psImageManip.c
===================================================================
--- trunk/psLib/src/image/psImageManip.c	(revision 1406)
+++ trunk/psLib/src/image/psImageManip.c	(revision 1407)
@@ -1,2 +1,3 @@
+
 /** @file  psImageManip.c
  *
@@ -10,13 +11,17 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-08-06 22:34:05 $
+ *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-08-07 00:06:06 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
-#include <math.h>                      // for isfinite(), etc.
+#include <math.h>                          // for
+// isfinite(),
+// etc.
 #include <stdlib.h>
 #include <stdbool.h>
-#include <string.h>                    // for memcpy, etc.
+#include <string.h>                        // for
+// memcpy,
+// etc.
 
 #include "psError.h"
@@ -26,5 +31,5 @@
 #include "psImageExtraction.h"
 
-int psImageClip(psImage* input, psF64 min, psF64 vmin, psF64 max, psF64 vmax)
+int psImageClip(psImage * input, psF64 min, psF64 vmin, psF64 max, psF64 vmax)
 {
     int numClipped = 0;
@@ -37,5 +42,5 @@
 
     if (max < min) {
-        psError(__func__,"psImageClip can not be invoked with max < min.");
+        psError(__func__, "psImageClip can not be invoked with max < min.");
         return 0;
     }
@@ -100,20 +105,19 @@
         break;
 
-        psImageClipCase(S8,"psS8")
-        psImageClipCase(S16,"psS16")
-        psImageClipCase(S32,"psS32")
-        psImageClipCase(S64,"psS64")
-        psImageClipCase(U8,"psU8")
-        psImageClipCase(U16,"psU16")
-        psImageClipCase(U32,"psU32")
-        psImageClipCase(U64,"psU64")
-        psImageClipCase(F32,"psF32")
-        psImageClipCase(F64,"psF64")
-        psImageClipCaseComplex(C32,"psC32",cabsf)
-        psImageClipCaseComplex(C64,"psC64",cabs)
+        psImageClipCase(S8, "psS8")
+        psImageClipCase(S16, "psS16")
+        psImageClipCase(S32, "psS32")
+        psImageClipCase(S64, "psS64")
+        psImageClipCase(U8, "psU8")
+        psImageClipCase(U16, "psU16")
+        psImageClipCase(U32, "psU32")
+        psImageClipCase(U64, "psU64")
+        psImageClipCase(F32, "psF32")
+        psImageClipCase(F64, "psF64")
+        psImageClipCaseComplex(C32, "psC32", cabsf)
+        psImageClipCaseComplex(C64, "psC64", cabs)
 
     default:
-        psError(__func__,"psImageClip does not support the given datatype (%d)",
-                input->type.type);
+        psError(__func__, "psImageClip does not support the given datatype (%d)", input->type.type);
     }
 
@@ -121,5 +125,5 @@
 }
 
-int psImageClipNaN(psImage* input,psF64 value)
+int psImageClipNaN(psImage * input, psF64 value)
 {
     int numClipped = 0;
@@ -154,6 +158,5 @@
 
     default:
-        psError(__func__,"psImageClip does not support the given datatype (%d)",
-                input->type.type);
+        psError(__func__, "psImageClip does not support the given datatype (%d)", input->type.type);
     }
 
@@ -161,6 +164,5 @@
 }
 
-int psImageOverlaySection(psImage* image, const psImage* overlay, int col0,
-                          int row0, const char* op)
+int psImageOverlaySection(psImage * image, const psImage * overlay, int col0, int row0, const char *op)
 {
     unsigned int imageNumRows;
@@ -170,13 +172,13 @@
     unsigned int imageRowLimit;
     unsigned int imageColLimit;
-    psElemType  type;
+    psElemType type;
 
     if (image == NULL || overlay == NULL) {
-        psError(__func__,"one of the input images was NULL.");
+        psError(__func__, "one of the input images was NULL.");
         return 1;
     }
 
     if (op == NULL) {
-        psError(__func__,"Operation can not be NULL.");
+        psError(__func__, "Operation can not be NULL.");
         return 1;
     }
@@ -185,6 +187,5 @@
 
     if (type != overlay->type.type) {
-        psError(__func__,"Image and overlay datatypes must match. (%d vs %d)",
-                type,overlay->type.type);
+        psError(__func__, "Image and overlay datatypes must match. (%d vs %d)", type, overlay->type.type);
         return 2;
     }
@@ -197,5 +198,6 @@
     /* check row0/col0 to see if it is within the image size */
     if (row0 < 0 || col0 < 0 || row0 >= imageNumRows || col0 >= imageNumCols) {
-        psError(__func__, "Overlay origin of (%d,%d) is outside of the image dimensions (%d x %d).",
+        psError(__func__,
+                "Overlay origin of (%d,%d) is outside of the image dimensions (%d x %d).",
                 col0, row0, imageNumCols, imageNumRows);
         return 3;
@@ -203,11 +205,11 @@
 
     /* check if overlay is totally withing input image */
-    imageRowLimit = row0+overlayNumRows;
-    imageColLimit = col0+overlayNumCols;
+    imageRowLimit = row0 + overlayNumRows;
+    imageColLimit = col0 + overlayNumCols;
     if (imageRowLimit > imageNumRows || imageColLimit > imageNumCols) {
-        psError(__func__, "Overlay image (%d,%d -> %d,%d) is partially outside"
+        psError(__func__,
+                "Overlay image (%d,%d -> %d,%d) is partially outside"
                 " of the input image (%d x %d).",
-                col0, row0, col0+overlayNumCols-1, row0+overlayNumRows-1,
-                imageNumCols,imageNumRows);
+                col0, row0, col0 + overlayNumCols - 1, row0 + overlayNumRows - 1, imageNumCols, imageNumRows);
         return 4;
     }
@@ -259,5 +261,5 @@
 
     default:
-        psError(__func__,"Can not operate on type %d.",type);
+        psError(__func__, "Can not operate on type %d.", type);
     }
 
@@ -265,5 +267,5 @@
 }
 
-int psImageClipComplexRegion(psImage* input, psC64 min, psC64 vmin, psC64 max, psC64 vmax)
+int psImageClipComplexRegion(psImage * input, psC64 min, psC64 vmin, psC64 max, psC64 vmax)
 {
     int numClipped = 0;
@@ -276,15 +278,16 @@
 
     if (input == NULL) {
-        psError(__func__,"Can not perform clip on NULL image");
+        psError(__func__, "Can not perform clip on NULL image");
         return 0;
     }
 
-    if ( realMax < realMin ) {
-        psError(__func__,"psImageClipComplexRegion can not be invoked with "
-                "max < min in the real image space.");
+    if (realMax < realMin) {
+        psError(__func__,
+                "psImageClipComplexRegion can not be invoked with " "max < min in the real image space.");
         return 0;
     }
-    if ( imagMax < imagMin ) {
-        psError(__func__,"psImageClipComplexRegion can not be invoked with "
+    if (imagMax < imagMin) {
+        psError(__func__,
+                "psImageClipComplexRegion can not be invoked with "
                 "max < min in the imaginary image space.");
         return 0;
@@ -294,43 +297,42 @@
     numCols = input->numCols;
 
+    #define psImageClipComplexRegionCase(type,typename,realfcn,imagfcn) \
+case PS_TYPE_##type: { \
+        if (realfcn(vmin) < PS_MIN_##type || imagfcn(vmin) < PS_MIN_##type || \
+                realfcn(vmin) > PS_MAX_##type || imagfcn(vmin) > PS_MAX_##type ) { \
+            psError(__func__, "Specified vmin (%g%+gi) is outside of image's " \
+                    typename " pixel range", \
+                    creal(vmin),cimag(vmin)); \
+            break; \
+        } \
+        if (realfcn(vmax) > PS_MAX_##type || imagfcn(vmax) > PS_MAX_##type || \
+                realfcn(vmax) < PS_MIN_##type || imagfcn(vmax) < PS_MIN_##type ) { \
+            psError(__func__, "Specified vmax (%g%+gi) is outside of image's " \
+                    typename " pixel range", \
+                    creal(vmax),cimag(vmax)); \
+            break; \
+        } \
+        for (unsigned int row = 0;row<numRows;row++) { \
+            ps##type* inputRow = input->data.type[row]; \
+            for (unsigned int col = 0; col < numCols; col++) { \
+                if ( (realfcn(inputRow[col]) > realMax) || (imagfcn(inputRow[col]) > imagMax) ) { \
+                    inputRow[col] = (ps##type)vmax; \
+                    numClipped++; \
+                } else if ( (realfcn(inputRow[col]) < realMin) || (imagfcn(inputRow[col]) < imagMin) ){ \
+                    inputRow[col] = (ps##type)vmin; \
+                    numClipped++; \
+                } \
+            } \
+        } \
+    } \
+    break;
+
     switch (input->type.type) {
 
-        #define psImageClipComplexRegionCase(type,typename,realfcn,imagfcn) \
-    case PS_TYPE_##type: { \
-            if (realfcn(vmin) < PS_MIN_##type || imagfcn(vmin) < PS_MIN_##type || \
-                    realfcn(vmin) > PS_MAX_##type || imagfcn(vmin) > PS_MAX_##type ) { \
-                psError(__func__, "Specified vmin (%g%+gi) is outside of image's " \
-                        typename " pixel range", \
-                        creal(vmin),cimag(vmin)); \
-                break; \
-            } \
-            if (realfcn(vmax) > PS_MAX_##type || imagfcn(vmax) > PS_MAX_##type || \
-                    realfcn(vmax) < PS_MIN_##type || imagfcn(vmax) < PS_MIN_##type ) { \
-                psError(__func__, "Specified vmax (%g%+gi) is outside of image's " \
-                        typename " pixel range", \
-                        creal(vmax),cimag(vmax)); \
-                break; \
-            } \
-            for (unsigned int row = 0;row<numRows;row++) { \
-                ps##type* inputRow = input->data.type[row]; \
-                for (unsigned int col = 0; col < numCols; col++) { \
-                    if ( (realfcn(inputRow[col]) > realMax) || (imagfcn(inputRow[col]) > imagMax) ) { \
-                        inputRow[col] = (ps##type)vmax; \
-                        numClipped++; \
-                    } else if ( (realfcn(inputRow[col]) < realMin) || (imagfcn(inputRow[col]) < imagMin) ){ \
-                        inputRow[col] = (ps##type)vmin; \
-                        numClipped++; \
-                    } \
-                } \
-            } \
-        } \
-        break;
-
-        psImageClipComplexRegionCase(C32,"psC32",crealf,cimagf)
-        psImageClipComplexRegionCase(C64,"psC64",creal,cimag)
+        psImageClipComplexRegionCase(C32, "psC32", crealf, cimagf)
+        psImageClipComplexRegionCase(C64, "psC64", creal, cimag)
 
     default:
-        psError(__func__,"psImageClip does not support the given datatype (%d)",
-                input->type.type);
+        psError(__func__, "psImageClip does not support the given datatype (%d)", input->type.type);
     }
 
@@ -338,6 +340,5 @@
 }
 
-
-psImage* psImageRebin(psImage* out,const psImage* in,unsigned int scale,const psStats* stats)
+psImage *psImageRebin(psImage * out, const psImage * in, unsigned int scale, const psStats * stats)
 {
     int inRows;
@@ -345,10 +346,13 @@
     int outRows;
     int outCols;
-    psVector* vec;            // vector to hold the values of a single bin.
-    psStats* myStats;
+    psVector *vec;              // vector to hold
+
+    // the values of
+    // a single bin.
+    psStats *myStats;
     double statVal;
 
     if (in == NULL) {
-        psError(__func__,"Input image is NULL.");
+        psError(__func__, "Input image is NULL.");
         psFree(out);
         return NULL;
@@ -356,5 +360,5 @@
 
     if (scale < 1) {
-        psError(__func__,"The scale must be positive.");
+        psError(__func__, "The scale must be positive.");
         psFree(out);
         return NULL;
@@ -362,11 +366,11 @@
 
     if (stats == NULL) {
-        psError(__func__,"The stats input can not be NULL.");
+        psError(__func__, "The stats input can not be NULL.");
         psFree(out);
         return NULL;
     }
 
-    if (p_psGetStatValue(stats,&statVal) == false) {
-        psError(__func__,"The stat options didn't specify a single supported statistic type.");
+    if (p_psGetStatValue(stats, &statVal) == false) {
+        psError(__func__, "The stat options didn't specify a single supported statistic type.");
         psFree(out);
         return NULL;
@@ -376,12 +380,16 @@
     *myStats = *stats;
 
-    vec = psVectorAlloc(scale*scale,in->type.type);
+    vec = psVectorAlloc(scale * scale, in->type.type);
 
     // create output image.
     inRows = in->numRows;
     inCols = in->numCols;
-    outRows = (inRows+scale-1) / scale;   // round-up for remainders
-    outCols = (inCols+scale-1) / scale;   // round-up for remainders
-    out = psImageRecycle(out,outCols,outRows,in->type.type);
+    outRows = (inRows + scale - 1) / scale;     // round-up
+    // for
+    // remainders
+    outCols = (inCols + scale - 1) / scale;     // round-up
+    // for
+    // remainders
+    out = psImageRecycle(out, outCols, outRows, in->type.type);
 
     #define PS_IMAGE_REBIN_CASE(type) \
@@ -425,5 +433,5 @@
         PS_IMAGE_REBIN_CASE(C64);
     default:
-        psError(__func__,"Input image type not supported.");
+        psError(__func__, "Input image type not supported.");
         psFree(out);
         out = NULL;
@@ -435,5 +443,6 @@
     return out;
 }
-psImage* psImageResample(psImage* out, const psImage* in, int scale, psImageInterpolateMode mode)
+
+psImage *psImageResample(psImage * out, const psImage * in, int scale, psImageInterpolateMode mode)
 {
     int outRows;
@@ -442,14 +451,13 @@
 
     if (in == NULL) {
-        psError(__func__,"Input image can not be NULL.");
+        psError(__func__, "Input image can not be NULL.");
         psFree(out);
         return NULL;
     }
-
-    // create an output image of the same size and type
-    outRows = in->numRows*scale;
-    outCols = in->numCols*scale;
+    // create an output image of the same size
+    // and type
+    outRows = in->numRows * scale;
+    outCols = in->numCols * scale;
     invScale = 1.0f / (float)scale;
-
 
     #define PSIMAGE_RESAMPLE_CASE(TYPE) \
@@ -466,5 +474,5 @@
     }
 
-    switch(in->type.type) {
+    switch (in->type.type) {
         PSIMAGE_RESAMPLE_CASE(U8)
         PSIMAGE_RESAMPLE_CASE(U16)
@@ -480,5 +488,5 @@
         PSIMAGE_RESAMPLE_CASE(C64)
     default:
-        psError(__func__,"Unsupported type (%d)",in->type.type);
+        psError(__func__, "Unsupported type (%d)", in->type.type);
         psFree(out);
         return NULL;
@@ -488,5 +496,5 @@
 }
 
-psImage* psImageRoll(psImage* out, const psImage* in, int dx, int dy)
+psImage *psImageRoll(psImage * out, const psImage * in, int dx, int dy)
 {
     int outRows;
@@ -495,16 +503,17 @@
 
     if (in == NULL) {
-        psError(__func__,"Input image can not be NULL.");
+        psError(__func__, "Input image can not be NULL.");
         psFree(out);
         return NULL;
     }
-
-    // create an output image of the same size and type
+    // create an output image of the same size
+    // and type
     outRows = in->numRows;
     outCols = in->numCols;
     elementSize = PSELEMTYPE_SIZEOF(in->type.type);
-    out = psImageRecycle(out,outCols, outRows, in->type.type);
-
-    // make dx and dy between 0 and outCols or outRows, respectively
+    out = psImageRecycle(out, outCols, outRows, in->type.type);
+
+    // make dx and dy between 0 and outCols or
+    // outRows, respectively
     dx = dx % outCols;
     dy = dy % outRows;
@@ -516,16 +525,25 @@
     }
 
-    int segment1Size = elementSize*(outCols-dx);
-    int segment2Size = elementSize*dx;
-
-    for (int row=0;row<outRows;row++) {
-        int inRowNumber = row+dy;
+    int segment1Size = elementSize * (outCols - dx);
+    int segment2Size = elementSize * dx;
+
+    for (int row = 0; row < outRows; row++) {
+        int inRowNumber = row + dy;
+
         if (inRowNumber >= outRows) {
             inRowNumber -= outRows;
         }
-        psU8* inRow = in->data.U8[inRowNumber]; // to allow byte arithmetic, but for all types
-        psU8* outRow = out->data.U8[row];
-        memcpy(outRow,inRow+segment2Size,segment1Size);
-        memcpy(outRow+segment1Size,inRow,segment2Size);
+        psU8 *inRow = in->data.U8[inRowNumber]; // to
+
+        // allow
+
+        // byte
+        // arithmetic,
+
+        // but for all types
+        psU8 *outRow = out->data.U8[row];
+
+        memcpy(outRow, inRow + segment2Size, segment1Size);
+        memcpy(outRow + segment1Size, inRow, segment2Size);
     }
 
@@ -533,16 +551,16 @@
 }
 
-psImage* psImageRotate(psImage* out, const psImage* in, float angle, float unexposedValue, psImageInterpolateMode mode)
+psImage *psImageRotate(psImage * out,
+                       const psImage * in, float angle, float unexposedValue, psImageInterpolateMode mode)
 {
     if (in == NULL) {
-        psError(__func__,"The input image was NULL.");
+        psError(__func__, "The input image was NULL.");
         psFree(out);
         return NULL;
     }
-
     // put the angle in the range of 0...360.
-    angle = angle - 360.0f*floor(angle/360.0f);
-
-    if (fabsf(angle-90.0f) < FLT_EPSILON) {
+    angle = angle - 360.0f * floor(angle / 360.0f);
+
+    if (fabsf(angle - 90.0f) < FLT_EPSILON) {
         // perform 1/4 rotate counter-clockwise
         int numRows = in->numCols;
@@ -550,5 +568,6 @@
         int lastCol = numCols - 1;
         psElemType type = in->type.type;
-        out = psImageRecycle(out,numCols,numRows,type);
+
+        out = psImageRecycle(out, numCols, numRows, type);
 
         #define PSIMAGE_ROTATE_LEFT_90(TYPE) \
@@ -578,217 +597,213 @@
             PSIMAGE_ROTATE_LEFT_90(C64);
         default:
-            psError(__func__,"Unsupported type (%d)",type);
+            psError(__func__, "Unsupported type (%d)", type);
             psFree(out);
             return NULL;
         }
-    } else
-        if (fabsf(angle-180.0f) < FLT_EPSILON) {
-            // perform 1/2 rotate
-            int numRows = in->numRows;
-            int lastRow = numRows - 1;
-            int numCols = in->numCols;
-            int lastCol = numCols - 1;
-            psElemType type = in->type.type;
-            out = psImageRecycle(out,numCols,numRows,type);
-
-            #define PSIMAGE_ROTATE_180_CASE(TYPE) \
-        case PS_TYPE_##TYPE: { \
-                for (int row=0;row<numRows;row++) { \
-                    ps##TYPE* outRow = out->data.TYPE[row]; \
-                    ps##TYPE* inRow = in->data.TYPE[lastRow-row]; \
-                    for (int col=0;col<numCols;col++) { \
-                        outRow[col] = inRow[lastCol - col]; \
-                    } \
-                } \
-            } \
-            break;
-
-            switch (type) {
-                PSIMAGE_ROTATE_180_CASE(U8);
-                PSIMAGE_ROTATE_180_CASE(U16);
-                PSIMAGE_ROTATE_180_CASE(U32);
-                PSIMAGE_ROTATE_180_CASE(U64);
-                PSIMAGE_ROTATE_180_CASE(S8);
-                PSIMAGE_ROTATE_180_CASE(S16);
-                PSIMAGE_ROTATE_180_CASE(S32);
-                PSIMAGE_ROTATE_180_CASE(S64);
-                PSIMAGE_ROTATE_180_CASE(F32);
-                PSIMAGE_ROTATE_180_CASE(F64);
-                PSIMAGE_ROTATE_180_CASE(C32);
-                PSIMAGE_ROTATE_180_CASE(C64);
-            default:
-                psError(__func__,"Unsupported type (%d)",type);
-                psFree(out);
-                return NULL;
-            }
-        } else
-            if (fabsf(angle-270.0f) < FLT_EPSILON) {
-                // perform 1/4 rotate clockwise
-                int numRows = in->numCols;
-                int lastRow = numRows - 1;
-                int numCols = in->numRows;
-                psElemType type = in->type.type;
-                out = psImageRecycle(out,numCols,numRows,type);
-
-                #define PSIMAGE_ROTATE_RIGHT_90(TYPE) \
-            case PS_TYPE_##TYPE: { \
-                    ps##TYPE** inData = in->data.TYPE; \
-                    for (int row=0;row<numRows;row++) { \
-                        ps##TYPE* outRow = out->data.TYPE[row]; \
-                        for (int col=0;col<numCols;col++) { \
-                            outRow[col] = inData[col][lastRow-row]; \
-                        } \
-                    } \
-                } \
-                break;
-
-                switch (type) {
-                    PSIMAGE_ROTATE_RIGHT_90(U8);
-                    PSIMAGE_ROTATE_RIGHT_90(U16);
-                    PSIMAGE_ROTATE_RIGHT_90(U32);
-                    PSIMAGE_ROTATE_RIGHT_90(U64);
-                    PSIMAGE_ROTATE_RIGHT_90(S8);
-                    PSIMAGE_ROTATE_RIGHT_90(S16);
-                    PSIMAGE_ROTATE_RIGHT_90(S32);
-                    PSIMAGE_ROTATE_RIGHT_90(S64);
-                    PSIMAGE_ROTATE_RIGHT_90(F32);
-                    PSIMAGE_ROTATE_RIGHT_90(F64);
-                    PSIMAGE_ROTATE_RIGHT_90(C32);
-                    PSIMAGE_ROTATE_RIGHT_90(C64);
-                default:
-                    psError(__func__,"Unsupported type (%d)",type);
-                    psFree(out);
-                    return NULL;
-                }
-            } else
-                if (fabsf(angle) < FLT_EPSILON) {
-                    out = psImageCopy(out,in,in->type.type);
-                } else {
-                    psElemType type = in->type.type;
-                    int numRows = in->numRows;
-                    int numCols = in->numCols;
-                    double centerX = (float)(numCols) / 2.0f;
-                    float centerY = (float)(numRows) / 2.0f;
-                    float t = angle*(3.14159265358f/180.0f);
-                    float cosT = cosf(t);
-                    float sinT = sinf(t);
-
-                    // calculate the corners of the rotated image so we know the proper output image size.
-                    //    x' = x cos(t) + y sin(t);  i.e, x' = (x-centerX)*cosT + (y-centerY)*sinT;
-                    //    y' = y cos(t) - x sin(t);  i.e. y' = (y-centerY)*cosT - (x-centerX)*sinT;
-
-
-                    int outCols = ceil(abs(numCols*cosT)+abs(numRows*sinT))+1;
-                    int outRows = ceil(abs(numCols*sinT)+abs(numRows*cosT))+1;
-                    float minX = (float)outCols/-2.0f;
-                    int intMinY = outRows/-2;
-
-                    out = psImageRecycle(out,outCols,outRows,type);
-
-                    /* optimized public domain rotation routine by Karl Lager
-                    float cosT,sinT;
-                    cosT = cos(t);
-                    sinT = sin(t);
-                    for (y = min_y; y <= max_y; y++)
-                     { x' = min_x * cosT + y * sinT + x1';
-                       y' = y * cosT - min_x * sinT + y1';
-                       for (x = min_x; x <= max_x; x++)
-                        { if (x', y') is in the bounds of the bitmap, 
-                             get pixel(x', y') and plot the pixel to 
-                             (x, y) on screen.
-                          x' += cosT;
-                          y' -= sinT;
-                        }
-                     }
-                    */
-
-                    // precalculate some figures that are used within loop
-                    float minXTimesCosTPlusCenterX = minX*cosT+centerX;
-                    float CenterYMinusminXTimesSinT = centerY-minX*sinT;
-
-                    #define PSIMAGE_ROTATE_ARBITRARY_LOOP(TYPE,MODE) { \
-                        if (unexposedValue < PS_MIN_##TYPE || unexposedValue > PS_MAX_##TYPE) { \
-                            psError(__func__,"The given unexposedValue (%g) is outside of the " \
-                                    "image type's range (%g->%g).", \
-                                    unexposedValue, (double)PS_MIN_##TYPE,(double)PS_MAX_##TYPE); \
-                            psFree(out); \
-                            out = NULL; \
-                            break; \
-                        } \
-                        float inX; \
-                        float inY; \
-                        ps##TYPE* outRow; \
-                        for (int y = 0; y < outRows; y++) { \
-                            inX = minXTimesCosTPlusCenterX + (y+intMinY) * sinT; \
-                            inY = CenterYMinusminXTimesSinT + (y+intMinY) * cosT; \
-                            outRow = out->data.TYPE[y]; \
-                            for (int x = 0; x < outCols; x++) { \
-                                outRow[x] = p_psImagePixelInterpolate##MODE##_##TYPE(in,inX,inY,unexposedValue); \
-                                inX += cosT; \
-                                inY -= sinT; \
-                            } \
-                        } \
-                    }
-
-                    #define PSIMAGE_ROTATE_ARBITRARY_CASE(MODE) \
-                case PS_INTERPOLATE_##MODE: \
-                    switch (type) { \
-                    case PS_TYPE_U8: \
-                        PSIMAGE_ROTATE_ARBITRARY_LOOP(U8,MODE); \
-                        break; \
-                    case PS_TYPE_U16: \
-                        PSIMAGE_ROTATE_ARBITRARY_LOOP(U16,MODE); \
-                        break; \
-                    case PS_TYPE_U32: \
-                        PSIMAGE_ROTATE_ARBITRARY_LOOP(U32,MODE); \
-                        break; \
-                    case PS_TYPE_U64: \
-                        PSIMAGE_ROTATE_ARBITRARY_LOOP(U64,MODE); \
-                        break; \
-                    case PS_TYPE_S8: \
-                        PSIMAGE_ROTATE_ARBITRARY_LOOP(S8,MODE); \
-                        break; \
-                    case PS_TYPE_S16: \
-                        PSIMAGE_ROTATE_ARBITRARY_LOOP(S16,MODE); \
-                        break; \
-                    case PS_TYPE_S32: \
-                        PSIMAGE_ROTATE_ARBITRARY_LOOP(S32,MODE); \
-                        break; \
-                    case PS_TYPE_S64: \
-                        PSIMAGE_ROTATE_ARBITRARY_LOOP(S64,MODE); \
-                        break; \
-                    case PS_TYPE_F32: \
-                        PSIMAGE_ROTATE_ARBITRARY_LOOP(F32,MODE); \
-                        break; \
-                    case PS_TYPE_F64: \
-                        PSIMAGE_ROTATE_ARBITRARY_LOOP(F64,MODE); \
-                        break; \
-                    case PS_TYPE_C32: \
-                        PSIMAGE_ROTATE_ARBITRARY_LOOP(C32,MODE); \
-                        break; \
-                    case PS_TYPE_C64: \
-                        PSIMAGE_ROTATE_ARBITRARY_LOOP(C64,MODE); \
-                        break; \
-                    default: \
-                        psError(__func__,"Image type (%d) not supported",type); \
-                        psFree(out); \
-                        out = NULL; \
-                    } \
-                    break;
-
-                    switch (mode) {
-                        PSIMAGE_ROTATE_ARBITRARY_CASE(FLAT);
-                        PSIMAGE_ROTATE_ARBITRARY_CASE(BILINEAR);
-                    default:
-                        psError(__func__,"Unsupported interpolation mode (%d)",mode);
-                        psFree(out);
-                        out = NULL;
-                    }
-                }
+    } else if (fabsf(angle - 180.0f) < FLT_EPSILON) {
+        // perform 1/2 rotate
+        int numRows = in->numRows;
+        int lastRow = numRows - 1;
+        int numCols = in->numCols;
+        int lastCol = numCols - 1;
+        psElemType type = in->type.type;
+
+        out = psImageRecycle(out, numCols, numRows, type);
+
+        #define PSIMAGE_ROTATE_180_CASE(TYPE) \
+    case PS_TYPE_##TYPE: { \
+            for (int row=0;row<numRows;row++) { \
+                ps##TYPE* outRow = out->data.TYPE[row]; \
+                ps##TYPE* inRow = in->data.TYPE[lastRow-row]; \
+                for (int col=0;col<numCols;col++) { \
+                    outRow[col] = inRow[lastCol - col]; \
+                } \
+            } \
+        } \
+        break;
+
+        switch (type) {
+            PSIMAGE_ROTATE_180_CASE(U8);
+            PSIMAGE_ROTATE_180_CASE(U16);
+            PSIMAGE_ROTATE_180_CASE(U32);
+            PSIMAGE_ROTATE_180_CASE(U64);
+            PSIMAGE_ROTATE_180_CASE(S8);
+            PSIMAGE_ROTATE_180_CASE(S16);
+            PSIMAGE_ROTATE_180_CASE(S32);
+            PSIMAGE_ROTATE_180_CASE(S64);
+            PSIMAGE_ROTATE_180_CASE(F32);
+            PSIMAGE_ROTATE_180_CASE(F64);
+            PSIMAGE_ROTATE_180_CASE(C32);
+            PSIMAGE_ROTATE_180_CASE(C64);
+        default:
+            psError(__func__, "Unsupported type (%d)", type);
+            psFree(out);
+            return NULL;
+        }
+    } else if (fabsf(angle - 270.0f) < FLT_EPSILON) {
+        // perform 1/4 rotate clockwise
+        int numRows = in->numCols;
+        int lastRow = numRows - 1;
+        int numCols = in->numRows;
+        psElemType type = in->type.type;
+
+        out = psImageRecycle(out, numCols, numRows, type);
+
+        #define PSIMAGE_ROTATE_RIGHT_90(TYPE) \
+    case PS_TYPE_##TYPE: { \
+            ps##TYPE** inData = in->data.TYPE; \
+            for (int row=0;row<numRows;row++) { \
+                ps##TYPE* outRow = out->data.TYPE[row]; \
+                for (int col=0;col<numCols;col++) { \
+                    outRow[col] = inData[col][lastRow-row]; \
+                } \
+            } \
+        } \
+        break;
+
+        switch (type) {
+            PSIMAGE_ROTATE_RIGHT_90(U8);
+            PSIMAGE_ROTATE_RIGHT_90(U16);
+            PSIMAGE_ROTATE_RIGHT_90(U32);
+            PSIMAGE_ROTATE_RIGHT_90(U64);
+            PSIMAGE_ROTATE_RIGHT_90(S8);
+            PSIMAGE_ROTATE_RIGHT_90(S16);
+            PSIMAGE_ROTATE_RIGHT_90(S32);
+            PSIMAGE_ROTATE_RIGHT_90(S64);
+            PSIMAGE_ROTATE_RIGHT_90(F32);
+            PSIMAGE_ROTATE_RIGHT_90(F64);
+            PSIMAGE_ROTATE_RIGHT_90(C32);
+            PSIMAGE_ROTATE_RIGHT_90(C64);
+        default:
+            psError(__func__, "Unsupported type (%d)", type);
+            psFree(out);
+            return NULL;
+        }
+    } else if (fabsf(angle) < FLT_EPSILON) {
+        out = psImageCopy(out, in, in->type.type);
+    } else {
+        psElemType type = in->type.type;
+        int numRows = in->numRows;
+        int numCols = in->numCols;
+        double centerX = (float)(numCols) / 2.0f;
+        float centerY = (float)(numRows) / 2.0f;
+        float t = angle * (3.14159265358f / 180.0f);
+        float cosT = cosf(t);
+        float sinT = sinf(t);
+
+        // calculate the corners of the rotated
+        // image so we know the proper
+        // output image size.
+        // x' = x cos(t) + y sin(t); i.e, x' =
+        // (x-centerX)*cosT +
+        // (y-centerY)*sinT;
+        // y' = y cos(t) - x sin(t); i.e. y' =
+        // (y-centerY)*cosT -
+        // (x-centerX)*sinT;
+
+        int outCols = ceil(abs(numCols * cosT) + abs(numRows * sinT)) + 1;
+        int outRows = ceil(abs(numCols * sinT) + abs(numRows * cosT)) + 1;
+        float minX = (float)outCols / -2.0f;
+        int intMinY = outRows / -2;
+
+        out = psImageRecycle(out, outCols, outRows, type);
+
+        /* optimized public domain rotation routine by Karl Lager float cosT,sinT; cosT = cos(t); sinT =
+         * sin(t); for (y = min_y; y <= max_y; y++) { x' = min_x * cosT + y * sinT + x1'; y' = y * cosT -
+         * min_x * sinT + y1'; for (x = min_x; x <= max_x; x++) { if (x', y') * * * * * * * * is in the
+         * bounds of the bitmap, get pixel(x', y') and plot the pixel to (x, y) on screen. x' += cosT; y' -=
+         * sinT; } } */
+
+        // precalculate some figures that are
+        // used within loop
+        float minXTimesCosTPlusCenterX = minX * cosT + centerX;
+        float CenterYMinusminXTimesSinT = centerY - minX * sinT;
+
+        #define PSIMAGE_ROTATE_ARBITRARY_LOOP(TYPE,MODE) { \
+            if (unexposedValue < PS_MIN_##TYPE || unexposedValue > PS_MAX_##TYPE) { \
+                psError(__func__,"The given unexposedValue (%g) is outside of the " \
+                        "image type's range (%g->%g).", \
+                        unexposedValue, (double)PS_MIN_##TYPE,(double)PS_MAX_##TYPE); \
+                psFree(out); \
+                out = NULL; \
+                break; \
+            } \
+            float inX; \
+            float inY; \
+            ps##TYPE* outRow; \
+            for (int y = 0; y < outRows; y++) { \
+                inX = minXTimesCosTPlusCenterX + (y+intMinY) * sinT; \
+                inY = CenterYMinusminXTimesSinT + (y+intMinY) * cosT; \
+                outRow = out->data.TYPE[y]; \
+                for (int x = 0; x < outCols; x++) { \
+                    outRow[x] = p_psImagePixelInterpolate##MODE##_##TYPE(in,inX,inY,unexposedValue); \
+                    inX += cosT; \
+                    inY -= sinT; \
+                } \
+            } \
+        }
+
+        #define PSIMAGE_ROTATE_ARBITRARY_CASE(MODE) \
+    case PS_INTERPOLATE_##MODE: \
+        switch (type) { \
+        case PS_TYPE_U8: \
+            PSIMAGE_ROTATE_ARBITRARY_LOOP(U8,MODE); \
+            break; \
+        case PS_TYPE_U16: \
+            PSIMAGE_ROTATE_ARBITRARY_LOOP(U16,MODE); \
+            break; \
+        case PS_TYPE_U32: \
+            PSIMAGE_ROTATE_ARBITRARY_LOOP(U32,MODE); \
+            break; \
+        case PS_TYPE_U64: \
+            PSIMAGE_ROTATE_ARBITRARY_LOOP(U64,MODE); \
+            break; \
+        case PS_TYPE_S8: \
+            PSIMAGE_ROTATE_ARBITRARY_LOOP(S8,MODE); \
+            break; \
+        case PS_TYPE_S16: \
+            PSIMAGE_ROTATE_ARBITRARY_LOOP(S16,MODE); \
+            break; \
+        case PS_TYPE_S32: \
+            PSIMAGE_ROTATE_ARBITRARY_LOOP(S32,MODE); \
+            break; \
+        case PS_TYPE_S64: \
+            PSIMAGE_ROTATE_ARBITRARY_LOOP(S64,MODE); \
+            break; \
+        case PS_TYPE_F32: \
+            PSIMAGE_ROTATE_ARBITRARY_LOOP(F32,MODE); \
+            break; \
+        case PS_TYPE_F64: \
+            PSIMAGE_ROTATE_ARBITRARY_LOOP(F64,MODE); \
+            break; \
+        case PS_TYPE_C32: \
+            PSIMAGE_ROTATE_ARBITRARY_LOOP(C32,MODE); \
+            break; \
+        case PS_TYPE_C64: \
+            PSIMAGE_ROTATE_ARBITRARY_LOOP(C64,MODE); \
+            break; \
+        default: \
+            psError(__func__,"Image type (%d) not supported",type); \
+            psFree(out); \
+            out = NULL; \
+        } \
+        break;
+
+        switch (mode) {
+            PSIMAGE_ROTATE_ARBITRARY_CASE(FLAT);
+            PSIMAGE_ROTATE_ARBITRARY_CASE(BILINEAR);
+        default:
+            psError(__func__, "Unsupported interpolation mode (%d)", mode);
+            psFree(out);
+            out = NULL;
+        }
+    }
 
     return out;
 }
 
-psImage* psImageShift(psImage* out, const psImage* in, float dx, float dy, psF64 unexposedValue, psImageInterpolateMode mode)
+psImage *psImageShift(psImage * out,
+                      const psImage * in,
+                      float dx, float dy, psF64 unexposedValue, psImageInterpolateMode mode)
 {
     int outRows;
@@ -798,14 +813,14 @@
 
     if (in == NULL) {
-        psError(__func__,"Input image can not be NULL.");
+        psError(__func__, "Input image can not be NULL.");
         return NULL;
     }
-
-    // create an output image of the same size and type
+    // create an output image of the same size
+    // and type
     outRows = in->numRows;
     outCols = in->numCols;
     type = in->type.type;
     elementSize = PSELEMTYPE_SIZEOF(type);
-    out = psImageRecycle(out,outCols, outRows, type);
+    out = psImageRecycle(out, outCols, outRows, type);
 
     #define PSIMAGE_SHIFT_CASE(TYPE) \
@@ -842,5 +857,5 @@
         PSIMAGE_SHIFT_CASE(C64);
     default:
-        psError(__func__,"Image type (%d) not supported.",type);
+        psError(__func__, "Image type (%d) not supported.", type);
         psFree(out);
         out = NULL;
Index: trunk/psLib/src/image/psImageManip.h
===================================================================
--- trunk/psLib/src/image/psImageManip.h	(revision 1406)
+++ trunk/psLib/src/image/psImageManip.h	(revision 1407)
@@ -1,2 +1,3 @@
+
 /** @file  psImageManip.h
  *
@@ -10,13 +11,13 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-07-22 20:42:22 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-08-07 00:06:06 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
 #ifndef PS_IMAGE_MANIP_H
-#define PS_IMAGE_MANIP_H
+#    define PS_IMAGE_MANIP_H
 
-#include "psImage.h"
+#    include "psImage.h"
 
 /// @addtogroup Image
@@ -31,11 +32,10 @@
  *  @return int     The number of clipped pixels
  */
-int psImageClip(
-    psImage* input,                 ///< the image to clip
-    psF64 min,                      ///< the minimum image value allowed
-    psF64 vmin,                     ///< the value pixels < min are set to
-    psF64 max,                      ///< the maximum image value allowed
-    psF64 vmax                      ///< the value pixels > max are set to
-);
+int psImageClip(psImage * input,        // /< the image to clip
+                psF64 min,      // /< the minimum image value allowed
+                psF64 vmin,     // /< the value pixels < min are set to
+                psF64 max,      // /< the maximum image value allowed
+                psF64 vmax      // /< the value pixels > max are set to
+               );
 
 /** Clip image values outside of a specified complex region
@@ -48,11 +48,10 @@
  *  @return int     The number of clipped pixels
  */
-int psImageClipComplexRegion(
-    psImage* input,                 ///< the image to clip
-    psC64 min,                      ///< the minimum image value allowed
-    psC64 vmin,                     ///< the value pixels < min are set to
-    psC64 max,                      ///< the maximum image value allowed
-    psC64 vmax                      ///< the value pixels > max are set to
-);
+int psImageClipComplexRegion(psImage * input,   // /< the image to clip
+                             psC64 min, // /< the minimum image value allowed
+                             psC64 vmin,        // /< the value pixels < min are set to
+                             psC64 max, // /< the maximum image value allowed
+                             psC64 vmax // /< the value pixels > max are set to
+                            );
 
 /** Clip NaN image pixels to given value.
@@ -63,8 +62,7 @@
  *  @return int     The number of clipped pixels
  */
-int psImageClipNaN(
-    psImage* input,                 ///< the image to clip
-    psF64 value                     ///< the value to set all NaN/Inf values to
-);
+int psImageClipNaN(psImage * input,     // /< the image to clip
+                   psF64 value  // /< the value to set all NaN/Inf values to
+                  );
 
 /** Overlay subregion of image with another image
@@ -79,11 +77,10 @@
  *  @return int         0 if success, non-zero if failed.
  */
-int psImageOverlaySection(
-    psImage* image,                 ///< target image
-    const psImage* overlay,         ///< the overlay image
-    int col0,                       ///< the column to start overlay
-    int row0,                       ///< the row to start overlay
-    const char* op                  ///< the operation to perform for overlay
-);
+int psImageOverlaySection(psImage * image,      // /< target image
+                          const psImage * overlay,      // /< the overlay image
+                          int col0,     // /< the column to start overlay
+                          int row0,     // /< the row to start overlay
+                          const char *op        // /< the operation to perform for overlay
+                         );
 
 /** Rebin image to new scale.
@@ -97,34 +94,22 @@
  *  @return psImage    new image formed by rebinning input image.
  */
-psImage* psImageRebin(
-    psImage* out,                   ///< an psImage to recycle.  If NULL, a new image is created
-    const psImage* in,              ///< input image
-    unsigned int scale,             ///< the scale to rebin for each dimension
-    const psStats* stats            ///< the statistic to perform when rebinning.  Only one method should be set.
-);
+psImage *psImageRebin(psImage * out,    // /< an psImage to recycle.  If NULL, a new image is created
+                      const psImage * in,       // /< input image
+                      unsigned int scale,       // /< the scale to rebin for each dimension
+                      const psStats * stats     // /< the statistic to perform when rebinning.  Only one
+                      // method should be set.
+                     );
 
-psImage* psImageResample(
-    psImage* out,                   ///< an psImage to recycle.  If NULL, a new image is created
-    const psImage* in,              ///< input image
-    int scale,
-    psImageInterpolateMode mode
-);
+psImage *psImageResample(psImage * out, // /< an psImage to recycle.  If NULL, a new image is created
+                         const psImage * in,    // /< input image
+                         int scale, psImageInterpolateMode mode);
 
-psImage* psImageRotate(
-    psImage* out,                   ///< an psImage to recycle.  If NULL, a new image is created
-    const psImage* in,              ///< input image
-    float angle,
-    float unexposedValue,
-    psImageInterpolateMode mode
-);
+psImage *psImageRotate(psImage * out,   // /< an psImage to recycle.  If NULL, a new image is created
+                       const psImage * in,      // /< input image
+                       float angle, float unexposedValue, psImageInterpolateMode mode);
 
-psImage* psImageShift(
-    psImage* out,                   ///< an psImage to recycle.  If NULL, a new image is created
-    const psImage* in,              ///< input image
-    float dx,
-    float dy,
-    float unexposedValue,
-    psImageInterpolateMode mode
-);
+psImage *psImageShift(psImage * out,    // /< an psImage to recycle.  If NULL, a new image is created
+                      const psImage * in,       // /< input image
+                      float dx, float dy, float unexposedValue, psImageInterpolateMode mode);
 
 /** Roll image by an integer number of pixels in either direction.
@@ -136,11 +121,9 @@
  *  @return psImage*    the rolled version of the input image.
  */
-psImage* psImageRoll(
-    psImage* out,                   ///< an psImage to recycle.  If NULL, a new image is created
-    const psImage* in,              ///< input image
-    int dx,                         ///< number of pixels to roll in the x-dimension
-    int dy                          ///< number of pixels to roll in the y-dimension
-);
+psImage *psImageRoll(psImage * out,     // /< an psImage to recycle.  If NULL, a new image is created
+                     const psImage * in,        // /< input image
+                     int dx,    // /< number of pixels to roll in the x-dimension
+                     int dy     // /< number of pixels to roll in the y-dimension
+                    );
 
 #endif
-
Index: trunk/psLib/src/image/psImageStats.c
===================================================================
--- trunk/psLib/src/image/psImageStats.c	(revision 1406)
+++ trunk/psLib/src/image/psImageStats.c	(revision 1407)
@@ -1,2 +1,3 @@
+
 /** @file psImageStats.c
 *  \brief Routines for calculating statistics on images.
@@ -9,6 +10,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-08-06 22:34:05 $
+*  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-08-07 00:06:06 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -32,49 +33,50 @@
 
 /// This routine must determine the various statistics for the image.
+
 /*****************************************************************************
     NOTE: verify that image/mask have the correct types, and sizes.
  *****************************************************************************/
-psStats *psImageStats(psStats *stats,
-                      psImage *in,
-                      psImage *mask,
-                      int maskVal)
-{
-    psVector* junkData=NULL;
-    psVector* junkMask=NULL;
+psStats *psImageStats(psStats * stats, psImage * in, psImage * mask, int maskVal)
+{
+    psVector *junkData = NULL;
+    psVector *junkMask = NULL;
 
     if (stats == NULL) {
-        psError(__func__,"The input psStats struct can not be NULL.");
+        psError(__func__, "The input psStats struct can not be NULL.");
         return NULL;
     }
 
     if (in == NULL) {
-        psError(__func__,"The input image can not be NULL.");
+        psError(__func__, "The input image can not be NULL.");
         return NULL;
     }
 
     if (stats->options == 0) {
-        psError(__func__,"No statistic option/operation was specified.");
+        psError(__func__, "No statistic option/operation was specified.");
         return stats;
     }
-
-    // stuff the image data into a psVector struct.
+    // stuff the image data into a psVector
+    // struct.
     junkData = psAlloc(sizeof(psVector));
     junkData->type = in->type;
-    junkData->nalloc = in->numRows*in->numCols;
+    junkData->nalloc = in->numRows * in->numCols;
     junkData->n = junkData->nalloc;
-    junkData->data.V = in->data.V[0];    // since psImage data is contiguous...
+    junkData->data.V = in->data.V[0];      // since
+    // psImage
+    // data
+    // is
+    // contiguous...
 
     if (mask != NULL) {
         if (mask->type.type != PS_TYPE_MASK) {
-            psError(__func__, "Expected the mask image type not found (type=%x)",
-                    mask->type.type);
+            psError(__func__, "Expected the mask image type not found (type=%x)", mask->type.type);
             psFree(junkData);
             return NULL;
         }
-
-        // stuff the mask data into a psVector struct.
+        // stuff the mask data into a psVector
+        // struct.
         junkMask = psAlloc(sizeof(psVector));
         junkMask->type = mask->type;
-        junkMask->nalloc = mask->numRows*mask->numCols;
+        junkMask->nalloc = mask->numRows * mask->numCols;
         junkMask->n = junkMask->nalloc;
         junkMask->data.V = mask->data.V[0];
@@ -85,5 +87,5 @@
     psFree(junkMask);
     psFree(junkData);
-    return(stats);
+    return (stats);
 }
 
@@ -93,36 +95,35 @@
     NOTE: verify that image/mask have the, correct types and  sizes.
  *****************************************************************************/
-psHistogram *psImageHistogram(psHistogram *out,
-                              psImage *in,
-                              psImage *mask,
-                              unsigned int maskVal)
-{
-    psVector *junkData=NULL;
-    psVector *junkMask=NULL;
+psHistogram *psImageHistogram(psHistogram * out, psImage * in, psImage * mask, unsigned int maskVal)
+{
+    psVector *junkData = NULL;
+    psVector *junkMask = NULL;
 
     // NOTE: Verify this action.
-    if ((out == NULL) ||
-            (in == NULL)) {
-        return(NULL);
+    if ((out == NULL) || (in == NULL)) {
+        return (NULL);
     }
 
     junkData = psAlloc(sizeof(psVector));
     junkData->type = in->type;
-    junkData->nalloc = in->numRows*in->numCols;
+    junkData->nalloc = in->numRows * in->numCols;
     junkData->n = junkData->nalloc;
-    junkData->data.V = in->data.V[0];    // since psImage data is contiguous...
+    junkData->data.V = in->data.V[0];      // since
+    // psImage
+    // data
+    // is
+    // contiguous...
 
     if (mask != NULL) {
         if (mask->type.type != PS_TYPE_MASK) {
-            psError(__func__, "Expected the mask image type not found (type=%x)",
-                    mask->type.type);
+            psError(__func__, "Expected the mask image type not found (type=%x)", mask->type.type);
             psFree(junkData);
             return NULL;
         }
-
-        // stuff the mask data into a psVector struct.
+        // stuff the mask data into a psVector
+        // struct.
         junkMask = psAlloc(sizeof(psVector));
         junkMask->type = mask->type;
-        junkMask->nalloc = mask->numRows*mask->numCols;
+        junkMask->nalloc = mask->numRows * mask->numCols;
         junkMask->n = junkMask->nalloc;
         junkMask->data.V = mask->data.V[0];
@@ -134,5 +135,5 @@
     psFree(junkData);
 
-    return(out);
+    return (out);
 }
 
@@ -141,15 +142,16 @@
     int i = 0;
     float tmp = 0.0;
-    float *scalingFactors = (float *) psAlloc(n * sizeof(float));
-
-    for (i=0;i<n;i++) {
-        //     ((2.0 * (float) i) / ((float) (n-1))) - 1.0;
-        //        tmp = (float) (i + 1);
-        tmp = (float) (n - i);
-        tmp = (M_PI * (tmp - 0.5)) / ((float) n);
+    float *scalingFactors = (float *)psAlloc(n * sizeof(float));
+
+    for (i = 0; i < n; i++) {
+        // ((2.0 * (float) i) / ((float) (n-1)))
+        // - 1.0;
+        // tmp = (float) (i + 1);
+        tmp = (float)(n - i);
+        tmp = (M_PI * (tmp - 0.5)) / ((float)n);
         scalingFactors[i] = cos(tmp);
     }
 
-    return(scalingFactors);
+    return (scalingFactors);
 }
 
@@ -165,15 +167,18 @@
     int i = 0;
     float tmp = 0.0;
+
     return p_psCalcScaleFactorsFit(n);
 
     printf("Should not get here\n");
-    float *scalingFactors = (float *) psAlloc(n * sizeof(float));
-    for (i=0;i<n;i++) {
-        //          scalingFactors[i] = ((2.0 * (float) i) / ((float) (n-1))) - 1.0;
-        tmp = (float) (n - i);
-        tmp = (M_PI * (tmp - 0.5)) / ((float) n);
+    float *scalingFactors = (float *)psAlloc(n * sizeof(float));
+
+    for (i = 0; i < n; i++) {
+        // scalingFactors[i] = ((2.0 * (float) i)
+        // / ((float) (n-1))) - 1.0;
+        tmp = (float)(n - i);
+        tmp = (M_PI * (tmp - 0.5)) / ((float)n);
         scalingFactors[i] = cos(tmp);
     }
-    return(scalingFactors);
+    return (scalingFactors);
 }
 
@@ -184,25 +189,24 @@
     int j = 0;
 
-    chebPolys = (psPolynomial1D **) psAlloc(maxChebyPoly *
-                                            sizeof(psPolynomial1D *));
-    for (i=0;i<maxChebyPoly;i++) {
-        chebPolys[i] = psPolynomial1DAlloc(i+1);
-    }
-
-    // Create the Chebyshev polynomials.  Polynomial i has i-th order.
+    chebPolys = (psPolynomial1D **) psAlloc(maxChebyPoly * sizeof(psPolynomial1D *));
+    for (i = 0; i < maxChebyPoly; i++) {
+        chebPolys[i] = psPolynomial1DAlloc(i + 1);
+    }
+
+    // Create the Chebyshev polynomials.
+    // Polynomial i has i-th order.
     chebPolys[0]->coeff[0] = 1;
     chebPolys[1]->coeff[1] = 1;
-    for (i=2;i<maxChebyPoly;i++) {
-        for (j=0;j<chebPolys[i-1]->n;j++) {
-            chebPolys[i]->coeff[j+1] = 2 * chebPolys[i-1]->coeff[j];
-        }
-        for (j=0;j<chebPolys[i-2]->n;j++) {
-            chebPolys[i]->coeff[j]-= chebPolys[i-2]->coeff[j];
-        }
-    }
-
-    return(chebPolys);
-}
-
+    for (i = 2; i < maxChebyPoly; i++) {
+        for (j = 0; j < chebPolys[i - 1]->n; j++) {
+            chebPolys[i]->coeff[j + 1] = 2 * chebPolys[i - 1]->coeff[j];
+        }
+        for (j = 0; j < chebPolys[i - 2]->n; j++) {
+            chebPolys[i]->coeff[j] -= chebPolys[i - 2]->coeff[j];
+        }
+    }
+
+    return (chebPolys);
+}
 
 /*****************************************************************************
@@ -220,7 +224,5 @@
         over all pixels (x,y) in the image.
  *****************************************************************************/
-psPolynomial2D *
-psImageFitPolynomial(const psImage *input,
-                     psPolynomial2D *coeffs)
+psPolynomial2D *psImageFitPolynomial(const psImage * input, psPolynomial2D * coeffs)
 {
     int x = 0;
@@ -235,16 +237,21 @@
     float tmp = 0.0;
 
-    // Create the sums[][] data structure.  This will hold the LHS of equation
-    // 29 in the ADD: sums[k][l] = SUM { image(x,y) * Tk(x) * Tl(y) }
-    sums = (float **) psAlloc(coeffs->nX * sizeof(float *));
-    for (i=0;i<coeffs->nX;i++) {
-        sums[i] = (float *) psAlloc(coeffs->nY * sizeof(float));
-    }
-
-    // We scale the pixel positions to values between -1.0 and 1.0
+    // Create the sums[][] data structure.  This
+    // will hold the LHS of
+    // equation
+    // 29 in the ADD: sums[k][l] = SUM {
+    // image(x,y) * Tk(x) * Tl(y) }
+    sums = (float **)psAlloc(coeffs->nX * sizeof(float *));
+    for (i = 0; i < coeffs->nX; i++) {
+        sums[i] = (float *)psAlloc(coeffs->nY * sizeof(float));
+    }
+
+    // We scale the pixel positions to values
+    // between -1.0 and 1.0
     rScalingFactors = p_psCalcScaleFactorsFit(input->numRows);
     cScalingFactors = p_psCalcScaleFactorsFit(input->numCols);
 
-    // Determine how many Chebyshev polynomials are needed, then create them.
+    // Determine how many Chebyshev polynomials
+    // are needed, then create them.
     maxChebyPoly = coeffs->nX;
     if (coeffs->nY > coeffs->nX) {
@@ -254,25 +261,29 @@
 
     // Sanity check for the Chebyshevs.
-    for (i=0;i<coeffs->nX;i++) {
-        for (j=0;j<coeffs->nY;j++) {
+    for (i = 0; i < coeffs->nX; i++) {
+        for (j = 0; j < coeffs->nY; j++) {
             tmp = 0.0;
-            for (x=0;x<input->numRows;x++) {
-                tmp+= psPolynomial1DEval(rScalingFactors[x], chebPolys[i]) *
-                      psPolynomial1DEval(rScalingFactors[x], chebPolys[j]);
+            for (x = 0; x < input->numRows; x++) {
+                tmp +=
+                    psPolynomial1DEval
+                    (rScalingFactors[x], chebPolys[i]) * psPolynomial1DEval(rScalingFactors[x], chebPolys[j]);
 
             }
-            //printf("SUM(Cheby(%d) * Cheby(%d)) is %f\n", i, j, tmp);
+            // printf("SUM(Cheby(%d) * Cheby(%d))
+            // is %f\n", i, j, tmp);
         }
     }
 
     // Compute the sums[][] data structure.
-    for (i=0;i<coeffs->nX;i++) {
-        for (j=0;j<coeffs->nY;j++) {
+    for (i = 0; i < coeffs->nX; i++) {
+        for (j = 0; j < coeffs->nY; j++) {
             sums[i][j] = 0.0;
-            for (x=0;x<input->numRows;x++) {
-                for (y=0;y<input->numCols;y++) {
-                    sums[i][j]+= input->data.F32[x][y] *
-                                 psPolynomial1DEval(rScalingFactors[x], chebPolys[i]) *
-                                 psPolynomial1DEval(cScalingFactors[y], chebPolys[j]);
+            for (x = 0; x < input->numRows; x++) {
+                for (y = 0; y < input->numCols; y++) {
+                    sums[i][j] +=
+                        input->data.F32[x][y] *
+                        psPolynomial1DEval
+                        (rScalingFactors[x],
+                         chebPolys[i]) * psPolynomial1DEval(cScalingFactors[y], chebPolys[j]);
                 }
             }
@@ -280,22 +291,22 @@
     }
 
-    for (i=0;i<coeffs->nX;i++) {
-        for (j=0;j<coeffs->nY;j++) {
+    for (i = 0; i < coeffs->nX; i++) {
+        for (j = 0; j < coeffs->nY; j++) {
             coeffs->coeff[i][j] = sums[i][j];
-            coeffs->coeff[i][j]/= (float) (input->numRows * input->numCols);
+            coeffs->coeff[i][j] /= (float)(input->numRows * input->numCols);
 
             if ((i != 0) && (j != 0)) {
-                coeffs->coeff[i][j]*= 4.0;
-            } else
-                if ((i == 0) && (j == 0)) {
-                    coeffs->coeff[i][j]*= 1.0;
-                } else {
-                    coeffs->coeff[i][j]*= 2.0;
-                }
-        }
-    }
-
-    // Free the Chebyshev polynomials that were created in this routine.
-    for (i=0;i<maxChebyPoly;i++) {
+                coeffs->coeff[i][j] *= 4.0;
+            } else if ((i == 0) && (j == 0)) {
+                coeffs->coeff[i][j] *= 1.0;
+            } else {
+                coeffs->coeff[i][j] *= 2.0;
+            }
+        }
+    }
+
+    // Free the Chebyshev polynomials that were
+    // created in this routine.
+    for (i = 0; i < maxChebyPoly; i++) {
         psFree(chebPolys[i]);
     }
@@ -303,5 +314,5 @@
 
     // Free some data
-    for (i=0;i<coeffs->nX;i++) {
+    for (i = 0; i < coeffs->nX; i++) {
         psFree(sums[i]);
     }
@@ -310,5 +321,5 @@
     psFree(rScalingFactors);
 
-    return(coeffs);
+    return (coeffs);
 }
 
@@ -316,7 +327,5 @@
  
  *****************************************************************************/
-int
-psImageEvalPolynomial(const psImage *input,
-                      const psPolynomial2D *coeffs)
+int psImageEvalPolynomial(const psImage * input, const psPolynomial2D * coeffs)
 {
     int x = 0;
@@ -331,21 +340,26 @@
     float polySum = 0.0;
 
-    // Create the sums[][] data structure.  This will hold the LHS of equation
-    // 29 in the ADD: sums[k][l] = SUM { image(x,y) * Tk(x) * Tl(y) }
-    sums = (float **) psAlloc(coeffs->nX * sizeof(float *));
-    for (i=0;i<coeffs->nX;i++) {
-        sums[i] = (float *) psAlloc(coeffs->nY * sizeof(float));
-    }
-    for (i=0;i<coeffs->nX;i++) {
-        for (j=0;j<coeffs->nY;j++) {
+    // Create the sums[][] data structure.  This
+    // will hold the LHS of
+    // equation
+    // 29 in the ADD: sums[k][l] = SUM {
+    // image(x,y) * Tk(x) * Tl(y) }
+    sums = (float **)psAlloc(coeffs->nX * sizeof(float *));
+    for (i = 0; i < coeffs->nX; i++) {
+        sums[i] = (float *)psAlloc(coeffs->nY * sizeof(float));
+    }
+    for (i = 0; i < coeffs->nX; i++) {
+        for (j = 0; j < coeffs->nY; j++) {
             sums[i][j] = 0.0;
         }
     }
 
-    // We scale the pixel positions to values between -1.0 and 1.0
+    // We scale the pixel positions to values
+    // between -1.0 and 1.0
     rScalingFactors = p_psCalcScaleFactorsEval(input->numRows);
     cScalingFactors = p_psCalcScaleFactorsEval(input->numCols);
 
-    // Determine how many Chebyshev polynomials are needed, then create them.
+    // Determine how many Chebyshev polynomials
+    // are needed, then create them.
     maxChebyPoly = coeffs->nX;
     if (coeffs->nY > coeffs->nX) {
@@ -355,12 +369,14 @@
     chebPolys = p_psCreateChebyshevPolys(maxChebyPoly);
 
-    for (x=0;x<input->numRows;x++) {
-        for (y=0;y<input->numCols;y++) {
+    for (x = 0; x < input->numRows; x++) {
+        for (y = 0; y < input->numCols; y++) {
             polySum = 0.0;
-            for (i=0;i<coeffs->nX;i++) {
-                for (j=0;j<coeffs->nY;j++) {
-                    polySum+= psPolynomial1DEval(rScalingFactors[x], chebPolys[i]) *
-                              psPolynomial1DEval(cScalingFactors[y], chebPolys[j]) *
-                              coeffs->coeff[i][j];
+            for (i = 0; i < coeffs->nX; i++) {
+                for (j = 0; j < coeffs->nY; j++) {
+                    polySum +=
+                        psPolynomial1DEval
+                        (rScalingFactors[x],
+                         chebPolys[i]) *
+                        psPolynomial1DEval(cScalingFactors[y], chebPolys[j]) * coeffs->coeff[i][j];
 
                 }
@@ -370,6 +386,7 @@
     }
 
-    // Free the Chebyshev polynomials that were created in this routine.
-    for (i=0;i<maxChebyPoly;i++) {
+    // Free the Chebyshev polynomials that were
+    // created in this routine.
+    for (i = 0; i < maxChebyPoly; i++) {
         psFree(chebPolys[i]);
     }
@@ -377,5 +394,5 @@
 
     // Free some data
-    for (i=0;i<coeffs->nX;i++) {
+    for (i = 0; i < coeffs->nX; i++) {
         psFree(sums[i]);
     }
@@ -384,4 +401,4 @@
     psFree(rScalingFactors);
 
-    return(0);
-}
+    return (0);
+}
Index: trunk/psLib/src/image/psImageStats.h
===================================================================
--- trunk/psLib/src/image/psImageStats.h	(revision 1406)
+++ trunk/psLib/src/image/psImageStats.h	(revision 1407)
@@ -1,2 +1,3 @@
+
 /** @file psImageStats.h
 *  \brief Routines for calculating statistics on images.
@@ -9,18 +10,17 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-08-04 00:55:17 $
+*  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-08-07 00:06:06 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
 */
 #if !defined(PS_IMAGE_STATS_H)
-#define PS_IMAGE_STATS_H
+#    define PS_IMAGE_STATS_H
 
-
-#include "psType.h"
-#include "psVector.h"
-#include "psImage.h"
-#include "psStats.h"
-#include "psFunctions.h"
+#    include "psType.h"
+#    include "psVector.h"
+#    include "psImage.h"
+#    include "psStats.h"
+#    include "psFunctions.h"
 
 /// @addtogroup ImageStats
@@ -28,27 +28,25 @@
 
 /// This routine must determine the various statistics for the image.
-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
-                       
-                       
-psHistogram *psImageHistogram( psHistogram *out,   ///< input histogram description & target
-                               psImage *in,        ///< Image data to be histogramed.
-                               psImage *mask,      ///< mask data for image (NULL ok)
-                               unsigned int maskVal );  ///< mask Mask for mask
-                               
+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
+
+psHistogram *psImageHistogram(psHistogram * out,        // /< input histogram description & target
+                              psImage * in,     // /< Image data to be histogramed.
+                              psImage * mask,   // /< mask data for image (NULL ok)
+                              unsigned int maskVal);    // /< mask Mask for mask
+
 /// Fit a 2-D polynomial surface to an image.
-psPolynomial2D *
-psImageFitPolynomial( const psImage *input,  ///< image to fit
-                      psPolynomial2D *coeffs ///< coefficient structure carries in desired terms & target
-                    );
-                    
+psPolynomial2D *psImageFitPolynomial(const psImage * input,     // /< image to fit
+                                     psPolynomial2D * coeffs    // /< coefficient structure carries in
+                                     // desired terms & target
+                                    );
+
 /// Evaluate a 2-D polynomial surface to image pixels.
-int
-psImageEvalPolynomial( const psImage *input,  ///< image to fit
-                       const psPolynomial2D *coeffs ///< coefficient structure carries in desired terms
-                     );
-                     
+int psImageEvalPolynomial(const psImage * input,        // /< image to fit
+                          const psPolynomial2D * coeffs // /< coefficient structure carries in desired terms
+                         );
+
 /// @}
 
