Index: /branches/eam_rel9_p0/psModules/src/detrend/pmFlatField.c
===================================================================
--- /branches/eam_rel9_p0/psModules/src/detrend/pmFlatField.c	(revision 6075)
+++ /branches/eam_rel9_p0/psModules/src/detrend/pmFlatField.c	(revision 6076)
@@ -24,6 +24,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.4.8.1.2.1 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-01-20 02:38:28 $
+ *  @version $Revision: 1.4.8.1.2.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-01-20 06:01:02 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -67,6 +67,12 @@
     }
 
-    inImage = in->image;
-    flatImage = flat->image;
+    // Get the TRIMSEC of each image
+    {
+        psRegion *trimsec = psMetadataLookupPtr(NULL, in->parent->concepts, "CELL.TRIMSEC");
+        inImage = psImageSubset(in->image, *trimsec);
+        trimsec = psMetadataLookupPtr(NULL, flat->parent->concepts, "CELL.TRIMSEC");
+        flatImage = psImageSubset(flat->image, *trimsec);
+    }
+
     if (inImage == NULL) {
         psError( PS_ERR_BAD_PARAMETER_NULL, true,
