Index: /trunk/archive/pslib/include/psImage.h
===================================================================
--- /trunk/archive/pslib/include/psImage.h	(revision 277)
+++ /trunk/archive/pslib/include/psImage.h	(revision 278)
@@ -39,31 +39,37 @@
 psImageAlloc (int nx,			///< image width 
 	      int ny,			///< image height 
-	      psType type)		///< image data type 
-;
+	      psType type		///< image data type 
+    );
 
 /// Create a subimage of the specified area.
 psImage *
-psImageSubset (psImage *image,		///< parent image 
-	       int nx,			///< subimage width (<= image.nx - x0)  
-	       int ny,			///< subimage width (<= image.ny - y0)  
-	       int x0,			///< subimage x-offset (0 <= x0 < nx)   
-	       int y0)			///< subimage y-offset (0 <= y0 < ny)   
-;
+psImageSubset(psImage *out,		//!< Subimage to return, or NULL
+	      const psImage *image,	///< parent image 
+	      int nx,			///< subimage width (<= image.nx - x0)  
+	      int ny,			///< subimage width (<= image.ny - y0)  
+	      int x0,			///< subimage x-offset (0 <= x0 < nx)   
+	      int y0			///< subimage y-offset (0 <= y0 < ny)   
+    );
 
 /// Destroy the specified image (destroy children if they exist).
 void 
-psImageFree (psImage *image)		///< free this image
-;
-
-/// Destroy the children of the specified image.
+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
+    );
+
+/// Destroy the children of the specified image.  Returns number of children freed.
 int 
-psImageFreeChildren (psImage *image)	///< free children of this image
-;
+psImageFreeChildren(const psImage *image ///< free children of this image
+);
 
 /// Create a copy of the specified image.
 psImage *
-psImageCopy (psImage *output, 		///< target structure for output image data
-	     psImage *input)		///< copy this image 
-;
+psImageCopy(psImage *output, 		///< target structure for output image data
+	    const psImage *input	///< copy this image 
+    );
 
 /*** various image pixel extractions ***/
@@ -71,133 +77,142 @@
 /// Extract pixels from rectlinear region to a vector.
 psFloatArray *
-psImageSlice (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, 			///< width of region in x
-	      int ny, 			///< width of region in y
-	      int direction,		///< direction of vector along slice
-	      psStats *stats)		///< defines statistics used to find output values
-;
+psImageSlice(psFloatArray *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, 			///< width of region in x
+	     int ny, 			///< width of region in y
+	     int direction,		///< direction of vector along slice
+	     const psStats *stats	///< defines statistics used to find output values
+    );
 
 /// Extract pixels along a line to a vector.
 psFloatArray *
-psImageCut (psImage *input, 		///< extract cut from this image
-	    float xs, 			///< starting x coord of cut
-	    float ys, 			///< starting y coord of cut
-	    float xe, 			///< ending x coord of cut
-	    float ye, 			///< ending y coord of cut
-	    float dw, 			///< width of cut
-	    psStats *stats)		///< defines statistics used to find output values
-;
+psImageCut(psFloatArray *out,		//!< Vector to output, or NULL
+	   const psImage *input,	///< extract cut from this image
+	   float xs, 			///< starting x coord of cut
+	   float ys, 			///< starting y coord of cut
+	   float xe, 			///< ending x coord of cut
+	   float ye, 			///< ending y coord of cut
+	   float dw, 			///< width of cut
+	   const psStats *stats		///< defines statistics used to find output values
+    );
 
 /// Extract radial annulii data to a vector.
 psFloatArray *
-psImageRadialCut (psImage *input, 	///< extract profile from this image
-		  float x, 		///< center x coord of annulii
-		  float y, 		///< center y coord of annulii
-		  float radius, 	///< outer radius of annulii
-		  float dr,		///< radial step size of annulii
-		  psStats *stats)		///< defines statistics used to find output values
-;
+psImageRadialCut(psFloatArray *out,	//!< Vector to output, or NULL
+		 const psImage *input,	///< extract profile from this image
+		 float x, 		///< center x coord of annulii
+		 float y, 		///< center y coord of annulii
+		 float radius,		///< outer radius of annulii
+		 float dr,		///< radial step size of annulii
+		 const psStats *stats	///< defines statistics used to find output values
+    );
 
 /// Extract a 2-d contour from an image at the given threshold.
 psFloatArray *
-psImageContour (psImage *input, 	///< create contour for this image
-		float threshold,	///< contour image at this threshold
-		int binning)		///< bin image by this value for contour calculation
-;
+psImageContour(psFloatArray *out,	//!< Vector to output, or NULL
+	       const psImage *input, 	///< create contour for this image
+	       float threshold,	///< contour image at this threshold
+	       int binning		///< bin image by this value for contour calculation
+    );
 
 /*** various image geometry manipulation ***/
 /// Rebin image to new scale.
 psImage *
-psImageRebin (psImage *input, 		///< rebin this image
-	      float scale, 		///< rebinning scale: doutput = scale*dinput
-	      psStats *stats)		///< defines statistics used to find output values
-;
+psImageRebin(psImage *out,		//!< Image to output, or NULL
+	     const psImage *input,	///< rebin this image
+	     float scale, 		///< rebinning scale: doutput = scale*dinput
+	     const psStats *stats	///< defines statistics used to find output values
+    );
 
 /// Rotate image by given angle.
 psImage *
-psImageRotate (psImage *input, 		///< rotate this image
-	       float angle)		///< rotate by this amount (degrees)
-;
+psImageRotate(psImage *out,		//!< Image to output, or NULL
+	      const psImage *input,	///< rotate this image
+	      float angle		///< rotate by this amount anti-clockwise (degrees)
+    );
 
 /// Shift image by an arbitrary number of pixels in either direction.
 /// Drop edge pixels, and set newly exposed pixels to 'exposed'.
 psImage *
-psImageShift (psImage *input, 		///< 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
-;
+psImageShift(psImage *out,		//!< Image to output, or NULL
+	     const psImage *input,	///< 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
+    );
 
 /// Roll image by an integer number of pixels in either direction.
 /// Edge pixels wrap to the other side (no values are lost).
 psImage *
-psImageRoll (psImage *input, 		///< roll this image
-	     int dx, 			///< roll this amount in x
-	     int dy)			///< roll this amount in y
-;
+psImageRoll(psImage *out,		//!< Image to output, or NULL
+	    const psImage *input,	///< roll this image
+	    int dx, 			///< roll this amount in x
+	    int dy			///< roll this amount in y
+    );
 
 /// Determine statistics for image (or subimage).
 psStats *
-psImageGetStats (psImage *input, 	///< image (or subimage) to calculate stats
-		 psStats *stats)	///< defines statistics to be calculated
-;
+psImageGetStats(psImage *out,		//!< Image to output, or NULL
+		const psImage *input, 	///< image (or subimage) to calculate stats
+		psStats *stats		///< defines statistics to be calculated & target
+    );
 
 /// Construct a histogram from an image (or subimage).
 psHistogram *
-psImageHistogram (psHistogram *hist,	///< input histogram description & target
-		  psImage *input)	///< determine histogram of this image
-;
+psImageHistogram(psHistogram *hist,	///< input histogram description & target
+		 const psImage *input	///< determine histogram of this image
+    );
 
 /// Fit a 2-D polynomial surface to an image.
 psPolynomial2D *
-psImageFitPolynomial (psImage *input, 	///< image to fit
-		      psPolynomial2D *coeffs) ///< coefficient structure carries in desired terms
-;
+psImageFitPolynomial(const psImage *input, ///< image to fit
+		     psPolynomial2D *coeffs ///< coefficient structure carries in desired terms & target
+    );
 
 /// Evaluate a 2-D polynomial surface to image pixels.
 int
-psImageEvalPolynomial (psImage *input, 	///< image to fit
-		       psPolynomial2D *coeffs) ///< coefficient structure carries in desired terms
-;
+psImageEvalPolynomial(const psImage *input, ///< image to fit
+		      const psPolynomial2D *coeffs ///< coefficient structure carries in desired terms
+    );
 
 /*** image input/output routines ***/
 /// Read an image or subimage from a named file.
 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 nx, 		///< x size of region (-1 for full range)
-		    int ny, 		///< y size of region (-1 for full range)
-		    int z, 		///< plane of interest
-		    char *extname, 	///< MEF extension name ("PHU" for primary header)
+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 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)
+		   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 dx,		///< x size of region (-1 for full range)	   
+		    int dy,		///< 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)
-		    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 dx,		///< x size of region (-1 for full range)	   
-		     int dy,		///< y size of region (-1 for full range)	   
-		     int z,		///< plane of interest			   
-		     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 FILE *f	///< file descriptor to read data from		   
+    );
 
 /// Write an image section to named file (which may exist).
 psImage *
-psImageWriteSection (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			   
-		     char *extname, 	///< MEF extension name ("PHU" for primary header)			   
-		     int extnum, 	///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)
-		     char *filename)	///< file to write data to		   
-;
+psImageWriteSection(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 ("PHU" for primary header)
+		    int extnum, 	///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)
+		    const char *filename ///< file to write data to		   
+    );
 
 /// Write an image section to named file (which may exist).
@@ -207,56 +222,56 @@
 		     int y, 		///< starting y coord of region		   
 		     int z, 		///< plane of interest			   
-		     char *extname, 	///< MEF extension name			   
+		     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		   
-;
+		     const FILE *f	///< file descriptor to write data to		   
+    );
 
 /// Read only header from image file.
-struct psMetadata *
-psImageReadHeader(struct psMetadata *output, 	///< read data to this structure
-		  char *extname, 	///< MEF extension name ("PHU" for primary header)
+psMetadata *
+psImageReadHeader(psMetadata *output,	///< read data to this structure
+		  const char *extname, 	///< MEF extension name ("PHU" for primary header)
 		  int extnum,		///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)
-		  char *filename)	///< file to read from
-;
+		  const char *filename	///< file to read from
+    );
 
 /// Read only header from image file descriptor.
-struct psMetadata *
-psImageFReadHeader (struct psMetadata *output, ///< read data to this structure
-		    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 from
-;
+psMetadata *
+psImageFReadHeader(psMetadata *output, ///< read data to this structure
+		   const char *extname,	///< MEF extension name ("PHU" for primary header)
+		   int extnum,		///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)
+		   const FILE *f	///< file descriptor to read from
+    );
 
 /*** image FFT operations ***/
 /// Perform an FFT on the image.
 psImage *
-psImageFFT (psImage *input, 		///< image to FFT
-	    int direction)		///< FFT direction 
-;
+psImageFFT(psImage *input, 		///< image to FFT
+	   int direction		///< FFT direction 
+    );
 
 /*** basic pixel manipulations ***/
-/// Clip image values outside of range to given values.
+/// Clip image values outside of range to given values.  Return number of clipped pixels.
 int
-psImageClip (psImage *input, 		///< clip this image
-	     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
-;
-
-/// Clip NaN image pixels to given value.
+psImageClip(psImage *input, 		///< clip this image
+	    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
+    );
+
+/// Clip NaN image pixels to given value.  Return number of clipped pixels.
 int
-psImageClipNaN (psImage *input, 	///< clip this image
-		float value)		///< set nan pixels to this value
-;
-
-/// Overlay subregion of image with another image.
+psImageClipNaN(psImage *input,		///< clip this image & target
+	       float value		///< set nan pixels to this value
+    );
+
+/// Overlay subregion of image with another image.  Return number of pixels replaced.
 int 
-psImageOverlaySection (psImage *image,	///< input image 
-		psImage *overlay,	///< image to overlay 
-		int x0,			///< x offset of overlay subimage 
-		int y0,			///< y offset of overlay subimage 
-		char *operator)		///< overlay operation 
-;
+psImageOverlaySection(psImage *image,	///< input image & target
+		      const psImage *overlay, ///< image to overlay 
+		      int x0,		///< x offset of overlay subimage 
+		      int y0,		///< y offset of overlay subimage 
+		      const char *operator ///< overlay operation 
+    );
 
 /* \} */ // End of AstroGroup Functions
