IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 21, 2008, 4:10:37 PM (18 years ago)
Author:
Paul Price
Message:

Reworking psImageInterpolate so that kernels are pre-calculated. Renamed a few things in the process: psImageInterpolateOptions --> psImageInterpolation (shorter), PS_INTERPOLATE_BICUBE --> PS_INTERPOLATE_BIQUADRATIC (accurate). I've moved all the interpolation kernels into 1D so that I can pre-calculate them with a reasonable amount of memory. This might be a mistake for the BIQUADRATIC kernel (doesn't have an obvious 1D kernel function), so I might revert just that one soon. Haven't checked if the speed is faster yet, but I checked something in that broke the build, so I need to check this in. Tests pass.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/imageops/tap_psImageInterpolate2.c

    r19129 r20306  
    7979    psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 12345);
    8080
    81     psImageInterpolateOptions *interp = psImageInterpolateOptionsAlloc(mode, image,
    82                                                                        variance, mask, 0, NAN, NAN,
    83                                                                        0, 0, 0.0);
     81    psImageInterpolation *interp = psImageInterpolationAlloc(mode, image, variance, mask, 0, NAN, NAN,
     82                                                             0, 0, 0.0, 0);
    8483    ok(interp, "Interpolation options set");
    8584    skip_start(!interp, 2 * num, "Interpolation options failed");
     
    9392        psMaskType maskVal;
    9493
    95         psImageInterpolateStatus status = psImageInterpolate(&imageVal, &varianceVal, &maskVal, x, y, interp);
    96         ok(status != PS_INTERPOLATE_STATUS_ERROR, "Interpolation at %.2f,%.2f (%x)", x, y, status);
    97         skip_start(status == PS_INTERPOLATE_STATUS_ERROR, 1, "Interpolation failed");
     94        psImageInterpolateStatus interpOK = psImageInterpolate(&imageVal, &varianceVal, &maskVal,
     95                                                               x, y, interp);
     96        ok(interpOK != PS_INTERPOLATE_STATUS_ERROR, "Interpolation at %.2f,%.2f (%x)", x, y, interpOK);
     97        skip_start(interpOK == PS_INTERPOLATE_STATUS_ERROR, 1, "Interpolation failed");
    9898
    99         int xCentral, yCentral;         // Central pixel of interpolation
    100         switch (mode) {
    101           case PS_INTERPOLATE_BICUBE:
    102           case PS_INTERPOLATE_GAUSS:
    103             xCentral = x;
    104             yCentral = y;
    105             break;
    106           default:
    107             xCentral = floor(x - 0.5);
    108             yCentral = floor(y - 0.5);
    109             break;
    110         }
     99        int xCentral = x - 0.5, yCentral = y - 0.5; // Central pixel of interpolation
    111100
    112101        if (xCentral - (xKernel - 1) / 2 < 0 || xCentral + xKernel / 2 > xSize - 1 ||
    113102            yCentral - (yKernel - 1) / 2 < 0 || yCentral + yKernel / 2 > ySize - 1) {
    114             ok(status == PS_INTERPOLATE_STATUS_BAD || status == PS_INTERPOLATE_STATUS_POOR,
    115                "Interpolation at border");
     103            ok(interpOK == PS_INTERPOLATE_STATUS_OFF || interpOK == PS_INTERPOLATE_STATUS_BAD ||
     104               interpOK == PS_INTERPOLATE_STATUS_POOR,
     105               "Interpolation at %.2f,%.2f (border): %x", x, y, interpOK);
    116106        } else {
    117             is_double_tol(imageVal, imageFunc(x, y), tol, "Interpolation = %f vs %f",
    118                           imageVal, imageFunc(x, y));
     107            is_double_tol(imageVal, imageFunc(x, y), tol, "Interpolation = %f vs %f (%d)",
     108                          imageVal, imageFunc(x, y), interpOK);
    119109        }
    120110
     
    146136    check(16, 16, PS_TYPE_F64, 32, PS_INTERPOLATE_BILINEAR, 2, 2, 1.0e-6); // 66 tests
    147137
    148     check(16, 16, PS_TYPE_F32, 32, PS_INTERPOLATE_BICUBE, 3, 3, 1.0e-6); // 66 tests
    149     check(16, 16, PS_TYPE_F64, 32, PS_INTERPOLATE_BICUBE, 3, 3, 1.0e-6); // 66 tests
     138    check(16, 16, PS_TYPE_F32, 32, PS_INTERPOLATE_BIQUADRATIC, 3, 3, 1.0e-6); // 66 tests
     139    check(16, 16, PS_TYPE_F64, 32, PS_INTERPOLATE_BIQUADRATIC, 3, 3, 1.0e-6); // 66 tests
    150140
    151141    check(16, 16, PS_TYPE_F32, 32, PS_INTERPOLATE_GAUSS, 3, 3, 1.0e-3); // 66 tests
Note: See TracChangeset for help on using the changeset viewer.