IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 16, 2004, 10:00:21 AM (22 years ago)
Author:
desonia
Message:

Added some psfits and pslist changes. More work needs to be done to make it match the current SDRS.

File:
1 edited

Legend:

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

    r2273 r2375  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-11-04 01:05:00 $
     7 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-11-16 20:00:21 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9393                           psBool relative)
    9494{
    95     psS32 x = 0;
    96     psS32 y = 0;
    97     psS32 t = 0;
    98     psS32 deltaT;
     95    psS32 lastX;
     96    psS32 lastY;
     97    psS32 lastT;
     98    psS32 x;
     99    psS32 y;
     100    psS32 t;
    99101    psS32 oldX;
    100102    psS32 oldY;
     
    148150        ps##TYPE *xShiftData = xShifts->data.TYPE; \
    149151        ps##TYPE *yShiftData = yShifts->data.TYPE; \
    150         x = 0; \
    151         y = 0; \
    152         t = 0; \
    153         for (psS32 lcv = 0; lcv < length; lcv++) { \
    154             if (relative) { \
    155                 x += xShiftData[lcv]; \
    156                 y += yShiftData[lcv]; \
    157                 t += tShiftData[lcv]; \
    158             } else { \
    159                 x = xShiftData[lcv]; \
    160                 y = yShiftData[lcv]; \
    161                 t = tShiftData[lcv]; \
    162             } \
     152        lastX =  xShiftData[length-1]; \
     153        lastY =  yShiftData[length-1]; \
     154        \
     155        for (int lcv = 0; lcv < length; lcv++) { \
     156            x = lastX - xShiftData[lcv]; \
     157            y = lastY - yShiftData[lcv]; \
     158            \
    163159            if (x < xMin) { \
    164160                xMin = x; \
     
    172168            } \
    173169        } \
     170        \
     171        normalizeTime = 1.0 / (psKernelType)(lastT - tShiftData[0]); \
    174172        result = psKernelAlloc(xMin,xMax,yMin,yMax); \
    175173        kernel = result->kernel; \
    176174        \
    177         normalizeTime = 1.0 / (psKernelType)(t); \
     175        lastT = 0; \
     176        for (int i = 0; i < length; i++) { \
     177            t = tShiftData[i] - lastT; \
     178            x = lastX - xShiftData[i]; \
     179            y = lastY - yShiftData[i]; \
     180            \
     181            kernel[y][x] += (psKernelType)t * normalizeTime; \
     182            lastT = t; \
     183        } \
     184        break; \
     185    }
     186
     187    #define RELATIVE_KERNEL_GENERATE_CASE(TYPE) \
     188case PS_TYPE_##TYPE: { \
     189        ps##TYPE *tShiftData = tShifts->data.TYPE; \
     190        ps##TYPE *xShiftData = xShifts->data.TYPE; \
     191        ps##TYPE *yShiftData = yShifts->data.TYPE; \
     192        \
    178193        x = 0; \
    179194        y = 0; \
    180195        t = 0; \
    181         for (psS32 i = 0; i < length; i++) { \
    182             deltaT = t; \
    183             oldX = x; \
    184             oldY = y; \
    185             if (relative) { \
    186                 t += tShiftData[i]; \
    187                 x += xShiftData[i]; \
    188                 y += yShiftData[i]; \
    189             } else { \
    190                 t = tShiftData[i]; \
    191                 x = xShiftData[i]; \
    192                 y = yShiftData[i]; \
     196        \
     197        for (int lcv = length-1; lcv >= 0; lcv--) { \
     198            t += tShiftData[lcv]; \
     199            \
     200            if (x < xMin) { \
     201                xMin = x; \
     202            } else if (x > xMax) { \
     203                xMax = x; \
    193204            } \
    194             deltaT = t - deltaT; \
     205            if (y < yMin) { \
     206                yMin = y; \
     207            } else if (y > yMax) { \
     208                yMax = y; \
     209            } \
     210            x += xShiftData[lcv]; \
     211            y += yShiftData[lcv]; \
    195212            \
    196             kernel[oldY][oldX] += deltaT * normalizeTime; \
     213        } \
     214        result = psKernelAlloc(xMin,xMax,yMin,yMax); \
     215        kernel = result->kernel; \
     216        \
     217        normalizeTime = 1.0 / (psKernelType)t; \
     218        x = 0; \
     219        y = 0; \
     220        for (psS32 i = length-1; i >= 0; i--) { \
     221            kernel[y][x] += (psKernelType)(tShiftData[i]) * normalizeTime; \
     222            x += xShiftData[i]; \
     223            y += yShiftData[i]; \
     224            \
    197225        } \
    198226        break; \
    199227    }
    200228
    201     switch (xShifts->type.type) {
    202         KERNEL_GENERATE_CASE(U8);
    203         KERNEL_GENERATE_CASE(U16);
    204         KERNEL_GENERATE_CASE(U32);
    205         KERNEL_GENERATE_CASE(U64);
    206         KERNEL_GENERATE_CASE(S8);
    207         KERNEL_GENERATE_CASE(S16);
    208         KERNEL_GENERATE_CASE(S32);
    209         KERNEL_GENERATE_CASE(S64);
    210         KERNEL_GENERATE_CASE(F32);
    211         KERNEL_GENERATE_CASE(F64);
    212         KERNEL_GENERATE_CASE(C32);
    213         KERNEL_GENERATE_CASE(C64);
    214 
    215     default: {
    216             char* typeStr;
    217             PS_TYPE_NAME(typeStr,xShifts->type.type);
    218             psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    219                     PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
    220                     typeStr);
     229    if (relative) {
     230        switch (xShifts->type.type) {
     231            RELATIVE_KERNEL_GENERATE_CASE(U8);
     232            RELATIVE_KERNEL_GENERATE_CASE(U16);
     233            RELATIVE_KERNEL_GENERATE_CASE(U32);
     234            RELATIVE_KERNEL_GENERATE_CASE(U64);
     235            RELATIVE_KERNEL_GENERATE_CASE(S8);
     236            RELATIVE_KERNEL_GENERATE_CASE(S16);
     237            RELATIVE_KERNEL_GENERATE_CASE(S32);
     238            RELATIVE_KERNEL_GENERATE_CASE(S64);
     239            RELATIVE_KERNEL_GENERATE_CASE(F32);
     240            RELATIVE_KERNEL_GENERATE_CASE(F64);
     241            RELATIVE_KERNEL_GENERATE_CASE(C32);
     242            RELATIVE_KERNEL_GENERATE_CASE(C64);
     243
     244        default: {
     245                char* typeStr;
     246                PS_TYPE_NAME(typeStr,xShifts->type.type);
     247                psError(PS_ERR_BAD_PARAMETER_TYPE, true,
     248                        PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
     249                        typeStr);
     250            }
     251        }
     252    } else {
     253        switch (xShifts->type.type) {
     254            KERNEL_GENERATE_CASE(U8);
     255            KERNEL_GENERATE_CASE(U16);
     256            KERNEL_GENERATE_CASE(U32);
     257            KERNEL_GENERATE_CASE(U64);
     258            KERNEL_GENERATE_CASE(S8);
     259            KERNEL_GENERATE_CASE(S16);
     260            KERNEL_GENERATE_CASE(S32);
     261            KERNEL_GENERATE_CASE(S64);
     262            KERNEL_GENERATE_CASE(F32);
     263            KERNEL_GENERATE_CASE(F64);
     264            KERNEL_GENERATE_CASE(C32);
     265            KERNEL_GENERATE_CASE(C64);
     266
     267        default: {
     268                char* typeStr;
     269                PS_TYPE_NAME(typeStr,xShifts->type.type);
     270                psError(PS_ERR_BAD_PARAMETER_TYPE, true,
     271                        PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
     272                        typeStr);
     273            }
    221274        }
    222275    }
Note: See TracChangeset for help on using the changeset viewer.