Index: /trunk/psLib/src/imageops/psImageConvolve.c
===================================================================
--- /trunk/psLib/src/imageops/psImageConvolve.c	(revision 5572)
+++ /trunk/psLib/src/imageops/psImageConvolve.c	(revision 5573)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-15 21:22:22 $
+ *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-11-22 20:15:35 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -504,56 +504,71 @@
     Ny = image->numRows;
 
-    // generate gaussian
-    psVector *gaussnorm = psVectorAlloc (Npixel, PS_TYPE_F64);
-    for (int i = -Nrange; i < Nrange + 1; i++) {
-        gaussnorm->data.F64[i+Nrange] = exp (factor*i*i);
-    }
-    psF64 *gauss = &gaussnorm->data.F64[Nrange];
-
-    // smooth in X direction
-    temp = psVectorAlloc (Nx, PS_TYPE_F64);
-    for (int j = 0; j < Ny; j++) {
-        psF64 *vi = image->data.F64[j];
-        psF64 *vo = temp->data.F64;
-        for (int i = 0; i < Nx; i++) {
-            g = s = 0;
-            for (int n = -Nrange; n < Nrange + 1; n++) {
-                if (i+n < 0)
-                    continue;
-                if (i+n >= Nx)
-                    continue;
-                s += gauss[n]*vi[i+n];
-                g += gauss[n];
-            }
-            vo[i] = s / g;
-        }
-        memcpy (image->data.F64[j], temp->data.F64, Nx*sizeof(psF64));
-    }
-    psFree (temp);
-
-    // smooth in Y direction
-    temp = psVectorAlloc (image->numRows, PS_TYPE_F64);
-    for (int i = 0; i < Nx; i++) {
-        psF64  *vo = temp->data.F64;
-        psF64 **vi = image->data.F64;
-        for (int j = 0; j < Ny; j++) {
-            g = s = 0;
-            for (int n = -Nrange; n < Nrange + 1; n++) {
-                if (j+n < 0)
-                    continue;
-                if (j+n >= Ny)
-                    continue;
-                s += gauss[n]*vi[j+n][i];
-                g += gauss[n];
-            }
-            vo[j] = s / g;
-        }
-        // replace temp in image
-        for (int j = 0; j < Ny; j++) {
-            vi[j][i] = vo[j];
-        }
-    }
-    psFree (temp);
-    psFree (gaussnorm);
+    #define IMAGESMOOTH_CASE(TYPE) \
+case PS_TYPE_##TYPE: { \
+        /* generate gaussian */ \
+        psVector *gaussnorm = psVectorAlloc (Npixel, PS_TYPE_##TYPE); \
+        for (int i = -Nrange; i < Nrange + 1; i++) { \
+            gaussnorm->data.TYPE[i+Nrange] = exp (factor*i*i); \
+        } \
+        ps##TYPE *gauss = &gaussnorm->data.TYPE[Nrange]; \
+        \
+        /* smooth in X direction */ \
+        temp = psVectorAlloc (Nx, PS_TYPE_##TYPE); \
+        for (int j = 0; j < Ny; j++) { \
+            ps##TYPE *vi = image->data.TYPE[j]; \
+            ps##TYPE *vo = temp->data.TYPE; \
+            for (int i = 0; i < Nx; i++) { \
+                g = s = 0; \
+                for (int n = -Nrange; n < Nrange + 1; n++) { \
+                    if (i+n < 0) \
+                        continue; \
+                    if (i+n >= Nx) \
+                        continue; \
+                    s += gauss[n]*vi[i+n]; \
+                    g += gauss[n]; \
+                } \
+                vo[i] = s / g; \
+            } \
+            memcpy (image->data.TYPE[j], temp->data.TYPE, Nx*sizeof(ps##TYPE)); \
+        } \
+        psFree (temp); \
+        \
+        /* smooth in Y direction */ \
+        temp = psVectorAlloc (image->numRows, PS_TYPE_##TYPE); \
+        for (int i = 0; i < Nx; i++) { \
+            ps##TYPE  *vo = temp->data.TYPE; \
+            ps##TYPE **vi = image->data.TYPE; \
+            for (int j = 0; j < Ny; j++) { \
+                g = s = 0; \
+                for (int n = -Nrange; n < Nrange + 1; n++) { \
+                    if (j+n < 0) \
+                        continue; \
+                    if (j+n >= Ny) \
+                        continue; \
+                    s += gauss[n]*vi[j+n][i]; \
+                    g += gauss[n]; \
+                } \
+                vo[j] = s / g; \
+            } \
+            /* replace temp in image */ \
+            for (int j = 0; j < Ny; j++) { \
+                vi[j][i] = vo[j]; \
+            } \
+        } \
+        psFree (temp); \
+        psFree (gaussnorm); \
+    }
+
+    switch (image->type.type) {
+        IMAGESMOOTH_CASE(F32);
+        IMAGESMOOTH_CASE(F64);
+    default: {
+            char* typeStr;
+            PS_TYPE_NAME(typeStr,image->type.type);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                    typeStr);
+        }
+    }
 }
 
