Index: /trunk/psLib/src/imageops/psImageGeomManip.c
===================================================================
--- /trunk/psLib/src/imageops/psImageGeomManip.c	(revision 6777)
+++ /trunk/psLib/src/imageops/psImageGeomManip.c	(revision 6778)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-04-01 02:43:57 $
+ *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-04-05 01:49:40 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
Index: /trunk/psLib/src/imageops/psImagePixelExtract.c
===================================================================
--- /trunk/psLib/src/imageops/psImagePixelExtract.c	(revision 6777)
+++ /trunk/psLib/src/imageops/psImagePixelExtract.c	(revision 6778)
@@ -8,6 +8,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-04-04 22:04:45 $
+ *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-04-05 01:49:40 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -333,27 +333,5 @@
         return NULL;
     }
-    /*
-        if (col1 < 1) {
-            col1 += input->numCols;
-        }
-
-        if (row1 < 1) {
-            row1 += input->numRows;
-        }
-
-        if (    col0 < 0 ||
-                row0 < 0 ||
-                col1 > input->numCols ||
-                row1 > input->numRows ||
-                col0 >= col1 ||
-                row0 >= row1) {
-            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
-                    PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID,
-                    col0, col1, row0, row1,
-                    input->numCols, input->numRows);
-            psFree(out);
-            return NULL;
-        }
-    */
+
     //Make sure x0 of region is inside image.  If so, set col0 to corresponding index number.
     if (col0 >= input->col0 && col0 < (input->col0 + input->numCols) ) {
@@ -709,64 +687,4 @@
         return NULL;
     }
-    /*
-        //Make sure x1 of region is valid.  If negative, index from tail (if valid).
-        if (col1 < 0) {
-            col1 += input->numCols;
-            if (col1 < 0) {
-                psError(PS_ERR_BAD_PARAMETER_VALUE, true,
-                        "Specified psRegion parameter, x1=%f=%f, is out of range [%d,%d].\n",
-                        region.x1, col1+input->col0, input->col0, input->col0+input->numCols);
-                psFree(out);
-                return NULL;
-            }
-        } else if (col1 >= input->col0 && col1 < (input->col0 + input->numCols) ) {
-            col1 -= input->col0;
-        } else {
-            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
-                    "Specified psRegion parameter, x1=%f=%f, is out of range [%d,%d].\n",
-                    region.x1, col1, input->col0, input->col0+input->numCols);
-            psFree(out);
-            return NULL;
-        }
-        //Make sure y1 of region is valid.  If negative, index from tail (if valid).
-        if (row1 < 0) {
-            row1 += input->numRows;
-            if (row1 < 0) {
-                psError(PS_ERR_BAD_PARAMETER_VALUE, true,
-                        "Specified psRegion parameter, y1=%f=%f, is out of range [%d,%d].\n",
-                        region.y1, row1+input->row0, input->row0, input->row0+input->numRows);
-                psFree(out);
-                return NULL;
-            }
-        } else if (row1 >= input->row0 && row1 < (input->row0 + input->numRows) ) {
-            row1 -= input->row0;
-        } else {
-            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
-                    "Specified psRegion parameter, y1=%f=%f, is out of range [%d,%d].\n",
-                    region.y1, row1, input->row0, input->row0+input->numRows);
-            psFree(out);
-            return NULL;
-        }
-    */
-    /*    //Now make sure that the region makes sense.
-        if (col0 > col1 || row0 > row1) {
-            if (col0 > col1) {
-                psError(PS_ERR_BAD_PARAMETER_VALUE, true,
-                        "Invalid psRegion specified.  x0=%f=%f is greater than x1=%f=%f.\n",
-                        region.x0, col0, region.x1, col1);
-            } else {
-                psError(PS_ERR_BAD_PARAMETER_VALUE, true,
-                        "Invalid psRegion specified.  y0=%f=%f is greater than y1=%f=%f.\n",
-                        region.y0, row0, region.y1, row1);
-            }
-            psFree(out);
-            return NULL;
-        } else if (col0 == col1 && row0 == row1) {
-            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
-                    "Invalid psRegion specified.  Region contains only 1 pixel.\n");
-            psFree(out);
-            return NULL;
-        }
-    */
     if (col1 < 0 || row1 < 0 || col0 < 0 || row0 < 0 || col0 >= numCols || col1 >= numCols ||
             row0 >= numRows || row1 >= numRows) {
@@ -778,21 +696,4 @@
     float endCol = col1;
     float endRow = row1;
-    /*
-        float startCol = region.x0;
-        float startRow = region.y0;
-        float endCol = region.x1;
-        float endRow = region.y1;
-        if (startCol < 0 || startCol >= numCols ||
-                startRow < 0 || startRow >= numRows ||
-                endCol < 0 || endCol >= numCols ||
-                endRow < 0 || endRow >= numRows) {
-            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
-                    PS_ERRORTEXT_psImage_LINE_NOT_IN_IMAGE,
-                    startCol,startRow,endCol,endRow,
-                    numCols-1,numRows-1);
-            psFree(out);
-            return NULL;
-        }
-    */
 
     if (mode < PS_INTERPOLATE_FLAT ) {
Index: /trunk/psLib/src/imageops/psImageStats.c
===================================================================
--- /trunk/psLib/src/imageops/psImageStats.c	(revision 6777)
+++ /trunk/psLib/src/imageops/psImageStats.c	(revision 6778)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.91 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-04-01 02:43:57 $
+ *  @version $Revision: 1.92 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-04-05 01:49:40 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -657,5 +657,5 @@
         }
         region = psRegionForImage(mask, region);
-     
+
         if (region.x0 == region.x1 || region.y0 == region.y1) {
             psError(PS_ERR_BAD_PARAMETER_SIZE, true,
@@ -670,9 +670,4 @@
     PS_ASSERT_INT_POSITIVE(mask->numRows, -1);
 
-    /*    x0 = (int)(roundf(region.x0));
-        x1 = (int)(roundf(region.x1));
-        y0 = (int)(roundf(region.y0));
-        y1 = (int)(roundf(region.y1));
-    */
     int col0 = (int)(roundf(region.x0));
     int col1 = (int)(roundf(region.x1));
@@ -753,9 +748,9 @@
         return -1;
     }/* else if (col0 == col1 && row0 == row1) {
-            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
-                    "Invalid psRegion specified.  Region contains only 1 pixel.\n");
-            return -1;
-        }
-    */
+                psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                        "Invalid psRegion specified.  Region contains only 1 pixel.\n");
+                return -1;
+            }
+        */
     x0 = col0;
     x1 = col1;
Index: /trunk/psLib/src/mathtypes/psImage.c
===================================================================
--- /trunk/psLib/src/mathtypes/psImage.c	(revision 6777)
+++ /trunk/psLib/src/mathtypes/psImage.c	(revision 6778)
@@ -9,6 +9,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.100 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-04-01 02:43:57 $
+ *  @version $Revision: 1.101 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-04-05 01:49:41 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -703,5 +703,7 @@
 }
 
-bool p_psImagePrint (int fd, psImage *a, char *name)
+bool p_psImagePrint (int fd,
+                     psImage *a,
+                     char *name)
 {
     write(fd,"matrix: ",8);
@@ -730,15 +732,18 @@
 {
 
-    /*    if (input == NULL) {
-            psError(PS_ERR_BAD_PARAMETER_NULL,true,
-                    PS_ERRORTEXT_psImage_IMAGE_NULL);
+    PS_ASSERT_IMAGE_NON_NULL(input, unexposedValue);
+    /*    if ( x < input->col0 || x >= (input->col0 + input->numCols) ) {
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                "x-input in psImagePixelInterpolate is outside of image region.\n");
             return unexposedValue;
         }
+        if ( y < input->row0 || y >= (input->row0 + input->numRows) ) {
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                "y-input in psImagePixelInterpolate is outside of image region.\n");
+            return unexposedValue;
+        }
+        x -= input->col0;
+        y -= input->row0;
     */
-    PS_ASSERT_IMAGE_NON_NULL(input, unexposedValue);
-    if (input->row0 != 0 || input->col0 != 0) {
-        x += input->col0;
-        y += input->row0;
-    }
 
     #define PSIMAGE_PIXEL_INTERPOLATE_CASE(TYPE)                             \
Index: /trunk/psLib/test/imageops/tst_psImagePixelExtract.c
===================================================================
--- /trunk/psLib/test/imageops/tst_psImagePixelExtract.c	(revision 6777)
+++ /trunk/psLib/test/imageops/tst_psImagePixelExtract.c	(revision 6778)
@@ -6,6 +6,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-04-04 22:04:46 $
+*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-04-05 01:49:41 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -100,5 +100,8 @@
         } \
     } \
-    out = psImageSlice(out,positions,image,mask,1,psRegionSet(c/10,c/10+M,r/10,r/10+N),DIRECTION,stat); \
+    image->col0 = 1; \
+    image->row0 = 1; \
+    out = psImageSlice(out,positions,image,mask,1, \
+                       psRegionSet(1+c/10,1+c/10+M,1+r/10,1+r/10+N),DIRECTION,stat); \
     \
     if (out->n != TRUTH_SIZE) { \
Index: /trunk/psLib/test/imageops/tst_psImageStats.c
===================================================================
--- /trunk/psLib/test/imageops/tst_psImageStats.c	(revision 6777)
+++ /trunk/psLib/test/imageops/tst_psImageStats.c	(revision 6778)
@@ -634,4 +634,16 @@
     }
 
+    //Test a subimage.
+    reg.y0 = 1;
+    reg.y1 = 5;
+    numPix2 = -1;
+    in2->row0 = 1;
+    numPix2 = psImageCountPixelMask(in2, reg, 1);
+    if (numPix2 != 2) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                "psImageCountPixelMask returned incorrect pixel count %ld (!=2)\n", numPix2);
+        return 11;
+    }
+
     psFree(in);
     psFree(in2);
