Index: trunk/psLib/src/imageops/psImageConvolve.c
===================================================================
--- trunk/psLib/src/imageops/psImageConvolve.c	(revision 2411)
+++ trunk/psLib/src/imageops/psImageConvolve.c	(revision 2911)
@@ -5,8 +5,8 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-11-24 00:05:54 $
+ *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-01-05 21:16:14 $
  *
- *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  */
 
@@ -130,15 +130,18 @@
     }
 
-    // determine the usable length of the shift vector
+    // sizes match?
     length = xShifts->n;
     if (length != yShifts->n ||
             length != tShifts->n) {
-        psLogMsg(__func__,PS_LOG_WARN,"Shift vectors found to be different sizes.");
-        if (yShifts->n < length) {
-            length = yShifts->n;
-        }
-        if (tShifts->n < length) {
-            length = tShifts->n;
-        }
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                "Shift vectors can not be of different sizes.");
+        return NULL;
+    }
+
+    // if no shifts, the kernel is just a 1 at 0,0
+    if (length < 1) {
+        result = psKernelAlloc(0,0,0,0);
+        result->kernel[0][0] = 1;
+        return result;
     }
 
@@ -148,6 +151,7 @@
         ps##TYPE *xShiftData = xShifts->data.TYPE; \
         ps##TYPE *yShiftData = yShifts->data.TYPE; \
-        lastX =  xShiftData[length-1]; \
-        lastY =  yShiftData[length-1]; \
+        lastX = xShiftData[length-1]; \
+        lastY = yShiftData[length-1]; \
+        lastT = tShiftData[length-1]; \
         \
         for (int lcv = 0; lcv < length; lcv++) { \
@@ -167,16 +171,16 @@
         } \
         \
-        normalizeTime = 1.0 / (psKernelType)(lastT - tShiftData[0]); \
+        normalizeTime = 1.0 / (psKernelType)(tShiftData[length-1]); \
         result = psKernelAlloc(xMin,xMax,yMin,yMax); \
         kernel = result->kernel; \
         \
-        lastT = 0; \
+        psS32 prevT = 0; \
         for (int i = 0; i < length; i++) { \
-            t = tShiftData[i] - lastT; \
+            t = tShiftData[i] - prevT; \
             x = lastX - xShiftData[i]; \
             y = lastY - yShiftData[i]; \
             \
-            kernel[y][x] += (psKernelType)t * normalizeTime; \
-            lastT = t; \
+            kernel[y][x] += (psKernelType)t / (psKernelType)lastT; \
+            prevT = tShiftData[i]; \
         } \
         break; \
@@ -206,6 +210,6 @@
                 yMax = y; \
             } \
-            x += xShiftData[lcv]; \
-            y += yShiftData[lcv]; \
+            x -= xShiftData[lcv]; \
+            y -= yShiftData[lcv]; \
             \
         } \
@@ -218,6 +222,6 @@
         for (psS32 i = length-1; i >= 0; i--) { \
             kernel[y][x] += (psKernelType)(tShiftData[i]) * normalizeTime; \
-            x += xShiftData[i]; \
-            y += yShiftData[i]; \
+            x -= xShiftData[i]; \
+            y -= yShiftData[i]; \
             \
         } \
