IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9875


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
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/mathtypes/psImage.c

    r9864 r9875  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.117 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2006-11-06 02:00:40 $
     11 *  @version $Revision: 1.118 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2006-11-07 07:45:33 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    811811    if (valid00 && valid10 && valid01 && valid11) { \
    812812        /* formula from the ADD */ \
     813        /* XXX this had V01 and V10 exchanged! */ \
    813814        return V00*FRACFUNC((1.0-fracX)*(1.0-fracY)) + V10*FRACFUNC(fracX*(1.0-fracY)) + \
    814815               V01*FRACFUNC(fracY*(1.0-fracX)) + V11*FRACFUNC(fracX*fracY); \
     
    852853}
    853854
     855// XXX this would be much faster to use a 3x3 kernel to determine the shift
     856// the same function can be used for all equivalent (kernel-based) shifts...
    854857#define PSIMAGE_PIXEL_INTERPOLATE_BICUBE(TYPE, RETURNTYPE, SUFFIX, FRACFUNC) \
    855858inline RETURNTYPE p_psImagePixelInterpolateBICUBE_##SUFFIX( \
  • trunk/psLib/test/imageops

    • Property svn:ignore
      •  

        old new  
        2121*.da
        2222gmon.out
         23tap_psImageShift
  • trunk/psLib/test/imageops/.cvsignore

    r7985 r9875  
    2121*.da
    2222gmon.out
     23tap_psImageShift
  • trunk/psLib/test/imageops/Makefile.am

    r8958 r9875  
    1 AM_CPPFLAGS = $(SRCINC) -I$(top_srcdir)/test/tap/src $(PSLIB_CFLAGS)
     1
     2AM_CPPFLAGS = \
     3        $(SRCINC) \
     4        -I$(top_srcdir)/test/tap/src \
     5        -I$(top_srcdir)/test/pstap/src \
     6        $(PSLIB_CFLAGS)
     7
    28AM_LDFLAGS = \
    39        $(top_builddir)/src/libpslib.la  \
    410        $(top_builddir)/test/tap/src/libtap.la \
     11        $(top_builddir)/test/pstap/src/libpstap.la \
    512        $(PSLIB_LIBS)
    613
    7 TEST_PROGS =
     14TEST_PROGS = \
     15        tap_psImageShift
    816
    917if BUILD_TESTS
  • 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);
  • trunk/psLib/test/pstap/src/pstap.h

    r9868 r9875  
    66return exit_status()
    77
    8        #define mem() ok(psMemCheckLeaks(psMemGetLastId(), NULL, stdout, false) == 0, "Memory Leaks")
     8       # define mem() ok(psMemCheckLeaks(psMemGetLastId(), NULL, stdout, false) == 0, "Memory Leaks")
    99
    10        #define checkLeaks false
     10       # define checkLeaks false
    1111
    12        #define checkMem() if(checkLeaks) mem()
     12       # define checkMem() if(checkLeaks) mem()
    1313
    14            #ifdef __GNUC__
     14           # ifdef __GNUC__
    1515
    16            // use to test the value of a double
    17            # define ok_double(VALUE,EXPECT,COMMENT, ...)\
    18            ok((fabsl((VALUE)-(EXPECT)) < DBL_EPSILON), COMMENT, ## __VA_ARGS__);
     16           // use to test the value of a float
     17           # define ok_float(VALUE,EXPECT,COMMENT, ...)\
     18           ok((fabs((VALUE)-(EXPECT)) < FLT_EPSILON), COMMENT, ## __VA_ARGS__);
    1919
    20 // use to test the value of a float
    21 # define ok_float(VALUE,EXPECT,COMMENT, ...)\
    22 ok((fabs((VALUE)-(EXPECT)) < FLT_EPSILON), COMMENT, ## __VA_ARGS__);
     20// use to test the value of a double
     21# define ok_double(VALUE,EXPECT,COMMENT, ...)\
     22ok((fabsl((VALUE)-(EXPECT)) < DBL_EPSILON), COMMENT, ## __VA_ARGS__);
     23
     24// use to test the value of a float within a defined tolerance
     25# define ok_float_tol(VALUE,EXPECT,TOL,COMMENT, ...)\
     26ok((fabs((VALUE)-(EXPECT)) < (TOL)), COMMENT, ## __VA_ARGS__);
     27
     28// use to test the value of a double within a defined tolerance
     29# define ok_double_tol(VALUE,EXPECT,TOL,COMMENT, ...)\
     30ok((fabsl((VALUE)-(EXPECT)) < (TOL)), COMMENT, ## __VA_ARGS__);
    2331
    2432# define ok_str(VALUE,EXPECT,COMMENT, ...)\
     
    3038#elif __STDC_VERSION__ >= 199901L /* __GNUC__ */
    3139
     40// use to test the value of a float
     41# define ok_float(VALUE,EXPECT, ...)\
     42ok((fabs((VALUE)-(EXPECT)) < FLT_EPSILON), __VA_ARGS__);
     43
    3244// use to test the value of a double
    3345# define ok_double(VALUE,EXPECT, ...)\
     
    3547
    3648// use to test the value of a float
    37 # define ok_float(VALUE,EXPECT, ...)\
    38 ok((fabs((VALUE)-(EXPECT)) < FLT_EPSILON), __VA_ARGS__);
     49# define ok_float_tol(VALUE,EXPECT,TOL, ...)\
     50ok((fabs((VALUE)-(EXPECT)) < (TOL)), __VA_ARGS__);
     51
     52// use to test the value of a double
     53# define ok_double_tol(VALUE,EXPECT,TOL, ...)\
     54ok((fabsl((VALUE)-(EXPECT)) < )(TOL)), __VA_ARGS__);
    3955
    4056# define ok_str(VALUE,EXPECT, ...)\
Note: See TracChangeset for help on using the changeset viewer.