Index: /trunk/psLib/src/image/psImage.c
===================================================================
--- /trunk/psLib/src/image/psImage.c	(revision 819)
+++ /trunk/psLib/src/image/psImage.c	(revision 820)
@@ -9,6 +9,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-29 01:42:12 $
+ *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-01 20:00:08 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -18,5 +18,7 @@
 /*  INCLUDE FILES                                                             */
 /******************************************************************************/
+
 #include <string.h>
+#include <math.h>
 
 #include "psMemory.h"
@@ -384,2 +386,94 @@
 }
 
+int psImageClip(psImage* input,float min,float vmin,float max,float vmax)
+{
+    int numClipped = 0;
+    psU32 numRows;
+    psU32 numCols;
+
+    if (input == NULL) {
+        return 0;
+    }
+    numRows = input->numRows;
+    numCols = input->numCols;
+
+    switch (input->type.type) {
+
+        #define psImageClipCase(type) \
+    case PS_TYPE_##type: { \
+            ps##type minimum = (ps##type) min; \
+            ps##type maximum = (ps##type) max; \
+            for (psU32 row = 0;row<numRows;row++) { \
+                ps##type* inputRow = input->data.type[row]; \
+                for (psU32 col = 0; col < numCols; col++) { \
+                    if (inputRow[col] < minimum) { \
+                        inputRow[col] = (ps##type)vmin; \
+                        numClipped++; \
+                    } else if (inputRow[col] > maximum) { \
+                        inputRow[col] = (ps##type)vmax; \
+                        numClipped++; \
+                    } \
+                } \
+            } \
+        } \
+        break;
+
+        psImageClipCase(S8)
+        psImageClipCase(S16)
+        psImageClipCase(S32)
+        psImageClipCase(S64)
+        psImageClipCase(U8)
+        psImageClipCase(U16)
+        psImageClipCase(U32)
+        psImageClipCase(U64)
+        psImageClipCase(F32)
+        psImageClipCase(F64)
+
+    default:
+        psError(__func__,"psImageClip does not support the given datatype (%d)",
+                input->type.type);
+    }
+
+    return numClipped;
+}
+
+int psImageClipNaN(psImage* input,float value)
+{
+    int numClipped = 0;
+    psU32 numRows;
+    psU32 numCols;
+
+    if (input == NULL) {
+        return 0;
+    }
+    numRows = input->numRows;
+    numCols = input->numCols;
+
+    switch (input->type.type) {
+
+        #define psImageClipNaNCase(type) \
+    case PS_TYPE_##type: { \
+            for (psU32 row = 0;row<numRows;row++) { \
+                ps##type* inputRow = input->data.type[row]; \
+                for (psU32 col = 0; col < numCols; col++) { \
+                    if (! isfinite(inputRow[col])) { \
+                        inputRow[col] = (ps##type)value; \
+                        numClipped++; \
+                    } \
+                } \
+            } \
+        } \
+        break;
+
+        psImageClipNaNCase(F32)
+        psImageClipNaNCase(F64)
+        psImageClipNaNCase(C32)
+        psImageClipNaNCase(C64)
+
+    default:
+        psError(__func__,"psImageClip does not support the given datatype (%d)",
+                input->type.type);
+    }
+
+    return numClipped;
+}
Index: /trunk/psLib/src/image/psImage.h
===================================================================
--- /trunk/psLib/src/image/psImage.h	(revision 819)
+++ /trunk/psLib/src/image/psImage.h	(revision 820)
@@ -9,6 +9,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-29 01:42:12 $
+ *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-01 20:00:08 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -88,5 +88,5 @@
 /** Resize a given image to the given size/type.
  *
- *  return psImage* Resized psImage.
+ *  @return psImage* Resized psImage.
  *
  */
@@ -127,5 +127,5 @@
 /** Frees all children of a psImage.
  *
- *  return int      Number of children freed.
+ *  @return int      Number of children freed.
  *
  */
@@ -137,5 +137,5 @@
 /** Makes a copy of a psImage
  *
- * return psImage*  Copy of the input psImage.  This may not be equal to the
+ * @return psImage*  Copy of the input psImage.  This may not be equal to the
  * output parameter
  *
@@ -152,4 +152,50 @@
 );
 
+/** Clip image values outside of tange to given values
+ *
+ *  All pixels with values less than min are set to the value vmin.  all pixels
+ *  with values greater than max are set to the value vmax. This function is
+ *  defined for psU8, psU16, psS8, psS16, psF32, psF64, psC32, and psC64.
+ *
+ *  @return int     The number of clipped pixels
+ */
+int psImageClip(
+    psImage* input,                 ///< the image to clip
+    psF32 min,                      ///< the minimum image value allowed
+    psF32 vmin,                     ///< the value pixels < min are set to
+    psF32 max,                      ///< the maximum image value allowed
+    psF32 vmax                      ///< the value pixels > max are set to
+);
+
+/** Clip NaN image pixels to given value.
+ *
+ *  Pixels with NaN, +Inf, or -Inf values are set to the specified value. This
+ *  function is defined for psF32, psF64, psC32, and psC64.
+ *
+ *  @return int     The number of clipped pixels
+ */
+int psImageClipNaN(
+    psImage* input,                 ///< the image to clip
+    psF32 value                     ///< the value to set all NaN/Inf values to
+);
+
+/** Overlay subregion of image with another image
+ *
+ *  Replace the pixels in the image which correspond to the pixels in OVERLAY
+ *  with values derived from the IMAGE and OVERLAY based on the given operator
+ *  OP.  Valid operators are "=" (set image value to OVERLAY value), "+" (add
+ *  OVERLAY value to image value), "-" (subtract OVERLAY from image), "*"
+ *  (multiply OVERLAY times image), "/" (divide image by OVERLAY).  This
+ *  function is defined for psU8, psS8, psS16, psF32, psF64, psC32, and psC64.
+ *
+ *  @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
+);
 
 #endif
Index: /trunk/psLib/src/mathtypes/psImage.c
===================================================================
--- /trunk/psLib/src/mathtypes/psImage.c	(revision 819)
+++ /trunk/psLib/src/mathtypes/psImage.c	(revision 820)
@@ -9,6 +9,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-29 01:42:12 $
+ *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-01 20:00:08 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -18,5 +18,7 @@
 /*  INCLUDE FILES                                                             */
 /******************************************************************************/
+
 #include <string.h>
+#include <math.h>
 
 #include "psMemory.h"
@@ -384,2 +386,94 @@
 }
 
+int psImageClip(psImage* input,float min,float vmin,float max,float vmax)
+{
+    int numClipped = 0;
+    psU32 numRows;
+    psU32 numCols;
+
+    if (input == NULL) {
+        return 0;
+    }
+    numRows = input->numRows;
+    numCols = input->numCols;
+
+    switch (input->type.type) {
+
+        #define psImageClipCase(type) \
+    case PS_TYPE_##type: { \
+            ps##type minimum = (ps##type) min; \
+            ps##type maximum = (ps##type) max; \
+            for (psU32 row = 0;row<numRows;row++) { \
+                ps##type* inputRow = input->data.type[row]; \
+                for (psU32 col = 0; col < numCols; col++) { \
+                    if (inputRow[col] < minimum) { \
+                        inputRow[col] = (ps##type)vmin; \
+                        numClipped++; \
+                    } else if (inputRow[col] > maximum) { \
+                        inputRow[col] = (ps##type)vmax; \
+                        numClipped++; \
+                    } \
+                } \
+            } \
+        } \
+        break;
+
+        psImageClipCase(S8)
+        psImageClipCase(S16)
+        psImageClipCase(S32)
+        psImageClipCase(S64)
+        psImageClipCase(U8)
+        psImageClipCase(U16)
+        psImageClipCase(U32)
+        psImageClipCase(U64)
+        psImageClipCase(F32)
+        psImageClipCase(F64)
+
+    default:
+        psError(__func__,"psImageClip does not support the given datatype (%d)",
+                input->type.type);
+    }
+
+    return numClipped;
+}
+
+int psImageClipNaN(psImage* input,float value)
+{
+    int numClipped = 0;
+    psU32 numRows;
+    psU32 numCols;
+
+    if (input == NULL) {
+        return 0;
+    }
+    numRows = input->numRows;
+    numCols = input->numCols;
+
+    switch (input->type.type) {
+
+        #define psImageClipNaNCase(type) \
+    case PS_TYPE_##type: { \
+            for (psU32 row = 0;row<numRows;row++) { \
+                ps##type* inputRow = input->data.type[row]; \
+                for (psU32 col = 0; col < numCols; col++) { \
+                    if (! isfinite(inputRow[col])) { \
+                        inputRow[col] = (ps##type)value; \
+                        numClipped++; \
+                    } \
+                } \
+            } \
+        } \
+        break;
+
+        psImageClipNaNCase(F32)
+        psImageClipNaNCase(F64)
+        psImageClipNaNCase(C32)
+        psImageClipNaNCase(C64)
+
+    default:
+        psError(__func__,"psImageClip does not support the given datatype (%d)",
+                input->type.type);
+    }
+
+    return numClipped;
+}
Index: /trunk/psLib/src/mathtypes/psImage.h
===================================================================
--- /trunk/psLib/src/mathtypes/psImage.h	(revision 819)
+++ /trunk/psLib/src/mathtypes/psImage.h	(revision 820)
@@ -9,6 +9,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-29 01:42:12 $
+ *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-01 20:00:08 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -88,5 +88,5 @@
 /** Resize a given image to the given size/type.
  *
- *  return psImage* Resized psImage.
+ *  @return psImage* Resized psImage.
  *
  */
@@ -127,5 +127,5 @@
 /** Frees all children of a psImage.
  *
- *  return int      Number of children freed.
+ *  @return int      Number of children freed.
  *
  */
@@ -137,5 +137,5 @@
 /** Makes a copy of a psImage
  *
- * return psImage*  Copy of the input psImage.  This may not be equal to the
+ * @return psImage*  Copy of the input psImage.  This may not be equal to the
  * output parameter
  *
@@ -152,4 +152,50 @@
 );
 
+/** Clip image values outside of tange to given values
+ *
+ *  All pixels with values less than min are set to the value vmin.  all pixels
+ *  with values greater than max are set to the value vmax. This function is
+ *  defined for psU8, psU16, psS8, psS16, psF32, psF64, psC32, and psC64.
+ *
+ *  @return int     The number of clipped pixels
+ */
+int psImageClip(
+    psImage* input,                 ///< the image to clip
+    psF32 min,                      ///< the minimum image value allowed
+    psF32 vmin,                     ///< the value pixels < min are set to
+    psF32 max,                      ///< the maximum image value allowed
+    psF32 vmax                      ///< the value pixels > max are set to
+);
+
+/** Clip NaN image pixels to given value.
+ *
+ *  Pixels with NaN, +Inf, or -Inf values are set to the specified value. This
+ *  function is defined for psF32, psF64, psC32, and psC64.
+ *
+ *  @return int     The number of clipped pixels
+ */
+int psImageClipNaN(
+    psImage* input,                 ///< the image to clip
+    psF32 value                     ///< the value to set all NaN/Inf values to
+);
+
+/** Overlay subregion of image with another image
+ *
+ *  Replace the pixels in the image which correspond to the pixels in OVERLAY
+ *  with values derived from the IMAGE and OVERLAY based on the given operator
+ *  OP.  Valid operators are "=" (set image value to OVERLAY value), "+" (add
+ *  OVERLAY value to image value), "-" (subtract OVERLAY from image), "*"
+ *  (multiply OVERLAY times image), "/" (divide image by OVERLAY).  This
+ *  function is defined for psU8, psS8, psS16, psF32, psF64, psC32, and psC64.
+ *
+ *  @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
+);
 
 #endif
