Index: trunk/psLib/src/fft/psImageFFT.c
===================================================================
--- trunk/psLib/src/fft/psImageFFT.c	(revision 21172)
+++ trunk/psLib/src/fft/psImageFFT.c	(revision 21183)
@@ -6,6 +6,6 @@
 /// @author Robert DeSonia, MHPCC
 ///
-/// @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
-/// @date $Date: 2008-11-06 23:36:20 $
+/// @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
+/// @date $Date: 2009-01-27 06:39:37 $
 ///
 /// Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -318,5 +318,5 @@
 
 
-psImage *psImageConvolveFFT(psImage *out, const psImage *in, const psImage *mask, psMaskType maskVal,
+psImage *psImageConvolveFFT(psImage *out, const psImage *in, const psImage *mask, psImageMaskType maskVal,
                             const psKernel *kernel)
 {
@@ -326,5 +326,5 @@
     if (mask) {
         PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
-        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
+        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
         PS_ASSERT_IMAGES_SIZE_EQUAL(mask, in, NULL);
     }
@@ -464,5 +464,5 @@
         for (int y = 0; y < numRows; y++) {
             for (int x = 0; x < numCols; x++) {
-                if (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
+                if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) {
                     data[x + paddedCols * y] = 0;
                 }
Index: trunk/psLib/src/fft/psImageFFT.h
===================================================================
--- trunk/psLib/src/fft/psImageFFT.h	(revision 21172)
+++ trunk/psLib/src/fft/psImageFFT.h	(revision 21183)
@@ -5,6 +5,6 @@
 /// @author Robert DeSonia, MHPCC
 ///
-/// @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
-/// @date $Date: 2008-04-04 22:44:56 $
+/// @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+/// @date $Date: 2009-01-27 06:39:37 $
 /// Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
 ///
@@ -70,5 +70,5 @@
     const psImage *in,                  ///< Image to convolve
     const psImage *mask,                ///< Corresponding mask
-    psMaskType maskVal,                 ///< Value to mask
+    psImageMaskType maskVal,		///< Value to mask
     const psKernel *kernel              ///< kernel to colvolve with
 );
Index: trunk/psLib/src/fits/psFitsImage.c
===================================================================
--- trunk/psLib/src/fits/psFitsImage.c	(revision 21172)
+++ trunk/psLib/src/fits/psFitsImage.c	(revision 21183)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-09-05 08:08:33 $
+ *  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-27 06:39:37 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -251,5 +251,5 @@
                                           const psImage *image, // Image to convert
                                           const psImage *mask, // Mask image, or NULL
-                                          psMaskType maskVal, // Value to mask
+                                          psImageMaskType maskVal, // Value to mask
                                           psRandom *rng, // Random number generator
                                           bool newScaleZero // Determine a new BSCALE and BZERO?
@@ -506,5 +506,5 @@
 
 bool psFitsWriteImageWithMask(psFits *fits, psMetadata *header, const psImage *input,
-                              const psImage *mask, psMaskType maskVal, int numZPlanes,
+                              const psImage *mask, psImageMaskType maskVal, int numZPlanes,
                               const char *extname)
 {
@@ -525,5 +525,5 @@
 
 bool psFitsInsertImageWithMask(psFits *fits, psMetadata *header, const psImage *image,
-                               const psImage *mask, psMaskType maskVal, int numZPlanes,
+                               const psImage *mask, psImageMaskType maskVal, int numZPlanes,
                                const char *extname, bool after)
 {
@@ -532,5 +532,5 @@
     PS_ASSERT_IMAGE_NON_NULL(image, false);
     if (mask) {
-        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, false);
+        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false);
         PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, false);
     }
@@ -706,5 +706,5 @@
 }
 
-bool psFitsUpdateImageWithMask(psFits *fits, const psImage *input, const psImage *mask, psMaskType maskVal,
+bool psFitsUpdateImageWithMask(psFits *fits, const psImage *input, const psImage *mask, psImageMaskType maskVal,
                                int x0, int y0, int z)
 {
@@ -713,5 +713,5 @@
     PS_ASSERT_IMAGE_NON_NULL(input, false);
     if (mask) {
-        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, false);
+        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false);
         PS_ASSERT_IMAGES_SIZE_EQUAL(mask, input, false);
     }
@@ -896,5 +896,5 @@
 
 bool psFitsWriteImageCubeWithMask(psFits *fits, psMetadata *header, const psArray *input,
-                                  const psArray *masks, psMaskType maskVal, const char *extname)
+                                  const psArray *masks, psImageMaskType maskVal, const char *extname)
 {
     PS_ASSERT_FITS_NON_NULL(fits, false);
@@ -976,5 +976,5 @@
 
 bool psFitsUpdateImageCubeWithMask(psFits *fits, const psArray *input,
-                                   const psArray *masks, psMaskType maskVal, int x0, int y0)
+                                   const psArray *masks, psImageMaskType maskVal, int x0, int y0)
 {
     PS_ASSERT_FITS_NON_NULL(fits, false);
Index: trunk/psLib/src/fits/psFitsImage.h
===================================================================
--- trunk/psLib/src/fits/psFitsImage.h	(revision 21172)
+++ trunk/psLib/src/fits/psFitsImage.h	(revision 21183)
@@ -4,6 +4,6 @@
  * @author Robert DeSonia, MHPCC
  *
- * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-09-05 08:08:33 $
+ * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-27 06:39:37 $
  * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  */
@@ -74,5 +74,5 @@
     const psImage *input,               ///< the image to output
     const psImage *mask,                ///< the mask image
-    psMaskType maskVal,                 ///< value to mask
+    psImageMaskType maskVal,		///< value to mask
     int depth,                          ///< the number of z-planes of the FITS image data cube
     const char *extname                 ///< FITS extension name
@@ -101,5 +101,5 @@
     const psImage *input,               ///< the image to output
     const psImage *mask,                ///< the mask image
-    psMaskType maskVal,                 ///< value to mask
+    psImageMaskType maskVal,		///< value to mask
     int depth,                          ///< the number of z-planes of the FITS image data cube
     const char *extname,                ///< FITS extension name
@@ -128,5 +128,5 @@
     const psImage *input,               ///< the image to output
     const psImage *mask,                ///< the mask image
-    psMaskType maskVal,                 ///< value to mask
+    psImageMaskType maskVal,		///< value to mask
     int x0,                             ///< psImage's x-axis origin in FITS image coordinates
     int y0,                             ///< psImage's y-axis origin in FITS image coordinates
@@ -157,5 +157,5 @@
     const psArray *input,               ///< Array of images
     const psArray *masks,               ///< Array of masks
-    psMaskType maskVal,                 ///< Value to mask
+    psImageMaskType maskVal,		///< Value to mask
     const char *extname                 ///< Name of extension
     );
@@ -175,5 +175,5 @@
     const psArray *input,               ///< Array of images
     const psArray *masks,               ///< Array of masks
-    psMaskType maskVal,                 ///< Value to mask
+    psImageMaskType maskVal,		///< Value to mask
     int x0,                             ///< x origin of images in FITS image coordinates
     int y0                              ///< y origin of images in FITS image coordinates
Index: trunk/psLib/src/fits/psFitsScale.c
===================================================================
--- trunk/psLib/src/fits/psFitsScale.c	(revision 21172)
+++ trunk/psLib/src/fits/psFitsScale.c	(revision 21183)
@@ -100,5 +100,5 @@
                        const psImage *image, // Image to scale
                        const psImage *mask, // Mask image
-                       psMaskType maskVal, // Value to mask
+                       psImageMaskType maskVal, // Value to mask
                        const psFitsOptions *options // FITS options
     )
@@ -167,5 +167,5 @@
 
 bool psFitsScaleDetermine(double *bscale, double *bzero, long *blank, const psImage *image,
-                          const psImage *mask, psMaskType maskVal, const psFits *fits)
+                          const psImage *mask, psImageMaskType maskVal, const psFits *fits)
 {
     PS_ASSERT_PTR_NON_NULL(bscale, false);
@@ -174,5 +174,5 @@
     PS_ASSERT_IMAGE_NON_NULL(image, false);
     if (mask) {
-        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, false);
+        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false);
         PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, false);
     }
Index: trunk/psLib/src/fits/psFitsScale.h
===================================================================
--- trunk/psLib/src/fits/psFitsScale.h	(revision 21172)
+++ trunk/psLib/src/fits/psFitsScale.h	(revision 21183)
@@ -13,5 +13,5 @@
                           const psImage *image, ///< Image to scale
                           const psImage *mask, ///< Mask image
-                          psMaskType maskVal, ///< Value to mask
+                          psImageMaskType maskVal, ///< Value to mask
                           const psFits *fits ///< FITS options
     );
Index: trunk/psLib/src/imageops/psImageBackground.c
===================================================================
--- trunk/psLib/src/imageops/psImageBackground.c	(revision 21172)
+++ trunk/psLib/src/imageops/psImageBackground.c	(revision 21183)
@@ -18,10 +18,10 @@
 // XXX allow the user to choose the stats method?
 // (SAMPLE_MEAN, CLIPPED_MEAN, ROBUST_MEDIAN, FITTED_MEAN)
-bool psImageBackground(psStats *stats, psVector **sample, const psImage *image, const psImage *mask, psMaskType maskValue, psRandom *rng)
+bool psImageBackground(psStats *stats, psVector **sample, const psImage *image, const psImage *mask, psImageMaskType maskValue, psRandom *rng)
 {
     PS_ASSERT_IMAGE_NON_NULL(image, NULL);
     if (mask) {
         PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
-        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_U8, NULL);
+        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
         PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, NULL);
     }
@@ -63,5 +63,5 @@
         int iy = pixel / nx;
 
-        if (!isfinite(image->data.F32[iy][ix]) || (mask && mask->data.U8[iy][ix] & maskValue)) {
+        if (!isfinite(image->data.F32[iy][ix]) || (mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskValue)) {
             continue;
         }
Index: trunk/psLib/src/imageops/psImageBackground.h
===================================================================
--- trunk/psLib/src/imageops/psImageBackground.h	(revision 21172)
+++ trunk/psLib/src/imageops/psImageBackground.h	(revision 21183)
@@ -5,6 +5,6 @@
  *  @author EAM, IfA
  *
- *  $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  $Date: 2008-01-17 22:07:33 $
+ *  $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  $Date: 2009-01-27 06:39:37 $
  *  Copyright 2004-2005 IfA, University of Hawaii
  */
@@ -27,5 +27,5 @@
                        const psImage *image, // Image for which to get the background
                        const psImage *mask, // Mask image
-                       psMaskType maskValue, // Mask pixels which this mask value
+                       psImageMaskType maskValue, // Mask pixels which this mask value
                        psRandom *rng // Random number generator (for pixel selection)
                       );
Index: trunk/psLib/src/imageops/psImageConvolve.c
===================================================================
--- trunk/psLib/src/imageops/psImageConvolve.c	(revision 21172)
+++ trunk/psLib/src/imageops/psImageConvolve.c	(revision 21183)
@@ -7,6 +7,6 @@
 /// @author Eugene Magnier, IfA
 ///
-/// @version $Revision: 1.81 $ $Name: not supported by cvs2svn $
-/// @date $Date: 2008-11-26 00:43:12 $
+/// @version $Revision: 1.82 $ $Name: not supported by cvs2svn $
+/// @date $Date: 2009-01-27 06:39:37 $
 ///
 /// Copyright 2004-2007 Institute for Astronomy, University of Hawaii
@@ -319,9 +319,9 @@
 }
 
-psImage *psImageConvolveMaskDirect(psImage *out, const psImage *mask, psMaskType maskVal,
-                                   psMaskType setVal, int xMin, int xMax, int yMin, int yMax)
+psImage *psImageConvolveMaskDirect(psImage *out, const psImage *mask, psImageMaskType maskVal,
+                                   psImageMaskType setVal, int xMin, int xMax, int yMin, int yMax)
 {
     PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
-    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
+    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
     if (out == mask && ((maskVal & setVal) || !setVal)) {
         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
@@ -352,10 +352,10 @@
     if (!out) {
         // Propagate the non-masked values
-        out = (psImage*)psBinaryOp(NULL, (const psPtr)mask, "&", psScalarAlloc(~maskVal, PS_TYPE_MASK));
+        out = (psImage*)psBinaryOp(NULL, (const psPtr)mask, "&", psScalarAlloc(~maskVal, PS_TYPE_IMAGE_MASK));
     }
 
     // Dereference mask images
-    psMaskType **maskData = mask->data.PS_TYPE_MASK_DATA;
-    psMaskType **outData = out->data.PS_TYPE_MASK_DATA;
+    psImageMaskType **maskData = mask->data.PS_TYPE_IMAGE_MASK_DATA;
+    psImageMaskType **outData = out->data.PS_TYPE_IMAGE_MASK_DATA;
 
     if (setVal) {
@@ -376,5 +376,5 @@
         for (int row = 0; row < numRows; row++) {
             for (int col = 0; col < numCols; col++) {
-                psMaskType pixel = outData[row][col]; // Pixel value to set
+                psImageMaskType pixel = outData[row][col]; // Pixel value to set
                 if (pixel & maskVal) {
                     // Already done this one
@@ -395,9 +395,9 @@
 
 
-psImage *psImageConvolveMaskFFT(psImage *out, const psImage *mask, psMaskType maskVal,
-                                psMaskType setVal, int xMin, int xMax, int yMin, int yMax, float thresh)
+psImage *psImageConvolveMaskFFT(psImage *out, const psImage *mask, psImageMaskType maskVal,
+                                psImageMaskType setVal, int xMin, int xMax, int yMin, int yMax, float thresh)
 {
     PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
-    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
+    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
     PS_ASSERT_FLOAT_LARGER_THAN(thresh, 0.0, NULL);
     PS_ASSERT_FLOAT_LESS_THAN(thresh, 1.0, NULL);
@@ -431,5 +431,5 @@
     for (int y = 0; y < numRows; y++) {
         for (int x = 0; x < numCols; x++) {
-            if (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
+            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) {
                 onoff->data.F32[y][x] = 1.0;
             }
@@ -452,10 +452,10 @@
 
     if (!out) {
-        out = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
+        out = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
     }
     for (int y = 0; y < numRows; y++) {
         for (int x = 0; x < numCols; x++) {
-            out->data.PS_TYPE_MASK_DATA[y][x] = (convolved->data.F32[y][x] >= thresh) ?
-                (mask->data.PS_TYPE_MASK_DATA[y][x] | setVal) : mask->data.PS_TYPE_MASK_DATA[y][x];
+            out->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = (convolved->data.F32[y][x] >= thresh) ?
+                (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] | setVal) : mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x];
         }
     }
@@ -651,5 +651,5 @@
 case PS_TYPE_##TYPE: { \
     psImage *calculation = psImageAlloc(numRows, numCols, PS_TYPE_##TYPE); /* Calculation image; BW */ \
-    psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_MASK); /* Mask for calculation image; BW */ \
+    psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_IMAGE_MASK); /* Mask for calculation image; BW */ \
     \
     /** Smooth in X direction **/ \
@@ -658,5 +658,5 @@
             int xMin = PS_MAX(i - size, 0); \
             int xMax = PS_MIN(i + size, xLast); \
-            const psMaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[j][xMin]; \
+            const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[j][xMin]; \
             const ps##TYPE *imageData = &image->data.TYPE[j][xMin]; \
             int uMin = - PS_MIN(i, size); /* Minimum kernel index */ \
@@ -673,8 +673,8 @@
                 /* BW */ \
                 calculation->data.TYPE[i][j] = sumIG / sumG; \
-                calcMask->data.PS_TYPE_MASK_DATA[i][j] = 0; \
+                calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0; \
             } else { \
                 /* BW */ \
-                calcMask->data.PS_TYPE_MASK_DATA[i][j] = 0xFF; \
+                calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0xFF; \
             } \
         } \
@@ -688,5 +688,5 @@
             int yMin = PS_MAX(j - size, 0); \
             int yMax = PS_MIN(j + size, yLast); \
-            const psMaskType *maskData = &calcMask->data.PS_TYPE_MASK_DATA[i][yMin]; /* BW */ \
+            const psImageMaskType *maskData = &calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][yMin]; /* BW */ \
             const ps##TYPE *imageData = &calculation->data.TYPE[i][yMin]; /* BW */ \
             int vMin = - PS_MIN(j, size); /* Minimum kernel index */ \
@@ -714,5 +714,5 @@
                            const psImage *image,
                            const psImage *mask,
-                           psMaskType maskVal,
+                           psImageMaskType maskVal,
                            float sigma,
                            float numSigma,
@@ -721,5 +721,5 @@
     PS_ASSERT_IMAGE_NON_NULL(image, NULL);
     PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
-    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
+    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
     PS_ASSERT_IMAGES_SIZE_EQUAL(image, mask, NULL);
 
@@ -751,5 +751,5 @@
       case PS_TYPE_F32: {
           psImage *calculation = psImageAlloc(numRows, numCols, PS_TYPE_F32); /* Calculation image; BW */
-          psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_MASK); /* Mask for calculation image; BW */
+          psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_IMAGE_MASK); /* Mask for calculation image; BW */
 
           /** Smooth in X direction **/
@@ -758,5 +758,5 @@
                   int xMin = PS_MAX(i - size, 0);
                   int xMax = PS_MIN(i + size, xLast);
-                  const psMaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[j][xMin];
+                  const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[j][xMin];
                   const psF32 *imageData = &image->data.F32[j][xMin];
                   int uMin = - PS_MIN(i, size); /* Minimum kernel index */
@@ -776,8 +776,8 @@
                       /* BW */
                       calculation->data.F32[i][j] = sumIG / sumG;
-                      calcMask->data.PS_TYPE_MASK_DATA[i][j] = 0;
+                      calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0;
                   } else {
                       /* BW */
-                      calcMask->data.PS_TYPE_MASK_DATA[i][j] = 0xFF;
+                      calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0xFF;
                   }
               }
@@ -791,5 +791,5 @@
                   int yMin = PS_MAX(j - size, 0);
                   int yMax = PS_MIN(j + size, yLast);
-                  const psMaskType *maskData = &calcMask->data.PS_TYPE_MASK_DATA[i][yMin]; /* BW */
+                  const psImageMaskType *maskData = &calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][yMin]; /* BW */
                   const psF32 *imageData = &calculation->data.F32[i][yMin]; /* BW */
                   int vMin = - PS_MIN(j, size); /* Minimum kernel index */
@@ -832,5 +832,5 @@
                                      const psImage *image,
                                      const psImage *mask,
-                                     psMaskType maskVal,
+                                     psImageMaskType maskVal,
                                      psVector *gaussNorm,
                                      float minGauss,
@@ -848,5 +848,5 @@
             int xMin = PS_MAX(i - size, 0);
             int xMax = PS_MIN(i + size, xLast);
-            const psMaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[j][xMin];
+            const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[j][xMin];
             const psF32 *imageData = &image->data.F32[j][xMin];
             int uMin = - PS_MIN(i, size); /* Minimum kernel index */
@@ -863,8 +863,8 @@
                 /* BW */
                 calculation->data.F32[i][j] = sumIG / sumG;
-                calcMask->data.PS_TYPE_MASK_DATA[i][j] = 0;
+                calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0;
             } else {
                 /* BW */
-                calcMask->data.PS_TYPE_MASK_DATA[i][j] = 0xFF;
+                calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0xFF;
             }
         }
@@ -876,5 +876,5 @@
                                      psImage *calculation,
                                      psImage *calcMask,
-                                     psMaskType maskVal,
+                                     psImageMaskType maskVal,
                                      psVector *gaussNorm,
                                      float minGauss,
@@ -892,5 +892,5 @@
             int yMin = PS_MAX(j - size, 0);
             int yMax = PS_MIN(j + size, yLast);
-            const psMaskType *maskData = &calcMask->data.PS_TYPE_MASK_DATA[i][yMin]; /* BW */
+            const psImageMaskType *maskData = &calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][yMin]; /* BW */
             const psF32 *imageData = &calculation->data.F32[i][yMin]; /* BW */
             int vMin = - PS_MIN(j, size); /* Minimum kernel index */
@@ -921,5 +921,5 @@
     const psImage *mask   = job->args->data[3]; // input mask
 
-    psMaskType maskVal    = PS_SCALAR_VALUE(job->args->data[4],U8);
+    psImageMaskType maskVal    = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA);
     psVector *gaussNorm   = job->args->data[5]; // gauss kernel
     float minGauss        = PS_SCALAR_VALUE(job->args->data[6],F32);
@@ -941,5 +941,5 @@
     psImage *calculation  = job->args->data[1]; // calculation image
     psImage *calcMask     = job->args->data[2]; // calculation mask
-    psMaskType maskVal    = PS_SCALAR_VALUE(job->args->data[3],U8);
+    psImageMaskType maskVal    = PS_SCALAR_VALUE(job->args->data[3],PS_TYPE_IMAGE_MASK_DATA);
 
     psVector *gaussNorm   = job->args->data[4]; // gauss kernel
@@ -956,5 +956,5 @@
                                     const psImage *image,
                                     const psImage *mask,
-                                    psMaskType maskVal,
+                                    psImageMaskType maskVal,
                                     float sigma,
                                     float numSigma,
@@ -963,5 +963,5 @@
     PS_ASSERT_IMAGE_NON_NULL(image, NULL);
     PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
-    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
+    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
     PS_ASSERT_IMAGES_SIZE_EQUAL(image, mask, NULL);
 
@@ -999,5 +999,5 @@
       case PS_TYPE_F32: {
           psImage *calculation = psImageAlloc(numRows, numCols, PS_TYPE_F32); /* Calculation image; BW */
-          psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_MASK); /* Mask for calculation image; BW */
+          psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_IMAGE_MASK); /* Mask for calculation image; BW */
 
           /** Smooth in X direction **/
@@ -1011,5 +1011,5 @@
               psArrayAdd(job->args, 1, (psImage *) image); // cast away const
               psArrayAdd(job->args, 1, (psImage *) mask); // cast away const
-              PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_U8);
+              PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_IMAGE_MASK);
               psArrayAdd(job->args, 1, gaussNorm);
               PS_ARRAY_ADD_SCALAR(job->args, minGauss, PS_TYPE_F32);
@@ -1046,5 +1046,5 @@
               psArrayAdd(job->args, 1, calculation);
               psArrayAdd(job->args, 1, calcMask);
-              PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_U8);
+              PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_IMAGE_MASK);
               psArrayAdd(job->args, 1, gaussNorm);
               PS_ARRAY_ADD_SCALAR(job->args, minGauss, PS_TYPE_F32);
@@ -1091,5 +1091,5 @@
 bool psImageSmoothMaskF32 (psImage *image,
                            psImage *mask,
-                           psMaskType maskVal,
+                           psImageMaskType maskVal,
                            double  sigma,
                            double  Nsigma)
@@ -1122,5 +1122,5 @@
     psVector *calculation = psVectorAlloc(Nx, PS_TYPE_F32);
     for (int j = 0; j < Ny; j++) {
-        psU8  *vm = mask->data.U8[j];
+        psImageMaskType  *vm = mask->data.PS_TYPE_IMAGE_MASK_DATA[j];
         psF32 *vi = image->data.F32[j];
         psF32 *vo = calculation->data.F32;
@@ -1128,5 +1128,5 @@
         for (int i = 0; i < Nx; i++, vi++, vo++, vm++) {
             int offset = PS_MIN (i, Nrange);
-            psU8  *sm = vm - offset;
+            psImageMaskType  *sm = vm - offset;
             psF32 *si = vi - offset;
             psF32 *sg = gauss - offset;
@@ -1171,5 +1171,5 @@
         int yMax = PS_MIN (j + Nrange + 1, Ny);
         for (int n = yMin; n < yMax; n++) {
-            psU8  *vm = mask->data.U8[n];
+            psImageMaskType  *vm = mask->data.PS_TYPE_IMAGE_MASK_DATA[n];
             psF32 *vi = image->data.F32[n];
             psF32 *vo = output->data.F32;
@@ -1214,11 +1214,11 @@
                                      const psImage *input, // Input image
                                      int start, int stop, // Range of rows
-                                     psMaskType maskVal, // Value to mask; NOTE subtle difference!
+                                     psImageMaskType maskVal, // Value to mask; NOTE subtle difference!
                                      int xMin, int xMax // Range in x for kernel
                                      )
 {
     // Dereference mask images
-    psMaskType **inputData = input->data.PS_TYPE_MASK_DATA;
-    psMaskType **targetData = target->data.PS_TYPE_MASK_DATA;
+    psImageMaskType **inputData = input->data.PS_TYPE_IMAGE_MASK_DATA;
+    psImageMaskType **targetData = target->data.PS_TYPE_IMAGE_MASK_DATA;
 
     int numCols = input->numCols;       // Number of columns
@@ -1241,5 +1241,5 @@
                 min = PS_MAX(0, min);
                 max = PS_MIN(numCols - 1, max);
-                memset(&targetData[y][min], 0xff, (max - min + 1) * PSELEMTYPE_SIZEOF(PS_TYPE_MASK));
+                memset(&targetData[y][min], 0xff, (max - min + 1) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK));
             }
         }
@@ -1247,5 +1247,5 @@
             // Mask from the minimum to the end of the row
             min = PS_MAX(0, min);
-            memset(&targetData[y][min], 0xff, (numCols - min) * PSELEMTYPE_SIZEOF(PS_TYPE_MASK));
+            memset(&targetData[y][min], 0xff, (numCols - min) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK));
         }
     }
@@ -1256,11 +1256,11 @@
                                      const psImage *input, // Input image
                                      int start, int stop, // Range of rows
-                                     psMaskType setVal, // Value to set; NOTE subtle difference!
+                                     psImageMaskType setVal, // Value to set; NOTE subtle difference!
                                      int yMin, int yMax // Range in y for kernel
                                      )
 {
     // Dereference mask images
-    psMaskType **inputData = input->data.PS_TYPE_MASK_DATA;
-    psMaskType **targetData = target->data.PS_TYPE_MASK_DATA;
+    psImageMaskType **inputData = input->data.PS_TYPE_IMAGE_MASK_DATA;
+    psImageMaskType **targetData = target->data.PS_TYPE_IMAGE_MASK_DATA;
 
     int numRows = input->numRows;       // Number of rows
@@ -1308,5 +1308,5 @@
     int start = PS_SCALAR_VALUE(args->data[2], S32); // Row/col to start at
     int stop = PS_SCALAR_VALUE(args->data[3], S32); // Row/col to stop at
-    psMaskType maskVal = PS_SCALAR_VALUE(args->data[4], U8); // Value to mask/set
+    psImageMaskType maskVal = PS_SCALAR_VALUE(args->data[4], PS_TYPE_IMAGE_MASK_DATA); // Value to mask/set
     int kernelMin = PS_SCALAR_VALUE(args->data[5], S32); // Minimum range for kernel
     int kernelMax = PS_SCALAR_VALUE(args->data[6], S32); // Maximum range for kernel
@@ -1317,12 +1317,12 @@
 }
 
-psImage *psImageConvolveMask(psImage *out, const psImage *mask, psMaskType maskVal,
-                             psMaskType setVal, int xMin, int xMax, int yMin, int yMax)
+psImage *psImageConvolveMask(psImage *out, const psImage *mask, psImageMaskType maskVal,
+                             psImageMaskType setVal, int xMin, int xMax, int yMin, int yMax)
 {
     PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
-    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
+    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
     if (out) {
         PS_ASSERT_IMAGE_NON_NULL(out, NULL);
-        PS_ASSERT_IMAGE_TYPE(out, PS_TYPE_MASK, NULL);
+        PS_ASSERT_IMAGE_TYPE(out, PS_TYPE_IMAGE_MASK, NULL);
         PS_ASSERT_IMAGES_SIZE_EQUAL(out, mask, NULL);
         if (out == mask && ((maskVal & setVal) || !setVal)) {
@@ -1354,5 +1354,5 @@
 
     // Propagate the non-masked values
-    out = (psImage*)psBinaryOp(out, (const psPtr)mask, "&", psScalarAlloc(~setVal, PS_TYPE_MASK));
+    out = (psImage*)psBinaryOp(out, (const psPtr)mask, "&", psScalarAlloc(~setVal, PS_TYPE_IMAGE_MASK));
 
     if (!setVal) {
@@ -1360,5 +1360,5 @@
     }
 
-    psImage *conv = psImageAlloc(numCols, numRows, PS_TYPE_MASK); // Temporary convolved image
+    psImage *conv = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); // Temporary convolved image
     psImageInit(conv, 0);
 
@@ -1377,5 +1377,5 @@
             PS_ARRAY_ADD_SCALAR(job->args, start, PS_TYPE_S32);
             PS_ARRAY_ADD_SCALAR(job->args, stop, PS_TYPE_S32);
-            PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_MASK);
+            PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK);
             PS_ARRAY_ADD_SCALAR(job->args, xMin, PS_TYPE_S32);
             PS_ARRAY_ADD_SCALAR(job->args, xMax, PS_TYPE_S32);
@@ -1415,5 +1415,5 @@
             PS_ARRAY_ADD_SCALAR(job->args, start, PS_TYPE_S32);
             PS_ARRAY_ADD_SCALAR(job->args, stop, PS_TYPE_S32);
-            PS_ARRAY_ADD_SCALAR(job->args, setVal, PS_TYPE_MASK);
+            PS_ARRAY_ADD_SCALAR(job->args, setVal, PS_TYPE_IMAGE_MASK);
             PS_ARRAY_ADD_SCALAR(job->args, yMin, PS_TYPE_S32);
             PS_ARRAY_ADD_SCALAR(job->args, yMax, PS_TYPE_S32);
@@ -1460,5 +1460,5 @@
                 min = PS_MAX(0, min);
                 max = PS_MIN(numCols - 1, max);
-                memset(&convData[y][min], 0xff, (max - min + 1) * PSELEMTYPE_SIZEOF(PS_TYPE_MASK));
+                memset(&convData[y][min], 0xff, (max - min + 1) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK));
             }
         }
@@ -1466,5 +1466,5 @@
             // Mask from the minimum to the end of the row
             min = PS_MAX(0, min);
-            memset(&convData[y][min], 0xff, (numCols - min) * PSELEMTYPE_SIZEOF(PS_TYPE_MASK));
+            memset(&convData[y][min], 0xff, (numCols - min) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK));
         }
     }
Index: trunk/psLib/src/imageops/psImageConvolve.h
===================================================================
--- trunk/psLib/src/imageops/psImageConvolve.h	(revision 21172)
+++ trunk/psLib/src/imageops/psImageConvolve.h	(revision 21183)
@@ -5,6 +5,6 @@
  * @author Robert DeSonia, MHPCC
  *
- * @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-11-26 00:43:12 $
+ * @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-27 06:39:37 $
  * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  */
@@ -148,6 +148,6 @@
 psImage *psImageConvolveMask(psImage *out, ///< Output image, or NULL
                              const psImage *mask, ///< Mask to convolve
-                             psMaskType maskVal, ///< Mask value to convolve
-                             psMaskType setVal, ///< Mask value to set; 0 to propagate maskVal
+                             psImageMaskType maskVal, ///< Mask value to convolve
+                             psImageMaskType setVal, ///< Mask value to set; 0 to propagate maskVal
                              int xMin, int xMax, int yMin, int yMax ///< Convolution bounds
     );
@@ -160,6 +160,6 @@
 psImage *psImageConvolveMaskDirect(psImage *out, ///< Output image, or NULL
                                    const psImage *mask, ///< Mask to convolve
-                                   psMaskType maskVal, ///< Mask value to convolve
-                                   psMaskType setVal, ///< Mask value to set; 0 to propagate maskVal
+                                   psImageMaskType maskVal, ///< Mask value to convolve
+                                   psImageMaskType setVal, ///< Mask value to set; 0 to propagate maskVal
                                    int xMin, int xMax, int yMin, int yMax ///< Convolution bounds
     );
@@ -174,6 +174,6 @@
 psImage *psImageConvolveMaskFFT(psImage *out, ///< Output image, or NULL
                                 const psImage *mask, ///< Mask to convolve
-                                psMaskType maskVal, ///< Mask value to convolve
-                                psMaskType setVal, ///< Mask value to set; 0 to use maskVal
+                                psImageMaskType maskVal, ///< Mask value to convolve
+                                psImageMaskType setVal, ///< Mask value to set; 0 to use maskVal
                                 int xMin, int xMax, int yMin, int yMax, ///< Convolution bounds
                                 float thresh ///< Threshold (0..1) for convolved floating-point image
@@ -201,5 +201,5 @@
     const psImage *image,               ///< Input image (F32 or F64)
     const psImage *mask,                ///< Mask image
-    psMaskType maskVal,                 ///< Mask value
+    psImageMaskType maskVal,		///< Mask value
     float sigma,                        ///< Width of the smoothing kernel (pixels)
     float numSigma,                     ///< Size of the smoothing box (sigma)
@@ -211,5 +211,5 @@
                                     const psImage *image,
                                     const psImage *mask,
-                                    psMaskType maskVal,
+                                    psImageMaskType maskVal,
                                     float sigma,
                                     float numSigma,
@@ -219,5 +219,5 @@
     psImage *image,                    ///< the image to be smoothed
     psImage *mask,                     ///< optional mask
-    psMaskType maskVal,
+    psImageMaskType maskVal,		///< masked bits
     double  sigma,                     ///< the width of the smoothing kernel in pixels
     double  Nsigma                     ///< the size of the smoothing box in sigmas
Index: trunk/psLib/src/imageops/psImageGeomManip.c
===================================================================
--- trunk/psLib/src/imageops/psImageGeomManip.c	(revision 21172)
+++ trunk/psLib/src/imageops/psImageGeomManip.c	(revision 21183)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-10-21 22:10:53 $
+ *  @version $Revision: 1.45 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-27 06:39:37 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -39,5 +39,5 @@
                       const psImage* in,
                       const psImage* mask,
-                      psMaskType maskVal,
+                      psImageMaskType maskVal,
                       int scale,
                       const psStats* stats)
@@ -47,8 +47,8 @@
     psS32 outRows;
     psS32 outCols;
-    psVector* vec;                     // vector to hold the values of a single bin.
-    psVector* maskVec = NULL;          // vector to hold the mask of a single bin.
-    psMaskType* maskData = NULL;
-    psStats* myStats;
+    psVector *vec;                     // vector to hold the values of a single bin.
+    psVector *maskVec = NULL;          // vector to hold the mask of a single bin.
+    psVectorMaskType *maskData = NULL;
+    psStats *myStats;
 
     if (in == NULL) {
@@ -86,16 +86,16 @@
 
     if (mask != NULL) {
-        if (mask->type.type != PS_TYPE_MASK) {
+        if (mask->type.type != PS_TYPE_IMAGE_MASK) {
             char* typeStr;
             PS_TYPE_NAME(typeStr,mask->type.type);
             psError(PS_ERR_BAD_PARAMETER_TYPE, true,
                     _("Input psImage mask type, %s, is not the supported mask datatype of %s."),
-                    typeStr, PS_TYPE_MASK_NAME);
+                    typeStr, PS_TYPE_IMAGE_MASK_NAME);
             psFree(out);
             psFree(vec);
             return NULL;
         }
-        maskVec = psVectorAllocEmpty(scale * scale, PS_TYPE_MASK);
-        maskData = maskVec->data.PS_TYPE_MASK_DATA;
+        maskVec = psVectorAllocEmpty(scale * scale, PS_TYPE_VECTOR_MASK);
+        maskData = maskVec->data.PS_TYPE_VECTOR_MASK_DATA;
     }
 
@@ -114,5 +114,5 @@
         ps##TYPE *outRowData; \
         ps##TYPE *vecData = vec->data.TYPE; \
-        psMaskType *inRowMask = NULL; \
+        psImageMaskType *inRowMask = NULL; \
         for (psS32 row = 0; row < outRows; row++) { \
             outRowData = out->data.TYPE[row]; \
@@ -126,9 +126,9 @@
                     ps##TYPE* inRowData = in->data.TYPE[inRow]; \
                     if (mask != NULL) { \
-                        inRowMask = mask->data.PS_TYPE_MASK_DATA[inRow]; \
+                        inRowMask = mask->data.PS_TYPE_IMAGE_MASK_DATA[inRow]; \
                     } \
                     for (psS32 inCol = inCurrentCol; inCol < inNextCol && inCol < inCols; inCol++) { \
                         if (maskData != NULL) { \
-                            maskData[n] = inRowMask[inCol]; \
+                            maskData[n] = (inRowMask[inCol] & maskVal); \
                         } \
                         vecData[n++] = inRowData[inCol]; \
@@ -139,5 +139,5 @@
                     maskVec->n = n; \
                 } \
-                psVectorStats(myStats, vec, NULL, maskVec, maskVal); \
+                 psVectorStats(myStats, vec, NULL, maskVec, 0xff); /* the mask vector has only 0 or 1 */ \
                 outRowData[col] = (ps##TYPE)psStatsGetValue(myStats, statistic); \
             } \
@@ -659,5 +659,5 @@
 
 bool psImageShiftMask(psImage **out, psImage **outMask, const psImage* in, const psImage *inMask,
-                      psMaskType maskVal, float dx, float dy, double exposed, psMaskType blank,
+                      psImageMaskType maskVal, float dx, float dy, double exposed, psImageMaskType blank,
                       psImageInterpolateMode mode)
 {
@@ -667,5 +667,5 @@
         PS_ASSERT_IMAGE_NON_NULL(inMask, false);
         PS_ASSERT_IMAGES_SIZE_EQUAL(in, inMask, false);
-        PS_ASSERT_IMAGE_TYPE(inMask, PS_TYPE_MASK, false);
+        PS_ASSERT_IMAGE_TYPE(inMask, PS_TYPE_IMAGE_MASK, false);
     }
 
@@ -675,5 +675,5 @@
     *out = psImageRecycle(*out, numCols, numRows, type);
     if (outMask) {
-        *outMask = psImageRecycle(*outMask, numCols, numRows, PS_TYPE_MASK);
+        *outMask = psImageRecycle(*outMask, numCols, numRows, PS_TYPE_IMAGE_MASK);
     }
 
@@ -702,10 +702,10 @@
     for (int row = 0; row < numRows; row++) { \
         ps##TYPE* outRow = (*out)->data.TYPE[row]; \
-        psMaskType *outMaskRow = (outMask ? (*outMask)->data.PS_TYPE_MASK_DATA[row] : NULL); \
+        psImageMaskType *outMaskRow = (outMask ? (*outMask)->data.PS_TYPE_IMAGE_MASK_DATA[row] : NULL); \
         float y = row + 0.5 - dy; \
         for (int col = 0; col < numCols; col++) { \
             float x = col + 0.5 - dx; \
             double value; \
-            psMaskType valueMask = 0; \
+            psImageMaskType valueMask = 0; \
             if (!psImageInterpolate(&value, NULL, &valueMask, x, y, interp)) { \
                 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image."); \
@@ -750,5 +750,5 @@
                           const psImage *input,
                           const psImage *inputMask,
-                          psMaskType inputMaskVal,
+                          psImageMaskType inputMaskVal,
                           const psPlaneTransform *outToIn,
                           psRegion region,
@@ -778,10 +778,10 @@
             return NULL;
         }
-        if (inputMask->type.type != PS_TYPE_MASK) {
+        if (inputMask->type.type != PS_TYPE_IMAGE_MASK) {
             char* typeStr;
             PS_TYPE_NAME(typeStr,inputMask->type.type);
             psError(PS_ERR_BAD_PARAMETER_TYPE, true,
                     _("Input psImage mask type, %s, is not the supported mask datatype of %s."),
-                    typeStr, PS_TYPE_MASK_NAME);
+                    typeStr, PS_TYPE_IMAGE_MASK_NAME);
             psFree(output);
             return NULL;
Index: trunk/psLib/src/imageops/psImageGeomManip.h
===================================================================
--- trunk/psLib/src/imageops/psImageGeomManip.h	(revision 21172)
+++ trunk/psLib/src/imageops/psImageGeomManip.h	(revision 21183)
@@ -6,6 +6,6 @@
  * @author Robert DeSonia, MHPCC
  *
- * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-03-11 00:41:30 $
+ * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-27 06:39:37 $
  * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  */
@@ -36,5 +36,5 @@
     const psImage* in,                 ///< input image
     const psImage* mask,               ///< mask for input image.  If NULL, no masking is done.
-    psMaskType maskVal,                ///< the bits to check in mask.
+    psImageMaskType maskVal,		///< the bits to check in mask.
     int scale,                         ///< the scale to rebin for each dimension
     const psStats* stats
@@ -106,8 +106,8 @@
     const psImage* in,                  ///< Input image
     const psImage *inMask,              ///< Input mask, or NULL
-    psMaskType maskVal,                 ///< Value to mask
+    psImageMaskType maskVal,		///< Value to mask
     float dx, float dy,                 ///< Shift to apply
     double exposed,                     ///< Value to give exposed pixels
-    psMaskType blank,                   ///< Mask value for exposed pixels
+    psImageMaskType blank,		///< Mask value for exposed pixels
     psImageInterpolateMode mode         ///< Interpolation mode
     );
@@ -159,5 +159,5 @@
     const psImage *input,              ///< psImage to apply transform to
     const psImage *inputMask,          ///< if not NULL, mask of input psImage
-    psMaskType inputMaskVal,           ///< masking value for inputMask
+    psImageMaskType inputMaskVal,	///< masking value for inputMask
     const psPlaneTransform *outToIn,   ///< the transform to apply
     psRegion region,                   ///< the size of the transformed image
Index: trunk/psLib/src/imageops/psImageInterpolate.c
===================================================================
--- trunk/psLib/src/imageops/psImageInterpolate.c	(revision 21172)
+++ trunk/psLib/src/imageops/psImageInterpolate.c	(revision 21183)
@@ -7,6 +7,6 @@
  *  @author Paul Price, IfA
  *
- *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-11-15 03:09:34 $
+ *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-27 06:39:37 $
  *
  *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
@@ -205,7 +205,7 @@
 psImageInterpolation *psImageInterpolationAlloc(psImageInterpolateMode mode,
                                                 const psImage *image, const psImage *variance,
-                                                const psImage *mask, psMaskType maskVal,
+                                                const psImage *mask, psImageMaskType maskVal,
                                                 double badImage, double badVariance,
-                                                psMaskType badMask, psMaskType poorMask,
+                                                psImageMaskType badMask, psImageMaskType poorMask,
                                                 float poorFrac, int numKernels)
 {
@@ -274,5 +274,5 @@
 // Interpolation engine for flat mode (nearest pixel)
 static inline psImageInterpolateStatus interpolateFlat(double *imageValue, double *varianceValue,
-                                                       psMaskType *maskValue, float x, float y,
+                                                       psImageMaskType *maskValue, float x, float y,
                                                        const psImageInterpolation *interp)
 {
@@ -331,5 +331,5 @@
         if (maskValue) {
             if (interp->mask) {
-                *maskValue = interp->mask->data.PS_TYPE_MASK_DATA[yInt][xInt];
+                *maskValue = interp->mask->data.PS_TYPE_IMAGE_MASK_DATA[yInt][xInt];
             } else {
                 *maskValue = 0;
@@ -456,5 +456,5 @@
 // Interpolation engine for separable interpolation kernels
 static psImageInterpolateStatus interpolateSeparable(double *imageValue, double *varianceValue,
-                                                     psMaskType *maskValue, float x, float y,
+                                                     psImageMaskType *maskValue, float x, float y,
                                                      const psImageInterpolation *interp)
 {
@@ -465,5 +465,5 @@
     const psImage *mask = interp->mask; // Image mask
     const psImage *variance = interp->variance; // Image variance
-    psMaskType maskVal = interp->maskVal; // Value to mask
+    psImageMaskType maskVal = interp->maskVal; // Value to mask
     bool wantVariance = variance && varianceValue; // Does the user want the variance value?
     bool haveMask = mask && maskVal; // Does the user want the variance value?
@@ -582,5 +582,5 @@
                   const ps##TYPE *imageData = &image->data.TYPE[yPix][xMin]; \
                   const ps##TYPE *varianceData = &variance->data.TYPE[yPix][xMin]; \
-                  const psMaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[yPix][xMin]; \
+                  const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[yPix][xMin]; \
                   const psF32 *xKernelData = xKernel; \
                   const psF32 *xKernel2Data = xKernel2; \
@@ -642,5 +642,5 @@
               /* Dereferenced versions of inputs */ \
               const ps##TYPE *imageData = &image->data.TYPE[yPix][xMin]; \
-              const psMaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[yPix][xMin]; \
+              const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[yPix][xMin]; \
               const psF32 *xKernelData = xKernel; \
               const psF32 *xKernel2Data = xKernel2; \
@@ -713,5 +713,5 @@
 // Interpolation engine for (separable) interpolation kernels
 static psImageInterpolateStatus interpolateKernel(double *imageValue, double *varianceValue,
-                                                  psMaskType *maskValue, float x, float y,
+                                                  psImageMaskType *maskValue, float x, float y,
                                                   const psImageInterpolation *interp)
 {
@@ -722,5 +722,5 @@
     const psImage *mask = interp->mask; // Image mask
     const psImage *variance = interp->variance; // Image variance
-    psMaskType maskVal = interp->maskVal; // Value to mask
+    psImageMaskType maskVal = interp->maskVal; // Value to mask
     bool wantVariance = variance && varianceValue; // Does the user want the variance value?
     bool haveMask = mask && maskVal; // Does the user want the variance value?
@@ -790,5 +790,5 @@
                       float kernelValue = kernel[j][i]; /* Value of kernel */ \
                       float kernelValue2 = PS_SQR(kernelValue); /* Square of kernel */ \
-                      if (mask->data.PS_TYPE_MASK_DATA[yPix][xPix] & maskVal) { \
+                      if (mask->data.PS_TYPE_IMAGE_MASK_DATA[yPix][xPix] & maskVal) { \
                           sumBad += kernelValue2; \
                       } else { \
@@ -820,5 +820,5 @@
                   float kernelValue = kernel[j][i]; /* Value of kernel */ \
                   float kernelValue2 = PS_SQR(kernelValue); /* Square of kernel */ \
-                  if (mask->data.PS_TYPE_MASK_DATA[yPix][xPix] & maskVal) { \
+                  if (mask->data.PS_TYPE_IMAGE_MASK_DATA[yPix][xPix] & maskVal) { \
                       sumBad += kernelValue2; \
                   } else { \
@@ -866,5 +866,5 @@
 
 
-psImageInterpolateStatus psImageInterpolate(double *imageValue, double *varianceValue, psMaskType *maskValue,
+psImageInterpolateStatus psImageInterpolate(double *imageValue, double *varianceValue, psImageMaskType *maskValue,
                                             float x, float y, const psImageInterpolation *interp)
 {
@@ -885,5 +885,5 @@
     if (maskValue && mask) {
         PS_ASSERT_IMAGE_NON_NULL(mask, PS_INTERPOLATE_STATUS_ERROR);
-        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, PS_INTERPOLATE_STATUS_ERROR);
+        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, PS_INTERPOLATE_STATUS_ERROR);
         psAssert(image->numCols == mask->numCols && image->numRows == mask->numRows, "Image and mask sizes");
     }
Index: trunk/psLib/src/imageops/psImageInterpolate.h
===================================================================
--- trunk/psLib/src/imageops/psImageInterpolate.h	(revision 21172)
+++ trunk/psLib/src/imageops/psImageInterpolate.h	(revision 21183)
@@ -7,6 +7,6 @@
  * @author Paul Price, Institute for Astronomy
  *
- * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-10-22 19:21:06 $
+ * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-27 06:39:37 $
  * Copyright 2004-2007 Institute for Astronomy, University of Hawaii
  */
@@ -50,9 +50,9 @@
     const psImage *variance;            ///< Variance image for interpolation
     const psImage *mask;                ///< Mask image for interpolation
-    psMaskType maskVal;                 ///< Value to mask
+    psImageMaskType maskVal;		///< Value to mask
     double badImage;                    ///< Image value if x,y location is not good
     double badVariance;                 ///< Variance value if x,y location is not good
-    psMaskType badMask;                 ///< Mask value to give bad pixels
-    psMaskType poorMask;                ///< Mask value to give poor pixels
+    psImageMaskType badMask;		///< Mask value to give bad pixels
+    psImageMaskType poorMask;		///< Mask value to give poor pixels
     float poorFrac;                     ///< Fraction of flux in bad pixels before output is marked bad
     bool shifting;                      ///< Shifting images? Don't interpolate if the shift is exact.
@@ -69,9 +69,9 @@
     const psImage *variance,            // Variance image
     const psImage *mask,                // Mask image
-    psMaskType maskVal,                 // Value to mask
+    psImageMaskType maskVal,                 // Value to mask
     double badImage,                    // Value for image if bad
     double badVariance,                 // Value for variance if bad
-    psMaskType badMask,                 // Mask value for bad pixels
-    psMaskType poorMask,                // Mask value for poor pixels
+    psImageMaskType badMask,                 // Mask value for bad pixels
+    psImageMaskType poorMask,                // Mask value for poor pixels
     float poorFrac,                     // Fraction of flux for question
     int numKernels                      // Number of interpolation kernels to pre-calculate
@@ -83,5 +83,5 @@
     double *imageValue,                 ///< Return value for image
     double *varianceValue,              ///< Return value for variance
-    psMaskType *maskValue,              ///< Return value for mask
+    psImageMaskType *maskValue,              ///< Return value for mask
     float x, float y,                   ///< Location to which to interpolate
     const psImageInterpolation *options ///< Options
Index: trunk/psLib/src/imageops/psImageMap.c
===================================================================
--- trunk/psLib/src/imageops/psImageMap.c	(revision 21172)
+++ trunk/psLib/src/imageops/psImageMap.c	(revision 21183)
@@ -7,6 +7,6 @@
  *  @author Eugene Magnier, IfA
  *
- *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2009-01-27 00:00:21 $
+ *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-27 06:39:37 $
  *
  *  Copyright 2007 Institute for Astronomy, University of Hawaii
@@ -145,5 +145,5 @@
     }
 
-    psImage *mask = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_MASK);
+    psImage *mask = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_IMAGE_MASK);
     psImage *xCoord = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_F32);
     psImage *yCoord = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_F32);
@@ -212,5 +212,5 @@
             // this will not in general be properly weighted...
             if (psVectorStats (map->stats, fCell, dfCell, NULL, 0)) {
-                mask->data.U8[iy][ix] = 0;
+                mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] = 0;
                 // XXX ensure only one option is selected, or save both position and width
                 map->map->data.F32[iy][ix] = psStatsGetValue (map->stats, map->stats->options);
@@ -224,5 +224,5 @@
                 yCoord->data.F32[iy][ix] = psStatsGetValue (meanStat, meanStat->options);
             } else {
-                mask->data.U8[iy][ix] = 1;
+                mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] = 1;
             }
 
@@ -353,5 +353,5 @@
 }
 
-psVector *psImageMapEvalVector(const psImageMap *map, const psVector *mask, psMaskType maskValue, const psVector *x, const psVector *y)
+psVector *psImageMapEvalVector(const psImageMap *map, const psVector *mask, psVectorMaskType maskValue, const psVector *x, const psVector *y)
 {
     PS_ASSERT_IMAGE_MAP_NON_NULL(map, NULL);
@@ -365,5 +365,5 @@
 
     for (int i = 0; i < x->n; i++) {
-      if (mask && (mask->data.U8[i] & maskValue)) {
+      if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) {
 	result->data.F32[i] = 0.0;
       } else {	
Index: trunk/psLib/src/imageops/psImageMapFit.c
===================================================================
--- trunk/psLib/src/imageops/psImageMapFit.c	(revision 21172)
+++ trunk/psLib/src/imageops/psImageMapFit.c	(revision 21183)
@@ -7,6 +7,6 @@
  *  @author Eugene Magnier, IfA
  *
- *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2009-01-27 00:00:21 $
+ *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-27 06:39:37 $
  *
  *  Copyright 2007 Institute for Astronomy, University of Hawaii
@@ -47,5 +47,5 @@
 
 // map defines the output image dimensions and scaling.
-bool psImageMapFit(psImageMap *map, const psVector *mask, psMaskType maskValue,
+bool psImageMapFit(psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
                    const psVector *x, const psVector *y, const psVector *f, const psVector *df)
 {
@@ -145,5 +145,5 @@
             for (int i = 0; i < x->n; i++) {
 
-                if (mask && (mask->data.U8[i] & maskValue)) continue;
+                if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) continue;
 
                 // base coordinate offset for this point (x,y) relative to this map element (n,m)
@@ -338,5 +338,5 @@
 
 // measure residuals on each pass and clip outliers based on stats
-bool psImageMapClipFit(psImageMap *map, psStats *stats, psVector *inMask, psMaskType maskValue,
+bool psImageMapClipFit(psImageMap *map, psStats *stats, psVector *inMask, psVectorMaskType maskValue,
                        const psVector *x, const psVector *y, const psVector *f, const psVector *df)
 {
@@ -377,5 +377,5 @@
     psVector *mask = inMask;
     if (!inMask) {
-        mask = psVectorAlloc (x->n, PS_TYPE_U8);
+        mask = psVectorAlloc (x->n, PS_TYPE_VECTOR_MASK);
         psVectorInit (mask, 0);
     }
@@ -429,5 +429,5 @@
         for (psS32 i = 0; i < resid->n; i++) {
             // XXX this prevents recovery of previously masked values
-            if (mask->data.U8[i] & maskValue) {
+            if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue) {
                 continue;
             }
@@ -435,5 +435,5 @@
             if ((resid->data.F32[i] - meanValue > maxClipValue) || (resid->data.F32[i] - meanValue < minClipValue)) {
                 psTrace("psLib.imageops", 6, "Masking element %d  : %f vs %f : resid is %f\n", i, f->data.F32[i], fit->data.F32[i], resid->data.F32[i]);
-                mask->data.U8[i] |= 0x01;
+                mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01;
                 continue;
             }
@@ -455,5 +455,5 @@
 
 // map defines the output image dimensions and scaling.
-bool psImageMapFit1DinY(psImageMap *map, const psVector *mask, psMaskType maskValue,
+bool psImageMapFit1DinY(psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
                         const psVector *x, const psVector *y, const psVector *f, const psVector *df)
 {
@@ -490,5 +490,5 @@
         for (int i = 0; i < y->n; i++) {
 
-            if (mask && (mask->data.U8[i] & maskValue)) continue;
+            if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) continue;
 
             float dy = psImageBinningGetRuffY (map->binning, y->data.F32[i]) - (m + 0.5);
@@ -603,5 +603,5 @@
 
 // map defines the output image dimensions and scaling.
-bool psImageMapFit1DinX(psImageMap *map, const psVector *mask, psMaskType maskValue,
+bool psImageMapFit1DinX(psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
                         const psVector *x, const psVector *y, const psVector *f, const psVector *df)
 {
@@ -638,5 +638,5 @@
         for (int i = 0; i < x->n; i++) {
 
-            if (mask && (mask->data.U8[i] & maskValue)) continue;
+            if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) continue;
 
             float dx = psImageBinningGetRuffX (map->binning, x->data.F32[i]) - (m + 0.5);
Index: trunk/psLib/src/imageops/psImageMapFit.h
===================================================================
--- trunk/psLib/src/imageops/psImageMapFit.h	(revision 21172)
+++ trunk/psLib/src/imageops/psImageMapFit.h	(revision 21183)
@@ -10,5 +10,5 @@
 bool psImageMapFit(psImageMap *map,
                    const psVector *mask,
-                   psMaskType maskValue,
+                   psVectorMaskType maskValue, // 
                    const psVector *x,
                    const psVector *y,
@@ -21,5 +21,5 @@
                        psStats *stats,
                        psVector *mask,  // WARNING: Mask is modified!
-                       psMaskType maskValue,
+                       psVectorMaskType maskValue,
                        const psVector *x,
                        const psVector *y,
@@ -30,5 +30,5 @@
 bool psImageMapFit1DinY(psImageMap *map,
                         const psVector *mask,
-                        psMaskType maskValue,
+                        psVectorMaskType maskValue,
                         const psVector *x,
                         const psVector *y,
@@ -39,5 +39,5 @@
 bool psImageMapFit1DinX(psImageMap *map,
                         const psVector *mask,
-                        psMaskType maskValue,
+                        psVectorMaskType maskValue,
                         const psVector *x,
                         const psVector *y,
Index: trunk/psLib/src/imageops/psImageMaskOps.c
===================================================================
--- trunk/psLib/src/imageops/psImageMaskOps.c	(revision 21172)
+++ trunk/psLib/src/imageops/psImageMaskOps.c	(revision 21183)
@@ -8,6 +8,6 @@
  *  @author David Robbins, MHPCC
  *
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-07-12 21:08:33 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-27 06:39:37 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -37,5 +37,5 @@
                        psRegion region,
                        const char *op,
-                       psMaskType maskValue)
+                       psImageMaskType maskValue)
 {
     if (image == NULL) {
@@ -53,5 +53,5 @@
 	  if ((i + image->col0) < region.x0) continue; \
 	  if ((i + image->col0) > region.x1) continue; /* is this correct (not >= ?) */ \
-	  image->data.PS_TYPE_MASK_DATA[j][i] OP maskValue; \
+	  image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] OP maskValue; \
 	} \
       }
@@ -84,5 +84,5 @@
                        psRegion region,
                        const char *op,
-                       psMaskType maskValue)
+                       psImageMaskType maskValue)
 {
     if (image == NULL) {
@@ -100,5 +100,5 @@
 	    (i + image->col0) < region.x0 || \
 	    (i + image->col0) > region.x1 ) { \
-	  image->data.PS_TYPE_MASK_DATA[j][i] OP maskValue; \
+	  image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] OP maskValue; \
 	} } }
 
@@ -131,5 +131,5 @@
                        double radius,
                        const char *op,
-                       psMaskType maskValue)
+                       psImageMaskType maskValue)
 {
     if (image == NULL) {
@@ -150,5 +150,5 @@
             r2 = PS_SQR(dx) + PS_SQR(dy); \
             if (r2 <= R2) { \
-	      image->data.PS_TYPE_MASK_DATA[iy][ix] OP maskValue; \
+	      image->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] OP maskValue; \
             } } }
 
@@ -182,5 +182,5 @@
                        double radius,
                        const char *op,
-                       psMaskType maskValue)
+                       psImageMaskType maskValue)
 {
 
@@ -201,5 +201,5 @@
             r2 = PS_SQR(dx) + PS_SQR(dy); \
             if (r2 > R2) { \
-	      image->data.PS_TYPE_MASK_DATA[iy][ix] OP maskValue; \
+	      image->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] OP maskValue; \
             } } }
 
@@ -228,7 +228,7 @@
 psImage *psImageGrowMask(psImage *out,
                          const psImage *in,
-                         psMaskType maskVal,
+                         psImageMaskType maskVal,
                          unsigned int growSize,
-                         psMaskType growVal)
+                         psImageMaskType growVal)
 {
     if (in == NULL) {
@@ -237,7 +237,7 @@
         return NULL;
     }
-    if (in->type.type != PS_TYPE_MASK) {
+    if (in->type.type != PS_TYPE_IMAGE_MASK) {
         psError(PS_ERR_BAD_PARAMETER_TYPE, true,
-                "Invalid input image.  Input image type must match psMaskType.\n");
+                "Invalid input image.  Input image type must match psImageMaskType.\n");
         return NULL;
     }
@@ -261,6 +261,6 @@
     for (k = 0; k < in->numRows; k++) {
         for (l = 0; l < in->numCols; l++) {
-            out->data.PS_TYPE_MASK_DATA[k][l] = in->data.PS_TYPE_MASK_DATA[k][l];
-            changed->data.PS_TYPE_MASK_DATA[k][l] = 0;
+            out->data.PS_TYPE_IMAGE_MASK_DATA[k][l] = in->data.PS_TYPE_IMAGE_MASK_DATA[k][l];
+            changed->data.PS_TYPE_IMAGE_MASK_DATA[k][l] = 0;
         }
     }
@@ -268,6 +268,6 @@
     for (int i = 0; i < in->numRows; i++) {
         for (int j = 0; j < in->numCols; j++) {
-            if ( (in->data.PS_TYPE_MASK_DATA[i][j] & maskVal) != 0 &&
-                    changed->data.PS_TYPE_MASK_DATA[i][j] == 0) {
+            if ( (in->data.PS_TYPE_IMAGE_MASK_DATA[i][j] & maskVal) != 0 &&
+                    changed->data.PS_TYPE_IMAGE_MASK_DATA[i][j] == 0) {
                 m = i - growSize;
                 if (m < 0) {
@@ -281,7 +281,7 @@
                     for (l = n; l <= (j + growSize) && l < in->numCols; l++) {
                         if (((k-i)*(k-i) + (l-j)*(l-j)) <= (growSize*growSize)) {
-                            out->data.PS_TYPE_MASK_DATA[k][l] |= growVal;
-                            if ( (in->data.PS_TYPE_MASK_DATA[i][j] & maskVal) == 0 ) {
-                                changed->data.PS_TYPE_MASK_DATA[k][l] = 1;
+                            out->data.PS_TYPE_IMAGE_MASK_DATA[k][l] |= growVal;
+                            if ( (in->data.PS_TYPE_IMAGE_MASK_DATA[i][j] & maskVal) == 0 ) {
+                                changed->data.PS_TYPE_IMAGE_MASK_DATA[k][l] = 1;
                             }
                         }
Index: trunk/psLib/src/imageops/psImageMaskOps.h
===================================================================
--- trunk/psLib/src/imageops/psImageMaskOps.h	(revision 21172)
+++ trunk/psLib/src/imageops/psImageMaskOps.h	(revision 21183)
@@ -6,6 +6,6 @@
  * @author David Robbins, MHPCC
  *
- * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-01-23 22:47:23 $
+ * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-27 06:39:37 $
  *
  * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -32,5 +32,5 @@
     psRegion region,                   ///< the specified region
     const char *op,                    ///< the logical operation
-    psMaskType maskValue               ///< the specified bits
+    psImageMaskType maskValue		///< the specified bits
 );
 
@@ -44,5 +44,5 @@
     psRegion region,                   ///< the specified region
     const char *op,                    ///< the logical operation
-    psMaskType maskValue               ///< the specified bits
+    psImageMaskType maskValue		///< the specified bits
 );
 
@@ -58,5 +58,5 @@
     double radius,                     ///< the radius of the specified circle
     const char *op,                    ///< the logical operation
-    psMaskType maskValue               ///< the specified bits
+    psImageMaskType maskValue		///< the specified bits
 );
 
@@ -72,5 +72,5 @@
     double radius,                     ///< the radius of the specified circle
     const char *op,                    ///< the logical operation
-    psMaskType maskValue               ///< the specified bits
+    psImageMaskType maskValue		///< the specified bits
 );
 
@@ -89,7 +89,7 @@
     psImage *out,                      ///< the image to set and return
     const psImage *in,                 ///< the input to image
-    psMaskType maskVal,                ///< the specified mask value
+    psImageMaskType maskVal,		///< the specified mask value
     unsigned int growSize,             ///< the range of values from maskVal
-    psMaskType growVal                 ///< the output value to set
+    psImageMaskType growVal		///< the output value to set
 );
 
Index: trunk/psLib/src/imageops/psImagePixelExtract.c
===================================================================
--- trunk/psLib/src/imageops/psImagePixelExtract.c	(revision 21172)
+++ trunk/psLib/src/imageops/psImagePixelExtract.c	(revision 21183)
@@ -8,6 +8,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-10-22 02:10:37 $
+ *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-27 06:39:37 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -206,5 +206,5 @@
                        const psImage* input,
                        const psImage* mask,
-                       psMaskType maskVal,
+                       psImageMaskType maskVal,
                        psRegion region,
                        psImageCutDirection direction,
@@ -357,10 +357,10 @@
             return NULL;
         }
-        if (mask->type.type != PS_TYPE_MASK) {
+        if (mask->type.type != PS_TYPE_IMAGE_MASK) {
             char* typeStr;
             PS_TYPE_NAME(typeStr,mask->type.type);
             psError(PS_ERR_BAD_PARAMETER_TYPE, true,
                     _("Input psImage mask type, %s, is not the supported mask datatype of %s."),
-                    typeStr, PS_TYPE_MASK_NAME);
+                    typeStr, PS_TYPE_IMAGE_MASK_NAME);
             psFree(out);
             return NULL;
@@ -394,5 +394,5 @@
         psVector* imgVec = psVectorAlloc(numRows, type);
         psVector* maskVec = NULL;
-        psMaskType* maskData = NULL;
+        psImageMaskType* maskData = NULL;
         psPixelCoord* outPosition = NULL;
 
@@ -416,25 +416,29 @@
 
         if (mask != NULL) {
-            maskVec = psVectorAlloc(numRows, mask->type.type);
-        }
-        #define PSIMAGE_CUT_VERTICAL(TYPE) \
+            maskVec = psVectorAlloc(numRows, PS_TYPE_VECTOR_MASK);
+        }
+
+#define PSIMAGE_CUT_VERTICAL(TYPE) \
     case PS_TYPE_##TYPE: { \
-            psMaskType* maskVecData = NULL; \
-            for (psS32 c=col0;c<col1;c++) { \
+            psVectorMaskType* maskVecData = NULL; \
+            for (psS32 c = col0; c < col1; c++) { \
                 ps##TYPE *imgData = input->data.TYPE[row0] + c; \
                 ps##TYPE *imgVecData = imgVec->data.TYPE; \
                 if (maskVec != NULL) { \
-                    maskVecData = maskVec->data.U8; \
-                    maskData = (psMaskType* )(mask->data.U8[row0]) + c; \
+                    maskVecData = maskVec->data.PS_TYPE_VECTOR_MASK_DATA; \
+                    maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[row0][c]; /* XXX double check this... */ \
+                    /** old entry: maskData = (psMaskType* )(mask->data.PS_TYPE_IMAGE_MASK_DATA[row0]) + c; */ \
                 } \
-                for (psS32 r=row0;r<row1;r++) { \
-                    *(imgVecData++) = *imgData; \
+                for (psS32 r = row0; r < row1; r++) { \
+                   *imgVecData = *imgData; \
+                    imgVecData ++; \
                     imgData += inCols; \
                     if (maskVecData != NULL) { \
-                        *(maskVecData++) = *maskData; \
+                        *maskVecData = (*maskData & maskVal); \
+                        maskVecData ++; \
                         maskData += inCols; \
                     } \
                 } \
-                psVectorStats(myStats,imgVec,NULL,maskVec,maskVal); \
+                psVectorStats(myStats, imgVec, NULL, maskVec, 0xff); \
                 *outData = psStatsGetValue(myStats, statistic); \
                 if (outPosition != NULL) { \
@@ -471,6 +475,8 @@
         psFree(imgVec);
         psFree(maskVec);
+
     } else if (direction == PS_CUT_Y_POS || direction == PS_CUT_Y_NEG) {
         // Cut in Y direction
+        // XXX use this if we drop the hackish stuff below: psVector* imgVec = psVectorAlloc(numCols, type);
         psVector* imgVec = NULL;
         psVector* maskVec = NULL;
@@ -479,12 +485,10 @@
 
         // fill in psVector to fake out the statistics functions.
+	// XXX EAM : this seems rather hackish: just use the needed psVectorAlloc (like above)?
         imgVec = psAlloc(sizeof(psVector));
         imgVec->type = input->type;
         P_PSVECTOR_SET_NALLOC(imgVec,numCols);
-        if (mask != NULL) {
-            maskVec = psAlloc(sizeof(psVector));
-            maskVec->type = mask->type;
-            P_PSVECTOR_SET_NALLOC(maskVec,numCols);
-        }
+        imgVec->n = imgVec->nalloc;
+
         // recycle output to make a proper sized/type output structure
         // n.b. type is double as that is the type given for all stats in
@@ -492,6 +496,4 @@
         out = psVectorRecycle(out, numRows, PS_TYPE_F64);
         out->n = numRows;
-        imgVec->n = imgVec->nalloc;
-        maskVec->n = maskVec->nalloc;
         if (coords != NULL) {
             coords = psPixelsRealloc(coords, numRows);
@@ -507,12 +509,30 @@
         }
 
+        if (mask != NULL) {
+            maskVec = psVectorAlloc(numRows, PS_TYPE_VECTOR_MASK);
+	    // XXX the old code (below) faked out the mask vector
+            // maskVec = psAlloc(sizeof(psVector));
+            // maskVec->type = mask->type;
+            // P_PSVECTOR_SET_NALLOC(maskVec,numCols);
+	    // maskVec->n = maskVec->nalloc;
+        }
+
         for (psS32 r = row0; r < row1; r++) {
             // point the vector struct to the
             // data to calculate the stats
             imgVec->data.U8 = (psPtr )(input->data.U8[r] + col0 * elementSize);
+
+	    // set the vector mask pixels based on the image pixels
             if (maskVec != NULL) {
-                maskVec->data.U8 = (psPtr )(mask->data.U8[r] + col0 * sizeof(psMaskType));
-            }
-            psVectorStats(myStats, imgVec, NULL, maskVec, maskVal);
+		psVectorMaskType *maskVecData = maskVec->data.PS_TYPE_VECTOR_MASK_DATA;
+		psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[r][col0];
+                for (psS32 c = col0; c < col1; c++) { 
+		    *maskVecData = (*maskData & maskVal); 
+		    maskVecData ++; 
+		    maskData ++;
+                } 
+	    }
+
+            psVectorStats(myStats, imgVec, NULL, maskVec, 0xff);
             *outData = psStatsGetValue(myStats, statistic);
             if (outPosition != NULL) {
@@ -544,5 +564,5 @@
                      const psImage* input,
                      const psImage* mask,
-                     psMaskType maskVal,
+                     psImageMaskType maskVal,
                      psRegion region,
                      unsigned int nSamples,
@@ -651,10 +671,10 @@
             return NULL;
         }
-        if (mask->type.type != PS_TYPE_MASK) {
+        if (mask->type.type != PS_TYPE_IMAGE_MASK) {
             char* typeStr;
             PS_TYPE_NAME(typeStr,mask->type.type);
             psError(PS_ERR_BAD_PARAMETER_TYPE, true,
                     _("Input psImage mask type, %s, is not the supported mask datatype of %s."),
-                    typeStr, PS_TYPE_MASK_NAME);
+                    typeStr, PS_TYPE_IMAGE_MASK_NAME);
             psFree(out);
             return NULL;
@@ -739,5 +759,5 @@
                            const psImage* input,
                            const psImage* mask,
-                           psMaskType maskVal,
+                           psImageMaskType maskVal,
                            float x,
                            float y,
@@ -765,10 +785,10 @@
             return NULL;
         }
-        if (mask->type.type != PS_TYPE_MASK) {
+        if (mask->type.type != PS_TYPE_IMAGE_MASK) {
             char* typeStr;
             PS_TYPE_NAME(typeStr,mask->type.type);
             psError(PS_ERR_BAD_PARAMETER_TYPE, true,
                     _("Input psImage mask type, %s, is not the supported mask datatype of %s."),
-                    typeStr, PS_TYPE_MASK_NAME);
+                    typeStr, PS_TYPE_IMAGE_MASK_NAME);
             psFree(out);
             return NULL;
@@ -868,5 +888,5 @@
         if (mask != NULL) {
             bufferMask[lcv] = psVectorAllocEmpty(1+4*(rSq[lcv+1]-rSq[lcv]),
-                                                 PS_TYPE_MASK);
+                                                 PS_TYPE_VECTOR_MASK);
         }
     }
@@ -877,7 +897,7 @@
     for (psS32 row=startRow; row <= endRow; row++) {
         psF32* inRow = input->data.F32[row];
-        psMaskType* maskRow = NULL;
+        psImageMaskType* maskRow = NULL;
         if (mask != NULL) {
-            maskRow = mask->data.PS_TYPE_MASK_DATA[row];
+            maskRow = mask->data.PS_TYPE_IMAGE_MASK_DATA[row];
         }
         for (psS32 col=startCol; col <= endCol; col++) {
@@ -899,5 +919,5 @@
 
                     if (maskRow != NULL) {
-                        bufferMask[r]->data.PS_TYPE_MASK_DATA[n] = maskRow[col];
+                        bufferMask[r]->data.PS_TYPE_VECTOR_MASK_DATA[n] = (maskRow[col] & maskVal);
                         bufferMask[r]->n = n+1;
                     }
@@ -913,5 +933,5 @@
 
     for (psS32 r = 0; r < numOut; r++) {
-        psVectorStats(myStats,buffer[r], NULL, bufferMask[r],maskVal);
+        psVectorStats(myStats, buffer[r], NULL, bufferMask[r], 0xff);
         outData[r] = psStatsGetValue(myStats, statistic);
     }
Index: trunk/psLib/src/imageops/psImagePixelExtract.h
===================================================================
--- trunk/psLib/src/imageops/psImagePixelExtract.h	(revision 21172)
+++ trunk/psLib/src/imageops/psImagePixelExtract.h	(revision 21183)
@@ -5,6 +5,6 @@
  * @author Robert DeSonia, MHPCC
  *
- * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-01-23 22:47:23 $
+ * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-27 06:39:37 $
  *
  * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -84,5 +84,5 @@
     const psImage* input,              ///< the input image in which to perform the slice
     const psImage* mask,               ///< the mask for the input image.
-    psMaskType maskVal,                ///< the mask value to apply to the mask
+    psImageMaskType maskVal,		///< the mask value to apply to the mask
     psRegion region,                   ///< the slice region
     psImageCutDirection direction,     ///< the slice dimension and direction
@@ -112,5 +112,5 @@
     const psImage* input,              ///< the input image in which to perform the cut
     const psImage* mask,               ///< the mask for the input image.
-    psMaskType maskVal,                ///< the mask value to apply to the mask
+    psImageMaskType maskVal,		///< the mask value to apply to the mask
     psRegion region,                   ///< the start and end points to cut along
     unsigned int nSamples,             ///< the number of samples along the cut
@@ -135,5 +135,5 @@
     const psImage* input,              ///< the input image in which to perform the cut
     const psImage* mask,               ///< the mask for the input image.
-    psMaskType maskVal,                ///< the mask value to apply to the mask
+    psImageMaskType maskVal,		///< the mask value to apply to the mask
     float x,                           ///< the column of the center of the cut circle
     float y,                           ///< the row of the center of the cut circle
Index: trunk/psLib/src/imageops/psImagePixelInterpolate.c
===================================================================
--- trunk/psLib/src/imageops/psImagePixelInterpolate.c	(revision 21172)
+++ trunk/psLib/src/imageops/psImagePixelInterpolate.c	(revision 21183)
@@ -11,6 +11,6 @@
  *  @author Eugene Magnier, IfA
  *
- *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-10-09 19:25:44 $
+ *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-27 06:39:37 $
  *
  *  Copyright 2007 Institute for Astronomy, University of Hawaii
@@ -54,5 +54,5 @@
 		    /* do not test self */ \
 		    if (!jx && !jy) { continue; } \
-		    if (mask->data.PS_TYPE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } \
+		    if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } \
 		    nGood ++; \
 		} \
@@ -67,5 +67,5 @@
 // just the mask, the output image contains enum values which define the type of interpolation which
 // can be performed
-psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, psMaskType maskVal) {
+psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, psImageMaskType maskVal) {
 
     psImage *result = psImageAlloc (mask->numCols, mask->numRows, PS_TYPE_S32);
@@ -79,5 +79,5 @@
 
 	    // state of the good pixels (unmasked)
-	    if (!(mask->data.PS_TYPE_MASK_DATA[iy][ix] & maskVal)) { 
+	    if (!(mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskVal)) { 
 		// count good neighbor pixels (+ self)
 		int nGood = 0;
@@ -94,5 +94,5 @@
 			if (jx + ix < 0) { continue; }
 			if (jx + ix >= mask->numCols) { continue; }
-			if (mask->data.PS_TYPE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
+			if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
 			nGood ++;
 			minX = PS_MIN (minX, jx);
@@ -137,5 +137,5 @@
 
 // interpolate the poor pixels using the available options
-bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, psMaskType maskVal) {
+bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, psImageMaskType maskVal) {
 
     assert (image->numCols == state->numCols);
@@ -185,5 +185,5 @@
 			  if (!jx && !jy) { continue; } 
 			  // skip masked pixels
-			  if (mask->data.PS_TYPE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
+			  if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
 			  x->data.F32[n] = jx;
 			  y->data.F32[n] = jy;
@@ -241,5 +241,5 @@
     
 // interpolate the good pixels to their true centers
-bool psImagePixelInterpolateCenter (psImage *value, psImage *xCoord, psImage *yCoord, psImage *state, psImage *mask, psMaskType maskVal) {
+bool psImagePixelInterpolateCenter (psImage *value, psImage *xCoord, psImage *yCoord, psImage *state, psImage *mask, psImageMaskType maskVal) {
 
     assert (value->numCols == state->numCols);
@@ -299,5 +299,5 @@
 			  if (jx + ix >= value->numCols) { continue; } 
 			  // skip masked pixels
-			  if (mask->data.PS_TYPE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
+			  if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
 			  x->data.F32[n] = xCoord->data.F32[iy+jy][ix+jx];
 			  y->data.F32[n] = yCoord->data.F32[iy+jy][ix+jx];
@@ -331,5 +331,5 @@
 			  if (jx + ix >= value->numCols) { continue; } 
 			  // skip masked pixels
-			  if (mask->data.PS_TYPE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
+			  if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
 			  x->data.F32[n] = xCoord->data.F32[iy+jy][ix+jx];
 			  y->data.F32[n] = yCoord->data.F32[iy+jy][ix+jx];
@@ -363,5 +363,5 @@
     for (int iy = 0; iy < value->numRows; iy++) {
 	for (int ix = 0; ix < value->numCols; ix++) {
-	  if (mask->data.PS_TYPE_MASK_DATA[iy][ix] & maskVal) { continue; }
+	  if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskVal) { continue; }
 	  value->data.F32[iy][ix] = output->data.F32[iy][ix];
 	}
Index: trunk/psLib/src/imageops/psImagePixelInterpolate.h
===================================================================
--- trunk/psLib/src/imageops/psImagePixelInterpolate.h	(revision 21172)
+++ trunk/psLib/src/imageops/psImagePixelInterpolate.h	(revision 21183)
@@ -7,6 +7,6 @@
  *  @author Eugene Magnier, IfA
  *
- *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-09-20 23:54:25 $
+ *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-27 06:39:37 $
  *
  *  Copyright 2007 Institute for Astronomy, University of Hawaii
@@ -34,7 +34,7 @@
 } psImagePixelInterpolateType;
 
-psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, psMaskType maskVal);
-bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, psMaskType maskVal);
-bool psImagePixelInterpolateCenter (psImage *value, psImage *xCoord, psImage *yCoord, psImage *state, psImage *mask, psMaskType maskVal);
+psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, psImageMaskType maskVal);
+bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, psImageMaskType maskVal);
+bool psImagePixelInterpolateCenter (psImage *value, psImage *xCoord, psImage *yCoord, psImage *state, psImage *mask, psImageMaskType maskVal);
 
 /// @}
Index: trunk/psLib/src/imageops/psImageStats.c
===================================================================
--- trunk/psLib/src/imageops/psImageStats.c	(revision 21172)
+++ trunk/psLib/src/imageops/psImageStats.c	(revision 21183)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.106 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-03-14 00:39:50 $
+ *  @version $Revision: 1.107 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-27 06:39:37 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -53,5 +53,5 @@
                       const psImage* in,
                       const psImage* mask,
-                      psMaskType maskVal)
+                      psImageMaskType maskVal)
 {
     psVector *junkData = NULL;
@@ -62,7 +62,70 @@
     PS_ASSERT_IMAGE_NON_NULL(in, false)
     if (mask != NULL) {
-        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_U8, false);
+        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false);
         PS_ASSERT_IMAGES_SIZE_EQUAL(in, mask, false);
     }
+
+    if (in->parent == NULL) {
+        // stuff the image data into a psVector struct.
+	// XXX this is a bit hackish: does it save much time? (avoids a Nx*Ny alloc)
+        junkData = (psVector *) psAlloc(sizeof(psVector));
+        junkData->type = in->type;
+        P_PSVECTOR_SET_NALLOC(junkData,in->numRows * in->numCols);
+        junkData->n = junkData->nalloc;
+        junkData->data.U8 = in->data.V[0];      // since psImage data is contiguous...
+    } else {
+        // image not necessarily contiguous
+        int numRows = in->numRows;
+        int numCols = in->numCols;
+        int rowSize = numCols * (PSELEMTYPE_SIZEOF(in->type.type));
+
+        junkData = psVectorAlloc(numRows*numCols, in->type.type);
+
+        psU8* data = junkData->data.U8;
+        for (int row = 0; row < numRows; row++) {
+            memcpy(data, in->data.V[row], rowSize);
+            data += rowSize;
+        }
+    }
+
+    if (mask != NULL) {
+	// image not necessarily contiguous, generate a temp vector to hold the full image
+	int numRows = mask->numRows;
+	int numCols = mask->numCols;
+
+	junkMask = psVectorAlloc(numRows*numCols, PS_TYPE_VECTOR_MASK);
+
+	psVectorMaskType *data = junkMask->data.PS_TYPE_VECTOR_MASK_DATA;
+	for (int row = 0, nVect = 0; row < numRows; row++) {
+	    for (int col = 0; col < numCols; col++, nVect++) {
+		data[nVect] = (mask->data.PS_TYPE_IMAGE_MASK_DATA[row][col] & maskVal);
+	    }
+	}
+    }
+
+    psVectorStats(stats, junkData, NULL, junkMask, 0xff);
+
+    psFree(junkMask);
+    psFree(junkData);
+    return true;
+}
+
+/*****************************************************************************
+NOTE: We assume that the psHistogram structure out has already been allocated
+and initialized.
+ *****************************************************************************/
+bool psImageHistogram(psHistogram* out,
+                              const psImage* in,
+                              const psImage* mask,
+                              psImageMaskType maskVal)
+{
+    PS_ASSERT_PTR_NON_NULL(out, false);
+    PS_ASSERT_PTR_NON_NULL(in, false);
+    if (mask != NULL) {
+        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false);
+        PS_ASSERT_IMAGES_SIZE_EQUAL(in, mask, false);
+    }
+    psVector* junkData = NULL;
+    psVector* junkMask = NULL;
 
     if (in->parent == NULL) {
@@ -89,96 +152,16 @@
 
     if (mask != NULL) {
-        if (mask->parent == NULL) {
-            // stuff the mask data into a psVector struct.
-            junkMask = psAlloc(sizeof(psVector));
-            junkMask->type = mask->type;
-            P_PSVECTOR_SET_NALLOC(junkMask,mask->numRows * mask->numCols);
-            junkMask->n = junkMask->nalloc;
-            junkMask->data.U8 = mask->data.V[0];
-        } else {
-            // image not necessarily contiguous
-            int numRows = mask->numRows;
-            int numCols = mask->numCols;
-            int rowSize = numCols * (PSELEMTYPE_SIZEOF(mask->type.type));
-
-            junkMask = psVectorAlloc(numRows*numCols, mask->type.type);
-
-            psU8* data = junkMask->data.U8;
-            for (int row = 0; row < numRows; row++) {
-                memcpy(data, mask->data.V[row], rowSize);
-                data += rowSize;
-            }
-        }
-    }
-
-    psVectorStats(stats, junkData, NULL, junkMask, maskVal);
-
-    psFree(junkMask);
-    psFree(junkData);
-    return true;
-}
-
-/*****************************************************************************
-NOTE: We assume that the psHistogram structure out has already been allocated
-and initialized.
- *****************************************************************************/
-bool psImageHistogram(psHistogram* out,
-                              const psImage* in,
-                              const psImage* mask,
-                              psMaskType maskVal)
-{
-    PS_ASSERT_PTR_NON_NULL(out, false);
-    PS_ASSERT_PTR_NON_NULL(in, false);
-    if (mask != NULL) {
-        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_U8, false);
-        PS_ASSERT_IMAGES_SIZE_EQUAL(in, mask, false);
-    }
-    psVector* junkData = NULL;
-    psVector* junkMask = NULL;
-
-    if (in->parent == NULL) {
-        // stuff the image data into a psVector struct.
-        junkData = (psVector *) psAlloc(sizeof(psVector));
-        junkData->type = in->type;
-        P_PSVECTOR_SET_NALLOC(junkData,in->numRows * in->numCols);
-        junkData->n = junkData->nalloc;
-        junkData->data.U8 = in->data.V[0];      // since psImage data is contiguous...
-    } else {
-        // image not necessarily contiguous
-        int numRows = in->numRows;
-        int numCols = in->numCols;
-        int rowSize = numCols * (PSELEMTYPE_SIZEOF(in->type.type));
-
-        junkData = psVectorAlloc(numRows*numCols, in->type.type);
-
-        psU8* data = junkData->data.U8;
-        for (int row = 0; row < numRows; row++) {
-            memcpy(data, in->data.V[row], rowSize);
-            data += rowSize;
-        }
-    }
-
-    if (mask != NULL) {
-        if (mask->parent == NULL) {
-            // stuff the mask data into a psVector struct.
-            junkMask = psAlloc(sizeof(psVector));
-            junkMask->type = mask->type;
-            P_PSVECTOR_SET_NALLOC(junkMask,mask->numRows * mask->numCols);
-            junkMask->n = junkMask->nalloc;
-            junkMask->data.U8 = mask->data.V[0];
-        } else {
-            // image not necessarily contiguous
-            int numRows = mask->numRows;
-            int numCols = mask->numCols;
-            int rowSize = numCols * (PSELEMTYPE_SIZEOF(mask->type.type));
-
-            junkMask = psVectorAlloc(numRows*numCols, mask->type.type);
-
-            psU8* data = junkMask->data.U8;
-            for (int row = 0; row < numRows; row++) {
-                memcpy(data, mask->data.V[row], rowSize);
-                data += rowSize;
-            }
-        }
+	// image not necessarily contiguous; vector & image mask types do not match
+	int numRows = mask->numRows;
+	int numCols = mask->numCols;
+
+	junkMask = psVectorAlloc(numRows*numCols, PS_TYPE_VECTOR_MASK);
+
+	psVectorMaskType *data = junkMask->data.PS_TYPE_VECTOR_MASK_DATA;
+	for (int row = 0, nVect = 0; row < numRows; row++) {
+	    for (int col = 0; col < numCols; col++, nVect++) {
+		data[nVect] = (mask->data.PS_TYPE_IMAGE_MASK_DATA[row][col] & maskVal);
+	    }
+	}
     }
 
@@ -472,5 +455,5 @@
 long psImageCountPixelMask (psImage *mask,
                             psRegion region,
-                            psMaskType value)
+                            psImageMaskType value)
 {
     long Npixels = 0;
@@ -479,5 +462,4 @@
     int x1 = 0;
     int y1 = 0;
-    psElemType type;
 
     // this is not a valid error: a psRegion with ranges outside the valid pixels
@@ -608,34 +590,30 @@
     y1 = row1;
 
-    type = mask->type.type;
-    if (type != PS_TYPE_MASK) {
-        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
-                "psImage type does not match the specified psMaskType!\n");
-        return -1;
-    }
-
+# define PS_IMAGE_COUNT_PIXEL_MASK(NAME,TYPE) \
+    case PS_TYPE_##NAME: \
+        for (long j = y0; j < y1; j++) { \
+            for (long i = x0; i < x1; i++) { \
+                if (mask->data.TYPE[j][i] & value) { \
+                    Npixels ++; \
+                } \
+            } \
+        } \
+        break;
+
+    psElemType type = mask->type.type;
     switch (type) {
-    case PS_TYPE_U8:
-    case PS_TYPE_U16:
-        for (long j = y0; j < y1; j++) {
-            for (long i = x0; i < x1; i++) {
-                if (mask->data.PS_TYPE_MASK_DATA[j][i] & value) {
-                    Npixels ++;
-                }
-            }
-        }
-        break;
-    case PS_TYPE_S8:
-    case PS_TYPE_S16:
-    case PS_TYPE_S32:
-    case PS_TYPE_S64:
-    case PS_TYPE_U32:
-    case PS_TYPE_U64:
-    case PS_TYPE_F32:
-    case PS_TYPE_F64:
+	PS_IMAGE_COUNT_PIXEL_MASK(U8, U8);
+	PS_IMAGE_COUNT_PIXEL_MASK(U16,U16);
+	PS_IMAGE_COUNT_PIXEL_MASK(U32,U32);
+	PS_IMAGE_COUNT_PIXEL_MASK(U64,U64);
+	PS_IMAGE_COUNT_PIXEL_MASK(S8, S8);
+	PS_IMAGE_COUNT_PIXEL_MASK(S16,S16);
+	PS_IMAGE_COUNT_PIXEL_MASK(S32,S32);
+	PS_IMAGE_COUNT_PIXEL_MASK(S64,S64);
+
     default:
         // XXX this should include the mask type (as a string)
         psError(PS_ERR_BAD_PARAMETER_TYPE, true,
-                _("Input psImage mask type is not a supported mask datatype"));
+                _("Input psImage is an unsupported datatype"));
 
         return -1;
Index: trunk/psLib/src/imageops/psImageStats.h
===================================================================
--- trunk/psLib/src/imageops/psImageStats.h	(revision 21172)
+++ trunk/psLib/src/imageops/psImageStats.h	(revision 21183)
@@ -9,6 +9,6 @@
  * @author GLG, MHPCC
  *
- * @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-02-13 03:01:23 $
+ * @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-27 06:39:37 $
  * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  */
@@ -42,5 +42,5 @@
     const psImage* in,                 ///< image (or subimage) to calculate stats
     const psImage* mask,               ///< mask data for image (NULL ok)
-    psMaskType maskVal                 ///< mask value for mask
+    psImageMaskType maskVal		///< mask value for mask
 );
 
@@ -57,5 +57,5 @@
     const psImage* in,                 ///< Image data to be histogramed.
     const psImage* mask,               ///< mask data for image (NULL ok)
-    psMaskType maskVal                 ///< mask Mask for mask
+    psImageMaskType maskVal		///< mask Mask for mask
 );
 
@@ -97,5 +97,5 @@
     psImage *mask,                     ///< input image to count
     psRegion region,                   ///< input region of image
-    psMaskType value                   ///< the mask value to satisfy
+    psImageMaskType value		///< the mask value to satisfy
 );
 
Index: trunk/psLib/src/mask.notes.txt
===================================================================
--- trunk/psLib/src/mask.notes.txt	(revision 21183)
+++ trunk/psLib/src/mask.notes.txt	(revision 21183)
@@ -0,0 +1,123 @@
+
+20081227 : upgrading masks
+
+  *** Additional notes ***
+
+  * psVectorCountPixelMask : fixed to use psU64 as input comparison value against any int-type input vector
+  * psImageBackground (and calling functions in psLib/src/fits) do not pass the image mask pixels to psStats, but instead pass a subset based on the mask: this is safe from psImageMaskType != psVectorMaskType
+
+  *** Conversion Plan ***
+
+  * start with the pure psVectorMaskType 
+  * do the psImageMaskType -> track places where the image values are converted to vectors
+
+  *** Initial Thoughts ***
+
+  We have decided to upgrade the image masks to 16bits.  This has a
+  variety of impacts and implications.  
+
+  * Currently, we have a single abstract mask type "psMaskType", which
+    is currently assigned to psU8.  Associated with this are the
+    PS_TYPE_MASK (== PS_TYPE_U8), PS_TYPE_MASK_DATA (== U8), and
+    PS_TYPE_MASK_NAME (== "psU8") macros.  
+
+  * The abstract names have not been used ubiquitously, so places with
+    U8 used explicitly need to be fixed.  Not all cases of U8 must be
+    changed: some places are simply referring to one of the types.
+
+  * In fact, we have several classes of masks, so we need to expand
+    the psMaskType to appropriate version for the different classes:
+    
+    ** There are mask images used to distinguish different types of
+    bad pixels or other reasons to include / exclude pixels from an
+    analysis.  We can call these psImageMaskType (and equiv).
+
+    ** There are mask vectors used to include or exclude elements of a
+       vector from operations.  We can call these psVectorMaskType
+       (etc).
+
+    ** There are various other random masks which are used (eg,
+       polynomial coeffs).  We will keep psMaskType for these cases.
+
+  The file U8.txt contains all of the psLib file with a U8 in them.
+  I am putting notes in that file as I fix the various files.  
+
+  Here are the related macros and types defined in psType.h:
+
+#define PS_TYPE_MASK PS_TYPE_U8        /**< the psElemType to use for mask image */
+#define PS_TYPE_MASK_DATA U8           /**< the data member to use for mask image */
+#define PS_TYPE_MASK_NAME "psU8"       /**< the data type for mask as a string */
+
+typedef psU8 psMaskType;               ///< the C datatype for a mask image
+
+#define PS_TYPE_IMAGE_MASK PS_TYPE_U8        /**< the psElemType to use for mask image */
+#define PS_TYPE_IMAGE_MASK_DATA U8           /**< the data member to use for mask image */
+#define PS_TYPE_IMAGE_MASK_NAME "psU8"       /**< the data type for mask as a string */
+
+typedef psU8 psImageMaskType;               ///< the C datatype for a mask image
+
+#define PS_TYPE_VECTOR_MASK PS_TYPE_U8        /**< the psElemType to use for mask image */
+#define PS_TYPE_VECTOR_MASK_DATA U8           /**< the data member to use for mask image */
+#define PS_TYPE_VECTOR_MASK_NAME "psU8"       /**< the data type for mask as a string */
+
+typedef psU8 psVectorMaskType;			  ///< the C datatype for a mask image
+
+
+---
+    #define PS_METADATA_ITEM_COPY_CASE(NAME,TYPE) \
+case PS_DATA_##NAME: \
+    newItem = p_psMetadataItemAlloc(file, lineno, func, in->name, PS_DATA_##NAME, in->comment, in->data.TYPE); \
+    break; \
+
+./mathtypes/psVector.c  -- DONE psVectorCountMaskPixels was modified to use any type
+./math/psHistogram.c -- DONE mask vectors need to be fixed (mostly explicit U8; double check)
+./math/psMinimizeLMM.c -- DONE param mask vectors need to be fixed (mostly explicit U8; double check)
+./math/psMinimizeLMM_ND.c -- DONE param mask vectors need to be fixed (mostly explicit U8; double check)
+./math/psMinimizePolyFit.c -- DONE mask vectors need to be fixed (mostly explicit U8; double check)
+./math/psMinimizePowell.c -- DONE mask vectors need to be fixed (mostly explicit U8; double check)
+./math/psPolynomialMD.c -- DONE mask vectors need to be fixed (mostly explicit U8; double check)
+./math/psPolynomialUtils.c --  DONE mask vectors need to be fixed (mostly explicit U8; double check)
+./math/psStats.c -- DONE mask vectors need to be fixed (mostly explicit U8; double check) -- XXX redefine MASK_MARK?
+./math/psClip.c -- DONE vector masks
+./imageops/psImageMapFit.c -- DONE vector masks need to use psVectorMaskType
+
+./fits/psFitsImage.c -- DONE various image masks need to be fixed
+./fits/psFitsScale.c -- DONE various image masks need to be fixed
+./imageops/psImageBackground.c -- DONE various image masks need to be fixed
+./imageops/psImageConvolve.c -- DONE various image masks need to be fixed
+./imageops/psImageGeomManip.c -- DONE various image masks need to be fixed
+./imageops/psImageInterpolate.c -- DONE image masks need to be updated.
+./imageops/psImageMap.c -- DONE image map mask is u8, should be psImageMaskType
+./imageops/psImagePixelExtract.c -- DONE : partially cleaned up psImageSlice to create vector mask; currently uses hackish coding to avoid allocating and assigning a vector
+./imageops/psImageStats.c -- DONE : some issues : image mask needs to be reconciled with fixes to psStats
+./fft/psImageFFT.c -- DONE image masks
+./imageops/psImageMaskOps.c -- DONE image masks
+./imageops/psImagePixelInterpolate.c -- DONE image masks
+./math/psPolynomial.c -- DONE psMaskType is used for coeffMask, OK?
+./types/psPixels.c -- DONE image masks
+
+# ./math/psPolynomialMetadata.c -- probably OK
+# ./types/psBitSet.c -- nothing needs to be changed
+# ./math/psMathUtils.c -- nothing needs to be changed
+# ./math/psUnaryOp.c  -- nothing needs to be changed
+# ./mathtypes/psImage.c  -- nothing needs to be changed
+# ./mathtypes/psScalar.c  -- nothing needs to be changed
+# ./types/psArguments.c  -- nothing needs to be changed
+# ./types/psLookupTable.c  -- nothing needs to be changed
+# ./types/psMetadata.c  -- nothing needs to be changed
+# ./types/psMetadataConfig.c  -- nothing needs to be changed
+# ./types/psMetadataItemCompare.c  -- nothing needs to be changed
+# ./types/psMetadataItemParse.c  -- nothing needs to be changed
+# ./types/psTree.c  -- nothing needs to be changed
+# ./db/psDB.c -- nothing needs to be changed
+# ./fits/psFits.c -- nothing needs to be changed
+# ./fits/psFitsHeader.c -- nothing needs to be changed
+# ./fits/psFitsTable.c -- nothing needs to be changed
+# ./imageops/psImagePixelManip.c  -- nothing needs to be changed
+# ./imageops/psImageStructManip.c  -- nothing needs to be changed
+# ./jpeg/psImageJpeg.c  -- nothing needs to be changed (U8 used for 24bit colors; required!)
+# ./math/psBinaryOp.c  -- nothing needs to be changed
+# ./math/psCompare.c  -- nothing needs to be changed
+# ./math/psMD5.c  -- nothing needs to be changed (U8 used for hash is OK)
+# ./math/psMathUtils.c  -- nothing needs to be changed
+# ./math/psMatrix.c  -- nothing needs to be changed
Index: trunk/psLib/src/math/psClip.c
===================================================================
--- trunk/psLib/src/math/psClip.c	(revision 21172)
+++ trunk/psLib/src/math/psClip.c	(revision 21183)
@@ -22,5 +22,5 @@
 
 psClipParams *psClipParamsAlloc(psStatsOptions meanStat, psStatsOptions stdevStat,
-                                psMaskType masked, psMaskType clipped)
+                                psVectorMaskType masked, psVectorMaskType clipped)
 {
     psClipParams *params = psAlloc(sizeof(psClipParams)); // Clip parameters
@@ -48,5 +48,5 @@
     PS_ASSERT_VECTOR_NON_NULL(values, -1);
     PS_ASSERT_VECTOR_NON_NULL(mask, -1);
-    PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_MASK, -1);
+    PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, -1);
     PS_ASSERT_PTR(params, -1);
     PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, -1);
@@ -62,8 +62,8 @@
     }
 
-    psMaskType masked = params->masked; // Indicates masked values
-    psMaskType clipped = params->clipped; // Indicates clipped values
+    psVectorMaskType masked = params->masked; // Indicates masked values
+    psVectorMaskType clipped = params->clipped; // Indicates clipped values
     masked |= clipped;                  // Make sure we're also masking clipped values
-    psMaskType *maskData = mask->data.PS_TYPE_MASK_DATA; // Dereference mask
+    psVectorMaskType *maskData = mask->data.PS_TYPE_VECTOR_MASK_DATA; // Dereference mask
     long totalMasked = 0;               // Total number of pixels masked
 
@@ -120,5 +120,5 @@
     PS_ASSERT_VECTOR_NON_NULL(values, -1);
     PS_ASSERT_VECTOR_NON_NULL(mask, -1);
-    PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_MASK, -1);
+    PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, -1);
     PS_ASSERT_PTR(params, -1);
     PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, -1);
@@ -141,6 +141,6 @@
     }
 
-    psMaskType masked = params->masked; // Indicates masked values
-    psMaskType clipped = params->clipped; // Indicates clipped values
+    psVectorMaskType masked = params->masked; // Indicates masked values
+    psVectorMaskType clipped = params->clipped; // Indicates clipped values
     masked |= clipped;                  // Make sure we're also masking clipped values
 
@@ -158,5 +158,5 @@
 case PS_TYPE_##TYPE: { \
         ps##TYPE *valuesData = values->data.TYPE; /* Dereference for speed */ \
-        psMaskType *maskData = mask->data.PS_TYPE_MASK_DATA; /* Dereference mask for speed */ \
+        psVectorMaskType *maskData = mask->data.PS_TYPE_VECTOR_MASK_DATA; /* Dereference mask for speed */ \
         if (errors) { \
             ps##TYPE *errorsData = errors->data.TYPE; \
Index: trunk/psLib/src/math/psClip.h
===================================================================
--- trunk/psLib/src/math/psClip.h	(revision 21172)
+++ trunk/psLib/src/math/psClip.h	(revision 21183)
@@ -4,6 +4,6 @@
  * @author Paul Price, IfA.
  *
- * $Revision: 1.5 $ $Name: not supported by cvs2svn $
- * $Date: 2007-08-09 01:40:07 $
+ * $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ * $Date: 2009-01-27 06:39:38 $
  * Copyright 2007 Institute for Astronomy, University of Hawaii
  */
@@ -25,6 +25,6 @@
     int iter;                           ///< Number of rejection iterations; unused by psClip functions
     float rej;                          ///< Rejection limit (standard deviations)
-    psMaskType masked;                  ///< Mask value for entries already masked
-    psMaskType clipped;                 ///< Mask value to give to clipped entries
+    psVectorMaskType masked;                  ///< Mask value for entries already masked
+    psVectorMaskType clipped;                 ///< Mask value to give to clipped entries
     double mean;                        ///< Resultant mean
     double stdev;                       ///< Resultant stdev
@@ -35,6 +35,6 @@
 psClipParams *psClipParamsAlloc(psStatsOptions meanStat, ///< Stats option to use for mean
                                 psStatsOptions stdevStat, ///< Stats option to use for standard deviation
-                                psMaskType masked, ///< Mask value for entries already masked
-                                psMaskType clipped ///< Mask value to give to clipped entries
+                                psVectorMaskType masked, ///< Mask value for entries already masked
+                                psVectorMaskType clipped ///< Mask value to give to clipped entries
     ) PS_ATTR_MALLOC;
 
Index: trunk/psLib/src/math/psConstants.h
===================================================================
--- trunk/psLib/src/math/psConstants.h	(revision 21172)
+++ trunk/psLib/src/math/psConstants.h	(revision 21183)
@@ -5,6 +5,6 @@
  * @author GLG, MHPCC
  *
- * @version $Revision: 1.96 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-03-18 18:25:00 $
+ * @version $Revision: 1.97 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-27 06:39:38 $
  *
  * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -67,6 +67,8 @@
 
 // These defines for bitwise opertaions are necessary to yield results of the proper size (use instead of ~)
-#define PS_NOT_U8(A)(UCHAR_MAX-(A)) // Perform bitwise NOT on A which is of type U8
-#define PS_NOT_U16(A)(USHORT_MAX-(A)) // Perform bitwaise NOT on A which is of type U16
+#define PS_NOT_U8(A)(UINT8_MAX-(A)) // Perform bitwise NOT on A which is of type U8
+#define PS_NOT_U16(A)(UINT16_MAX-(A)) // Perform bitwaise NOT on A which is of type U16
+#define PS_NOT_U32(A)(UINT32_MAX-(A)) // Perform bitwise NOT on A which is of type U8
+#define PS_NOT_U64(A)(UINT64_MAX-(A)) // Perform bitwaise NOT on A which is of type U16
 
 /// @}
Index: trunk/psLib/src/math/psHistogram.c
===================================================================
--- trunk/psLib/src/math/psHistogram.c	(revision 21172)
+++ trunk/psLib/src/math/psHistogram.c	(revision 21183)
@@ -5,6 +5,6 @@
  *  @author GLG (MHPCC), EAM (IfA)
  *
- *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-05-07 23:11:30 $
+ *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-27 06:39:38 $
  *
  *  Copyright 2006 IfA, University of Hawaii
@@ -231,5 +231,5 @@
                                const psVector* errors,
                                const psVector* mask,
-                               psMaskType maskVal)
+                               psVectorMaskType maskVal)
 {
     psTrace("psLib.math", 3, "---- %s() begin  ----\n", __func__);
@@ -244,5 +244,5 @@
     if (mask) {
         PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, false);
-        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
+        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
     }
     if (errors) {
@@ -274,5 +274,5 @@
     for (long i = 0; i < inF32->n; i++) {
         // Check if this pixel is masked, and if so, skip it.
-        if (!mask || (mask && (!(mask->data.U8[i] & maskVal)))) {
+        if (!mask || (mask && (!(mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal)))) {
             if (inF32->data.F32[i] < out->bounds->data.F32[0]) {
                 // If this pixel is below minimum value, count it, then skip.
Index: trunk/psLib/src/math/psHistogram.h
===================================================================
--- trunk/psLib/src/math/psHistogram.h	(revision 21172)
+++ trunk/psLib/src/math/psHistogram.h	(revision 21183)
@@ -7,6 +7,6 @@
  * @author GLG, MHPCC
  *
- * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-08-09 01:40:07 $
+ * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-27 06:39:38 $
  *
  * Copyright 2004-2005 IfA, University of Hawaii
@@ -88,6 +88,6 @@
     const psVector* errors,            ///< Errors
     const psVector* mask,              ///< Mask dat for input vector
-    psMaskType maskVal                 ///< Mask value
-);
+    psVectorMaskType maskVal		///< Mask value
+    );
 
 /// @}
Index: trunk/psLib/src/math/psMinimizeLMM.c
===================================================================
--- trunk/psLib/src/math/psMinimizeLMM.c	(revision 21172)
+++ trunk/psLib/src/math/psMinimizeLMM.c	(revision 21183)
@@ -10,6 +10,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-10-02 20:49:22 $
+ *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-27 06:39:38 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -74,5 +74,5 @@
     PS_ASSERT_VECTOR_TYPE(params,    PS_TYPE_F32,  false);
     if (paramMask) {
-        PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_MASK, false);
+        PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false);
     }
 
@@ -113,5 +113,5 @@
     // set tmpBeta values which are not masked
     for (int j = 0, n = 0; j < params->n; j++) {
-	if (paramMask && (paramMask->data.U8[j])) continue;
+	if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue;
 	tmpBeta->data.F32[j] = Beta->data.F32[n];
 	n++;
@@ -120,5 +120,5 @@
     // apply Beta to get new Params values
     for (int j = 0; j < params->n; j++) {
-        if (paramMask && (paramMask->data.U8[j])) {
+        if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) {
             Params->data.F32[j] = params->data.F32[j];
             continue;
@@ -140,5 +140,5 @@
     // apply tmpBeta after limits have been checked
     for (int j = 0, n = 0; j < params->n; j++) {
-	if (paramMask && (paramMask->data.U8[j])) continue;
+	if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue;
 	Beta->data.F32[n] = tmpBeta->data.F32[j];
 	n++;
@@ -269,5 +269,5 @@
     PS_ASSERT_VECTOR_TYPE(params, PS_TYPE_F32, false);
     if (paramMask) {
-        PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_MASK, false);
+        PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false);
     }
 
@@ -297,10 +297,10 @@
 	// we track alpha,beta and params,deriv separately
         for (int j = 0, J = 0; j < params->n; j++) {
-            if (paramMask && (paramMask->data.U8[j])) continue;
+            if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue;
 
             weight = deriv->data.F32[j] * dy->data.F32[i];
 
             for (int k = 0, K = 0; k <= j; k++) {
-                if (paramMask && (paramMask->data.U8[k])) continue;
+                if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[k])) continue;
                 alpha->data.F32[J][K] += weight * deriv->data.F32[k];
 		K++;
@@ -351,5 +351,5 @@
         paramMask = constraint->paramMask;
         if (paramMask != NULL) {
-            PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_U8, false);
+            PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false);
             PS_ASSERT_VECTORS_SIZE_EQUAL(params, paramMask, false);
         }
@@ -493,10 +493,10 @@
 	psImageInit (covar, 0.0);
 	for (int j = 0, J = 0; j < params->n; j++) {
-	    if (paramMask && (paramMask->data.U8[j])) {
+	    if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) {
 		covar->data.F32[j][j] = 1.0;
 		continue;
 	    }
 	    for (int k = 0, K = 0; k < params->n; k++) {
-		if (paramMask && (paramMask->data.U8[k])) continue;
+		if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[k])) continue;
 		covar->data.F32[j][k] = Alpha->data.F32[J][K];
 		K++;
@@ -535,5 +535,5 @@
 	nParams = 0;
 	for (int i = 0; i < paramMask->n; i++) {
-	    if (paramMask->data.U8[i]) continue;
+	    if (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue;
 	    nParams ++;
 	}
Index: trunk/psLib/src/math/psMinimizeLMM_ND.c
===================================================================
--- trunk/psLib/src/math/psMinimizeLMM_ND.c	(revision 21172)
+++ trunk/psLib/src/math/psMinimizeLMM_ND.c	(revision 21183)
@@ -8,6 +8,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-04-11 08:01:29 $
+ *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-27 06:39:38 $
  *
  *  Copyright 2007 Institute for Astronomy, University of Hawaii
@@ -55,5 +55,5 @@
         paramMask = constraint->paramMask;
         if (paramMask != NULL) {
-            PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_U8, false);
+            PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false);
             PS_ASSERT_VECTORS_SIZE_EQUAL(params, paramMask, false);
         }
@@ -201,10 +201,10 @@
 	psImageInit (covar, 0.0);
 	for (int j = 0, J = 0; j < params->n; j++) {
-	    if (paramMask && (paramMask->data.U8[j])) {
+	    if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) {
 		covar->data.F32[j][j] = 1.0;
 		continue;
 	    }
 	    for (int k = 0, K = 0; k < params->n; k++) {
-		if (paramMask && (paramMask->data.U8[k])) continue;
+		if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[k])) continue;
 		covar->data.F32[j][k] = Alpha->data.F32[J][K];
 		K++;
@@ -251,5 +251,5 @@
     PS_ASSERT_VECTOR_TYPE(params,    PS_TYPE_F32,  false);
     if (paramMask) {
-        PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_MASK, false);
+        PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false);
     }
 
@@ -282,5 +282,5 @@
     // set tmpBeta values which are not masked
     for (int j = 0, n = 0; j < params->n; j++) {
-	if (paramMask && (paramMask->data.U8[j])) continue;
+	if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue;
 	tmpBeta->data.F32[j] = Beta->data.F32[n];
 	n++;
@@ -289,5 +289,5 @@
     // apply Beta to get new Params values
     for (int j = 0; j < params->n; j++) {
-        if (paramMask && (paramMask->data.U8[j])) {
+        if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) {
             Params->data.F32[j] = params->data.F32[j];
             continue;
@@ -309,5 +309,5 @@
     // apply tmpBeta after limits have been checked
     for (int j = 0, n = 0; j < params->n; j++) {
-	if (paramMask && (paramMask->data.U8[j])) continue;
+	if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue;
 	Beta->data.F32[n] = tmpBeta->data.F32[j];
 	n++;
@@ -438,5 +438,5 @@
     PS_ASSERT_VECTOR_TYPE(params, PS_TYPE_F32, false);
     if (paramMask) {
-        PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_MASK, false);
+        PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false);
     }
 
@@ -474,10 +474,10 @@
 	// we track alpha,beta and params,deriv separately
         for (int j = 0, J = 0; j < params->n; j++) {
-            if (paramMask && (paramMask->data.U8[j])) continue;
+            if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue;
 
             weight = deriv->data.F32[j] * dy->data.F32[i];
 
             for (int k = 0, K = 0; k <= j; k++) {
-                if (paramMask && (paramMask->data.U8[k])) continue;
+                if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[k])) continue;
                 alpha->data.F32[J][K] += weight * deriv->data.F32[k];
 		K++;
@@ -512,5 +512,5 @@
 	nParams = 0;
 	for (int i = 0; i < paramMask->n; i++) {
-	    if (paramMask->data.U8[i]) continue;
+	    if (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue;
 	    nParams ++;
 	}
Index: trunk/psLib/src/math/psMinimizePolyFit.c
===================================================================
--- trunk/psLib/src/math/psMinimizePolyFit.c	(revision 21172)
+++ trunk/psLib/src/math/psMinimizePolyFit.c	(revision 21183)
@@ -10,6 +10,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-09-02 19:03:38 $
+ *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-27 06:39:38 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -307,5 +307,5 @@
     psPolynomial1D* myPoly,
     const psVector *mask,
-    psMaskType maskValue,
+    psVectorMaskType maskValue,
     const psVector* y,
     const psVector* yErr,
@@ -326,5 +326,5 @@
     if (mask != NULL) {
         PS_ASSERT_VECTORS_SIZE_EQUAL(y, mask, NULL);
-        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, NULL);
+        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, NULL);
     }
 
@@ -354,9 +354,9 @@
     psF64 **matrix = A->data.F64;       // Least-squares matrix
     psF64 *vector = B->data.F64;        // Least-squares vector
-    psU8 *dataMask = NULL;              // Mask for data
+    psVectorMaskType *dataMask = NULL;              // Mask for data
     if (mask) {
-        dataMask = mask->data.U8;
-    }
-    psU8 *coeffMask = myPoly->coeffMask;      // Mask for polynomial terms
+        dataMask = mask->data.PS_TYPE_VECTOR_MASK_DATA;
+    }
+    psMaskType *coeffMask = myPoly->coeffMask;      // Mask for polynomial terms
     psF64 *yData = y->data.F64;         // Coordinate data
     psF64 *yErrData = NULL;             // Errors in the coordinate
@@ -473,5 +473,5 @@
     psPolynomial1D* myPoly,
     const psVector *mask,
-    psMaskType maskValue,
+    psVectorMaskType maskValue,
     const psVector *f,
     const psVector *fErr,
@@ -484,5 +484,5 @@
     if (mask) {
         PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false);
-        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
+        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
     }
     if (x) {
@@ -529,9 +529,9 @@
 
     // Dereference some pointers for speed in the loop
-    psU8 *dataMask = NULL;              // Dereferenced version of mask for data points
+    psVectorMaskType *dataMask = NULL;              // Dereferenced version of mask for data points
     if (mask) {
-        dataMask = mask->data.U8;
-    }
-    psU8 *coeffMask = myPoly->coeffMask;      // Dereferenced version of mask for polynomial terms
+        dataMask = mask->data.PS_TYPE_VECTOR_MASK_DATA;
+    }
+    psMaskType *coeffMask = myPoly->coeffMask;      // Dereferenced version of mask for polynomial terms
     psF64 *ordinates = NULL;            // Dereferenced version of ordinate data
     if (x) {
@@ -698,5 +698,5 @@
     psPolynomial1D *poly,
     const psVector *mask,
-    psMaskType maskValue,
+    psVectorMaskType maskValue,
     const psVector *f,
     const psVector *fErr,
@@ -711,5 +711,5 @@
     if (mask != NULL) {
         PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false);
-        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
+        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
     }
     if (fErr != NULL) {
@@ -782,5 +782,5 @@
     psStats *stats,
     const psVector *mask,
-    psMaskType maskValue,
+    psVectorMaskType maskValue,
     const psVector *f,
     const psVector *fErr,
@@ -794,5 +794,5 @@
     PS_ASSERT_VECTOR_NON_NULL(mask, false);
     PS_ASSERT_VECTORS_SIZE_EQUAL(mask, f, false);
-    PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
+    PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
 
     if (fErr != NULL) {
@@ -862,5 +862,5 @@
             if (mask != NULL) {
                 for (psS32 i = 0 ; i < mask->n ; i++) {
-                    psTrace("psLib.math", 6,  "mask[%d] is %d\n", i, mask->data.U8[i]);
+                    psTrace("psLib.math", 6,  "mask[%d] is %d\n", i, mask->data.PS_TYPE_VECTOR_MASK_DATA[i]);
                 }
             }
@@ -895,5 +895,5 @@
             if (mask != NULL) {
                 for (psS32 i = 0 ; i < mask->n ; i++) {
-                    if (!((mask != NULL) && (mask->data.U8[i] & maskValue))) {
+                    if (!((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue))) {
                         psTrace("psLib.math", 6,  "(f, fit)[%d] is (%f, %f).  resid is (%f)\n",
                                 i, f->data.F32[i], fit->data.F32[i], resid->data.F64[i]);
@@ -922,5 +922,5 @@
         // recovery is not allowed with this scheme
         for (psS32 i = 0; i < resid->n; i++) {
-            if ((mask != NULL) && (mask->data.U8[i] & maskValue)) {
+            if ((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) {
                 continue;
             }
@@ -936,5 +936,5 @@
 
                 if (mask != NULL) {
-                    mask->data.U8[i] |= 0x01;
+                    mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01;
                 }
                 continue;
@@ -979,5 +979,5 @@
     psPolynomial2D* myPoly,
     const psVector* mask,
-    psMaskType maskValue,
+    psVectorMaskType maskValue,
     const psVector *f,
     const psVector *fErr,
@@ -1003,5 +1003,5 @@
     if (mask != NULL) {
         PS_ASSERT_VECTORS_SIZE_EQUAL(y, mask, false);
-        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
+        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
     }
 
@@ -1026,8 +1026,8 @@
     psF64 **matrix = A->data.F64;       // Dereference the least-squares matrix
     psF64 *vector = B->data.F64;        // Dereference the least-squares vector
-    psU8 **coeffMask = myPoly->coeffMask;     // Dereference mask for polynomial terms
-    psU8 *dataMask = NULL;              // Dereference mask for data
+    psMaskType **coeffMask = myPoly->coeffMask;     // Dereference mask for polynomial terms
+    psVectorMaskType *dataMask = NULL;              // Dereference mask for data
     if (mask) {
-        dataMask = mask->data.U8;
+        dataMask = mask->data.PS_TYPE_VECTOR_MASK_DATA;
     }
     psF64 *xData = x->data.F64;         // Dereference x
@@ -1162,5 +1162,5 @@
     psPolynomial2D *poly,
     const psVector *mask,
-    psMaskType maskValue,
+    psVectorMaskType maskValue,
     const psVector *f,
     const psVector *fErr,
@@ -1179,5 +1179,5 @@
     if (mask != NULL) {
         PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false);
-        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
+        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
     }
     if (fErr != NULL) {
@@ -1231,5 +1231,5 @@
     psStats *stats,
     const psVector *mask,
-    psMaskType maskValue,
+    psVectorMaskType maskValue,
     const psVector *f,
     const psVector *fErr,
@@ -1254,5 +1254,5 @@
 
     PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false);
-    PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
+    PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
 
     if (fErr != NULL) {
@@ -1300,5 +1300,5 @@
             if (mask != NULL) {
                 for (psS32 i = 0 ; i < mask->n ; i++) {
-                    psTrace("psLib.math", 7,  "mask[%d] is %d\n", i, mask->data.U8[i]);
+                    psTrace("psLib.math", 7,  "mask[%d] is %d\n", i, mask->data.PS_TYPE_VECTOR_MASK_DATA[i]);
                 }
             }
@@ -1329,5 +1329,5 @@
             if (mask != NULL) {
                 for (psS32 i = 0 ; i < mask->n ; i++) {
-                    if (!((mask != NULL) && (mask->data.U8[i] & maskValue))) {
+                    if (!((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue))) {
                         psTrace("psLib.math", 7,  "point %d at %f %f : value, fit : %f  %f resid: %f\n",
                                 i, x->data.F32[i], y->data.F32[i], f->data.F32[i], fit->data.F32[i], resid->data.F64[i]);
@@ -1356,5 +1356,5 @@
         // recovery is not allowed with this scheme
         for (psS32 i = 0; i < resid->n; i++) {
-            if ((mask != NULL) && (mask->data.U8[i] & maskValue)) {
+            if ((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) {
                 continue;
             }
@@ -1370,5 +1370,5 @@
 
                 if (mask != NULL) {
-                    mask->data.U8[i] |= 0x01;
+                    mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01;
                 }
                 continue;
@@ -1403,5 +1403,5 @@
     psPolynomial3D* myPoly,
     const psVector* mask,
-    psMaskType maskValue,
+    psVectorMaskType maskValue,
     const psVector *f,
     const psVector *fErr,
@@ -1433,5 +1433,5 @@
     if (mask != NULL) {
         PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false);
-        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
+        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
     }
 
@@ -1464,9 +1464,9 @@
         fErrData = fErr->data.F64;
     }
-    psU8 *dataMask = NULL;              // Mask for data
+    psVectorMaskType *dataMask = NULL;              // Mask for data
     if (mask) {
-        dataMask = mask->data.U8;
-    }
-    psU8 ***coeffMask = myPoly->coeffMask;    // Mask for polynomial terms
+        dataMask = mask->data.PS_TYPE_VECTOR_MASK_DATA;
+    }
+    psMaskType ***coeffMask = myPoly->coeffMask;    // Mask for polynomial terms
     int nYZterm = nYterm * nZterm;      // Multiplication of the numbers, to calculate the index
 
@@ -1603,5 +1603,5 @@
     psPolynomial3D *poly,
     const psVector *mask,
-    psMaskType maskValue,
+    psVectorMaskType maskValue,
     const psVector *f,
     const psVector *fErr,
@@ -1623,5 +1623,5 @@
     if (mask != NULL) {
         PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false);
-        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
+        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
     }
     if (fErr != NULL) {
@@ -1677,5 +1677,5 @@
     psStats *stats,
     const psVector *mask,
-    psMaskType maskValue,
+    psVectorMaskType maskValue,
     const psVector *f,
     const psVector *fErr,
@@ -1705,5 +1705,5 @@
 
     PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false);
-    PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
+    PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
 
     if (fErr != NULL) {
@@ -1751,5 +1751,5 @@
             if (mask != NULL) {
                 for (psS32 i = 0 ; i < mask->n ; i++) {
-                    psTrace("psLib.math", 6,  "mask[%d] is %d\n", i, mask->data.U8[i]);
+                    psTrace("psLib.math", 6,  "mask[%d] is %d\n", i, mask->data.PS_TYPE_VECTOR_MASK_DATA[i]);
                 }
             }
@@ -1778,5 +1778,5 @@
             if (mask != NULL) {
                 for (psS32 i = 0 ; i < mask->n ; i++) {
-                    if (!((mask != NULL) && (mask->data.U8[i] & maskValue))) {
+                    if (!((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue))) {
                         psTrace("psLib.math", 6,  "(f, fit)[%d] is (%f, %f).  resid is (%f)\n",
                                 i, f->data.F32[i], fit->data.F32[i], resid->data.F64[i]);
@@ -1805,5 +1805,5 @@
         // recovery is not allowed with this scheme
         for (psS32 i = 0; i < resid->n; i++) {
-            if ((mask != NULL) && (mask->data.U8[i] & maskValue)) {
+            if ((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) {
                 continue;
             }
@@ -1819,5 +1819,5 @@
 
                 if (mask != NULL) {
-                    mask->data.U8[i] |= 0x01;
+                    mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01;
                 }
                 continue;
@@ -1850,5 +1850,5 @@
     psPolynomial4D* myPoly,
     const psVector* mask,
-    psMaskType maskValue,
+    psVectorMaskType maskValue,
     const psVector *f,
     const psVector *fErr,
@@ -1884,5 +1884,5 @@
     if (mask) {
         PS_ASSERT_VECTORS_SIZE_EQUAL(y, mask, false);
-        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
+        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
     }
 
@@ -1918,9 +1918,9 @@
         fErrData = fErr->data.F64;
     }
-    psU8 *dataMask = NULL;              // Mask for data
+    psVectorMaskType *dataMask = NULL;              // Mask for data
     if (mask) {
-        dataMask = mask->data.U8;
-    }
-    psU8 ****coeffMask = myPoly->coeffMask;    // Mask for polynomial terms
+        dataMask = mask->data.PS_TYPE_VECTOR_MASK_DATA;
+    }
+    psMaskType ****coeffMask = myPoly->coeffMask;    // Mask for polynomial terms
     int nYZTterm = nYterm * nZterm * nTterm; // Multiplication of the numbers, for calculating the index
     int nZTterm = nZterm * nTterm;      // Multiplication of the numbers, for calculating the index
@@ -2068,5 +2068,5 @@
     psPolynomial4D *poly,
     const psVector *mask,
-    psMaskType maskValue,
+    psVectorMaskType maskValue,
     const psVector *f,
     const psVector *fErr,
@@ -2091,5 +2091,5 @@
     if (mask) {
         PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false);
-        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
+        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
     }
     if (fErr != NULL) {
@@ -2148,5 +2148,5 @@
     psStats *stats,
     const psVector *mask,
-    psMaskType maskValue,
+    psVectorMaskType maskValue,
     const psVector *f,
     const psVector *fErr,
@@ -2181,5 +2181,5 @@
 
     PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false);
-    PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
+    PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
 
     if (fErr != NULL) {
@@ -2227,5 +2227,5 @@
             if (mask != NULL) {
                 for (psS32 i = 0 ; i < mask->n ; i++) {
-                    psTrace("psLib.math", 6,  "mask[%d] is %d\n", i, mask->data.U8[i]);
+                    psTrace("psLib.math", 6,  "mask[%d] is %d\n", i, mask->data.PS_TYPE_VECTOR_MASK_DATA[i]);
                 }
             }
@@ -2255,5 +2255,5 @@
             if (mask != NULL) {
                 for (psS32 i = 0 ; i < mask->n ; i++) {
-                    if (!((mask != NULL) && (mask->data.U8[i] & maskValue))) {
+                    if (!((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue))) {
                         psTrace("psLib.math", 6,  "(f, fit)[%d] is (%f, %f).  resid is (%f)\n",
                                 i, f->data.F32[i], fit->data.F32[i], resid->data.F64[i]);
@@ -2282,5 +2282,5 @@
         // recovery is not allowed with this scheme
         for (psS32 i = 0; i < resid->n; i++) {
-            if ((mask != NULL) && (mask->data.U8[i] & maskValue)) {
+            if ((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) {
                 continue;
             }
@@ -2296,5 +2296,5 @@
 
                 if (mask != NULL) {
-                    mask->data.U8[i] |= 0x01;
+                    mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01;
                 }
                 continue;
Index: trunk/psLib/src/math/psMinimizePolyFit.h
===================================================================
--- trunk/psLib/src/math/psMinimizePolyFit.h	(revision 21172)
+++ trunk/psLib/src/math/psMinimizePolyFit.h	(revision 21183)
@@ -7,6 +7,6 @@
  * @author GLG, MHPCC
  *
- * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-01-23 22:47:23 $
+ * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-27 06:39:38 $
  * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  *
@@ -48,5 +48,5 @@
     psPolynomial1D *poly,
     const psVector *mask,
-    psMaskType maskValue,
+    psVectorMaskType maskValue,
     const psVector *f,
     const psVector *fErr,
@@ -57,5 +57,5 @@
     psPolynomial2D *poly,
     const psVector *mask,
-    psMaskType maskValue,
+    psVectorMaskType maskValue,
     const psVector *f,
     const psVector *fErr,
@@ -67,5 +67,5 @@
     psPolynomial3D *poly,
     const psVector *mask,
-    psMaskType maskValue,
+    psVectorMaskType maskValue,
     const psVector *f,
     const psVector *fErr,
@@ -78,5 +78,5 @@
     psPolynomial4D *poly,
     const psVector *mask,
-    psMaskType maskValue,
+    psVectorMaskType maskValue,
     const psVector *f,
     const psVector *fErr,
@@ -92,5 +92,5 @@
     psStats *stats,
     const psVector *mask,
-    psMaskType maskValue,
+    psVectorMaskType maskValue,
     const psVector *f,
     const psVector *fErr,
@@ -102,5 +102,5 @@
     psStats *stats,
     const psVector *mask,
-    psMaskType maskValue,
+    psVectorMaskType maskValue,
     const psVector *f,
     const psVector *fErr,
@@ -113,5 +113,5 @@
     psStats *stats,
     const psVector *mask,
-    psMaskType maskValue,
+    psVectorMaskType maskValue,
     const psVector *f,
     const psVector *fErr,
@@ -125,5 +125,5 @@
     psStats *stats,
     const psVector *mask,
-    psMaskType maskValue,
+    psVectorMaskType maskValue,
     const psVector *f,
     const psVector *fErr,
Index: trunk/psLib/src/math/psMinimizePowell.c
===================================================================
--- trunk/psLib/src/math/psMinimizePowell.c	(revision 21172)
+++ trunk/psLib/src/math/psMinimizePowell.c	(revision 21183)
@@ -11,6 +11,6 @@
  *  NOTE: XXX: The SDR is silent about data types.  F32 is implemented here.
  *
- *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-02-06 21:36:09 $
+ *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-27 06:39:38 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -43,5 +43,5 @@
 #define PS_VECTOR_ADD_MULTIPLE(BASE, BASEMASK, LINE, OUT, MUL) \
 for (psS32 i=0;i<BASE->n;i++) { \
-    if (BASEMASK->data.U8[i] == 0) { \
+    if (BASEMASK->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) { \
         OUT->data.F32[i] = BASE->data.F32[i] + (MUL * LINE->data.F32[i]); \
     } else { \
@@ -62,5 +62,5 @@
 BOOL_VAR = true; \
 for (psS32 i=0;i<IN->n;i++) { \
-    if ((INMASK->data.U8[i] == 0) && (fabs(IN->data.F32[i]) >= FLT_EPSILON)) { \
+    if ((INMASK->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) && (fabs(IN->data.F32[i]) >= FLT_EPSILON)) { \
         BOOL_VAR = false; \
         break; \
@@ -359,5 +359,5 @@
     PS_ASSERT_VECTOR_NON_NULL(paramMask, NAN);
     PS_ASSERT_VECTOR_NON_EMPTY(paramMask, NAN);
-    PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_U8, NAN);
+    PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, NAN);
     PS_ASSERT_PTR_NON_NULL(coords, NAN);
     PS_ASSERT_PTR_NON_NULL(func, NAN);
@@ -388,5 +388,5 @@
         for (i=0;i<params->n;i++) {
             psTrace("psLib.math", 6, "(params, paramMask, line)[%d] is (%f %d %f)\n", i,
-                    params->data.F32[i], paramMask->data.U8[i], line->data.F32[i]);
+                    params->data.F32[i], paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i], line->data.F32[i]);
         }
     }
@@ -527,5 +527,5 @@
 
     if (paramMask == NULL) {
-        myParamMask = psVectorAlloc(params->n, PS_TYPE_U8);
+        myParamMask = psVectorAlloc(params->n, PS_TYPE_VECTOR_MASK);
         psVectorInit(myParamMask, 0);
     } else {
@@ -572,5 +572,5 @@
         biggestIter = 0;
         for (i=0;i<numDims;i++) {
-            if (myParamMask->data.U8[i] == 0) {
+            if (myParamMask->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) {
                 P_PSMINIMIZATION_SET_MAXITER((&dummyMin),PS_MINIMIZE_POWELL_LINEMIN_MAX_ITERATIONS);
                 *(float*)&dummyMin.tol = PS_MINIMIZE_POWELL_LINEMIN_ERROR_TOLERANCE;
@@ -603,5 +603,5 @@
         // 4: Set the vector u = Q - P
         for (i=0;i<numDims;i++) {
-            if (myParamMask->data.U8[i] == 0) {
+            if (myParamMask->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) {
                 u->data.F32[i] = Q->data.F32[i] - params->data.F32[i];
                 u->n++;
@@ -649,5 +649,5 @@
 
         for (i=0;i<numDims;i++) {
-            if (myParamMask->data.U8[i] == 0) {
+            if (myParamMask->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) {
                 pQP->data.F32[i] = (2 * Q->data.F32[i]) - params->data.F32[i];
             } else {
@@ -663,5 +663,5 @@
         if (term1 < term2) {
             for (i=0;i<numDims;i++) {
-                if (myParamMask->data.U8[i] == 0) {
+                if (myParamMask->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) {
                     ((psVector *) v->data[biggestIter])->data.F32[i] = u->data.F32[i];
                 }
@@ -671,5 +671,5 @@
         // 7: Set P to Q
         for (i=0;i<numDims;i++) {
-            if (myParamMask->data.U8[i] == 0) {
+            if (myParamMask->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) {
                 params->data.F32[i] = Q->data.F32[i];
             }
Index: trunk/psLib/src/math/psPolynomialMD.c
===================================================================
--- trunk/psLib/src/math/psPolynomialMD.c	(revision 21172)
+++ trunk/psLib/src/math/psPolynomialMD.c	(revision 21183)
@@ -132,5 +132,5 @@
                               const psVector *values, // Measured values
                               const psVector *mask, // Mask for values
-			      psMaskType maskVal 
+			      psVectorMaskType maskVal 
                               )
 {
@@ -143,5 +143,5 @@
     int numGood = numValues;            // Number of good values
     for (int i = 0; i < numValues; i++) {
-        if (mask && (mask->data.U8[i] & maskVal)) {
+        if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal)) {
             numGood--;
             continue;
@@ -253,5 +253,5 @@
 
 bool psPolynomialMDFit(psPolynomialMD *poly, const psVector *values, const psVector *errors,
-                       const psVector *mask, psMaskType maskVal, const psArray *coordsArray)
+                       const psVector *mask, psVectorMaskType maskVal, const psArray *coordsArray)
 {
     PS_ASSERT_POLYNOMIALMD_NON_NULL(poly, false);
@@ -268,5 +268,5 @@
     if (mask) {
         PS_ASSERT_VECTOR_NON_NULL(mask, false);
-        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_MASK, false);
+        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
         PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, false);
     }
@@ -294,5 +294,5 @@
         PS_ASSERT_VECTOR_TYPE(coords, PS_TYPE_F32, false);
 
-        if (mask && (mask->data.PS_TYPE_MASK_DATA[i] & maskVal)) {
+        if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal)) {
             continue;
         }
@@ -321,7 +321,7 @@
 }
 
-// XXX this function should take a (psMaskType markVal) argument
+// XXX this function should take a (psVectorMaskType markVal) argument
 bool psPolynomialMDClipFit(psPolynomialMD *poly, const psVector *values, const psVector *errors,
-                           const psVector *mask, psMaskType maskVal, const psArray *coordsArray,
+                           const psVector *mask, psVectorMaskType maskVal, const psArray *coordsArray,
                            int numIter, float rej) 
 {
@@ -340,5 +340,5 @@
     if (mask) {
         PS_ASSERT_VECTOR_NON_NULL(mask, false);
-        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_MASK, false);
+        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
         PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, false);
     }
@@ -355,9 +355,9 @@
 
     // copy the input mask to a local temporary mask 
-    poly->ownMask = psVectorRecycle(poly->ownMask, numValues, PS_TYPE_U8); // Our own mask for input values
+    poly->ownMask = psVectorRecycle(poly->ownMask, numValues, PS_TYPE_VECTOR_MASK); // Our own mask for input values
     psVectorInit(poly->ownMask, 0);
     for (int i = 0; mask && (i < numValues); i++) {
-	if (mask->data.PS_TYPE_MASK_DATA[i] & maskVal) {
-	    poly->ownMask->data.U8[i] = 0xff;
+	if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal) {
+	    poly->ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff;
 	    numGood--;
 	}
@@ -392,5 +392,5 @@
 		    i, values->data.F32[i], values->data.F32[i] - poly->deviations->data.F32[i], poly->deviations->data.F32[i], limit);
 
-            if (poly->ownMask->data.U8[i]) continue;
+            if (poly->ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue;
 
             if (fabs(poly->deviations->data.F32[i]) > limit) {
@@ -398,5 +398,5 @@
                         i, values->data.F32[i], values->data.F32[i] + poly->deviations->data.F32[i], 
                         poly->deviations->data.F32[i], limit);
-                poly->ownMask->data.U8[i] = 0xff;
+                poly->ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff;
                 numClipped++;
                 numGood--;
@@ -435,5 +435,5 @@
     psVectorInit(vector, 0.0);
     for (int i = 0; i < numValues; i++) {
-        if (mask->data.U8[i]) {
+        if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
             continue;
         }
@@ -462,5 +462,5 @@
 
 bool psPolynomialMDClipFit(psPolynomialMD *poly, const psVector *values, const psVector *errors,
-                           const psVector *mask, psMaskType maskVal, const psArray *coordsArray,
+                           const psVector *mask, psVectorMaskType maskVal, const psArray *coordsArray,
                            int numIter, float rej)
 {
@@ -478,5 +478,5 @@
     if (mask) {
         PS_ASSERT_VECTOR_NON_NULL(mask, false);
-        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_MASK, false);
+        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
         PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, false);
     }
@@ -500,5 +500,5 @@
         PS_ASSERT_VECTOR_TYPE(coords, PS_TYPE_F32, false);
 
-        if (mask && (mask->data.PS_TYPE_MASK_DATA[i] & maskVal)) {
+        if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal)) {
             continue;
         }
@@ -516,10 +516,10 @@
     psImage *matrix = psImageAlloc(numTerms, numTerms, PS_TYPE_F64); // Least-squares matrix
     psVector *vector = psVectorAlloc(numTerms, PS_TYPE_F64); // Least-squares vector
-    psVector *ownMask = psVectorAlloc(numValues, PS_TYPE_U8); // Our own mask for input values
+    psVector *ownMask = psVectorAlloc(numValues, PS_TYPE_VECTOR_MASK); // Our own mask for input values
     psVectorInit(ownMask, 0);
     if (mask) {
         for (int i = 0; i < numValues; i++) {
-            if (mask->data.PS_TYPE_MASK_DATA[i] & maskVal) {
-                ownMask->data.U8[i] = 0xff;
+            if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal) {
+                ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff;
                 numGood--;
             }
@@ -551,5 +551,5 @@
         float limit = rej * poly->stdevFit; // Rejection limit
         for (int i = 0; i < numValues; i++) {
-            if (ownMask->data.U8[i]) {
+            if (ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
                 continue;
             }
@@ -558,5 +558,5 @@
                         i, values->data.F32[i], psPolynomialMDEval(poly, coordsArray->data[i]),
                         deviations->data.F32[i], limit);
-                ownMask->data.U8[i] = 0xff;
+                ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff;
                 numClipped++;
                 numGood--;
Index: trunk/psLib/src/math/psPolynomialMD.h
===================================================================
--- trunk/psLib/src/math/psPolynomialMD.h	(revision 21172)
+++ trunk/psLib/src/math/psPolynomialMD.h	(revision 21183)
@@ -52,5 +52,5 @@
                        const psVector *errors, ///< Errors
                        const psVector *mask, ///< Mask
-                       psMaskType maskVal, ///< Value to mask
+                       psVectorMaskType maskVal, ///< Value to mask
                        const psArray *coordsArray ///< Array of coordinates
     );
@@ -61,5 +61,5 @@
                            const psVector *errors, ///< Errors
                            const psVector *mask, ///< Mask
-                           psMaskType maskVal, ///< Value to mask
+                           psVectorMaskType maskVal, ///< Value to mask
                            const psArray *coordsArray, ///< Array of coordinates
                            int numIter,    ///< Number of rejection iterations
Index: trunk/psLib/src/math/psPolynomialUtils.c
===================================================================
--- trunk/psLib/src/math/psPolynomialUtils.c	(revision 21172)
+++ trunk/psLib/src/math/psPolynomialUtils.c	(revision 21183)
@@ -21,5 +21,5 @@
     psStats *stats,
     const psVector *mask,
-    psMaskType maskValue,
+    psVectorMaskType maskValue,
     const psVector *f,
     const psVector *fErr,
@@ -36,5 +36,5 @@
     if (mask != NULL) {
         PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, NULL);
-        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, NULL);
+        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, NULL);
     }
     PS_ASSERT_VECTOR_NON_NULL(x, NULL);
@@ -106,5 +106,5 @@
         // recovery is not allowed with this scheme
         for (int i = 0; i < resid->n; i++) {
-            if ((mask != NULL) && (mask->data.U8[i] & maskValue)) {
+            if ((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) {
                 continue;
             }
@@ -112,5 +112,5 @@
             if (resid->data.F64[i] - stats->sampleMedian > sigma*maxClipSigma) {
                 if (mask != NULL) {
-                    mask->data.U8[i] |= 0x01;
+                    mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01;
                 }
                 continue;
@@ -118,5 +118,5 @@
             if (resid->data.F64[i] - stats->sampleMedian < sigma*minClipSigma) {
                 if (mask != NULL) {
-                    mask->data.U8[i] |= 0x01;
+                    mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01;
                 }
                 continue;
Index: trunk/psLib/src/math/psPolynomialUtils.h
===================================================================
--- trunk/psLib/src/math/psPolynomialUtils.h	(revision 21172)
+++ trunk/psLib/src/math/psPolynomialUtils.h	(revision 21183)
@@ -2,6 +2,6 @@
  * @brief extra psPolynomial-related functions
  *
- * $Revision: 1.5 $ $Name: not supported by cvs2svn $
- * $Date: 2007-01-23 22:47:23 $
+ * $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ * $Date: 2009-01-27 06:39:38 $
  * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  */
@@ -24,5 +24,5 @@
     psStats *stats,                     // Statistics to use in clipping
     const psVector *mask,               // Mask for input values
-    psMaskType maskValue,               // Mask value
+    psVectorMaskType maskValue,		// Mask value
     const psVector *f,                  // Value of the function, f(x,y,z,t)
     const psVector *fErr,               // Error in the value
Index: trunk/psLib/src/math/psStats.c
===================================================================
--- trunk/psLib/src/math/psStats.c	(revision 21172)
+++ trunk/psLib/src/math/psStats.c	(revision 21183)
@@ -13,6 +13,6 @@
  * use ->min and ->max (PS_STAT_USE_RANGE)
  *
- *  @version $Revision: 1.230 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-11-04 00:55:14 $
+ *  @version $Revision: 1.231 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-27 06:39:38 $
  *
  *  Copyright 2006 IfA, University of Hawaii
@@ -68,5 +68,6 @@
 #define PS_CLIPPED_SIGMA_UB 10.0
 #define PS_POLY_MEDIAN_MAX_ITERATIONS 30
-#define MASK_MARK 0x80   // bit to use internally to mark data as bad
+
+#define MASK_MARK 0x80   // XXX : can we change this? bit to use internally to mark data as bad
 #define PS_ROBUST_MAX_ITERATIONS 20     // Maximum number of iterations for robust statistics
 
@@ -178,5 +179,5 @@
                                  const psVector* errors,
                                  const psVector* maskVector,
-                                 psMaskType maskVal,
+                                 psVectorMaskType maskVal,
                                  psStats* stats)
 {
@@ -190,5 +191,5 @@
     int numData = myVector->n;          // Number of data points
 
-    psU8 *maskData = (maskVector == NULL) ? NULL : maskVector->data.U8;
+    psVectorMaskType *maskData = (maskVector == NULL) ? NULL : maskVector->data.PS_TYPE_VECTOR_MASK_DATA;
     bool useRange = stats->options & PS_STAT_USE_RANGE;
 
@@ -245,5 +246,5 @@
     static long vectorMinMax(const psVector* myVector,
                              const psVector* maskVector,
-                             psMaskType maskVal,
+                             psVectorMaskType maskVal,
                              psStats* stats
         )
@@ -257,5 +258,5 @@
     int numValid = 0;                   // Number of valid values
 
-    psU8 *maskData = (maskVector == NULL) ? NULL : maskVector->data.U8;
+    psVectorMaskType *maskData = (maskVector == NULL) ? NULL : maskVector->data.PS_TYPE_VECTOR_MASK_DATA;
     bool useRange = stats->options & PS_STAT_USE_RANGE;
 
@@ -302,5 +303,5 @@
 static bool vectorSampleMedian(const psVector* inVector,
                                const psVector* maskVector,
-                               psMaskType maskVal,
+                               psVectorMaskType maskVal,
                                psStats* stats)
 {
@@ -308,5 +309,5 @@
 
     bool useRange = stats->options & PS_STAT_USE_RANGE;
-    psU8 *maskData = (maskVector == NULL) ? NULL : maskVector->data.U8; // Dereference the vector
+    psVectorMaskType *maskData = (maskVector == NULL) ? NULL : maskVector->data.PS_TYPE_VECTOR_MASK_DATA; // Dereference the vector
     psF32 *input = inVector->data.F32; // Dereference the vector
 
@@ -387,5 +388,5 @@
                               const psVector* errors,
                               const psVector* maskVector,
-                              psMaskType maskVal,
+                              psVectorMaskType maskVal,
                               psStats* stats)
 {
@@ -407,5 +408,5 @@
 
     psF32 *data = myVector->data.F32;   // Dereference
-    psU8 *maskData = (maskVector == NULL) ? NULL : maskVector->data.U8;
+    psVectorMaskType *maskData = (maskVector == NULL) ? NULL : maskVector->data.PS_TYPE_VECTOR_MASK_DATA;
     bool useRange = stats->options & PS_STAT_USE_RANGE;
     psF32 *errorsData = (errors == NULL) ? NULL : errors->data.F32;
@@ -468,5 +469,5 @@
 static bool vectorSampleMoments(const psVector* myVector,
                                 const psVector* maskVector,
-                                psMaskType maskVal,
+                                psVectorMaskType maskVal,
                                 psStats* stats)
 {
@@ -490,5 +491,5 @@
 
     psF32 *data = myVector->data.F32;   // Dereference
-    psU8 *maskData = (maskVector == NULL) ? NULL : maskVector->data.U8;
+    psVectorMaskType *maskData = (maskVector == NULL) ? NULL : maskVector->data.PS_TYPE_VECTOR_MASK_DATA;
     bool useRange = stats->options & PS_STAT_USE_RANGE;
 
@@ -557,5 +558,5 @@
                                const psVector* errors,
                                psVector* maskInput,
-                               psMaskType maskValInput,
+                               psVectorMaskType maskValInput,
                                psStats* stats
     )
@@ -580,14 +581,14 @@
 
     // We copy the mask vector, to preserve the original
-    psMaskType maskVal = MASK_MARK | maskValInput;
+    psVectorMaskType maskVal = MASK_MARK | maskValInput;
 
     // use the temporary vector for local temporary mask
-    stats->tmpMask = psVectorRecycle (stats->tmpMask, myVector->n, PS_TYPE_U8);
+    stats->tmpMask = psVectorRecycle (stats->tmpMask, myVector->n, PS_TYPE_VECTOR_MASK);
     psVector *tmpMask = stats->tmpMask;
     psVectorInit(tmpMask, 0);
     if (maskInput) {
         for (long i = 0; i < myVector->n; i++) {
-            if (maskInput->data.U8[i] & maskValInput) {
-                tmpMask->data.U8[i] = maskVal;
+            if (maskInput->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValInput) {
+                tmpMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = maskVal;
             }
         }
@@ -629,7 +630,7 @@
             // sqrt(A))
             for (long j = 0; j < myVector->n; j++) {
-                if (!tmpMask->data.U8[j] &&
+                if (!tmpMask->data.PS_TYPE_VECTOR_MASK_DATA[j] &&
                     fabsf(myVector->data.F32[j] - clippedMean) > stats->clipSigma * errors->data.F32[j]) {
-                    tmpMask->data.U8[j] = 0xff;
+                    tmpMask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xff;
                     psTrace(TRACE, 10, "Clipped %ld: %f +/- %f\n", j,
                             myVector->data.F32[j], errors->data.F32[j]);
@@ -640,7 +641,7 @@
         } else {
             for (long j = 0; j < myVector->n; j++) {
-                if (!tmpMask->data.U8[j] &&
+                if (!tmpMask->data.PS_TYPE_VECTOR_MASK_DATA[j] &&
                     fabsf(myVector->data.F32[j] - clippedMean) > (stats->clipSigma * clippedStdev)) {
-                    tmpMask->data.U8[j] = 0xff;
+                    tmpMask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xff;
                     psTrace(TRACE, 10, "Clipped %ld: %f\n", j, myVector->data.F32[j]);
                     numClipped++;
@@ -715,5 +716,5 @@
                               const psVector* errors,
                               psVector* maskInput,
-                              psMaskType maskValInput,
+                              psVectorMaskType maskValInput,
                               psStats* stats)
 {
@@ -726,11 +727,11 @@
     // and tested even if there is no supplied mask (and/or the maskVal is 0)
     // XXX this would be better if we had globally defined mask values
-    psMaskType maskVal = MASK_MARK | maskValInput;
-    psVector *mask = psVectorAlloc(myVector->n, PS_TYPE_MASK); // The actual mask we will use
+    psVectorMaskType maskVal = MASK_MARK | maskValInput;
+    psVector *mask = psVectorAlloc(myVector->n, PS_TYPE_VECTOR_MASK); // The actual mask we will use
     psVectorInit(mask, 0);
     if (maskInput) {
         for (long i = 0; i < myVector->n; i++) {
-            if (maskInput->data.U8[i] & maskValInput) {
-                mask->data.U8[i] = maskVal;
+            if (maskInput->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValInput) {
+                mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = maskVal;
             }
         }
@@ -934,5 +935,5 @@
                 if ((myVector->data.F32[i] < medianLo) || (myVector->data.F32[i] > medianHi)) {
                     // XXXX is this correct?  is MASK_MARK safe?
-                    mask->data.U8[i] |= MASK_MARK;
+                    mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= MASK_MARK;
                     psTrace(TRACE, 6, "Masking element %ld is %f\n", i, myVector->data.F32[i]);
                 }
@@ -998,5 +999,5 @@
     long N50 = 0;
     for (long i = 0 ; i < myVector->n ; i++) {
-        if (!mask->data.U8[i] &&
+        if (!mask->data.PS_TYPE_VECTOR_MASK_DATA[i] &&
             (binLo25F32 <= myVector->data.F32[i]) && (binHi25F32 >= myVector->data.F32[i])) {
             N50++;
@@ -1046,5 +1047,5 @@
                                const psVector* errors,
                                psVector* mask,
-                               psMaskType maskVal,
+                               psVectorMaskType maskVal,
                                psStats* stats)
 {
@@ -1224,5 +1225,5 @@
                                   const psVector* errors,
                                   psVector* mask,
-                                  psMaskType maskVal,
+                                  psVectorMaskType maskVal,
                                   psStats* stats)
 {
@@ -1347,5 +1348,5 @@
         // fitStats->clipIter = 3.0;
         // fitStats->clipSigma = 3.0;
-        // psVector *fitMask = psVectorAlloc(y->n, PS_TYPE_U8);
+        // psVector *fitMask = psVectorAlloc(y->n, PS_TYPE_VECTOR_MASK);
         // psVectorInit (fitMask, 0);
 
@@ -1418,5 +1419,5 @@
                                   const psVector* errors,
                                   psVector* mask,
-                                  psMaskType maskVal,
+                                  psVectorMaskType maskVal,
                                   psStats* stats)
 {
@@ -1713,5 +1714,5 @@
                                   const psVector* errors,
                                   psVector* mask,
-                                  psMaskType maskVal,
+                                  psVectorMaskType maskVal,
                                   psStats* stats)
 {
@@ -2225,5 +2226,5 @@
                    const psVector* errors,
                    const psVector* mask,
-                   psMaskType maskVal)
+                   psVectorMaskType maskVal)
 {
     psTrace(TRACE, 3,"---- %s() begin  ----\n", __func__);
@@ -2233,5 +2234,5 @@
     if (mask) {
         PS_ASSERT_VECTORS_SIZE_EQUAL(mask, in, false);
-        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
+        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
     }
     if (errors) {
@@ -2255,10 +2256,10 @@
         }
     }
-    psVector *maskU8 = NULL;            // Input mask vector, U8 version
+    psVector *maskVector = NULL;            // Input mask vector, U8 version
     if (mask) {
-        if (mask->type.type == PS_TYPE_MASK) {
-            maskU8 = psMemIncrRefCounter((psPtr)mask);
+        if (mask->type.type == PS_TYPE_VECTOR_MASK) {
+            maskVector = psMemIncrRefCounter((psPtr)mask);
         } else {
-            maskU8 = psVectorCopy(NULL, mask, PS_TYPE_MASK);
+            maskVector = psVectorCopy(NULL, mask, PS_TYPE_VECTOR_MASK);
         }
     }
@@ -2279,5 +2280,5 @@
     // ************************************************************************
     if (stats->options & PS_STAT_SAMPLE_MEAN) {
-        if (!vectorSampleMean(inF32, errorsF32, maskU8, maskVal, stats)) {
+        if (!vectorSampleMean(inF32, errorsF32, maskVector, maskVal, stats)) {
             psError(PS_ERR_UNKNOWN, false, "Failed to calculate vector sample mean");
             status &= false;
@@ -2287,5 +2288,5 @@
     // ************************************************************************
     if (stats->options & (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_QUARTILE)) {
-        if (!vectorSampleMedian(inF32, maskU8, maskVal, stats)) {
+        if (!vectorSampleMedian(inF32, maskVector, maskVal, stats)) {
             psError(PS_ERR_UNKNOWN, false, "Failed to calculate sample median");
             status &= false;
@@ -2295,5 +2296,5 @@
     // ************************************************************************
     if (stats->options & PS_STAT_SAMPLE_STDEV) {
-        if (!vectorSampleStdev(inF32, errorsF32, maskU8, maskVal, stats)) {
+        if (!vectorSampleStdev(inF32, errorsF32, maskVector, maskVal, stats)) {
             psError(PS_ERR_UNKNOWN, false, "Failed to calculate sample stdev");
             status &= false;
@@ -2302,5 +2303,5 @@
 
     if (stats->options & (PS_STAT_SAMPLE_SKEWNESS | PS_STAT_SAMPLE_KURTOSIS)) {
-        if (!vectorSampleMoments(inF32, maskU8, maskVal, stats)) {
+        if (!vectorSampleMoments(inF32, maskVector, maskVal, stats)) {
             psError(PS_ERR_UNKNOWN, false, "Failed to calculate sample moments");
             status &= false;
@@ -2310,5 +2311,5 @@
     // ************************************************************************
     if (stats->options & (PS_STAT_MAX | PS_STAT_MIN)) {
-        if (vectorMinMax(inF32, maskU8, maskVal, stats) == 0) {
+        if (vectorMinMax(inF32, maskVector, maskVal, stats) == 0) {
             psError(PS_ERR_UNKNOWN, false, "Failed to calculate vector minimum and maximum");
             status &= false;
@@ -2318,5 +2319,5 @@
     // ************************************************************************
     if (stats->options & (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV | PS_STAT_ROBUST_QUARTILE)) {
-        if (!vectorRobustStats(inF32, errorsF32, maskU8, maskVal, stats)) {
+        if (!vectorRobustStats(inF32, errorsF32, maskVector, maskVal, stats)) {
             psError(PS_ERR_UNKNOWN, false, _("Failed to calculate robust statistics"));
             status &= false;
@@ -2326,5 +2327,5 @@
     // ************************************************************************
     if (stats->options & (PS_STAT_FITTED_MEAN | PS_STAT_FITTED_STDEV)) {
-        if (!vectorFittedStats(inF32, errorsF32, maskU8, maskVal, stats)) {
+        if (!vectorFittedStats(inF32, errorsF32, maskVector, maskVal, stats)) {
             psError(PS_ERR_UNKNOWN, false, _("Failed to calculate fitted statistics"));
             status &= false;
@@ -2337,5 +2338,5 @@
             psAbort("you may not specify both FITTED_MEAN and FITTED_MEAN_V2");
         }
-        if (!vectorFittedStats_v2(inF32, errorsF32, maskU8, maskVal, stats)) {
+        if (!vectorFittedStats_v2(inF32, errorsF32, maskVector, maskVal, stats)) {
             psError(PS_ERR_UNKNOWN, false, _("Failed to calculate fitted statistics"));
             status &= false;
@@ -2348,5 +2349,5 @@
             psAbort("you may not specify both FITTED_MEAN and FITTED_MEAN_V3");
         }
-        if (!vectorFittedStats_v3(inF32, errorsF32, maskU8, maskVal, stats)) {
+        if (!vectorFittedStats_v3(inF32, errorsF32, maskVector, maskVal, stats)) {
             psError(PS_ERR_UNKNOWN, false, _("Failed to calculate fitted statistics"));
             status &= false;
@@ -2359,5 +2360,5 @@
             psAbort("you may not specify both FITTED_MEAN and FITTED_MEAN_V4");
         }
-        if (!vectorFittedStats_v4(inF32, errorsF32, maskU8, maskVal, stats)) {
+        if (!vectorFittedStats_v4(inF32, errorsF32, maskVector, maskVal, stats)) {
             psError(PS_ERR_UNKNOWN, false, _("Failed to calculate fitted statistics"));
             status &= false;
@@ -2367,5 +2368,5 @@
     // ************************************************************************
     if ((stats->options & PS_STAT_CLIPPED_MEAN) || (stats->options & PS_STAT_CLIPPED_STDEV)) {
-        if (!vectorClippedStats(inF32, errorsF32, maskU8, maskVal, stats)) {
+        if (!vectorClippedStats(inF32, errorsF32, maskVector, maskVal, stats)) {
             psError(PS_ERR_UNKNOWN, false, "Failed to calculate clipped statistics\n");
             status &= false;
@@ -2375,5 +2376,5 @@
     psFree(inF32);
     psFree(errorsF32);
-    psFree(maskU8);
+    psFree(maskVector);
     psTrace(TRACE, 3,"---- %s() end  ----\n", __func__);
     return status;
Index: trunk/psLib/src/math/psStats.h
===================================================================
--- trunk/psLib/src/math/psStats.h	(revision 21172)
+++ trunk/psLib/src/math/psStats.h	(revision 21183)
@@ -8,6 +8,6 @@
  * @author GLG, MHPCC
  *
- * @version $Revision: 1.65 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-08-03 20:55:09 $
+ * @version $Revision: 1.66 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-27 06:39:38 $
  * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  */
@@ -96,9 +96,9 @@
  */
 bool psVectorStats(
-    psStats* stats,                    ///< stats structure defines stats to be calculated and how
-    const psVector* in,                ///< Vector to be analysed.
-    const psVector* errors,            ///< Errors.
-    const psVector* mask,              ///< Ignore elements where (maskVector & maskVal) != 0: must be INT or NULL
-    psMaskType maskVal                 ///< Only mask elements with one of these bits set in maskVector
+    psStats* stats,	       ///< stats structure defines stats to be calculated and how
+    const psVector* in,			///< Vector to be analysed.
+    const psVector* errors,		///< Errors.
+    const psVector* mask, ///< Ignore elements where (maskVector & maskVal) != 0: must be INT or NULL
+    psVectorMaskType maskVal ///< Only mask elements with one of these bits set in maskVector
 );
 
Index: trunk/psLib/src/mathtypes/psVector.c
===================================================================
--- trunk/psLib/src/mathtypes/psVector.c	(revision 21172)
+++ trunk/psLib/src/mathtypes/psVector.c	(revision 21183)
@@ -10,6 +10,6 @@
 *  @author Joshua Hoblitt, University of Hawaii
 *
-*  @version $Revision: 1.104 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2008-11-05 11:12:40 $
+*  @version $Revision: 1.105 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2009-01-27 06:39:38 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -987,7 +987,8 @@
 }
 
-// count number of pixels with given mask value
+// count number of pixels with given mask value.  the comparison is against a U64 type to
+// allow any int-type of vector.  all signed and unsigned int types are allowed
 long psVectorCountPixelMask (psVector *mask,
-                             psMaskType value)
+                             psU64 value)
 {
     long Npixels = 0;
@@ -998,30 +999,23 @@
     }
 
-    psElemType type;
-    type = mask->type.type;
-
-    if (type != PS_TYPE_MASK) {
-        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
-                "psVector type does not match the specified psMaskType!\n");
-        return -1;
-    }
-
+# define PS_VECTOR_COUNT_PIXEL_MASK(NAME,TYPE) \
+    case PS_TYPE_##NAME: \
+        for (long i = 0; i < mask->n; i++) { \
+            if (mask->data.TYPE[i] & value) { \
+                Npixels ++; \
+            } \
+        } \
+        break;
+
+    psElemType type = mask->type.type;
     switch (type) {
-    case PS_TYPE_U8:
-    case PS_TYPE_U16:
-        for (long i = 0; i < mask->n; i++) {
-            if (mask->data.PS_TYPE_MASK_DATA[i] & value) {
-                Npixels ++;
-            }
-        }
-        break;
-    case PS_TYPE_S8:
-    case PS_TYPE_S16:
-    case PS_TYPE_S32:
-    case PS_TYPE_S64:
-    case PS_TYPE_U32:
-    case PS_TYPE_U64:
-    case PS_TYPE_F32:
-    case PS_TYPE_F64:
+	PS_VECTOR_COUNT_PIXEL_MASK(U8, U8);
+	PS_VECTOR_COUNT_PIXEL_MASK(U16,U16);
+	PS_VECTOR_COUNT_PIXEL_MASK(U32,U32);
+	PS_VECTOR_COUNT_PIXEL_MASK(U64,U64);
+	PS_VECTOR_COUNT_PIXEL_MASK(S8, S8);
+	PS_VECTOR_COUNT_PIXEL_MASK(S16,S16);
+	PS_VECTOR_COUNT_PIXEL_MASK(S32,S32);
+	PS_VECTOR_COUNT_PIXEL_MASK(S64,S64);
     default:
         psError(PS_ERR_BAD_PARAMETER_TYPE, true,
Index: trunk/psLib/src/mathtypes/psVector.h
===================================================================
--- trunk/psLib/src/mathtypes/psVector.h	(revision 21172)
+++ trunk/psLib/src/mathtypes/psVector.h	(revision 21183)
@@ -10,6 +10,6 @@
  * @author Joshua Hoblitt, University of Hawaii
  *
- * @version $Revision: 1.73 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-09-12 00:22:48 $
+ * @version $Revision: 1.74 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-27 06:39:38 $
  * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  */
@@ -379,6 +379,6 @@
  */
 long psVectorCountPixelMask(
-    psVector *mask,                    ///< input vector to count
-    psMaskType value                   ///< the mask value to satisfy
+    psVector *mask,			///< input vector to count
+    psU64 value				///< the mask value to satisfy
 );
 
Index: trunk/psLib/src/sys/psType.h
===================================================================
--- trunk/psLib/src/sys/psType.h	(revision 21172)
+++ trunk/psLib/src/sys/psType.h	(revision 21183)
@@ -10,6 +10,6 @@
 *  @author Ross Harman, MHPCC
 *
-*  @version $Revision: 1.62 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2007-08-09 03:30:47 $
+*  @version $Revision: 1.63 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2009-01-27 06:39:38 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -141,9 +141,35 @@
 } psDataType;
 
+// macros to abstract the generic mask type : these values must be consistent 
 #define PS_TYPE_MASK PS_TYPE_U8        /**< the psElemType to use for mask image */
 #define PS_TYPE_MASK_DATA U8           /**< the data member to use for mask image */
 #define PS_TYPE_MASK_NAME "psU8"       /**< the data type for mask as a string */
-
+#define PS_MIN_MASK_TYPE 0             /**< minimum valid Mask value */
+#define PS_MAX_MASK_TYPE UINT8_MAX     /**< maximum valid Mask value */
 typedef psU8 psMaskType;               ///< the C datatype for a mask image
+#define PS_NOT_MASK(A)(UINT8_MAX-(A))
+
+// alternate versions if needed
+// #define PS_NOT_MASK(A)(UINT16_MAX-(A))
+// #define PS_NOT_MASK(A)(UINT32_MAX-(A)) 
+// #define PS_NOT_MASK(A)(UINT64_MAX-(A))
+
+// macros to abstract the vector mask type : these values must be consistent 
+#define PS_TYPE_VECTOR_MASK PS_TYPE_U8        /**< the psElemType to use for mask image */
+#define PS_TYPE_VECTOR_MASK_DATA U8           /**< the data member to use for mask image */
+#define PS_TYPE_VECTOR_MASK_NAME "psU8"       /**< the data type for mask as a string */
+#define PS_MIN_VECTOR_MASK_TYPE 0             /**< minimum valid Vector Mask value */
+#define PS_MAX_VECTOR_MASK_TYPE UINT8_MAX     /**< maximum valid Vector Mask value */
+typedef psU8 psVectorMaskType;			  ///< the C datatype for a mask image
+#define PS_NOT_VECTOR_MASK(A)(UINT8_MAX-(A))
+
+// macros to abstract the image mask type : these values must be consistent 
+#define PS_TYPE_IMAGE_MASK PS_TYPE_U16	     /**< the psElemType to use for mask image */
+#define PS_TYPE_IMAGE_MASK_DATA U16	     /**< the data member to use for mask image */
+#define PS_TYPE_IMAGE_MASK_NAME "psU16"	     /**< the data type for mask as a string */
+#define PS_MIN_IMAGE_MASK_TYPE 0             /**< minimum valid Image Mask value */
+#define PS_MAX_IMAGE_MASK_TYPE UINT16_MAX    /**< maximum valid Image Mask value */
+typedef psU16 psImageMaskType;               ///< the C datatype for a mask image
+#define PS_NOT_IMAGE_MASK(A)(UINT16_MAX-(A))
 
 #define PS_MIN_S8        INT8_MIN      /**< minimum valid psS8 value */
Index: trunk/psLib/src/types/psMetadata.c
===================================================================
--- trunk/psLib/src/types/psMetadata.c	(revision 21172)
+++ trunk/psLib/src/types/psMetadata.c	(revision 21183)
@@ -12,6 +12,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.174 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-10-28 00:13:19 $
+ *  @version $Revision: 1.175 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-27 06:39:38 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -866,4 +866,9 @@
 METADATA_ADD_TYPE(F32,psF32,PS_DATA_F32)
 METADATA_ADD_TYPE(F64,psF64,PS_DATA_F64)
+
+METADATA_ADD_TYPE(Mask,psMaskType,PS_TYPE_MASK)
+METADATA_ADD_TYPE(VectorMask,psVectorMaskType,PS_TYPE_VECTOR_MASK)
+METADATA_ADD_TYPE(ImageMask,psImageMaskType,PS_TYPE_IMAGE_MASK)
+
 METADATA_ADD_TYPE(List,psList*,PS_DATA_LIST)
 METADATA_ADD_TYPE(Str,const char*,PS_DATA_STRING)
@@ -1011,6 +1016,6 @@
 }
 
-#define psMetadataLookupNumTYPE(TYPE) \
-ps##TYPE psMetadataLookup##TYPE(bool *status, const psMetadata *md, const char *key) \
+#define psMetadataLookupNumTYPE(TYPE,NAME) \
+ps##TYPE psMetadataLookup##NAME(bool *status, const psMetadata *md, const char *key) \
 { \
     psMetadataItem *metadataItem = NULL; \
@@ -1081,15 +1086,19 @@
 }
 
-psMetadataLookupNumTYPE(F32)
-psMetadataLookupNumTYPE(F64)
-psMetadataLookupNumTYPE(S8)
-psMetadataLookupNumTYPE(S16)
-psMetadataLookupNumTYPE(S32)
-psMetadataLookupNumTYPE(S64)
-psMetadataLookupNumTYPE(U8)
-psMetadataLookupNumTYPE(U16)
-psMetadataLookupNumTYPE(U32)
-psMetadataLookupNumTYPE(U64)
-psMetadataLookupNumTYPE(Bool)
+psMetadataLookupNumTYPE(F32,F32)
+psMetadataLookupNumTYPE(F64,F64)
+psMetadataLookupNumTYPE(S8,S8)
+psMetadataLookupNumTYPE(S16,S16)
+psMetadataLookupNumTYPE(S32,S32)
+psMetadataLookupNumTYPE(S64,S64)
+psMetadataLookupNumTYPE(U8,U8)
+psMetadataLookupNumTYPE(U16,U16)
+psMetadataLookupNumTYPE(U32,U32)
+psMetadataLookupNumTYPE(U64,U64)
+psMetadataLookupNumTYPE(Bool,Bool)
+
+psMetadataLookupNumTYPE(MaskType,Mask)
+psMetadataLookupNumTYPE(VectorMaskType,VectorMask)
+psMetadataLookupNumTYPE(ImageMaskType,ImageMask)
 
 psMetadataItem* psMetadataGet(const psMetadata *md,
Index: trunk/psLib/src/types/psMetadata.h
===================================================================
--- trunk/psLib/src/types/psMetadata.h	(revision 21172)
+++ trunk/psLib/src/types/psMetadata.h	(revision 21183)
@@ -9,6 +9,6 @@
 *  @author Ross Harman, MHPCC
 *
-*  @version $Revision: 1.105 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2008-08-14 03:18:41 $
+*  @version $Revision: 1.106 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2009-01-27 06:39:38 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -763,4 +763,47 @@
 
 
+/** Add a psMaskType value to metadata collection.
+ *
+ *  @return bool:  True for success, False for failure.
+ */
+bool psMetadataAddMask(
+    psMetadata* md,                    ///< Metadata collection to insert metadata item
+    long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
+    const char* name,                  ///< Name of metadata item
+    int format,                        ///< psMetadataFlag options/flags
+    const char* comment,               ///< Comment for metadata item
+    psMaskType value			///< Value for metadata item data
+);
+
+
+/** Add a psVectorMaskType value to metadata collection.
+ *
+ *  @return bool:  True for success, False for failure.
+ */
+bool psMetadataAddVectorMask(
+    psMetadata* md,                    ///< Metadata collection to insert metadata item
+    long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
+    const char* name,                  ///< Name of metadata item
+    int format,                        ///< psMetadataFlag options/flags
+    const char* comment,               ///< Comment for metadata item
+    psVectorMaskType value			///< Value for metadata item data
+);
+
+
+/** Add a psImageMaskType value to metadata collection.
+ *
+ *  @return bool:  True for success, False for failure.
+ */
+bool psMetadataAddImageMask(
+    psMetadata* md,                    ///< Metadata collection to insert metadata item
+    long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
+    const char* name,                  ///< Name of metadata item
+    int format,                        ///< psMetadataFlag options/flags
+    const char* comment,               ///< Comment for metadata item
+    psImageMaskType value			///< Value for metadata item data
+);
+
+
+
 /** Add a psList to metadata collection.
  *
@@ -1095,4 +1138,49 @@
  */
 psU64 psMetadataLookupU64(
+    bool *status,                      ///< Status of lookup.
+    const psMetadata *md,              ///< Metadata collection to lookup metadata item.
+    const char *key                    ///< Name of metadata key.
+);
+
+
+/** Find an item in the metadata collection based on key name and return its integer value.
+ *
+ *  Items may be found in the metadata by providing a key. If the key is
+ *  non-unique, the value of the first item is returned. If the item is not
+ *  found, zero is returned.
+ *
+ * @return psMaskType : Value of metadata item.
+ */
+psMaskType psMetadataLookupMask(
+    bool *status,                      ///< Status of lookup.
+    const psMetadata *md,              ///< Metadata collection to lookup metadata item.
+    const char *key                    ///< Name of metadata key.
+);
+
+
+/** Find an item in the metadata collection based on key name and return its integer value.
+ *
+ *  Items may be found in the metadata by providing a key. If the key is
+ *  non-unique, the value of the first item is returned. If the item is not
+ *  found, zero is returned.
+ *
+ * @return psVectorMaskType : Value of metadata item.
+ */
+psVectorMaskType psMetadataLookupVectorMask(
+    bool *status,                      ///< Status of lookup.
+    const psMetadata *md,              ///< Metadata collection to lookup metadata item.
+    const char *key                    ///< Name of metadata key.
+);
+
+
+/** Find an item in the metadata collection based on key name and return its integer value.
+ *
+ *  Items may be found in the metadata by providing a key. If the key is
+ *  non-unique, the value of the first item is returned. If the item is not
+ *  found, zero is returned.
+ *
+ * @return psImageMaskType : Value of metadata item.
+ */
+psImageMaskType psMetadataLookupImageMask(
     bool *status,                      ///< Status of lookup.
     const psMetadata *md,              ///< Metadata collection to lookup metadata item.
Index: trunk/psLib/src/types/psPixels.c
===================================================================
--- trunk/psLib/src/types/psPixels.c	(revision 21172)
+++ trunk/psLib/src/types/psPixels.c	(revision 21183)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-09-12 22:36:29 $
+ *  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-27 06:39:38 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -150,5 +150,5 @@
                         const psPixels *pixels,
                         psRegion region,
-                        psMaskType maskVal)
+                        psImageMaskType maskVal)
 {
     PS_ASSERT_PIXELS_NON_NULL(pixels, NULL);
@@ -169,5 +169,5 @@
     int numRows = y1 - y0 + 1, numCols = x1 - x0 + 1; // Size of image
 
-    out = psImageRecycle(out, numCols, numRows, PS_TYPE_MASK);
+    out = psImageRecycle(out, numCols, numRows, PS_TYPE_IMAGE_MASK);
     if (!out) {
         psError(PS_ERR_UNKNOWN, false, _("Failed to create image of size %dx%d."), numCols, numRows);
@@ -181,5 +181,5 @@
     // cycle through the vector of pixels and insert pixels into image
     long length = pixels->n;            // Length of pixel array
-    psMaskType** outData = out->data.PS_TYPE_MASK_DATA;
+    psImageMaskType** outData = out->data.PS_TYPE_IMAGE_MASK_DATA;
     for (int p = 0; p < length; p++) {
         float x = pixels->data[p].x;
@@ -196,8 +196,8 @@
 psPixels* psPixelsFromMask(psPixels* out,
                            const psImage* mask,
-                           psMaskType maskVal)
+                           psImageMaskType maskVal)
 {
     PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
-    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
+    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
 
     int numRows = mask->numRows, numCols = mask->numCols; // Size of image
@@ -214,5 +214,5 @@
     for (int y = 0; y < numRows; y++) {
         for (int x = 0; x < numCols; x++) {
-            if (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
+            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) {
                 psPixelsAdd(out, out->nalloc, x, y);
             }
Index: trunk/psLib/src/types/psPixels.h
===================================================================
--- trunk/psLib/src/types/psPixels.h	(revision 21172)
+++ trunk/psLib/src/types/psPixels.h	(revision 21183)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-09-12 22:36:29 $
+ *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-27 06:39:38 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -189,5 +189,5 @@
     const psPixels* pixels,            ///< list of pixels to use
     psRegion region,                   ///< region to define the output mask image
-    psMaskType maskVal                 ///< the mask bit-values to act upon
+    psImageMaskType maskVal		///< the mask bit-values to act upon
 );
 
@@ -205,5 +205,5 @@
     psPixels *out,                     ///< psPixels to recycle, or NULL
     const psImage *mask,               ///< the input mask psImage
-    psMaskType maskVal                 ///< the mask bit-values to act upon
+    psImageMaskType maskVal		///< the mask bit-values to act upon
 );
 
