Index: /trunk/psLib/src/image/psImageExtraction.c
===================================================================
--- /trunk/psLib/src/image/psImageExtraction.c	(revision 3308)
+++ /trunk/psLib/src/image/psImageExtraction.c	(revision 3309)
@@ -9,6 +9,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-02-17 19:26:24 $
+ *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-02-23 21:32:40 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -394,16 +394,16 @@
 
         switch (type) {
-            //            PSIMAGE_CUT_VERTICAL(U8);         Not a requirement
+            PSIMAGE_CUT_VERTICAL(U8);  // Not a requirement
             PSIMAGE_CUT_VERTICAL(U16);
-            //            PSIMAGE_CUT_VERTICAL(U32);        Not a requirement
-            //            PSIMAGE_CUT_VERTICAL(U64);        Not a requirement
+            PSIMAGE_CUT_VERTICAL(U32); // Not a requirement
+            PSIMAGE_CUT_VERTICAL(U64); // Not a requirement
             PSIMAGE_CUT_VERTICAL(S8);
-            //            PSIMAGE_CUT_VERTICAL(S16);        Not a requirement
-            //            PSIMAGE_CUT_VERTICAL(S32);        Not a requirement
-            //            PSIMAGE_CUT_VERTICAL(S64);        Not a requirement
+            PSIMAGE_CUT_VERTICAL(S16); // Not a requirement
+            PSIMAGE_CUT_VERTICAL(S32); // Not a requirement
+            PSIMAGE_CUT_VERTICAL(S64); // Not a requirement
             PSIMAGE_CUT_VERTICAL(F32);
             PSIMAGE_CUT_VERTICAL(F64);
-            //            PSIMAGE_CUT_VERTICAL(C32);        Not a requirement
-            //            PSIMAGE_CUT_VERTICAL(C64);        Not a requirement
+            PSIMAGE_CUT_VERTICAL(C32); // Not a requirement
+            PSIMAGE_CUT_VERTICAL(C64); // Not a requirement
         default: {
                 char* typeStr;
Index: /trunk/psLib/src/image/psImageStats.c
===================================================================
--- /trunk/psLib/src/image/psImageStats.c	(revision 3308)
+++ /trunk/psLib/src/image/psImageStats.c	(revision 3309)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.67 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-02-22 20:06:24 $
+ *  @version $Revision: 1.68 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-02-23 21:32:40 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -130,17 +130,50 @@
     psVector* junkMask = NULL;
 
-    junkData = psAlloc(sizeof(psVector));
-    junkData->type = in->type;
-    junkData->nalloc = in->numRows * in->numCols;
-    junkData->n = junkData->nalloc;
-    junkData->data.V = in->data.V[0];  // since psImage data is contiguous...
+    if (in->parent == NULL) {
+        // stuff the image data into a psVector struct.
+        junkData = (psVector *) psAlloc(sizeof(psVector));
+        junkData->type = in->type;
+        junkData->nalloc = in->numRows * in->numCols;
+        junkData->n = junkData->nalloc;
+        junkData->data.V = in->data.V[0];      // since psImage data is contiguous...
+    } else {
+        // image not necessarily contiguous
+        int numRows = in->numRows;
+        int numCols = in->numCols;
+        int rowSize = numCols * (PSELEMTYPE_SIZEOF(in->type.type));
+
+        junkData = psVectorAlloc(numRows*numCols, in->type.type);
+        junkData->n = junkData->nalloc;
+
+        psU8* data = junkData->data.V;
+        for (int row = 0; row < numRows; row++) {
+            memcpy(data, in->data.V[row], rowSize);
+            data += rowSize;
+        }
+    }
 
     if (mask != NULL) {
-        // stuff the mask data into a psVector struct.
-        junkMask = psAlloc(sizeof(psVector));
-        junkMask->type = mask->type;
-        junkMask->nalloc = mask->numRows * mask->numCols;
-        junkMask->n = junkMask->nalloc;
-        junkMask->data.V = mask->data.V[0];
+        if (mask->parent == NULL) {
+            // stuff the mask data into a psVector struct.
+            junkMask = psAlloc(sizeof(psVector));
+            junkMask->type = mask->type;
+            junkMask->nalloc = mask->numRows * mask->numCols;
+            junkMask->n = junkMask->nalloc;
+            junkMask->data.V = mask->data.V[0];
+        } else {
+            // image not necessarily contiguous
+            int numRows = mask->numRows;
+            int numCols = mask->numCols;
+            int rowSize = numCols * (PSELEMTYPE_SIZEOF(mask->type.type));
+
+            junkMask = psVectorAlloc(numRows*numCols, mask->type.type);
+            junkMask->n = junkMask->nalloc;
+
+            psU8* data = junkMask->data.V;
+            for (int row = 0; row < numRows; row++) {
+                memcpy(data, mask->data.V[row], rowSize);
+                data += rowSize;
+            }
+        }
     }
 
Index: /trunk/psLib/src/imageops/psImageStats.c
===================================================================
--- /trunk/psLib/src/imageops/psImageStats.c	(revision 3308)
+++ /trunk/psLib/src/imageops/psImageStats.c	(revision 3309)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.67 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-02-22 20:06:24 $
+ *  @version $Revision: 1.68 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-02-23 21:32:40 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -130,17 +130,50 @@
     psVector* junkMask = NULL;
 
-    junkData = psAlloc(sizeof(psVector));
-    junkData->type = in->type;
-    junkData->nalloc = in->numRows * in->numCols;
-    junkData->n = junkData->nalloc;
-    junkData->data.V = in->data.V[0];  // since psImage data is contiguous...
+    if (in->parent == NULL) {
+        // stuff the image data into a psVector struct.
+        junkData = (psVector *) psAlloc(sizeof(psVector));
+        junkData->type = in->type;
+        junkData->nalloc = in->numRows * in->numCols;
+        junkData->n = junkData->nalloc;
+        junkData->data.V = in->data.V[0];      // since psImage data is contiguous...
+    } else {
+        // image not necessarily contiguous
+        int numRows = in->numRows;
+        int numCols = in->numCols;
+        int rowSize = numCols * (PSELEMTYPE_SIZEOF(in->type.type));
+
+        junkData = psVectorAlloc(numRows*numCols, in->type.type);
+        junkData->n = junkData->nalloc;
+
+        psU8* data = junkData->data.V;
+        for (int row = 0; row < numRows; row++) {
+            memcpy(data, in->data.V[row], rowSize);
+            data += rowSize;
+        }
+    }
 
     if (mask != NULL) {
-        // stuff the mask data into a psVector struct.
-        junkMask = psAlloc(sizeof(psVector));
-        junkMask->type = mask->type;
-        junkMask->nalloc = mask->numRows * mask->numCols;
-        junkMask->n = junkMask->nalloc;
-        junkMask->data.V = mask->data.V[0];
+        if (mask->parent == NULL) {
+            // stuff the mask data into a psVector struct.
+            junkMask = psAlloc(sizeof(psVector));
+            junkMask->type = mask->type;
+            junkMask->nalloc = mask->numRows * mask->numCols;
+            junkMask->n = junkMask->nalloc;
+            junkMask->data.V = mask->data.V[0];
+        } else {
+            // image not necessarily contiguous
+            int numRows = mask->numRows;
+            int numCols = mask->numCols;
+            int rowSize = numCols * (PSELEMTYPE_SIZEOF(mask->type.type));
+
+            junkMask = psVectorAlloc(numRows*numCols, mask->type.type);
+            junkMask->n = junkMask->nalloc;
+
+            psU8* data = junkMask->data.V;
+            for (int row = 0; row < numRows; row++) {
+                memcpy(data, mask->data.V[row], rowSize);
+                data += rowSize;
+            }
+        }
     }
 
