IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 6, 2006, 9:45:33 PM (20 years ago)
Author:
magnier
Message:

added tests for psImageShift and psImageInterpolate, fixed low-level bugs in psImageInterpolate BILINEAR, added BICUBE; added ok_float_tol and ok_double_tol to pstap.h

Location:
trunk/psLib/test/mathtypes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/mathtypes

    • Property svn:ignore
      •  

        old new  
        1616*.da
        1717gmon.out
         18tap_psImageInterpolate
  • trunk/psLib/test/mathtypes/.cvsignore

    r7985 r9875  
    1616*.da
    1717gmon.out
     18tap_psImageInterpolate
  • trunk/psLib/test/mathtypes/tap_psImageInterpolate.c

    r9863 r9875  
    88int main (void)
    99{
    10     plan_tests(14);
     10    plan_tests(47);
    1111
    1212    diag("psImageInterpolate() tests");
     
    1515    {
    1616        psMemId id = psMemGetId();
     17
     18        diag ("interpolate a delta function");
     19
     20        // generate simple image (x ramp)
     21        psImage *image = psImageAlloc(32, 32, PS_TYPE_F32);
     22        ok(image != NULL, "psImage successfully allocated");
     23        skip_start(image == NULL, 5, "Skipping tests because psImageAlloc() failed");
     24
     25        image->data.F32[10][10] = 1;
     26
     27        // center of pixels is 0.5, 0.5
     28        float value;
     29
     30        value = psImagePixelInterpolate (image, 10.5, 10.5, NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR);
     31        ok_float (value, 1.0, "pixel center value - %f", value);
     32
     33        diag ("why do I need to have tolerances of 4epsilon or so??");
     34        value = psImagePixelInterpolate (image, 10.9, 10.5, NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR);
     35        ok_float_tol (value, 0.6, 4.0*FLT_EPSILON, "pixel value - %.20f", value);
     36
     37        value = psImagePixelInterpolate (image, 10.5, 10.9, NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR);
     38        ok_float_tol (value, 0.6, 4.0*FLT_EPSILON, "pixel value - %.20f", value);
     39
     40        value = psImagePixelInterpolate (image, 10.1, 10.5, NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR);
     41        ok_float_tol (value, 0.6, 4.0*FLT_EPSILON, "pixel value - %.20f", value);
     42
     43        skip_end();
     44
     45        psFree(image);
     46        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     47    }
     48
     49    // very simple tests: no mask, bilinear mode, xramp image only
     50    {
     51        psMemId id = psMemGetId();
     52
     53        diag ("interpolate an x-ramp");
    1754
    1855        // generate simple image (x ramp)
     
    66103        psMemId id = psMemGetId();
    67104
    68         // generate simple image (x ramp)
     105        diag ("interpolate a y-ramp: ");
     106
     107        // generate simple image (y ramp)
    69108        psImage *image = psImageAlloc(32, 32, PS_TYPE_F32);
    70109        ok(image != NULL, "psImage successfully allocated");
     
    106145        psMemId id = psMemGetId();
    107146
     147        diag ("interpolate an x-ramp (bicube)");
     148
    108149        // generate simple image (x ramp)
    109150        psImage *image = psImageAlloc(32, 32, PS_TYPE_F32);
     
    136177        ok_float (value, 2.8, "coord: 2.8, 2.8, value: %f", value);
    137178
    138         // no extrapolation: unsure of result
     179        diag ("coords outside of nominal range (1 < x < Nx - 2) return 'uncover'");
     180
     181        // no extrapolation: these return the 'uncover' value
    139182        value = psImagePixelInterpolate (image, 0.8, 2.8, NULL, 0, 0.0, PS_INTERPOLATE_BICUBE);
    140         ok_float (value, 0.8, "coord: 0.8, 2.8, value: %f", value);
     183        ok_float (value, 0.0, "coord: 0.8, 2.8, value: %f", value);
    141184
    142185        value = psImagePixelInterpolate (image, 0.3, 2.8, NULL, 0, 0.0, PS_INTERPOLATE_BICUBE);
    143         ok_float (value, 0.5, "coord: 0.3, 2.8, value: %f", value);
     186        ok_float (value, 0.0, "coord: 0.3, 2.8, value: %f", value);
    144187
    145188        value = psImagePixelInterpolate (image, -0.2, 2.8, NULL, 0, 0.0, PS_INTERPOLATE_BICUBE);
    146         ok_float (value, 0.5, "coord: -0.2, 2.8, value: %f", value);
     189        ok_float (value, 0.0, "coord: -0.2, 2.8, value: %f", value);
    147190
    148191        skip_end();
     
    156199        psMemId id = psMemGetId();
    157200
    158         // generate simple image (x ramp)
     201        diag ("interpolate a y-ramp (bicube)");
     202
     203        // generate simple image (y ramp)
    159204        psImage *image = psImageAlloc(32, 32, PS_TYPE_F32);
    160205        ok(image != NULL, "psImage successfully allocated");
     
    196241        psMemId id = psMemGetId();
    197242
     243        diag ("interpolate a quadratic shape (bicube)");
     244
    198245        // generate simple image (x ramp)
    199246        psImage *image = psImageAlloc(32, 32, PS_TYPE_F32);
Note: See TracChangeset for help on using the changeset viewer.