Index: trunk/archive/pslib/include/psImage.h
===================================================================
--- trunk/archive/pslib/include/psImage.h	(revision 1576)
+++ trunk/archive/pslib/include/psImage.h	(revision 1585)
@@ -48,6 +48,6 @@
 psImage *
 psImageSubset(const psImage *image,	///< parent image 
-	      int width,		///< subimage width (<= image.ncols - col0)  
-	      int height,		///< subimage height (<= image.nrows - row0)  
+	      int nx,			///< subimage width (<= image.ncols - col0)  
+	      int ny,			///< subimage height (<= image.nrows - row0)  
 	      int x0,			///< subimage starting col (0 <= col0 < ncols)   
 	      int y0)			///< subimage starting row (0 <= row0 < nrows)   
@@ -57,17 +57,7 @@
 psImage *
 psImageSubsection(const psImage *image,	///< Parent image
-		  const *section	///< Image section, of the form [x1:x2,y1:y2]
-    );
-
-
-/// Destroy the specified image (destroy children if they exist).
-void 
-psImageFree(psImage *restrict image)	///< free this image
-;
-
-/** Destroy the pixels of the specified image */
-psImage *
-psImageFreePixels(psImage *restrict image) ///< Image whose pixels are to be freed
-;
+		  const char *section	///< Image section, of the form [x1:x2,y1:y2]
+    );
+
 
 /// Create a copy of the specified image.
@@ -78,4 +68,5 @@
 ;
 
+
 /// Trim an image, in-place in memory
 psImage *
@@ -85,18 +76,28 @@
     );
 	    
-
 /*** various image pixel extractions ***/
+
+/** Direction in which to cut */
+typedef enum {
+    PS_CUT_X_POS,			///< Cut in positive x direction
+    PS_CUT_X_NEG,			///< Cut in negative x direction
+    PS_CUT_Y_POS,			///< Cut in positive y direction
+    PS_CUT_Y_NEG			///< Cut in negative y direction
+} psImageCutDirection;
 
 /// Extract pixels from rectlinear region to a vector.
 psVector *
 psImageSlice(psVector *out,		///< Vector to output, or NULL
-	     const psImage *input,	///< extract slice from this image
-	     int x, 			///< starting x coord of region to slice
-	     int y, 			///< starting y coord of region to slice
-	     int nx,			///< length of region in x
-	     int ny,			///< length of region in y
-	     int direction,		///< direction of vector along slice
-	     const psStats *stats)	///< defines statistics used to find output values
-;
+	     psVector *coords,		///< Returned coordinates along the slice, or NULL
+	     const psImage *input,	///< Input image
+	     const psImage *mask,	///< Ignore those pixels where mask & maskVal == 1.  May be NULL
+	     unsigned int maskVal,	///< Value in mask to ignore
+	     unsigned int x,		///< starting x coord of region to slice
+	     unsigned int y,		///< starting y coord of region to slice
+	     unsigned int nx,		///< length of region in x
+	     unsigned int ny,		///< length of region in y
+	     psImageCutDirection direction, ///< Direction in which to cut
+	     const psStats *stats	///< defines statistics used to find output values
+    );
 
 /// Extract pixels along a line to a vector.
@@ -104,4 +105,6 @@
 psImageCut(psVector *out,		///< Vector to output, or NULL
 	   const psImage *input,	///< extract cut from this image
+	   const psImage *mask,		///< Ignore those pixels where mask & maskVal == 1.  May be NULL
+	   unsigned int maskVal,	///< Value in mask to ignore
 	   float xs, 			///< starting x coord of cut
 	   float ys, 			///< starting y coord of cut
@@ -109,5 +112,5 @@
 	   float ye, 			///< ending y coord of cut
 	   float dw, 			///< width of cut
-	   const psStats *stats)		///< defines statistics used to find output values
+	   const psStats *stats)	///< defines statistics used to find output values
 ;
 
@@ -116,4 +119,6 @@
 psImageRadialCut(psVector *out,		///< Vector to output, or NULL
 		 const psImage *input,	///< extract profile from this image
+		 const psImage *mask,	///< Ignore those pixels where mask & maskVal == 1.  May be NULL
+		 unsigned int maskVal,	///< Value in mask to ignore
 		 float x, 		///< center x coord of annulii
 		 float y, 		///< center y coord of annulii
@@ -123,18 +128,39 @@
 
 /*** various image geometry manipulation ***/
+
+/** How to do interpolation */
+typedef enum {
+    PS_INTERPOLATE_FLAT, 
+    PS_INTERPOLATE_BILINEAR, 
+    PS_INTERPOLATE_BICUBIC, 
+    PS_INTERPOLATE_SINC 
+} psImageInterpolateMode mode;
+
 /// Rebin image to new scale.
 psImage *
 psImageRebin(psImage *out,		///< Image to output, or NULL
-	     const psImage *input,	///< rebin this image
-	     float scale, 		///< rebinning scale: doutput = scale*dinput
+	     const psImage *in,		///< rebin this image
+	     const psImage *restrict mask, ///< Ignore those pixels where mask & maskVal == 1.  May be NULL
+	     unsigned int maskVal,	///< Value in mask to ignore
+	     int scale, 		///< rebinning scale
 	     const psStats *stats)	///< defines statistics used to find output values
 ;
 
+/** Resample image to new scale */
+psImage *
+psImageResample(psImage *out,		///< Image to output, or NULL
+		const psImage *in,	///< resample this image
+		int scale,		///< Factor by which to resample
+		psImageInterpolateMode mode ///< Interpolation method
+    );
+
 /// Rotate image by given angle.
 psImage *
 psImageRotate(psImage *out,		///< Image to output, or NULL
-	      const psImage *input,	///< rotate this image
-	      float angle)		///< rotate by this amount anti-clockwise (degrees)
-;
+	      const psImage *in,	///< rotate this image
+	      float angle		///< rotate by this amount anti-clockwise (degrees)
+	      psC64 exposed,		///< Set exposed pixels to this value
+	      psImageInterpolateMode mode ///< Interpolation method
+    );
 
 /// Shift image by an arbitrary number of pixels in either direction.
@@ -142,9 +168,10 @@
 psImage *
 psImageShift(psImage *out,		///< Image to output, or NULL
-	     const psImage *input,	///< shift this image
+	     const psImage *in,		///< shift this image
 	     float dx,			///< shift by this amount in x
 	     float dy,			///< shift by this amount in y
-	     float exposed)		///< set exposed pixels to this value
-;
+	     psC64 exposed,		///< set exposed pixels to this value
+	     psImageInterpolateMode mode ///< Interpolation method
+);
 
 /// Roll image by an integer number of pixels in either direction.
@@ -152,5 +179,5 @@
 psImage *
 psImageRoll(psImage *out,		///< Image to output, or NULL
-	    const psImage *input,	///< roll this image
+	    const psImage *in,	///< roll this image
 	    int dx, 			///< roll this amount in x
 	    int dy)			///< roll this amount in y
@@ -160,12 +187,16 @@
 psStats *
 psImageGetStats(psStats *stats,		///< defines statistics to be calculated & target
-		const psImage *input) 	///< image (or subimage) to calculate stats
-;
+		const psImage *in, 	///< image (or subimage) to calculate stats
+		const psImage *mask,	///< Ignore those pixels where mask & maskVal == 1.  May be NULL
+		unsigned int maskVal	///< Value in mask to ignore
+    );
 
 /// Construct a histogram from an image (or subimage).
 psHistogram *
 psImageHistogram(psHistogram *hist,	///< input histogram description & target
-		 const psImage *input)	///< determine histogram of this image
-;
+		 const psImage *in	///< determine histogram of this image
+		 const psImage *mask,	///< Ignore those pixels where mask & maskVal == 1.  May be NULL
+		 unsigned int maskVal	///< Value in mask to ignore
+    );
 
 /// Fit a 2-D polynomial surface to an image.
@@ -177,7 +208,16 @@
 /// Evaluate a 2-D polynomial surface to image pixels.
 psImage *
-psImageEvalPolynomial(const psImage *input, ///< image to produce
+psImageEvalPolynomial(psImage *input,	///< image to produce
 		      const psPolynomial2D *coeffs) ///< coefficient structure carries in desired terms
 ;
+
+/** Perform interpolation of image pixel values */
+psF64
+psImagePixelInterpolate(const psImage *input, ///< Image on which to interpolate
+			float x, float y, ///< Fractional pixel coordinates at which to interpolate
+			psC64 unexposedValue, ///< Value for pixels that don't have an input value
+			psImageInterpolateMode mode ///< Interpolation method
+    );
+
 
 /*** image input/output routines ***/
@@ -185,6 +225,6 @@
 psImage *
 psImageReadSection(psImage *output, 	///< place data in this structure for output 
-		   int x, 		///< starting x coord of region
-		   int y, 		///< starting y coord of region
+		   int x0, 		///< starting x coord of region
+		   int y0, 		///< starting y coord of region
 		   int nx, 		///< x size of region (-1 for full range)
 		   int ny, 		///< y size of region (-1 for full range)
@@ -192,18 +232,5 @@
 		   const char *extname,	///< MEF extension name ("PHU" for primary header)
 		   int extnum,		///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)
-		   const char *filename)	///< file to read data from
-;
-
-/// Read an image or subimage from file descriptor.
-psImage *
-psImageFReadSection(psImage *output,	///< place data in this structure for output 
-		    int x,		///< starting x coord of region		   
-		    int y,		///< starting y coord of region		   
-		    int nx,		///< x size of region (-1 for full range)	   
-		    int ny,		///< y size of region (-1 for full range)	   
-		    int z,		///< plane of interest			   
-		    const char *extname, ///< MEF extension name ("PHU" for primary header)
-		    int extnum, 	///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)
-		    FILE *f)		///< file descriptor to read data from		   
+		   const char *filename) ///< file to read data from
 ;
 
@@ -219,24 +246,22 @@
 ;
 
-/// Write an image section to named file (which may exist).
-psImage *
-psImageFWriteSection(const psImage *input, ///< image to write out
-		     int x, 		///< starting x coord of region		   
-		     int y, 		///< starting y coord of region		   
-		     int z, 		///< plane of interest			   
-		     const char *extname, ///< MEF extension name			   
-		     int extnum, 	///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)
-		     FILE *f)		///< file descriptor to write data to		   
-;
-
 /*** basic pixel manipulations ***/
 /// Clip image values outside of range to given values.  Return number of clipped pixels.
 int
 psImageClip(psImage *input, 		///< Image to be clipped, and output
-	    float min,			///< clip pixels with values < min
-	    float vmin, 		///< set min-clipped pixels to vmin
-	    float max,			///< clip pixels with values > max
-	    float vmax)			///< set max-clipped pixels to vmax
-;
+	    double min,			///< clip pixels with values < min
+	    double vmin, 		///< set min-clipped pixels to vmin
+	    double max,			///< clip pixels with values > max
+	    double vmax)		///< set max-clipped pixels to vmax
+;
+
+/** Clipping for complex data */
+int
+psImageClipComplexRegion(psImage *input, ///< Image to be clipped, and output
+			 complex double min, ///< clip pixels with values < min
+			 complex double vmin, ///< set min-clipped pixels to vmin
+			 complex double max, ///< clip pixels with values > max
+			 complex double vmax ///< set max-clipped pixels to vmax
+    );
 
 /// Clip NaN image pixels to given value.  Return number of clipped pixels.
