Index: trunk/psLib/src/astro/psCoord.c
===================================================================
--- trunk/psLib/src/astro/psCoord.c	(revision 3976)
+++ trunk/psLib/src/astro/psCoord.c	(revision 3977)
@@ -10,6 +10,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.66 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-05-11 22:02:15 $
+*  @version $Revision: 1.67 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-05-19 05:18:20 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -876,6 +876,11 @@
 psPlaneTransform *psPlaneTransformCombine(psPlaneTransform *out,
         const psPlaneTransform *trans1,
-        const psPlaneTransform *trans2)
-{
+        const psPlaneTransform *trans2,
+        psRegion region,
+        int nSamples)
+{
+
+    // XXX: This does not yet use region and nSamples:  need to modify -rdd
+
     PS_PTR_CHECK_NULL(trans1, NULL);
     PS_PTR_CHECK_NULL(trans2, NULL);
@@ -1128,5 +1133,5 @@
 psPlaneTransform *psPlaneTransformInvert(psPlaneTransform *out,
         const psPlaneTransform *in,
-        psRegion *region,
+        psRegion region,
         int nSamples)
 {
@@ -1138,5 +1143,4 @@
         return(p_psPlaneTransformLinearInvert((psPlaneTransform *) in));
     }
-    PS_PTR_CHECK_NULL(region, NULL);
     PS_INT_COMPARE(1, nSamples, NULL);
 
@@ -1197,7 +1201,7 @@
     psS32 cnt = 0;
     for (int yint = 0; yint < nSamples; yint++) {
-        inCoord->y = region->y0 + ((psF32) yint) * ((region->y1 - region->y0) / ((psF32) nSamples));
+        inCoord->y = region.y0 + ((psF32) yint) * ((region.y1 - region.y0) / ((psF32) nSamples));
         for (int xint = 0; xint < nSamples; xint++) {
-            inCoord->x = region->x0 + ((psF32) xint) * ((region->x1 - region->x0) / ((psF32) nSamples));
+            inCoord->x = region.x0 + ((psF32) xint) * ((region.x1 - region.x0) / ((psF32) nSamples));
             (void)psPlaneTransformApply(outCoord, in, inCoord);
 
Index: trunk/psLib/src/astro/psCoord.h
===================================================================
--- trunk/psLib/src/astro/psCoord.h	(revision 3976)
+++ trunk/psLib/src/astro/psCoord.h	(revision 3977)
@@ -10,6 +10,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-03-31 23:01:46 $
+*  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-05-19 05:18:20 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -383,5 +383,5 @@
     psPlaneTransform *out,             ///< a transform to recycle, or NULL if one is to be created.
     const psPlaneTransform *in,        ///< transform to invert
-    psRegion *region,                  ///< region to fit for non-linear transform inversion
+    psRegion region,                   ///< region to fit for non-linear transform inversion
     int nSamples                       ///< number of samples in each axis for fit
 );
@@ -404,5 +404,7 @@
     psPlaneTransform *out,             ///< a transform to recycle, or NULL if one is to be created.
     const psPlaneTransform *trans1,    ///< first transform to combine
-    const psPlaneTransform *trans2     ///< first transform to combine
+    const psPlaneTransform *trans2,    ///< first transform to combine
+    psRegion region,                   ///< region to cover (for non-linear transforms)
+    int nSamples                       ///< number of samples on each axis (for non-linear transforms)
 );
 
@@ -431,4 +433,5 @@
     float sigmaClip
 );
+//XXX: need to add doxygen comments on the parameters above. -rdd
 
 /// @}
Index: trunk/psLib/src/astronomy/psCoord.c
===================================================================
--- trunk/psLib/src/astronomy/psCoord.c	(revision 3976)
+++ trunk/psLib/src/astronomy/psCoord.c	(revision 3977)
@@ -10,6 +10,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.66 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-05-11 22:02:15 $
+*  @version $Revision: 1.67 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-05-19 05:18:20 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -876,6 +876,11 @@
 psPlaneTransform *psPlaneTransformCombine(psPlaneTransform *out,
         const psPlaneTransform *trans1,
-        const psPlaneTransform *trans2)
-{
+        const psPlaneTransform *trans2,
+        psRegion region,
+        int nSamples)
+{
+
+    // XXX: This does not yet use region and nSamples:  need to modify -rdd
+
     PS_PTR_CHECK_NULL(trans1, NULL);
     PS_PTR_CHECK_NULL(trans2, NULL);
@@ -1128,5 +1133,5 @@
 psPlaneTransform *psPlaneTransformInvert(psPlaneTransform *out,
         const psPlaneTransform *in,
-        psRegion *region,
+        psRegion region,
         int nSamples)
 {
@@ -1138,5 +1143,4 @@
         return(p_psPlaneTransformLinearInvert((psPlaneTransform *) in));
     }
-    PS_PTR_CHECK_NULL(region, NULL);
     PS_INT_COMPARE(1, nSamples, NULL);
 
@@ -1197,7 +1201,7 @@
     psS32 cnt = 0;
     for (int yint = 0; yint < nSamples; yint++) {
-        inCoord->y = region->y0 + ((psF32) yint) * ((region->y1 - region->y0) / ((psF32) nSamples));
+        inCoord->y = region.y0 + ((psF32) yint) * ((region.y1 - region.y0) / ((psF32) nSamples));
         for (int xint = 0; xint < nSamples; xint++) {
-            inCoord->x = region->x0 + ((psF32) xint) * ((region->x1 - region->x0) / ((psF32) nSamples));
+            inCoord->x = region.x0 + ((psF32) xint) * ((region.x1 - region.x0) / ((psF32) nSamples));
             (void)psPlaneTransformApply(outCoord, in, inCoord);
 
Index: trunk/psLib/src/astronomy/psCoord.h
===================================================================
--- trunk/psLib/src/astronomy/psCoord.h	(revision 3976)
+++ trunk/psLib/src/astronomy/psCoord.h	(revision 3977)
@@ -10,6 +10,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-03-31 23:01:46 $
+*  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-05-19 05:18:20 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -383,5 +383,5 @@
     psPlaneTransform *out,             ///< a transform to recycle, or NULL if one is to be created.
     const psPlaneTransform *in,        ///< transform to invert
-    psRegion *region,                  ///< region to fit for non-linear transform inversion
+    psRegion region,                   ///< region to fit for non-linear transform inversion
     int nSamples                       ///< number of samples in each axis for fit
 );
@@ -404,5 +404,7 @@
     psPlaneTransform *out,             ///< a transform to recycle, or NULL if one is to be created.
     const psPlaneTransform *trans1,    ///< first transform to combine
-    const psPlaneTransform *trans2     ///< first transform to combine
+    const psPlaneTransform *trans2,    ///< first transform to combine
+    psRegion region,                   ///< region to cover (for non-linear transforms)
+    int nSamples                       ///< number of samples on each axis (for non-linear transforms)
 );
 
@@ -431,4 +433,5 @@
     float sigmaClip
 );
+//XXX: need to add doxygen comments on the parameters above. -rdd
 
 /// @}
Index: trunk/psLib/src/dataIO/psFits.c
===================================================================
--- trunk/psLib/src/dataIO/psFits.c	(revision 3976)
+++ trunk/psLib/src/dataIO/psFits.c	(revision 3977)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-05-19 02:09:39 $
+ *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-05-19 05:18:20 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -1005,8 +1005,5 @@
     if (dx != numCols || dy != numRows) {
         // the input image needs to be subsetted
-        subset = psImageSubset((psImage*)input,(psRegion) {
-                                   0,0,dx+1,dy+1
-                               }
-                              );
+        subset = psImageSubset((psImage*)input, psRegionSet(0,dx+1,0,dy+1));
     } else {
         subset = psMemIncrRefCounter((psImage*)input);
Index: trunk/psLib/src/dataManip/psMinimize.c
===================================================================
--- trunk/psLib/src/dataManip/psMinimize.c	(revision 3976)
+++ trunk/psLib/src/dataManip/psMinimize.c	(revision 3977)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.116 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-05-11 22:02:16 $
+ *  @version $Revision: 1.117 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-05-19 05:18:20 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -26,4 +26,6 @@
 #include "psMinimize.h"
 #include "psStats.h"
+#include "psImage.h"
+#include "psImageStructManip.h"
 #include "psImageIO.h"
 /*****************************************************************************/
Index: trunk/psLib/src/fft/psImageFFT.c
===================================================================
--- trunk/psLib/src/fft/psImageFFT.c	(revision 3976)
+++ trunk/psLib/src/fft/psImageFFT.c	(revision 3977)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-05-19 02:08:21 $
+ *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-05-19 05:18:20 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -20,4 +20,5 @@
 #include "psLogMsg.h"
 #include "psImageIO.h"
+#include "psImageStructManip.h"
 
 #include "psImageErrors.h"
Index: trunk/psLib/src/fits/psFits.c
===================================================================
--- trunk/psLib/src/fits/psFits.c	(revision 3976)
+++ trunk/psLib/src/fits/psFits.c	(revision 3977)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-05-19 02:09:39 $
+ *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-05-19 05:18:20 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -1005,8 +1005,5 @@
     if (dx != numCols || dy != numRows) {
         // the input image needs to be subsetted
-        subset = psImageSubset((psImage*)input,(psRegion) {
-                                   0,0,dx+1,dy+1
-                               }
-                              );
+        subset = psImageSubset((psImage*)input, psRegionSet(0,dx+1,0,dy+1));
     } else {
         subset = psMemIncrRefCounter((psImage*)input);
Index: trunk/psLib/src/image/psImage.c
===================================================================
--- trunk/psLib/src/image/psImage.c	(revision 3976)
+++ trunk/psLib/src/image/psImage.c	(revision 3977)
@@ -9,6 +9,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.65 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-04-29 02:25:10 $
+ *  @version $Revision: 1.66 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-05-19 05:18:20 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -91,20 +91,20 @@
 }
 
-psRegion* psRegionAlloc(psF32 x0,
-                        psF32 x1,
-                        psF32 y0,
-                        psF32 y1)
-{
-    psRegion* out = psAlloc(sizeof(psRegion));
-
-    out->x0 = x0;
-    out->y0 = y0;
-    out->x1 = x1;
-    out->y1 = y1;
+psRegion psRegionSet(psF32 x0,
+                     psF32 x1,
+                     psF32 y0,
+                     psF32 y1)
+{
+    psRegion out;
+
+    out.x0 = x0;
+    out.y0 = y0;
+    out.x1 = x1;
+    out.y1 = y1;
 
     return out;
 }
 
-psRegion* psRegionFromString(char* region)
+psRegion psRegionFromString(char* region)
 {
     psS32 col0;
@@ -117,5 +117,5 @@
         psError(PS_ERR_BAD_PARAMETER_NULL, true,
                 PS_ERRORTEXT_psImage_SUBSECTION_NULL);
-        return NULL;
+        return psRegionSet(NAN,NAN,NAN,NAN);
     }
 
@@ -124,5 +124,5 @@
                 PS_ERRORTEXT_psImage_SUBSECTION_INVALID,
                 region);
-        return NULL;
+        return psRegionSet(NAN,NAN,NAN,NAN);
     }
 
@@ -131,23 +131,17 @@
                 PS_ERRORTEXT_psImage_SUBSET_RANGE_MALFORMED,
                 col0,col1,row0,row1);
-        return NULL;
-    }
-
-    return psRegionAlloc(col0,col1,row0,row1);
-}
-
-char* psRegionToString(psRegion* region)
+        return psRegionSet(NAN,NAN,NAN,NAN);
+    }
+
+    return psRegionSet(col0,col1,row0,row1);
+}
+
+char* psRegionToString(psRegion region)
 {
     char tmpText[256]; // big enough to store any region as text
 
-    if (region == NULL) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                PS_ERRORTEXT_psImage_REGION_NULL);
-        return NULL;
-    }
-
     snprintf(tmpText,256,"[%g:%g,%g:%g]",
-             region->x0, region->x1,
-             region->y0, region->y1);
+             region.x0, region.x1,
+             region.y0, region.y1);
 
     return psStringCopy(tmpText);
@@ -195,158 +189,4 @@
 
     return old;
-}
-
-psImage* psImageCopy(psImage* output,
-                     const psImage* input,
-                     psElemType type)
-{
-    psElemType inDatatype;
-    psS32 elementSize;
-    psS32 elements;
-    psS32 numRows;
-    psS32 numCols;
-
-    if (input == NULL || input->data.V == NULL) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                PS_ERRORTEXT_psImage_IMAGE_NULL);
-        psFree(output);
-        return NULL;
-    }
-
-    if (input == output) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                PS_ERRORTEXT_psImage_INPLACE_NOTSUPPORTED);
-        psFree(output);
-        return NULL;
-    }
-
-    if (input->type.dimen != PS_DIMEN_IMAGE) {
-        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
-                PS_ERRORTEXT_psImage_NOT_AN_IMAGE);
-        psFree(output);
-        return NULL;
-    }
-
-    inDatatype = input->type.type;
-    numRows = input->numRows;
-    numCols = input->numCols;
-    elements = numRows * numCols;
-    elementSize = PSELEMTYPE_SIZEOF(inDatatype);
-
-    output = psImageRecycle(output, numCols, numRows, type);
-
-    // cover the trival case of copy of the same
-    // datatype.
-    if (type == inDatatype) {
-        for (psS32 row=0;row<numRows;row++) {
-            memcpy(output->data.V[row], input->data.V[row], elementSize * numCols);
-        }
-        return output;
-    }
-
-    #define PSIMAGE_ELEMENT_COPY(IN,INTYPE,OUT,OUTTYPE,ELEMENTS) { \
-        ps##INTYPE *in; \
-        ps##OUTTYPE *out; \
-        for(psS32 row=0;row<numRows;row++) { \
-            in = IN->data.INTYPE[row]; \
-            out = OUT->data.OUTTYPE[row]; \
-            for (psS32 col=0;col<numCols;col++) { \
-                *(out++) = *(in++); \
-            } \
-        } \
-    }
-
-    #define PSIMAGE_COPY_CASE(OUT,OUTTYPE) { \
-        switch (inDatatype) { \
-        case PS_TYPE_S8: \
-            PSIMAGE_ELEMENT_COPY(input,S8,OUT,OUTTYPE,elements); \
-            break; \
-        case PS_TYPE_S16: \
-            PSIMAGE_ELEMENT_COPY(input,S16,OUT,OUTTYPE,elements); \
-            break; \
-        case PS_TYPE_S32: \
-            PSIMAGE_ELEMENT_COPY(input,S32,OUT,OUTTYPE,elements); \
-            break; \
-        case PS_TYPE_S64: \
-            PSIMAGE_ELEMENT_COPY(input,S64,OUT,OUTTYPE,elements); \
-            break; \
-        case PS_TYPE_U8: \
-            PSIMAGE_ELEMENT_COPY(input,U8,OUT,OUTTYPE,elements); \
-            break; \
-        case PS_TYPE_U16: \
-            PSIMAGE_ELEMENT_COPY(input,U16,OUT,OUTTYPE,elements); \
-            break; \
-        case PS_TYPE_U32: \
-            PSIMAGE_ELEMENT_COPY(input,U32,OUT,OUTTYPE,elements); \
-            break; \
-        case PS_TYPE_U64: \
-            PSIMAGE_ELEMENT_COPY(input,U64,OUT,OUTTYPE,elements); \
-            break; \
-        case PS_TYPE_F32: \
-            PSIMAGE_ELEMENT_COPY(input,F32,OUT,OUTTYPE,elements); \
-            break; \
-        case PS_TYPE_F64: \
-            PSIMAGE_ELEMENT_COPY(input,F64,OUT,OUTTYPE,elements); \
-            break; \
-        case PS_TYPE_C32: \
-            PSIMAGE_ELEMENT_COPY(input,C32,OUT,OUTTYPE,elements); \
-            break; \
-        case PS_TYPE_C64: \
-            PSIMAGE_ELEMENT_COPY(input,C64,OUT,OUTTYPE,elements); \
-            break; \
-        default: \
-            break; \
-        } \
-    }
-
-    switch (type) {
-    case PS_TYPE_S8:
-        PSIMAGE_COPY_CASE(output, S8);
-        break;
-    case PS_TYPE_S16:
-        PSIMAGE_COPY_CASE(output, S16);
-        break;
-    case PS_TYPE_S32:
-        PSIMAGE_COPY_CASE(output, S32);
-        break;
-    case PS_TYPE_S64:
-        PSIMAGE_COPY_CASE(output, S64);
-        break;
-    case PS_TYPE_U8:
-        PSIMAGE_COPY_CASE(output, U8);
-        break;
-    case PS_TYPE_U16:
-        PSIMAGE_COPY_CASE(output, U16);
-        break;
-    case PS_TYPE_U32:
-        PSIMAGE_COPY_CASE(output, U32);
-        break;
-    case PS_TYPE_U64:
-        PSIMAGE_COPY_CASE(output, U64);
-        break;
-    case PS_TYPE_F32:
-        PSIMAGE_COPY_CASE(output, F32);
-        break;
-    case PS_TYPE_F64:
-        PSIMAGE_COPY_CASE(output, F64);
-        break;
-    case PS_TYPE_C32:
-        PSIMAGE_COPY_CASE(output, C32);
-        break;
-    case PS_TYPE_C64:
-        PSIMAGE_COPY_CASE(output, C64);
-        break;
-    default: {
-            char* typeStr;
-            PS_TYPE_NAME(typeStr,type);
-            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
-                    PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                    typeStr);
-            psFree(output);
-
-            break;
-        }
-    }
-    return output;
 }
 
Index: trunk/psLib/src/image/psImage.h
===================================================================
--- trunk/psLib/src/image/psImage.h	(revision 3976)
+++ trunk/psLib/src/image/psImage.h	(revision 3977)
@@ -11,6 +11,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.51 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-04-29 02:25:10 $
+ *  @version $Revision: 1.52 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-05-19 05:18:20 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -110,15 +110,11 @@
 /** Create a psRegion with the specified attributes.
  *
- * Uses psLib memory allocation functions to create a psRegion the
- * specified x0, x1, y0, and y1.
- *
- * @return psRegion* : Pointer to psRegion.
- *
- */
-psRegion* psRegionAlloc(
+ * @return psRegion : a cooresponding psRegion.
+ */
+psRegion psRegionSet(
     psF32 x0,                         ///< the first column of the region.
-    psF32 x1,                         ///< the last column of the region.
+    psF32 x1,                         ///< the last column of the region + 1.
     psF32 y0,                         ///< the first row of the region.
-    psF32 y1                          ///< the last row of the region.
+    psF32 y1                          ///< the last row of the region + 1.
 );
 
@@ -128,7 +124,7 @@
  *  shall be of the standard IRAF form '[x0:x1,y0:y1]'
  *
- *  @return psRegion*:  A new psRegion struct, or NULL is not successful.
- */
-psRegion* psRegionFromString(
+ *  @return psRegion:  A new psRegion struct, or NULL is not successful.
+ */
+psRegion psRegionFromString(
     char* region                       ///< image rectangular region in the form '[x0:x1,y0:y1]'
 );
@@ -140,5 +136,5 @@
  */
 char* psRegionToString(
-    psRegion* region                   ///< the psRegion to convert to a string
+    psRegion region                   ///< the psRegion to convert to a string
 );
 
@@ -153,16 +149,4 @@
     psU32 numRows,                     ///< the desired number of rows in image
     const psElemType type              ///< the desired datatype of the image
-);
-
-/** Makes a copy of a psImage
- *
- * @return psImage* Copy of the input psImage.  This may not be equal to the
- * output parameter
- *
- */
-psImage* psImageCopy(
-    psImage* output,                   ///< if not NULL, a psImage that could be recycled.
-    const psImage* input,              ///< the psImage to copy
-    psElemType type                    ///< the desired datatype of the returned copy
 );
 
Index: trunk/psLib/src/image/psImageConvolve.c
===================================================================
--- trunk/psLib/src/image/psImageConvolve.c	(revision 3976)
+++ trunk/psLib/src/image/psImageConvolve.c	(revision 3977)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-05-19 02:08:21 $
+ *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-05-19 05:18:20 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -454,9 +454,6 @@
 
         // subset out the padded area now.
-        psImage* complexOutSansPad = psImageSubset(complexOut,(psRegion) {
-                                         FOURIER_PADDING,FOURIER_PADDING,
-                                         FOURIER_PADDING+numCols,FOURIER_PADDING+numRows
-                                     }
-                                                  );
+        psImage* complexOutSansPad = psImageSubset(complexOut,
+                                     psRegionSet(FOURIER_PADDING, FOURIER_PADDING+numCols,FOURIER_PADDING,FOURIER_PADDING+numRows));
 
         out = psImageRecycle(out,numCols,numRows,PS_TYPE_F32);
Index: trunk/psLib/src/image/psImageFFT.c
===================================================================
--- trunk/psLib/src/image/psImageFFT.c	(revision 3976)
+++ trunk/psLib/src/image/psImageFFT.c	(revision 3977)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-05-19 02:08:21 $
+ *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-05-19 05:18:20 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -20,4 +20,5 @@
 #include "psLogMsg.h"
 #include "psImageIO.h"
+#include "psImageStructManip.h"
 
 #include "psImageErrors.h"
Index: trunk/psLib/src/image/psImageGeomManip.c
===================================================================
--- trunk/psLib/src/image/psImageGeomManip.c	(revision 3976)
+++ trunk/psLib/src/image/psImageGeomManip.c	(revision 3977)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-05-19 02:08:21 $
+ *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-05-19 05:18:20 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -25,4 +25,5 @@
 #include "psError.h"
 #include "psImage.h"
+#include "psImageStructManip.h"
 #include "psStats.h"
 #include "psMemory.h"
Index: trunk/psLib/src/image/psImageStructManip.c
===================================================================
--- trunk/psLib/src/image/psImageStructManip.c	(revision 3976)
+++ trunk/psLib/src/image/psImageStructManip.c	(revision 3977)
@@ -8,6 +8,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-05-19 02:08:21 $
+ *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-05-19 05:18:20 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -136,34 +136,156 @@
 }
 
-psImage* psImageSubsection(psImage* image,
-                           const char* section)
+psImage* psImageCopy(psImage* output,
+                     const psImage* input,
+                     psElemType type)
 {
-    psS32 col0;
-    psS32 col1;
-    psS32 row0;
-    psS32 row1;
-
-    // section should be of the form '[col0:col1,row0:row1]'
-    if (section == NULL) {
+    psElemType inDatatype;
+    psS32 elementSize;
+    psS32 elements;
+    psS32 numRows;
+    psS32 numCols;
+
+    if (input == NULL || input->data.V == NULL) {
         psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                PS_ERRORTEXT_psImage_SUBSECTION_NULL);
-        return NULL;
-    }
-
-    if (sscanf(section,"[%d:%d,%d:%d]",&col0,&col1,&row0,&row1) < 4) {
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psFree(output);
+        return NULL;
+    }
+
+    if (input == output) {
         psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                PS_ERRORTEXT_psImage_SUBSECTION_INVALID,
-                section);
-        return NULL;
-    }
-
-    if (col0 > col1 || row0 > row1) {
-        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
-                PS_ERRORTEXT_psImage_SUBSET_RANGE_MALFORMED,
-                col0,col1,row0,row1);
-        return NULL;
-    }
-
-    return imageSubset(NULL,image,col0,row0,col1+1,row1+1);
+                PS_ERRORTEXT_psImage_INPLACE_NOTSUPPORTED);
+        psFree(output);
+        return NULL;
+    }
+
+    if (input->type.dimen != PS_DIMEN_IMAGE) {
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImage_NOT_AN_IMAGE);
+        psFree(output);
+        return NULL;
+    }
+
+    inDatatype = input->type.type;
+    numRows = input->numRows;
+    numCols = input->numCols;
+    elements = numRows * numCols;
+    elementSize = PSELEMTYPE_SIZEOF(inDatatype);
+
+    output = psImageRecycle(output, numCols, numRows, type);
+
+    // cover the trival case of copy of the same
+    // datatype.
+    if (type == inDatatype) {
+        for (psS32 row=0;row<numRows;row++) {
+            memcpy(output->data.V[row], input->data.V[row], elementSize * numCols);
+        }
+        return output;
+    }
+
+    #define PSIMAGE_ELEMENT_COPY(IN,INTYPE,OUT,OUTTYPE,ELEMENTS) { \
+        ps##INTYPE *in; \
+        ps##OUTTYPE *out; \
+        for(psS32 row=0;row<numRows;row++) { \
+            in = IN->data.INTYPE[row]; \
+            out = OUT->data.OUTTYPE[row]; \
+            for (psS32 col=0;col<numCols;col++) { \
+                *(out++) = *(in++); \
+            } \
+        } \
+    }
+
+    #define PSIMAGE_COPY_CASE(OUT,OUTTYPE) { \
+        switch (inDatatype) { \
+        case PS_TYPE_S8: \
+            PSIMAGE_ELEMENT_COPY(input,S8,OUT,OUTTYPE,elements); \
+            break; \
+        case PS_TYPE_S16: \
+            PSIMAGE_ELEMENT_COPY(input,S16,OUT,OUTTYPE,elements); \
+            break; \
+        case PS_TYPE_S32: \
+            PSIMAGE_ELEMENT_COPY(input,S32,OUT,OUTTYPE,elements); \
+            break; \
+        case PS_TYPE_S64: \
+            PSIMAGE_ELEMENT_COPY(input,S64,OUT,OUTTYPE,elements); \
+            break; \
+        case PS_TYPE_U8: \
+            PSIMAGE_ELEMENT_COPY(input,U8,OUT,OUTTYPE,elements); \
+            break; \
+        case PS_TYPE_U16: \
+            PSIMAGE_ELEMENT_COPY(input,U16,OUT,OUTTYPE,elements); \
+            break; \
+        case PS_TYPE_U32: \
+            PSIMAGE_ELEMENT_COPY(input,U32,OUT,OUTTYPE,elements); \
+            break; \
+        case PS_TYPE_U64: \
+            PSIMAGE_ELEMENT_COPY(input,U64,OUT,OUTTYPE,elements); \
+            break; \
+        case PS_TYPE_F32: \
+            PSIMAGE_ELEMENT_COPY(input,F32,OUT,OUTTYPE,elements); \
+            break; \
+        case PS_TYPE_F64: \
+            PSIMAGE_ELEMENT_COPY(input,F64,OUT,OUTTYPE,elements); \
+            break; \
+        case PS_TYPE_C32: \
+            PSIMAGE_ELEMENT_COPY(input,C32,OUT,OUTTYPE,elements); \
+            break; \
+        case PS_TYPE_C64: \
+            PSIMAGE_ELEMENT_COPY(input,C64,OUT,OUTTYPE,elements); \
+            break; \
+        default: \
+            break; \
+        } \
+    }
+
+    switch (type) {
+    case PS_TYPE_S8:
+        PSIMAGE_COPY_CASE(output, S8);
+        break;
+    case PS_TYPE_S16:
+        PSIMAGE_COPY_CASE(output, S16);
+        break;
+    case PS_TYPE_S32:
+        PSIMAGE_COPY_CASE(output, S32);
+        break;
+    case PS_TYPE_S64:
+        PSIMAGE_COPY_CASE(output, S64);
+        break;
+    case PS_TYPE_U8:
+        PSIMAGE_COPY_CASE(output, U8);
+        break;
+    case PS_TYPE_U16:
+        PSIMAGE_COPY_CASE(output, U16);
+        break;
+    case PS_TYPE_U32:
+        PSIMAGE_COPY_CASE(output, U32);
+        break;
+    case PS_TYPE_U64:
+        PSIMAGE_COPY_CASE(output, U64);
+        break;
+    case PS_TYPE_F32:
+        PSIMAGE_COPY_CASE(output, F32);
+        break;
+    case PS_TYPE_F64:
+        PSIMAGE_COPY_CASE(output, F64);
+        break;
+    case PS_TYPE_C32:
+        PSIMAGE_COPY_CASE(output, C32);
+        break;
+    case PS_TYPE_C64:
+        PSIMAGE_COPY_CASE(output, C64);
+        break;
+    default: {
+            char* typeStr;
+            PS_TYPE_NAME(typeStr,type);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                    typeStr);
+            psFree(output);
+
+            break;
+        }
+    }
+    return output;
 }
 
Index: trunk/psLib/src/image/psImageStructManip.h
===================================================================
--- trunk/psLib/src/image/psImageStructManip.h	(revision 3976)
+++ trunk/psLib/src/image/psImageStructManip.h	(revision 3977)
@@ -8,6 +8,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-05-19 02:08:21 $
+*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-05-19 05:18:20 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -45,15 +45,14 @@
 );
 
-/** Create a subimage of the specified area.
+/** Makes a copy of a psImage
  *
- * Uses psLib memory allocation functions to create an image based on a larger
- * one.
- *
- * @return psImage* : Pointer to psImage.
+ * @return psImage* Copy of the input psImage.  This may not be equal to the
+ * output parameter
  *
  */
-psImage* psImageSubsection(
-    psImage* image,                    ///< Parent image.
-    const char* section                ///< Subsection in the form '[x1:x2,y1:y2]'
+psImage* psImageCopy(
+    psImage* output,                   ///< if not NULL, a psImage that could be recycled.
+    const psImage* input,              ///< the psImage to copy
+    psElemType type                    ///< the desired datatype of the returned copy
 );
 
Index: trunk/psLib/src/imageops/psImageConvolve.c
===================================================================
--- trunk/psLib/src/imageops/psImageConvolve.c	(revision 3976)
+++ trunk/psLib/src/imageops/psImageConvolve.c	(revision 3977)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-05-19 02:08:21 $
+ *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-05-19 05:18:20 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -454,9 +454,6 @@
 
         // subset out the padded area now.
-        psImage* complexOutSansPad = psImageSubset(complexOut,(psRegion) {
-                                         FOURIER_PADDING,FOURIER_PADDING,
-                                         FOURIER_PADDING+numCols,FOURIER_PADDING+numRows
-                                     }
-                                                  );
+        psImage* complexOutSansPad = psImageSubset(complexOut,
+                                     psRegionSet(FOURIER_PADDING, FOURIER_PADDING+numCols,FOURIER_PADDING,FOURIER_PADDING+numRows));
 
         out = psImageRecycle(out,numCols,numRows,PS_TYPE_F32);
Index: trunk/psLib/src/imageops/psImageGeomManip.c
===================================================================
--- trunk/psLib/src/imageops/psImageGeomManip.c	(revision 3976)
+++ trunk/psLib/src/imageops/psImageGeomManip.c	(revision 3977)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-05-19 02:08:21 $
+ *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-05-19 05:18:20 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -25,4 +25,5 @@
 #include "psError.h"
 #include "psImage.h"
+#include "psImageStructManip.h"
 #include "psStats.h"
 #include "psMemory.h"
Index: trunk/psLib/src/imageops/psImageStructManip.c
===================================================================
--- trunk/psLib/src/imageops/psImageStructManip.c	(revision 3976)
+++ trunk/psLib/src/imageops/psImageStructManip.c	(revision 3977)
@@ -8,6 +8,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-05-19 02:08:21 $
+ *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-05-19 05:18:20 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -136,34 +136,156 @@
 }
 
-psImage* psImageSubsection(psImage* image,
-                           const char* section)
+psImage* psImageCopy(psImage* output,
+                     const psImage* input,
+                     psElemType type)
 {
-    psS32 col0;
-    psS32 col1;
-    psS32 row0;
-    psS32 row1;
-
-    // section should be of the form '[col0:col1,row0:row1]'
-    if (section == NULL) {
+    psElemType inDatatype;
+    psS32 elementSize;
+    psS32 elements;
+    psS32 numRows;
+    psS32 numCols;
+
+    if (input == NULL || input->data.V == NULL) {
         psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                PS_ERRORTEXT_psImage_SUBSECTION_NULL);
-        return NULL;
-    }
-
-    if (sscanf(section,"[%d:%d,%d:%d]",&col0,&col1,&row0,&row1) < 4) {
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psFree(output);
+        return NULL;
+    }
+
+    if (input == output) {
         psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                PS_ERRORTEXT_psImage_SUBSECTION_INVALID,
-                section);
-        return NULL;
-    }
-
-    if (col0 > col1 || row0 > row1) {
-        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
-                PS_ERRORTEXT_psImage_SUBSET_RANGE_MALFORMED,
-                col0,col1,row0,row1);
-        return NULL;
-    }
-
-    return imageSubset(NULL,image,col0,row0,col1+1,row1+1);
+                PS_ERRORTEXT_psImage_INPLACE_NOTSUPPORTED);
+        psFree(output);
+        return NULL;
+    }
+
+    if (input->type.dimen != PS_DIMEN_IMAGE) {
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImage_NOT_AN_IMAGE);
+        psFree(output);
+        return NULL;
+    }
+
+    inDatatype = input->type.type;
+    numRows = input->numRows;
+    numCols = input->numCols;
+    elements = numRows * numCols;
+    elementSize = PSELEMTYPE_SIZEOF(inDatatype);
+
+    output = psImageRecycle(output, numCols, numRows, type);
+
+    // cover the trival case of copy of the same
+    // datatype.
+    if (type == inDatatype) {
+        for (psS32 row=0;row<numRows;row++) {
+            memcpy(output->data.V[row], input->data.V[row], elementSize * numCols);
+        }
+        return output;
+    }
+
+    #define PSIMAGE_ELEMENT_COPY(IN,INTYPE,OUT,OUTTYPE,ELEMENTS) { \
+        ps##INTYPE *in; \
+        ps##OUTTYPE *out; \
+        for(psS32 row=0;row<numRows;row++) { \
+            in = IN->data.INTYPE[row]; \
+            out = OUT->data.OUTTYPE[row]; \
+            for (psS32 col=0;col<numCols;col++) { \
+                *(out++) = *(in++); \
+            } \
+        } \
+    }
+
+    #define PSIMAGE_COPY_CASE(OUT,OUTTYPE) { \
+        switch (inDatatype) { \
+        case PS_TYPE_S8: \
+            PSIMAGE_ELEMENT_COPY(input,S8,OUT,OUTTYPE,elements); \
+            break; \
+        case PS_TYPE_S16: \
+            PSIMAGE_ELEMENT_COPY(input,S16,OUT,OUTTYPE,elements); \
+            break; \
+        case PS_TYPE_S32: \
+            PSIMAGE_ELEMENT_COPY(input,S32,OUT,OUTTYPE,elements); \
+            break; \
+        case PS_TYPE_S64: \
+            PSIMAGE_ELEMENT_COPY(input,S64,OUT,OUTTYPE,elements); \
+            break; \
+        case PS_TYPE_U8: \
+            PSIMAGE_ELEMENT_COPY(input,U8,OUT,OUTTYPE,elements); \
+            break; \
+        case PS_TYPE_U16: \
+            PSIMAGE_ELEMENT_COPY(input,U16,OUT,OUTTYPE,elements); \
+            break; \
+        case PS_TYPE_U32: \
+            PSIMAGE_ELEMENT_COPY(input,U32,OUT,OUTTYPE,elements); \
+            break; \
+        case PS_TYPE_U64: \
+            PSIMAGE_ELEMENT_COPY(input,U64,OUT,OUTTYPE,elements); \
+            break; \
+        case PS_TYPE_F32: \
+            PSIMAGE_ELEMENT_COPY(input,F32,OUT,OUTTYPE,elements); \
+            break; \
+        case PS_TYPE_F64: \
+            PSIMAGE_ELEMENT_COPY(input,F64,OUT,OUTTYPE,elements); \
+            break; \
+        case PS_TYPE_C32: \
+            PSIMAGE_ELEMENT_COPY(input,C32,OUT,OUTTYPE,elements); \
+            break; \
+        case PS_TYPE_C64: \
+            PSIMAGE_ELEMENT_COPY(input,C64,OUT,OUTTYPE,elements); \
+            break; \
+        default: \
+            break; \
+        } \
+    }
+
+    switch (type) {
+    case PS_TYPE_S8:
+        PSIMAGE_COPY_CASE(output, S8);
+        break;
+    case PS_TYPE_S16:
+        PSIMAGE_COPY_CASE(output, S16);
+        break;
+    case PS_TYPE_S32:
+        PSIMAGE_COPY_CASE(output, S32);
+        break;
+    case PS_TYPE_S64:
+        PSIMAGE_COPY_CASE(output, S64);
+        break;
+    case PS_TYPE_U8:
+        PSIMAGE_COPY_CASE(output, U8);
+        break;
+    case PS_TYPE_U16:
+        PSIMAGE_COPY_CASE(output, U16);
+        break;
+    case PS_TYPE_U32:
+        PSIMAGE_COPY_CASE(output, U32);
+        break;
+    case PS_TYPE_U64:
+        PSIMAGE_COPY_CASE(output, U64);
+        break;
+    case PS_TYPE_F32:
+        PSIMAGE_COPY_CASE(output, F32);
+        break;
+    case PS_TYPE_F64:
+        PSIMAGE_COPY_CASE(output, F64);
+        break;
+    case PS_TYPE_C32:
+        PSIMAGE_COPY_CASE(output, C32);
+        break;
+    case PS_TYPE_C64:
+        PSIMAGE_COPY_CASE(output, C64);
+        break;
+    default: {
+            char* typeStr;
+            PS_TYPE_NAME(typeStr,type);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                    typeStr);
+            psFree(output);
+
+            break;
+        }
+    }
+    return output;
 }
 
Index: trunk/psLib/src/imageops/psImageStructManip.h
===================================================================
--- trunk/psLib/src/imageops/psImageStructManip.h	(revision 3976)
+++ trunk/psLib/src/imageops/psImageStructManip.h	(revision 3977)
@@ -8,6 +8,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-05-19 02:08:21 $
+*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-05-19 05:18:20 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -45,15 +45,14 @@
 );
 
-/** Create a subimage of the specified area.
+/** Makes a copy of a psImage
  *
- * Uses psLib memory allocation functions to create an image based on a larger
- * one.
- *
- * @return psImage* : Pointer to psImage.
+ * @return psImage* Copy of the input psImage.  This may not be equal to the
+ * output parameter
  *
  */
-psImage* psImageSubsection(
-    psImage* image,                    ///< Parent image.
-    const char* section                ///< Subsection in the form '[x1:x2,y1:y2]'
+psImage* psImageCopy(
+    psImage* output,                   ///< if not NULL, a psImage that could be recycled.
+    const psImage* input,              ///< the psImage to copy
+    psElemType type                    ///< the desired datatype of the returned copy
 );
 
Index: trunk/psLib/src/math/psMinimize.c
===================================================================
--- trunk/psLib/src/math/psMinimize.c	(revision 3976)
+++ trunk/psLib/src/math/psMinimize.c	(revision 3977)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.116 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-05-11 22:02:16 $
+ *  @version $Revision: 1.117 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-05-19 05:18:20 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -26,4 +26,6 @@
 #include "psMinimize.h"
 #include "psStats.h"
+#include "psImage.h"
+#include "psImageStructManip.h"
 #include "psImageIO.h"
 /*****************************************************************************/
Index: trunk/psLib/src/mathtypes/psImage.c
===================================================================
--- trunk/psLib/src/mathtypes/psImage.c	(revision 3976)
+++ trunk/psLib/src/mathtypes/psImage.c	(revision 3977)
@@ -9,6 +9,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.65 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-04-29 02:25:10 $
+ *  @version $Revision: 1.66 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-05-19 05:18:20 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -91,20 +91,20 @@
 }
 
-psRegion* psRegionAlloc(psF32 x0,
-                        psF32 x1,
-                        psF32 y0,
-                        psF32 y1)
-{
-    psRegion* out = psAlloc(sizeof(psRegion));
-
-    out->x0 = x0;
-    out->y0 = y0;
-    out->x1 = x1;
-    out->y1 = y1;
+psRegion psRegionSet(psF32 x0,
+                     psF32 x1,
+                     psF32 y0,
+                     psF32 y1)
+{
+    psRegion out;
+
+    out.x0 = x0;
+    out.y0 = y0;
+    out.x1 = x1;
+    out.y1 = y1;
 
     return out;
 }
 
-psRegion* psRegionFromString(char* region)
+psRegion psRegionFromString(char* region)
 {
     psS32 col0;
@@ -117,5 +117,5 @@
         psError(PS_ERR_BAD_PARAMETER_NULL, true,
                 PS_ERRORTEXT_psImage_SUBSECTION_NULL);
-        return NULL;
+        return psRegionSet(NAN,NAN,NAN,NAN);
     }
 
@@ -124,5 +124,5 @@
                 PS_ERRORTEXT_psImage_SUBSECTION_INVALID,
                 region);
-        return NULL;
+        return psRegionSet(NAN,NAN,NAN,NAN);
     }
 
@@ -131,23 +131,17 @@
                 PS_ERRORTEXT_psImage_SUBSET_RANGE_MALFORMED,
                 col0,col1,row0,row1);
-        return NULL;
-    }
-
-    return psRegionAlloc(col0,col1,row0,row1);
-}
-
-char* psRegionToString(psRegion* region)
+        return psRegionSet(NAN,NAN,NAN,NAN);
+    }
+
+    return psRegionSet(col0,col1,row0,row1);
+}
+
+char* psRegionToString(psRegion region)
 {
     char tmpText[256]; // big enough to store any region as text
 
-    if (region == NULL) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                PS_ERRORTEXT_psImage_REGION_NULL);
-        return NULL;
-    }
-
     snprintf(tmpText,256,"[%g:%g,%g:%g]",
-             region->x0, region->x1,
-             region->y0, region->y1);
+             region.x0, region.x1,
+             region.y0, region.y1);
 
     return psStringCopy(tmpText);
@@ -195,158 +189,4 @@
 
     return old;
-}
-
-psImage* psImageCopy(psImage* output,
-                     const psImage* input,
-                     psElemType type)
-{
-    psElemType inDatatype;
-    psS32 elementSize;
-    psS32 elements;
-    psS32 numRows;
-    psS32 numCols;
-
-    if (input == NULL || input->data.V == NULL) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                PS_ERRORTEXT_psImage_IMAGE_NULL);
-        psFree(output);
-        return NULL;
-    }
-
-    if (input == output) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                PS_ERRORTEXT_psImage_INPLACE_NOTSUPPORTED);
-        psFree(output);
-        return NULL;
-    }
-
-    if (input->type.dimen != PS_DIMEN_IMAGE) {
-        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
-                PS_ERRORTEXT_psImage_NOT_AN_IMAGE);
-        psFree(output);
-        return NULL;
-    }
-
-    inDatatype = input->type.type;
-    numRows = input->numRows;
-    numCols = input->numCols;
-    elements = numRows * numCols;
-    elementSize = PSELEMTYPE_SIZEOF(inDatatype);
-
-    output = psImageRecycle(output, numCols, numRows, type);
-
-    // cover the trival case of copy of the same
-    // datatype.
-    if (type == inDatatype) {
-        for (psS32 row=0;row<numRows;row++) {
-            memcpy(output->data.V[row], input->data.V[row], elementSize * numCols);
-        }
-        return output;
-    }
-
-    #define PSIMAGE_ELEMENT_COPY(IN,INTYPE,OUT,OUTTYPE,ELEMENTS) { \
-        ps##INTYPE *in; \
-        ps##OUTTYPE *out; \
-        for(psS32 row=0;row<numRows;row++) { \
-            in = IN->data.INTYPE[row]; \
-            out = OUT->data.OUTTYPE[row]; \
-            for (psS32 col=0;col<numCols;col++) { \
-                *(out++) = *(in++); \
-            } \
-        } \
-    }
-
-    #define PSIMAGE_COPY_CASE(OUT,OUTTYPE) { \
-        switch (inDatatype) { \
-        case PS_TYPE_S8: \
-            PSIMAGE_ELEMENT_COPY(input,S8,OUT,OUTTYPE,elements); \
-            break; \
-        case PS_TYPE_S16: \
-            PSIMAGE_ELEMENT_COPY(input,S16,OUT,OUTTYPE,elements); \
-            break; \
-        case PS_TYPE_S32: \
-            PSIMAGE_ELEMENT_COPY(input,S32,OUT,OUTTYPE,elements); \
-            break; \
-        case PS_TYPE_S64: \
-            PSIMAGE_ELEMENT_COPY(input,S64,OUT,OUTTYPE,elements); \
-            break; \
-        case PS_TYPE_U8: \
-            PSIMAGE_ELEMENT_COPY(input,U8,OUT,OUTTYPE,elements); \
-            break; \
-        case PS_TYPE_U16: \
-            PSIMAGE_ELEMENT_COPY(input,U16,OUT,OUTTYPE,elements); \
-            break; \
-        case PS_TYPE_U32: \
-            PSIMAGE_ELEMENT_COPY(input,U32,OUT,OUTTYPE,elements); \
-            break; \
-        case PS_TYPE_U64: \
-            PSIMAGE_ELEMENT_COPY(input,U64,OUT,OUTTYPE,elements); \
-            break; \
-        case PS_TYPE_F32: \
-            PSIMAGE_ELEMENT_COPY(input,F32,OUT,OUTTYPE,elements); \
-            break; \
-        case PS_TYPE_F64: \
-            PSIMAGE_ELEMENT_COPY(input,F64,OUT,OUTTYPE,elements); \
-            break; \
-        case PS_TYPE_C32: \
-            PSIMAGE_ELEMENT_COPY(input,C32,OUT,OUTTYPE,elements); \
-            break; \
-        case PS_TYPE_C64: \
-            PSIMAGE_ELEMENT_COPY(input,C64,OUT,OUTTYPE,elements); \
-            break; \
-        default: \
-            break; \
-        } \
-    }
-
-    switch (type) {
-    case PS_TYPE_S8:
-        PSIMAGE_COPY_CASE(output, S8);
-        break;
-    case PS_TYPE_S16:
-        PSIMAGE_COPY_CASE(output, S16);
-        break;
-    case PS_TYPE_S32:
-        PSIMAGE_COPY_CASE(output, S32);
-        break;
-    case PS_TYPE_S64:
-        PSIMAGE_COPY_CASE(output, S64);
-        break;
-    case PS_TYPE_U8:
-        PSIMAGE_COPY_CASE(output, U8);
-        break;
-    case PS_TYPE_U16:
-        PSIMAGE_COPY_CASE(output, U16);
-        break;
-    case PS_TYPE_U32:
-        PSIMAGE_COPY_CASE(output, U32);
-        break;
-    case PS_TYPE_U64:
-        PSIMAGE_COPY_CASE(output, U64);
-        break;
-    case PS_TYPE_F32:
-        PSIMAGE_COPY_CASE(output, F32);
-        break;
-    case PS_TYPE_F64:
-        PSIMAGE_COPY_CASE(output, F64);
-        break;
-    case PS_TYPE_C32:
-        PSIMAGE_COPY_CASE(output, C32);
-        break;
-    case PS_TYPE_C64:
-        PSIMAGE_COPY_CASE(output, C64);
-        break;
-    default: {
-            char* typeStr;
-            PS_TYPE_NAME(typeStr,type);
-            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
-                    PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                    typeStr);
-            psFree(output);
-
-            break;
-        }
-    }
-    return output;
 }
 
Index: trunk/psLib/src/mathtypes/psImage.h
===================================================================
--- trunk/psLib/src/mathtypes/psImage.h	(revision 3976)
+++ trunk/psLib/src/mathtypes/psImage.h	(revision 3977)
@@ -11,6 +11,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.51 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-04-29 02:25:10 $
+ *  @version $Revision: 1.52 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-05-19 05:18:20 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -110,15 +110,11 @@
 /** Create a psRegion with the specified attributes.
  *
- * Uses psLib memory allocation functions to create a psRegion the
- * specified x0, x1, y0, and y1.
- *
- * @return psRegion* : Pointer to psRegion.
- *
- */
-psRegion* psRegionAlloc(
+ * @return psRegion : a cooresponding psRegion.
+ */
+psRegion psRegionSet(
     psF32 x0,                         ///< the first column of the region.
-    psF32 x1,                         ///< the last column of the region.
+    psF32 x1,                         ///< the last column of the region + 1.
     psF32 y0,                         ///< the first row of the region.
-    psF32 y1                          ///< the last row of the region.
+    psF32 y1                          ///< the last row of the region + 1.
 );
 
@@ -128,7 +124,7 @@
  *  shall be of the standard IRAF form '[x0:x1,y0:y1]'
  *
- *  @return psRegion*:  A new psRegion struct, or NULL is not successful.
- */
-psRegion* psRegionFromString(
+ *  @return psRegion:  A new psRegion struct, or NULL is not successful.
+ */
+psRegion psRegionFromString(
     char* region                       ///< image rectangular region in the form '[x0:x1,y0:y1]'
 );
@@ -140,5 +136,5 @@
  */
 char* psRegionToString(
-    psRegion* region                   ///< the psRegion to convert to a string
+    psRegion region                   ///< the psRegion to convert to a string
 );
 
@@ -153,16 +149,4 @@
     psU32 numRows,                     ///< the desired number of rows in image
     const psElemType type              ///< the desired datatype of the image
-);
-
-/** Makes a copy of a psImage
- *
- * @return psImage* Copy of the input psImage.  This may not be equal to the
- * output parameter
- *
- */
-psImage* psImageCopy(
-    psImage* output,                   ///< if not NULL, a psImage that could be recycled.
-    const psImage* input,              ///< the psImage to copy
-    psElemType type                    ///< the desired datatype of the returned copy
 );
 
Index: trunk/psLib/test/astronomy/verified/tst_psAstrometry01.stderr
===================================================================
--- trunk/psLib/test/astronomy/verified/tst_psAstrometry01.stderr	(revision 3976)
+++ trunk/psLib/test/astronomy/verified/tst_psAstrometry01.stderr	(revision 3977)
@@ -63,6 +63,4 @@
     Unallowable operation: in is NULL.
 <DATE><TIME>|<HOST>|E|psPlaneTransformInvert (FILE:LINENO)
-    Unallowable operation: region is NULL.
-<DATE><TIME>|<HOST>|E|psPlaneTransformInvert (FILE:LINENO)
     Error: (1 > nSamples) (1 0).
 
Index: trunk/psLib/test/astronomy/verified/tst_psAstrometry01.stdout
===================================================================
--- trunk/psLib/test/astronomy/verified/tst_psAstrometry01.stdout	(revision 3976)
+++ trunk/psLib/test/astronomy/verified/tst_psAstrometry01.stdout	(revision 3977)
@@ -27,6 +27,4 @@
 Calling psPlaneTransformInvert with NULL trans.  Should generate error and return NULL.
 ----------------------------------------------------------------------------------
-Calling psPlaneTransformInvert with NULL psRegion.  Should generate error and return NULL.
-----------------------------------------------------------------------------------
 Calling psPlaneTransformInvert with zero nSamples.  Should generate error and return NULL.
 Calling psPlaneTransformInvert with an acceptable linear transformation.
Index: trunk/psLib/test/collections/tst_psPixels.c
===================================================================
--- trunk/psLib/test/collections/tst_psPixels.c	(revision 3976)
+++ trunk/psLib/test/collections/tst_psPixels.c	(revision 3977)
@@ -5,7 +5,7 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.1 $
+ *  @version $Revision: 1.2 $
  *           $Name: not supported by cvs2svn $
- *  @date $Date: 2005-05-19 02:57:03 $
+ *  @date $Date: 2005-05-19 05:18:20 $
  *
  *  Copyright 2005 Maui High Performance Computing Center, University of Hawaii
@@ -328,8 +328,5 @@
     pixels->n = 10;
 
-    psImage* mask = psPixelsToMask(NULL,pixels,(psRegion) {
-                                       0,10,0,10
-                                   }
-                                   ,1);
+    psImage* mask = psPixelsToMask(NULL,pixels, psRegionSet(0,10,0,10), 1);
 
     if (mask == NULL) {
@@ -358,8 +355,5 @@
 
     // test when input psPixels is NULL.
-    mask = psPixelsToMask(mask, NULL, (psRegion) {
-                              0,10,0,10
-                          }
-                          ,1);
+    mask = psPixelsToMask(mask, NULL, psRegionSet(0,10,0,10), 1);
     if (mask != NULL) {
         psError(PS_ERR_UNKNOWN, true,
Index: trunk/psLib/test/collections/verified/tst_psMetadata_01.stdout
===================================================================
--- trunk/psLib/test/collections/verified/tst_psMetadata_01.stdout	(revision 3976)
+++ trunk/psLib/test/collections/verified/tst_psMetadata_01.stdout	(revision 3977)
@@ -44,9 +44,9 @@
  Key Name:   PCOUNT  Key mdType: 0x00000104  Key Value:               0  Key Comment: required keyword; must = 0
  Key Name: XTENSION  Key mdType: 0x00010001  Key Value:      'IMAGE   '  Key Comment: IMAGE extension
- Key Name:   BITPIX  Key mdType: 0x0001000a  Key Value:                  Key Comment: 
+ Key Name:   BITPIX  Key mdType: 0x0001000a  Key Value:                  Key Comment: List of Metadata Items
     Key Name:   BITPIX  Key mdType: 0x00000104  Key Value:             -64  Key Comment: number of bits per data pixel
     Key Name:   BITPIX  Key mdType: 0x00000104  Key Value:             -64  Key Comment: number of bits per data pixel
  Key Name:   GCOUNT  Key mdType: 0x00000104  Key Value:               1  Key Comment: required keyword; must = 1
- Key Name:  HISTORY  Key mdType: 0x0001000a  Key Value:                  Key Comment: 
+ Key Name:  HISTORY  Key mdType: 0x0001000a  Key Value:                  Key Comment: List of Metadata Items
     Key Name:  HISTORY  Key mdType: 0x00010001  Key Value:                  Key Comment: File modified by user 'harman' with fv  on 2004-08-04T<DATE>
     Key Name:  HISTORY  Key mdType: 0x00010001  Key Value:                  Key Comment: File modified by user 'harman' with fv  on 2004-08-04T<DATE>
@@ -81,5 +81,5 @@
  Key Name:   GCOUNT  Key mdType: 0x00000104  Key Value:               1  Key Comment: required keyword; must = 1
  Key Name:   BITPIX  Key mdType: 0x00000104  Key Value:             -64  Key Comment: number of bits per data pixel
- Key Name:  HISTORY  Key mdType: 0x0001000a  Key Value:                  Key Comment: 
+ Key Name:  HISTORY  Key mdType: 0x0001000a  Key Value:                  Key Comment: List of Metadata Items
     Key Name:  HISTORY  Key mdType: 0x00010001  Key Value:                  Key Comment: File modified by user 'harman' with fv  on 2004-08-04T<DATE>
     Key Name:  HISTORY  Key mdType: 0x00010001  Key Value:                  Key Comment: File modified by user 'harman' with fv  on 2004-08-04T<DATE>
Index: trunk/psLib/test/image/tst_psImageStats.c
===================================================================
--- trunk/psLib/test/image/tst_psImageStats.c	(revision 3976)
+++ trunk/psLib/test/image/tst_psImageStats.c	(revision 3977)
@@ -113,14 +113,8 @@
             tmpImage2 = psImageAlloc( IMAGE_X_SIZE*2, IMAGE_Y_SIZE*2, PS_TYPE_F32 );
             tmpMask2 = psImageAlloc( IMAGE_X_SIZE*2, IMAGE_Y_SIZE*2, PS_TYPE_U8 );
-            tmpImage = psImageSubset(tmpImage2, (psRegion) {
-                                         IMAGE_X_SIZE/4, IMAGE_Y_SIZE/4,
-                                         IMAGE_X_SIZE/4+IMAGE_X_SIZE, IMAGE_Y_SIZE/4+IMAGE_Y_SIZE
-                                     }
-                                    );
-            tmpMask= psImageSubset(tmpMask2,(psRegion) {
-                                       IMAGE_X_SIZE/4, IMAGE_Y_SIZE/4,
-                                       IMAGE_X_SIZE/4+IMAGE_X_SIZE, IMAGE_Y_SIZE/4+IMAGE_Y_SIZE
-                                   }
-                                  );
+            tmpImage = psImageSubset(tmpImage2, psRegionSet(IMAGE_X_SIZE/4, IMAGE_X_SIZE/4+IMAGE_X_SIZE,
+                                     IMAGE_Y_SIZE/4, IMAGE_Y_SIZE/4+IMAGE_Y_SIZE));
+            tmpMask= psImageSubset(tmpMask2, psRegionSet(IMAGE_X_SIZE/4, IMAGE_X_SIZE/4+IMAGE_X_SIZE,
+                                   IMAGE_Y_SIZE/4, IMAGE_Y_SIZE/4+IMAGE_Y_SIZE));
         }
 
@@ -291,97 +285,101 @@
             tmpImage2 = psImageAlloc( IMAGE_X_SIZE*2, IMAGE_Y_SIZE*2, PS_TYPE_F32 );
             tmpMask2 = psImageAlloc( IMAGE_X_SIZE*2, IMAGE_Y_SIZE*2, PS_TYPE_U8 );
-            tmpImage = psImageSubset(tmpImage2,(psRegion) {
-                                         IMAGE_X_SIZE/4, IMAGE_Y_SIZE/4,
-                                         IMAGE_X_SIZE/4+IMAGE_X_SIZE, IMAGE_Y_SIZE/4+IMAGE_Y_SIZE
-                                     }
-                                    );
-            tmpMask = psImageSubset(tmpMask2,(psRegion) {
-                                        IMAGE_X_SIZE/4, IMAGE_Y_SIZE/4,
-                                        IMAGE_X_SIZE/4+IMAGE_X_SIZE, IMAGE_Y_SIZE/4+IMAGE_Y_SIZE
-                                    }
-                                   );
-        }
-
-        for ( i = 0;i < tmpImage->numRows;i++ ) {
-            for ( j = 0;j < tmpImage->numCols;j++ ) {
-                tmpImage->data.F32[ i ][ j ] = ( float ) ( i + j );
-            }
-        }
-        for ( i = 0;i < tmpMask->numRows;i++ ) {
-            for ( j = 0;j < tmpMask->numCols;j++ ) {
-                if ( ( i > ( tmpMask->numRows / 2 ) ) &&
-                        ( j > ( tmpMask->numCols / 2 ) ) ) {
-                    tmpMask->data.U8[ i ][ j ] = 1;
-                } else {
-                    tmpMask->data.U8[ i ][ j ] = 0;
-                }
-            }
-        }
-
-        myStats = psStatsAlloc( PS_STAT_SAMPLE_MEAN );
-        /*************************************************************************/
-        /*  Calculate Sample Mean with no mask                           */
-        /*************************************************************************/
-        psStats* tmpStats = myStats;
-        myStats = psImageStats( myStats, tmpImage, NULL, 0 );
-        if ( myStats != tmpStats ) {
-            fprintf(stderr,"ERROR: input psStats not equal to return psStats\n");
-            psAbort(__func__,"Failed input psStats equal to returned psStats");
-        }
-        fprintf(stderr, "The sample mean was %.2f\n", myStats->sampleMean );
-
-        /*************************************************************************/
-        /*  Calculate Sample Mean with mask                              */
-        /*************************************************************************/
-
-        myStats = psImageStats( myStats, tmpImage, tmpMask, 1 );
-        fprintf(stderr, "The sample mean was %.2f\n", myStats->sampleMean );
-
-        /*************************************************************************/
-        /*  Deallocate data structures                                   */
-        /*************************************************************************/
-        psFree( myStats );
-        psFree( tmpImage );
-        psFree( tmpMask );
-        psFree( tmpImage2 );
-        psFree( tmpMask2 );
-    }
-
-    /*************************************************************************/
-    /*  Test With Various Null Inputs                                        */
-    /*************************************************************************/
-
-    tmpImage = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_F32 );
-    tmpMask = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_U8 );
-    myStats = psStatsAlloc( 0 );
-
-    myStats2 = psImageStats( myStats, NULL, NULL, 0 );
-    if ( myStats2 != NULL ) {
-        fprintf(stderr, "ERROR: myStats2 = psImageStats(myStats, NULL, NULL, 0) != NULL\n" );
-    }
-
-    myStats2 = psImageStats( NULL, tmpImage, NULL, 0 );
-    if ( myStats2 != NULL ) {
-        fprintf(stderr, "ERROR: myStats2 = psImageStats(NULL, tmpImage, NULL, 0) != NULL\n" );
-    }
-
-    myStats2 = psImageStats( myStats, tmpImage, NULL, 0 );
-
-    psFree( myStats );
-    psFree( tmpImage );
-    psFree( tmpMask );
-
-    tmpImage = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_F32);
-    tmpMask = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_U32);
-    myStats = psStatsAlloc( PS_STAT_SAMPLE_MEAN );
-    myStats2 = psImageStats( myStats, tmpImage, tmpMask, 0 );
-    if ( myStats2 != NULL ) {
-        fprintf(stderr, "ERROR: psImageStats did not return null when mask is invalid type.\n");
-    }
-    psFree(tmpImage);
-    psFree(tmpMask);
-    psFree(myStats);
-
-    return ( !testStatus );
+            tmpImage = psImageSubset(tmpImage2, psRegionSet(IMAGE_X_SIZE/4, IMAGE_X_SIZE/4+IMAGE_X_SIZE,
+                                     IMAGE_Y_SIZE/4, IMAGE_Y_SIZE/4+IMAGE_Y_SIZE
+                                 }
+                                                       );
+        tmpMask = psImageSubset(tmpMask2, psRegionSet(IMAGE_X_SIZE/4, IMAGE_X_SIZE/4+IMAGE_X_SIZE,
+                                IMAGE_Y_SIZE/4, IMAGE_Y_SIZE/4+IMAGE_Y_SIZE
+                            }
+                                                 );
+}
+
+for ( i = 0;i < tmpImage->numRows;i++ )
+{
+    for ( j = 0;j < tmpImage->numCols;j++ ) {
+        tmpImage->data.F32[ i ][ j ] = ( float ) ( i + j );
+    }
+}
+for ( i = 0;i < tmpMask->numRows;i++ )
+{
+    for ( j = 0;j < tmpMask->numCols;j++ ) {
+        if ( ( i > ( tmpMask->numRows / 2 ) ) &&
+                ( j > ( tmpMask->numCols / 2 ) ) ) {
+            tmpMask->data.U8[ i ][ j ] = 1;
+        } else {
+            tmpMask->data.U8[ i ][ j ] = 0;
+        }
+    }
+}
+
+myStats = psStatsAlloc( PS_STAT_SAMPLE_MEAN );
+/*************************************************************************/
+/*  Calculate Sample Mean with no mask                           */
+/*************************************************************************/
+psStats* tmpStats = myStats;
+myStats = psImageStats( myStats, tmpImage, NULL, 0 );
+if ( myStats != tmpStats )
+{
+    fprintf(stderr,"ERROR: input psStats not equal to return psStats\n");
+    psAbort(__func__,"Failed input psStats equal to returned psStats");
+}
+fprintf(stderr, "The sample mean was %.2f\n", myStats->sampleMean );
+
+/*************************************************************************/
+/*  Calculate Sample Mean with mask                              */
+/*************************************************************************/
+
+myStats = psImageStats( myStats, tmpImage, tmpMask, 1 );
+fprintf(stderr, "The sample mean was %.2f\n", myStats->sampleMean );
+
+/*************************************************************************/
+/*  Deallocate data structures                                   */
+/*************************************************************************/
+psFree( myStats );
+psFree( tmpImage );
+psFree( tmpMask );
+psFree( tmpImage2 );
+psFree( tmpMask2 );
+}
+
+/*************************************************************************/
+/*  Test With Various Null Inputs                                        */
+/*************************************************************************/
+
+tmpImage = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_F32 );
+tmpMask = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_U8 );
+myStats = psStatsAlloc( 0 );
+
+myStats2 = psImageStats( myStats, NULL, NULL, 0 );
+if ( myStats2 != NULL ) {
+    fprintf(stderr, "ERROR: myStats2 = psImageStats(myStats, NULL, NULL, 0) != NULL\n" )
+    ;
+}
+
+myStats2 = psImageStats( NULL, tmpImage, NULL, 0 );
+if ( myStats2 != NULL ) {
+    fprintf(stderr, "ERROR: myStats2 = psImageStats(NULL, tmpImage, NULL, 0) != NULL\n" )
+    ;
+}
+
+myStats2 = psImageStats( myStats, tmpImage, NULL, 0 );
+
+psFree( myStats );
+psFree( tmpImage );
+psFree( tmpMask );
+
+tmpImage = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_F32);
+tmpMask = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_U32);
+myStats = psStatsAlloc( PS_STAT_SAMPLE_MEAN );
+myStats2 = psImageStats( myStats, tmpImage, tmpMask, 0 );
+if ( myStats2 != NULL ) {
+    fprintf(stderr, "ERROR: psImageStats did not return null when mask is invalid type.\n")
+    ;
+}
+psFree(tmpImage);
+psFree(tmpMask);
+psFree(myStats);
+
+return ( !testStatus );
 }
 
