Index: /branches/rel10_ifa/psLib/src/imageops/psImageStats.c
===================================================================
--- /branches/rel10_ifa/psLib/src/imageops/psImageStats.c	(revision 6429)
+++ /branches/rel10_ifa/psLib/src/imageops/psImageStats.c	(revision 6430)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.90 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-02-07 23:14:21 $
+ *  @version $Revision: 1.90.4.1 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-02-16 07:50:03 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -649,8 +649,8 @@
     }
 
-    x0 = (int)(roundf(region.x0));
-    x1 = (int)(roundf(region.x1));
-    y0 = (int)(roundf(region.y0));
-    y1 = (int)(roundf(region.y1));
+    x0 = (int)(roundf(region.x0)) - mask->col0;
+    x1 = (int)(roundf(region.x1)) - mask->col0;
+    y0 = (int)(roundf(region.y0)) - mask->row0;
+    y1 = (int)(roundf(region.y1)) - mask->row0;
 
     type = mask->type.type;
Index: /branches/rel10_ifa/psLib/src/imageops/psImageStructManip.c
===================================================================
--- /branches/rel10_ifa/psLib/src/imageops/psImageStructManip.c	(revision 6429)
+++ /branches/rel10_ifa/psLib/src/imageops/psImageStructManip.c	(revision 6430)
@@ -8,6 +8,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-12-05 21:05:20 $
+ *  @version $Revision: 1.7.10.1 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-02-16 07:50:03 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -33,5 +33,5 @@
     psS32 inputColOffset;       // offset in bytes to first subset pixel in input row
 
-    if ( col0 < 0 || row0 < 0 ) {
+    if ( col0 < image->col0 || row0 < image->row0 ) {
         //        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
         //                PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID);
@@ -56,16 +56,16 @@
 
     if (col1 < 1) {
-        col1 = image->numCols + col1;
+        col1 = image->col0 + image->numCols + col1;
     }
     if (row1 < 1) {
-        row1 = image->numRows + row1;
+        row1 = image->row0 + image->numRows + row1;
     }
 
     if (    col1 <= col0 ||
             row1 <= row0 ||
-            col0 >= image->numCols ||
-            row0 >= image->numRows ||
-            col1 > image->numCols ||
-            row1 > image->numRows ) {
+            col0 >= image->col0 + image->numCols ||
+            row0 >= image->row0 + image->numRows ||
+            col1 > image->col0 + image->numCols ||
+            row1 > image->row0 + image->numRows ) {
         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
                 PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID,
@@ -83,8 +83,9 @@
 
     if (image->parent != NULL) { // if this is a child, we need to start working with parent.
-        col0 += image->col0;
-        col1 += image->col0;
-        row0 += image->row0;
-        row1 += image->row0;
+        // XXX EAM : we now treat the region as parent coordinates
+        // col0 += image->col0;
+        // col1 += image->col0;
+        // row0 += image->row0;
+        // row1 += image->row0;
         image = (psImage*)image->parent;
     }
Index: /branches/rel10_ifa/psLib/src/mathtypes/psImage.c
===================================================================
--- /branches/rel10_ifa/psLib/src/mathtypes/psImage.c	(revision 6429)
+++ /branches/rel10_ifa/psLib/src/mathtypes/psImage.c	(revision 6430)
@@ -9,6 +9,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.95 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-02-06 22:19:28 $
+ *  @version $Revision: 1.95.4.1 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-02-16 07:50:16 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -178,16 +178,18 @@
 
     // convert non-positive upper-limits
-    in.x1 = (in.x1 <= 0) ? (image->numCols + in.x1) : in.x1;
-    in.y1 = (in.y1 <= 0) ? (image->numRows + in.y1) : in.y1;
+    // XXX note that the upper limit in these cases is defined relative to the subimage
+    // also note that truncation limits to the valid subimage pixels
+    in.x1 = (in.x1 <= 0) ? (image->col0 + image->numCols + in.x1) : in.x1;
+    in.y1 = (in.y1 <= 0) ? (image->row0 + image->numRows + in.y1) : in.y1;
 
     // force the upper-limits to be on the image
-    in.x1 = PS_MIN(image->numCols, in.x1);
-    in.y1 = PS_MIN(image->numRows, in.y1);
+    in.x1 = PS_MIN(image->col0 + image->numCols, in.x1);
+    in.y1 = PS_MIN(image->row0 + image->numRows, in.y1);
 
     // force the lower-limits to be on the image
-    in.x0 = PS_MAX(0, in.x0);
-    in.y0 = PS_MAX(0, in.y0);
-    in.x0 = PS_MIN(image->numCols, in.x0);
-    in.y0 = PS_MIN(image->numRows, in.y0);
+    in.x0 = PS_MAX(image->col0, in.x0);
+    in.y0 = PS_MAX(image->row0, in.y0);
+    in.x0 = PS_MIN(image->col0 + image->numCols, in.x0);
+    in.y0 = PS_MIN(image->row0 + image->numRows, in.y0);
 
     // flip start and end if out of order
