Index: /trunk/psLib/src/image/psImageErrors.dat
===================================================================
--- /trunk/psLib/src/image/psImageErrors.dat	(revision 1917)
+++ /trunk/psLib/src/image/psImageErrors.dat	(revision 1918)
@@ -13,5 +13,5 @@
 psImage_IMAGE_TYPE_UNSUPPORTED         Specified psImage type, %s, is not supported.
 psImage_INTERPOLATE_METHOD_INVALID     Specified interpolation method (%d) is not supported.
-psImage_SUBSET_RANGE_INVALID           Specified subset range, [%d:%d,%d:%d], lies outside psImage's boundaries, [0:%d,0:%d].
+psImage_SUBSET_RANGE_INVALID           Specified subset range, [%d:%d,%d:%d], is invalid or outside input psImage's boundaries, [0:%d,0:%d].
 psImage_SUBSECTION_NULL                Specified subsection string can not be NULL.
 psImage_SUBSECTION_INVALID             Specified subsection string, '%s', can not be parsed.  Must be in the form '[x1:x2,y1:y2]'.
Index: /trunk/psLib/src/image/psImageErrors.h
===================================================================
--- /trunk/psLib/src/image/psImageErrors.h	(revision 1917)
+++ /trunk/psLib/src/image/psImageErrors.h	(revision 1918)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-25 02:06:12 $
+ *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-28 02:27:58 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -35,5 +35,5 @@
 #define PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED "Specified psImage type, %s, is not supported."
 #define PS_ERRORTEXT_psImage_INTERPOLATE_METHOD_INVALID "Specified interpolation method (%d) is not supported."
-#define PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID "Specified subset range, [%d:%d,%d:%d], lies outside psImage's boundaries, [0:%d,0:%d]."
+#define PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID "Specified subset range, [%d:%d,%d:%d], is invalid or outside input psImage's boundaries, [0:%d,0:%d]."
 #define PS_ERRORTEXT_psImage_SUBSECTION_NULL "Specified subsection string can not be NULL."
 #define PS_ERRORTEXT_psImage_SUBSECTION_INVALID "Specified subsection string, '%s', can not be parsed.  Must be in the form '[x1:x2,y1:y2]'."
Index: /trunk/psLib/src/image/psImageExtraction.c
===================================================================
--- /trunk/psLib/src/image/psImageExtraction.c	(revision 1917)
+++ /trunk/psLib/src/image/psImageExtraction.c	(revision 1918)
@@ -10,6 +10,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-09-25 02:06:12 $
+*  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-09-28 02:27:58 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -26,8 +26,8 @@
 
 psImage* psImageSubset(psImage* image,
-                       unsigned int numCols,
-                       unsigned int numRows,
-                       unsigned int col0,
-                       unsigned int row0)
+                       int col0,
+                       int row0,
+                       int col1,
+                       int row1)
 {
     psImage* out;
@@ -49,23 +49,26 @@
     }
 
-    if (numCols < 1 || numRows < 1) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSubset",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImage_AREA_NEGATIVE,
-                   numCols,numRows);
-        return NULL;
-    }
-
-    if ( col0 >= image->numCols ||
+    if (col1 < 1) {
+        col1 = image->numCols + col1;
+    }
+    if (row1 < 1) {
+        row1 = image->numRows + row1;
+    }
+
+    if (    col1 <= col0 ||
+            row1 <= row0 ||
+            col0 >= image->numCols ||
             row0 >= image->numRows ||
-            col0 + numCols >= image->numCols ||
-            row0 + numRows >= image->numRows ) {
+            col1 > image->numCols ||
+            row1 > image->numRows ) {
         psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSubset",
                    PS_ERR_BAD_PARAMETER_VALUE, true,
                    PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID,
-                   col0, col0 + numCols, row0, row0 + numRows,
+                   col0, col1, row0, row1,
                    image->numCols, image->numRows);
         return NULL;
     }
+    int numRows = row1-row0;
+    int numCols = col1-row0;
 
     elementSize = PSELEMTYPE_SIZEOF(image->type.type);
@@ -123,5 +126,5 @@
         return NULL;
     }
-    return psImageSubset(image,x2-x1+1,y2-y1+1,x1,y1);
+    return psImageSubset(image,x1,y1,x2,y2);
 }
 
Index: /trunk/psLib/src/image/psImageExtraction.h
===================================================================
--- /trunk/psLib/src/image/psImageExtraction.h	(revision 1917)
+++ /trunk/psLib/src/image/psImageExtraction.h	(revision 1918)
@@ -10,6 +10,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-09-25 02:06:12 $
+*  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-09-28 02:27:58 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -37,16 +37,25 @@
 /** Create a subimage of the specified area.
  *
- * Uses psLib memory allocation functions to create an image based on a larger
- * one.
+ *  Extracts a subimage starting at (col0,row0) to (col1-1,row1-1).  Note: 
+ *  the column col1 and row row1 are NOT included in the resulting subimage.
+ *  In the event that x1 or y1 are non-positive, they shall be interpreted as
+ *  being relative to the size of the parent image in that dimension.
  *
- * @return psImage* : Pointer to psImage.
+ *  If the entire specified subimage is not contained within the parent 
+ *  image, an error results and the return value will be NULL.
+ *
+ *  The resulting psImage does not create a copy of the underlying image 
+ *  data.  Future changes in the parent may be reflecting in the child
+ *  subimage and vis versa.
+ *
+ *  @return psImage* : Pointer to psImage.
  *
  */
 psImage* psImageSubset(
     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).
+    int col0,                          ///< starting column of subimage
+    int row0,                          ///< starting row of subimage
+    int col1,                          ///< exclusive end column of subimage.
+    int row1                           ///< exclusive end row of subimage
 );
 
