Index: trunk/archive/scripts/src/phase2/pmFlatField.c
===================================================================
--- trunk/archive/scripts/src/phase2/pmFlatField.c	(revision 5107)
+++ trunk/archive/scripts/src/phase2/pmFlatField.c	(revision 5462)
@@ -18,15 +18,19 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-23 02:58:30 $
+ *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-11-03 01:30:32 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
 
-#include <stdio.h>
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include<stdio.h>
+#include<math.h>
 #include <string.h>
+
 #include "pslib.h"
-
-#include "pmFPA.h"
 #include "pmFlatField.h"
 #include "pmMaskBadPixels.h"
@@ -34,6 +38,8 @@
 
 
-bool pmFlatField(pmReadout *in, const pmReadout *flat)
+bool pmFlatField(pmReadout *in, pmReadout *mask, const pmReadout *flat)
 {
+    // XXX: Not sure if this is correct.  Must consult with IfA.
+    PS_ASSERT_PTR_NON_NULL(mask, false);
     int i = 0;
     int j = 0;
@@ -67,17 +73,16 @@
                  PS_ERRORTEXT_pmFlatField_NULL_FLAT_IMAGE);
         return false;
-    } else if(in->mask == NULL) {
-        in->mask = psImageAlloc(inImage->numCols, inImage->numRows, PS_TYPE_MASK);
-        memset(in->mask->data.V[0], 0, inImage->numCols*inImage->numRows*PSELEMTYPE_SIZEOF(PS_TYPE_MASK));
     }
-    inMask = in->mask;
+    inMask = mask->image;
 
     // Check input image and its mask are not larger than flat image
-    if(inImage->numRows>flatImage->numRows || inImage->numCols>flatImage->numCols) {
+
+    if (inImage->numRows>flatImage->numRows || inImage->numCols>flatImage->numCols) {
         psError( PS_ERR_BAD_PARAMETER_SIZE, true,
                  PS_ERRORTEXT_pmFlatField_SIZE_INPUT_IMAGE,
                  inImage->numRows, inImage->numCols, flatImage->numRows, flatImage->numCols);
         return false;
-    } else if(inMask->numRows>flatImage->numRows || inMask->numCols > flatImage->numCols) {
+    }
+    if (inMask->numRows > flatImage->numRows || inMask->numCols > flatImage->numCols) {
         psError( PS_ERR_BAD_PARAMETER_SIZE, true,
                  PS_ERRORTEXT_pmFlatField_SIZE_MASK_IMAGE,
