Index: /trunk/psLib/src/imageops/psImageInterpolate.c
===================================================================
--- /trunk/psLib/src/imageops/psImageInterpolate.c	(revision 13650)
+++ /trunk/psLib/src/imageops/psImageInterpolate.c	(revision 13651)
@@ -7,6 +7,6 @@
  *  @author Paul Price, IfA
  *
- *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-05-23 02:55:01 $
+ *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-06-05 22:04:28 $
  *
  *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
@@ -121,6 +121,10 @@
         }
 
-        if (maskValue && options->mask) {
-            *maskValue = options->mask->data.PS_TYPE_MASK_DATA[yInt][xInt];
+        if (maskValue) {
+            if (options->mask) {
+                *maskValue = options->mask->data.PS_TYPE_MASK_DATA[yInt][xInt];
+            } else {
+                *maskValue = 0;
+            }
         }
     }
@@ -270,28 +274,30 @@
     const psImage *mask = options->mask; // Image mask
     psImageInterpolateStatus status = PS_INTERPOLATE_STATUS_GOOD; // Status of interpolation
-    if (maskValue && mask) {
+    if (maskValue) {
         *maskValue = 0;
-        psMaskType maskVal = options->maskVal; // Mask value
-        double badContrib = 0.0;        // Amount of kernel on bad pixels
-        double totContrib = 0.0;        // Total amount of kernel
-        bool badPix = false;            // Is there a bad pixel?
-        for (int j = 0, yPix = yCentral - (yNum - 1) / 2; j < yNum; j++, yPix++) {
-            for (int i = 0, xPix = xCentral - (xNum - 1) / 2; i < xNum; i++, xPix++) {
-                if (mask->data.PS_TYPE_MASK_DATA[yPix][xPix] & maskVal) {
-                    badContrib += fabs(kernel[j][i]);
-                    badPix = true;
+        if (mask) {
+            psMaskType maskVal = options->maskVal; // Mask value
+            double badContrib = 0.0;        // Amount of kernel on bad pixels
+            double totContrib = 0.0;        // Total amount of kernel
+            bool badPix = false;            // Is there a bad pixel?
+            for (int j = 0, yPix = yCentral - (yNum - 1) / 2; j < yNum; j++, yPix++) {
+                for (int i = 0, xPix = xCentral - (xNum - 1) / 2; i < xNum; i++, xPix++) {
+                    if (mask->data.PS_TYPE_MASK_DATA[yPix][xPix] & maskVal) {
+                        badContrib += fabs(kernel[j][i]);
+                        badPix = true;
+                    }
+                    *maskValue |= mask->data.PS_TYPE_MASK_DATA[yPix][xPix];
+                    totContrib += fabs(kernel[j][i]);
                 }
-                *maskValue |= mask->data.PS_TYPE_MASK_DATA[yPix][xPix];
-                totContrib += fabs(kernel[j][i]);
             }
-        }
-
-        if (badPix) {
-            if (badContrib / totContrib >= options->poorFrac) {
-                *maskValue |= options->badMask;
-                status = PS_INTERPOLATE_STATUS_BAD;
-            } else {
-                *maskValue |= options->poorMask;
-            status = PS_INTERPOLATE_STATUS_POOR;
+
+            if (badPix) {
+                if (badContrib / totContrib >= options->poorFrac) {
+                    *maskValue |= options->badMask;
+                    status = PS_INTERPOLATE_STATUS_BAD;
+                } else {
+                    *maskValue |= options->poorMask;
+                    status = PS_INTERPOLATE_STATUS_POOR;
+                }
             }
         }
@@ -492,34 +498,36 @@
     const psImage *mask = options->mask; // Image mask
     psImageInterpolateStatus status = PS_INTERPOLATE_STATUS_GOOD; // Status of interpolation
-    if (maskValue && mask) {
-        psMaskType maskVal = options->maskVal; // Mask value
-        double badContrib = 0.0;        // Amount of kernel on bad pixels
-        double totContrib = 0.0;        // Total amount of kernel
-        bool badPix = false;            // Number of bad pixels
+    if (maskValue) {
         *maskValue = 0;
-        for (int j = 0, yPix = yCentral - (yNum - 1) / 2; j < yNum; j++, yPix++) {
-            // Interpolation in x
-            double xBadContrib = 0.0;   // Amount of x kernel on bad pixels
-            double xTotContrib = 0.0;   // Total amount of x kernel
-            for (int i = 0, xPix = xCentral - (xNum - 1) / 2; i < xNum; i++, xPix++) {
-                if (mask->data.PS_TYPE_MASK_DATA[yPix][xPix] & maskVal) {
-                    xBadContrib += fabs(xKernel[i]);
-                    badPix = true;
+        if (mask) {
+            psMaskType maskVal = options->maskVal; // Mask value
+            double badContrib = 0.0;        // Amount of kernel on bad pixels
+            double totContrib = 0.0;        // Total amount of kernel
+            bool badPix = false;            // Number of bad pixels
+            for (int j = 0, yPix = yCentral - (yNum - 1) / 2; j < yNum; j++, yPix++) {
+                // Interpolation in x
+                double xBadContrib = 0.0;   // Amount of x kernel on bad pixels
+                double xTotContrib = 0.0;   // Total amount of x kernel
+                for (int i = 0, xPix = xCentral - (xNum - 1) / 2; i < xNum; i++, xPix++) {
+                    if (mask->data.PS_TYPE_MASK_DATA[yPix][xPix] & maskVal) {
+                        xBadContrib += fabs(xKernel[i]);
+                        badPix = true;
+                    }
+                    *maskValue |= mask->data.PS_TYPE_MASK_DATA[yPix][xPix];
+                    xTotContrib += fabs(xKernel[i]);
                 }
-                *maskValue |= mask->data.PS_TYPE_MASK_DATA[yPix][xPix];
-                xTotContrib += fabs(xKernel[i]);
+                // Interpolating in y
+                badContrib += fabs(yKernel[j]) * xBadContrib;
+                totContrib += fabs(yKernel[j]) * xTotContrib;
             }
-            // Interpolating in y
-            badContrib += fabs(yKernel[j]) * xBadContrib;
-            totContrib += fabs(yKernel[j]) * xTotContrib;
-        }
-
-        if (badPix) {
-            if (badContrib / totContrib >= options->poorFrac) {
-                *maskValue |= options->badMask;
-                status = PS_INTERPOLATE_STATUS_BAD;
-            } else {
-                *maskValue |= options->poorMask;
-                status = PS_INTERPOLATE_STATUS_POOR;
+
+            if (badPix) {
+                if (badContrib / totContrib >= options->poorFrac) {
+                    *maskValue |= options->badMask;
+                    status = PS_INTERPOLATE_STATUS_BAD;
+                } else {
+                    *maskValue |= options->poorMask;
+                    status = PS_INTERPOLATE_STATUS_POOR;
+                }
             }
         }
