Index: /trunk/psLib/src/dataManip/psFFT.c
===================================================================
--- /trunk/psLib/src/dataManip/psFFT.c	(revision 1612)
+++ /trunk/psLib/src/dataManip/psFFT.c	(revision 1613)
@@ -1,14 +1,13 @@
-
 /** @file  psFFT.c
-*
-*  @brief Contains FFT transforms functions
-*
-*  @author Robert DeSonia, MHPCC
-*
-*  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-08-10 18:54:38 $
-*
-*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
-*/
+ *
+ *  @brief Contains FFT transforms functions
+ *
+ *  @author Robert DeSonia, MHPCC
+ *
+ *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-08-25 00:04:01 $
+ *
+ *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ */
 
 #include <unistd.h>
Index: /trunk/psLib/src/dataManip/psVectorFFT.c
===================================================================
--- /trunk/psLib/src/dataManip/psVectorFFT.c	(revision 1612)
+++ /trunk/psLib/src/dataManip/psVectorFFT.c	(revision 1613)
@@ -1,14 +1,13 @@
-
 /** @file  psFFT.c
-*
-*  @brief Contains FFT transforms functions
-*
-*  @author Robert DeSonia, MHPCC
-*
-*  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-08-10 18:54:38 $
-*
-*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
-*/
+ *
+ *  @brief Contains FFT transforms functions
+ *
+ *  @author Robert DeSonia, MHPCC
+ *
+ *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-08-25 00:04:01 $
+ *
+ *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ */
 
 #include <unistd.h>
Index: /trunk/psLib/src/fft/psVectorFFT.c
===================================================================
--- /trunk/psLib/src/fft/psVectorFFT.c	(revision 1612)
+++ /trunk/psLib/src/fft/psVectorFFT.c	(revision 1613)
@@ -1,14 +1,13 @@
-
 /** @file  psFFT.c
-*
-*  @brief Contains FFT transforms functions
-*
-*  @author Robert DeSonia, MHPCC
-*
-*  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-08-10 18:54:38 $
-*
-*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
-*/
+ *
+ *  @brief Contains FFT transforms functions
+ *
+ *  @author Robert DeSonia, MHPCC
+ *
+ *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-08-25 00:04:01 $
+ *
+ *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ */
 
 #include <unistd.h>
Index: /trunk/psLib/src/image/psImageExtraction.c
===================================================================
--- /trunk/psLib/src/image/psImageExtraction.c	(revision 1612)
+++ /trunk/psLib/src/image/psImageExtraction.c	(revision 1613)
@@ -10,6 +10,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-08-23 22:36:03 $
+*  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-08-25 00:04:01 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -93,4 +93,77 @@
 
     return (out);
+}
+
+psImage* psImageSubsection(psImage* image, const char* section)
+{
+    int x1;
+    int x2;
+    int y1;
+    int y2;
+
+    // section should be of the form '[x1:x2,y1:y2]'
+    if (section == NULL) {
+        psError(__func__,"The subsection string input can not be NULL.");
+        return NULL;
+    }
+
+    if (sscanf(section,"[%d:%d,%d:%d]",&x1,&x2,&y1,&y2) < 4) {
+        psError(__func__,"The subsection string (%s) can not be parsed.  "
+                "Needs to be of the form '[x1:x2,y1:y2]'",
+                section);
+        return NULL;
+    }
+    return psImageSubset(image,x2-x1+1,y2-y1+1,x1,y1);
+}
+
+psImage* psImageTrim(psImage* image, int x0, int x1, int y0, int y1)
+{
+    if (image == NULL || image->data.V == NULL) {
+        psError(__func__, "Can not subset image because input image or its "
+                "pixel buffer is NULL.");
+        return NULL;
+    }
+
+    if (image->parent != NULL) {
+        psError(__func__, "Can not perform a trim on a child image.");
+        return NULL;
+    }
+
+    if (x0 < 0 || x1 < 0 || y0 < 0 || y1 < 0 ||
+            x0 >= image->numCols || x1 >= image->numCols ||
+            y0 >= image->numRows || y1 >= image->numRows ||
+            x0 > x1 || y0 > y1 ) {
+        psError(__func__, "Can not subset image because specified region "
+                "[%d:%d,%d:%d] is not valid for image of size %dx%d.",
+                x0,x1,y0,y1,image->numCols,image->numRows);
+        return NULL;
+    }
+
+    psImageFreeChildren(image);
+
+    unsigned int elementSize = PSELEMTYPE_SIZEOF(image->type.type);
+    unsigned int numCols = x1-x0+1;
+    unsigned int numRows = y1-y0+1;
+    unsigned int rowSize = elementSize*numCols;
+    unsigned int colOffset = elementSize * x0;
+    void* imageData = image->rawDataBuffer;
+    for (int row = y0; row < y1; row++) {
+        memmove(imageData,image->data.U8[row] + colOffset,rowSize);
+        imageData = (psU8*)imageData + rowSize;
+    }
+
+    *(unsigned int*)&image->numRows = numRows;
+    *(unsigned int*)&image->numCols = numCols;
+
+    // XXX: should I really resize the buffers?
+    image->data.V = psRealloc(image->data.V,sizeof(void*)*numRows);
+    image->rawDataBuffer = psRealloc(image->rawDataBuffer,rowSize*numRows);
+
+    image->data.V[0] = image->rawDataBuffer;
+    for (int r = 1; r < numRows; r++) {
+        image->data.U8[r] = image->data.U8[r-1] + rowSize;
+    }
+
+    return (image);
 }
 
Index: /trunk/psLib/src/image/psImageExtraction.h
===================================================================
--- /trunk/psLib/src/image/psImageExtraction.h	(revision 1612)
+++ /trunk/psLib/src/image/psImageExtraction.h	(revision 1613)
@@ -10,6 +10,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-08-23 22:36:03 $
+*  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-08-25 00:04:01 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -62,4 +62,24 @@
     psImage* image,                    ///< Parent image.
     const char* section                ///< Subsection in the form '[x1:x2,y1:y2]'
+);
+
+/** Trim an image
+ *
+ *  Trim the specified image in-place, which involves shuffling the pixels 
+ *  around in memory.  The pixels in the region [x0:x1,y0:y1] (inclusive)
+ *  shall consist the output image.
+ *
+ *  N.b., An image that has a parent image will be orphaned from the parent 
+ *  upon trimming.  Any children of the trimmed image will also be obliterated, 
+ *  i.e., freed from memory.
+ *
+ *  @return psImage*  trimmed image result
+ */
+psImage* psImageTrim(
+    psImage* image,                    ///< image to trim
+    int x0,                            ///< column of trim region's left boundary
+    int x1,                            ///< column of trim region's right boundary
+    int y0,                            ///< row of trim region's lower boundary
+    int y1                             ///< row of trim region's upper boundary
 );
 
