IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41522 for trunk


Ignore:
Timestamp:
Apr 2, 2021, 2:43:17 PM (5 years ago)
Author:
eugene
Message:

add code (unused in default compile) to allocate static kernel arrays based on max possible size; init the kernel values; add dynamically-allocated version

Location:
trunk/psLib/src/imageops
Files:
1 added
1 edited

Legend:

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

    r35158 r41522  
    5151};
    5252
     53// code below uses statically allocated kernel arrays that need to know the
     54// maximum possible size of a kernel.  16 is >> 8 above
     55# define MAX_KERNEL_SIZE 16
     56# define USE_MAX_KERNEL 0
     57
    5358# if (IS_BILIN_SEPARABLE)
    5459/// Generate a linear interpolation kernel
     
    190195    switch (mode) {
    191196      case PS_INTERPOLATE_FLAT:
     197        // Nothing to pre-compute
     198        break;
    192199      case PS_INTERPOLATE_BILINEAR_SIMPLE:
    193200        // Nothing to pre-compute
     201        kernel[0] = 1.0 - frac;
     202        kernel[1] = frac;
    194203        break;
    195204# if (IS_BILIN_SEPARABLE)
     
    793802
    794803    // Get the appropriate kernels
     804# if (USE_MAX_KERNEL)
     805    psAssert (size <= MAX_KERNEL_SIZE, "oops");
     806    psF32 kernel[MAX_KERNEL_SIZE][MAX_KERNEL_SIZE];
     807    for (int ix = 0; ix < MAX_KERNEL_SIZE; ix++) {
     808      for (int iy = 0; iy < MAX_KERNEL_SIZE; iy++) {
     809        kernel[ix][iy] = 1;
     810      }
     811    }
     812# else
    795813    psF32 kernel[size][size];
     814    for (int ix = 0; ix < size; ix++) {
     815      for (int iy = 0; iy < size; iy++) {
     816        kernel[ix][iy] = 1;
     817      }
     818    }
     819# endif
    796820
    797821# if (IS_BILIN_SEPARABLE)
     
    10601084    if (xExact && yExact) { /* possible alternative */ }
    10611085
     1086# if (USE_MAX_KERNEL)
     1087    psAssert (size <= MAX_KERNEL_SIZE, "oops");
     1088    psF32 xKernel[MAX_KERNEL_SIZE], yKernel[MAX_KERNEL_SIZE]; // Interpolation kernels
     1089    for (int ix = 0; ix < MAX_KERNEL_SIZE; ix++) { xKernel[ix] = 1; yKernel[ix] = 1; }
     1090# else
     1091    // init these arrays
    10621092    psF32 xKernel[size], yKernel[size]; // Interpolation kernels
     1093    for (int ix = 0; ix < size; ix++) { xKernel[ix] = 1; yKernel[ix] = 1; }
     1094# endif
     1095
    10631096    interpolationKernel(xKernel, xFrac, mode);
    10641097    interpolationKernel(yKernel, yFrac, mode);
     
    11111144    if (xExact && yExact) { /* possible alternative */ }
    11121145
     1146# if (USE_MAX_KERNEL)
     1147    psAssert (size <= MAX_KERNEL_SIZE, "oops");
     1148    psF32 xKernel[MAX_KERNEL_SIZE], yKernel[MAX_KERNEL_SIZE]; // Interpolation kernels
     1149    for (int ix = 0; ix < MAX_KERNEL_SIZE; ix++) { xKernel[ix] = 1; yKernel[ix] = 1; }
     1150# else
    11131151    psF32 xKernel[size], yKernel[size]; // Interpolation kernels
     1152    for (int ix = 0; ix < size; ix++) { xKernel[ix] = 1; yKernel[ix] = 1; }
     1153# endif
     1154
    11141155    interpolationKernel(xKernel, xFrac, mode);
    11151156    interpolationKernel(yKernel, yFrac, mode);
     
    11281169    int min = -size/2, max = (size - 1) / 2; // Range for kernel
    11291170    psKernel *kernel = psKernelAlloc(min, max, min, max); // Kernel to return
     1171
     1172    fprintf (stderr, "kernel: %d x %d == %d\n", kernel->image->numRows, kernel->image->numCols, size);
     1173    psAssert (size == kernel->image->numRows, "oops");
     1174    psAssert (size == kernel->image->numCols, "oops");
    11301175
    11311176    for (int y = 0; y < size; y++) {
Note: See TracChangeset for help on using the changeset viewer.