IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 5, 2005, 11:16:15 AM (22 years ago)
Author:
desonia
Message:

adjusted psKernelGenerate to better match Tonry's code. Also made
mis-match sizes of input vectors an error.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/imageops/psImageConvolve.c

    r2411 r2911  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-11-24 00:05:54 $
     7 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2005-01-05 21:16:14 $
    99 *
    10  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     10 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1111 */
    1212
     
    130130    }
    131131
    132     // determine the usable length of the shift vector
     132    // sizes match?
    133133    length = xShifts->n;
    134134    if (length != yShifts->n ||
    135135            length != tShifts->n) {
    136         psLogMsg(__func__,PS_LOG_WARN,"Shift vectors found to be different sizes.");
    137         if (yShifts->n < length) {
    138             length = yShifts->n;
    139         }
    140         if (tShifts->n < length) {
    141             length = tShifts->n;
    142         }
     136        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
     137                "Shift vectors can not be of different sizes.");
     138        return NULL;
     139    }
     140
     141    // if no shifts, the kernel is just a 1 at 0,0
     142    if (length < 1) {
     143        result = psKernelAlloc(0,0,0,0);
     144        result->kernel[0][0] = 1;
     145        return result;
    143146    }
    144147
     
    148151        ps##TYPE *xShiftData = xShifts->data.TYPE; \
    149152        ps##TYPE *yShiftData = yShifts->data.TYPE; \
    150         lastX =  xShiftData[length-1]; \
    151         lastY =  yShiftData[length-1]; \
     153        lastX = xShiftData[length-1]; \
     154        lastY = yShiftData[length-1]; \
     155        lastT = tShiftData[length-1]; \
    152156        \
    153157        for (int lcv = 0; lcv < length; lcv++) { \
     
    167171        } \
    168172        \
    169         normalizeTime = 1.0 / (psKernelType)(lastT - tShiftData[0]); \
     173        normalizeTime = 1.0 / (psKernelType)(tShiftData[length-1]); \
    170174        result = psKernelAlloc(xMin,xMax,yMin,yMax); \
    171175        kernel = result->kernel; \
    172176        \
    173         lastT = 0; \
     177        psS32 prevT = 0; \
    174178        for (int i = 0; i < length; i++) { \
    175             t = tShiftData[i] - lastT; \
     179            t = tShiftData[i] - prevT; \
    176180            x = lastX - xShiftData[i]; \
    177181            y = lastY - yShiftData[i]; \
    178182            \
    179             kernel[y][x] += (psKernelType)t * normalizeTime; \
    180             lastT = t; \
     183            kernel[y][x] += (psKernelType)t / (psKernelType)lastT; \
     184            prevT = tShiftData[i]; \
    181185        } \
    182186        break; \
     
    206210                yMax = y; \
    207211            } \
    208             x += xShiftData[lcv]; \
    209             y += yShiftData[lcv]; \
     212            x -= xShiftData[lcv]; \
     213            y -= yShiftData[lcv]; \
    210214            \
    211215        } \
     
    218222        for (psS32 i = length-1; i >= 0; i--) { \
    219223            kernel[y][x] += (psKernelType)(tShiftData[i]) * normalizeTime; \
    220             x += xShiftData[i]; \
    221             y += yShiftData[i]; \
     224            x -= xShiftData[i]; \
     225            y -= yShiftData[i]; \
    222226            \
    223227        } \
Note: See TracChangeset for help on using the changeset viewer.