Index: trunk/psModules/src/detrend/pmSkySubtract.c
===================================================================
--- trunk/psModules/src/detrend/pmSkySubtract.c	(revision 12716)
+++ trunk/psModules/src/detrend/pmSkySubtract.c	(revision 12742)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-03-30 21:12:56 $
+ *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-04-04 22:42:48 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -35,5 +35,5 @@
 DetermineNumBits(data): This routine takes an enum psStatsOptions as an
 argument and returns the number of non-zero bits.
- 
+
 XXX: This code is duplicated in the ReadoutCombine file.
  *****************************************************************************/
@@ -91,5 +91,5 @@
 input psImage and scales it smaller by a factor of binFactor.  The statistic
 used in combining input pixels is specified in statOptions.
- 
+
 XXX: use static vectors for myStats, binVector and binMask.
 XXX: I coded this before I was aware of a psLib reBin function.  I don't
@@ -163,7 +163,7 @@
 CalculatePolyTerms(xOrder, yOrder): this routine will calculate the number of
 coefficients (or terms) in a 2-D polynomial of order (xOrder, yOrder).
- 
+
 XXX: Use your brain and figure out the analytical expression.
- 
+
 XXX: Why isn't it simply (xOrder+1) * (yOrder+1)?
  *****************************************************************************/
@@ -199,5 +199,5 @@
     polyTerms[i][0] = the power to which X is raised in the i-th term of in an
     poly-order sky background polynomial.
- 
+
     polyTerms[i][1] = the power to which Y is raised in the i-th term of in an
     poly-order sky background polynomial.
@@ -248,7 +248,7 @@
 This procedure calculates various combinations of powers of x and y and stores
 them in the data structure p_psPolySums[][].  After it completes:
- 
+
     p_psPolySums[i][j] == x^i * y^j
- 
+
 XXX: Use a psImage for the p_psPolySums data structure?
 XXX: p_psPolySums: should this be a global?  Did you get the storage classifier
@@ -296,5 +296,5 @@
 used in this routine is based on that of the pilot project ADD, but is not
 documented anywhere.
- 
+
 XXX: Different trace message facilities in use here.
  *****************************************************************************/
@@ -471,9 +471,9 @@
 /******************************************************************************
 pmReadout pmSubtractSky():
- 
+
 XXX: use static vectors for myStats, and the binned image
- 
+
 XXX: The SDR is silent about types.  PS_TYPE_F32 is implemented here.
- 
+
 XXX: Sync the psTrace message facilities.
  *****************************************************************************/
@@ -691,4 +691,9 @@
         }
     } else {
+
+        psImageInterpolateOptions *interp = psImageInterpolateOptionsAlloc(PS_INTERPOLATE_BILINEAR,
+                                                                           binnedImage, NULL, NULL, 0,
+                                                                           0.0, 0.0, 0, 0, 0.0);
+
         for (psS32 row = 0; row < trimmedImg->numRows ; row++) {
             for (psS32 col = 0; col < trimmedImg->numCols ; col++) {
@@ -705,14 +710,19 @@
                 binColF64+= 0.5;
 
-                psF32 binPixel = (psF32) psImagePixelInterpolate(
-                                     binnedImage, binColF64, binRowF64,
-                                     NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR);
-                trimmedImg->data.F32[row][col]-= binPixel;
+                double binPixel;
+                if (!psImagePixelInterpolate(&binPixel, NULL, NULL, binColF64, binRowF64, interp)) {
+                    psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");
+                    psFree(interp);
+                    psFree(binnedImage);
+                    return NULL;
+                }
+                trimmedImg->data.F32[row][col] -= binPixel;
 
                 psTrace("psModules.detrend", 8,
-                        "image[%d][%d] <--> binnedImage[%.2f][%.2f]: %f\n",
+                        "image[%d][%d] <--> binnedImage[%.2f][%.2f]: %lf\n",
                         row, col, binRowF64-0.5, binColF64-0.5, binPixel);
             }
         }
+        psFree(interp);
 
     }
Index: trunk/psModules/src/imcombine/pmImageCombine.c
===================================================================
--- trunk/psModules/src/imcombine/pmImageCombine.c	(revision 12716)
+++ trunk/psModules/src/imcombine/pmImageCombine.c	(revision 12742)
@@ -8,6 +8,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-01-16 23:51:51 $
+ *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-04-04 22:42:48 $
  *
  *  XXX: pmRejectPixels() has a known bug with the pmImageTransform() call.
@@ -375,8 +375,8 @@
 image, this routine determines the size of the input image which maps to that
 image, and returns the result in a psRegion struct.
- 
+
 XXX: Basically, this routine is only guaranteed to work if the transform is
 linear.
- 
+
 XXX: Shouldn't this functionality be part of psImageTransform()?
  *****************************************************************************/
@@ -491,5 +491,5 @@
 pmRejectPixels(images, errors, inToOut, outToIn, rejThreshold,
 gradLimit)
- 
+
 XXX: Optimization: we don't need to transform the entire mask image.
 XXX: The inToOut and outToIn transforms are confusing.  Verify that what
@@ -591,10 +591,25 @@
         // in other images.
         //
+
+        psImageInterpolateOptions *interp = psImageInterpolateOptionsAlloc(PS_INTERPOLATE_BILINEAR,
+                                                                           transformedImage, NULL, NULL,
+                                                                           0, 0.0, 0.0, 0, 0, 0.0);
+
         for (psS32 p = 0 ; p < pixelList->n ; p++) {
             inCoords->x = 0.5 + (psF32) (pixelList->data[p]).x;
             inCoords->y = 0.5 + (psF32) (pixelList->data[p]).y;
             psPlaneTransformApply(outCoords, myInToOut, inCoords);
-            psF32 maskVal = (psF32) psImagePixelInterpolate(transformedImage, outCoords->x, outCoords->y,
-                            NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR);
+            double maskVal;
+            if (!psImageInterpolate(&maskVal, NULL, NULL, outCoords->x, outCoords->y, interp)) {
+                psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");
+                psFree(interp);
+                psFree(maskImage);
+                psFree(maskImageF32);
+                psFree(transformedImage);
+                psFree(inCoords);
+                psFree(outCoords);
+                psFree(rejects);
+                return NULL;
+            }
             if (maskVal > rejThreshold) {
 
@@ -656,4 +671,5 @@
         }
 
+        psFree(interp);
         psFree(maskImage);
         psFree(maskImageF32);
