IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 4, 2007, 12:42:02 PM (19 years ago)
Author:
Paul Price
Message:

Reworking image interpolation to work on mask and variance image
simultaneously with the proper image. Working in the idea of having
"good", "bad" and "poor" output mask pixels (taken from Andy Becker),
where "poor" pixels have at least one bad input pixel contributing to
the flux, but the contribution is small (where 'small' is defined by a
user option). To handle all the options, created a
psImageInterpolateOptions structure, which contains all the things
which are constant while looping over an image (including the input
image, variance and mask). Changed function name, and split code out
of psImage.[ch] into its own file. Function returns boolean error
status; output values for image, variance and mask come from pointers
to double. Added interpolation types (GAUSS, LANCZOS2, LANCZOS3,
LANCZOS4). Using a fairly general framework so that additional
interpolation methods might be easily added. Updated tests and other
dependent code. Tests pass (but only test BILINEAR and BICUBE), and
pswarp works (but currently only uses BILINEAR).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/mathtypes/tap_psImageInterpolate.c

    r12607 r12741  
    88int main (void)
    99{
    10     plan_tests(47);
     10    plan_tests(88);
    1111
    1212//    diag("psImageInterpolate() tests");
     
    1919
    2020        // 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         is_float (value, 1.0, "pixel center value - %f", value);
     21        psImage *image = psImageAlloc(32, 32, PS_TYPE_F64);
     22        ok(image != NULL, "psImage successfully allocated");
     23        skip_start(image == NULL, 5, "Skipping tests because psImageAlloc() failed");
     24
     25        psImageInit(image, 0.0);
     26        image->data.F64[10][10] = 1;
     27
     28        // center of pixels is 0.5, 0.5
     29        double value;
     30
     31        psImageInterpolateOptions *interp = psImageInterpolateOptionsAlloc(PS_INTERPOLATE_BILINEAR,
     32                                                                           image, NULL, NULL, 0, 0.0, 0.0,
     33                                                                           0, 0, 0.0);
     34        ok(interp, "Interpolation options set");
     35
     36        ok(psImageInterpolate(&value, NULL, NULL, 10.5, 10.5, interp), "Interpolation");
     37        is_double (value, 1.0, "pixel center value - %f", value);
    3238
    3339//        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         is_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         is_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         is_float_tol (value, 0.6, 4.0*FLT_EPSILON, "pixel value - %.20f", value);
     40
     41        ok(psImageInterpolate(&value, NULL, NULL, 10.9, 10.5, interp), "Interpolation");
     42        is_double_tol (value, 0.6, 4.0*FLT_EPSILON, "pixel value - %.20f", value);
     43
     44        ok(psImageInterpolate(&value, NULL, NULL, 10.5, 10.9, interp), "Interpolation");
     45        is_double_tol (value, 0.6, 4.0*FLT_EPSILON, "pixel value - %.20f", value);
     46
     47        ok(psImageInterpolate(&value, NULL, NULL, 10.1, 10.5, interp), "Interpolation");
     48        is_double_tol (value, 0.6, 4.0*FLT_EPSILON, "pixel value - %.20f", value);
     49
     50        psFree(interp);
    4251
    4352        skip_end();
     
    5463
    5564        // generate simple image (x ramp)
    56         psImage *image = psImageAlloc(32, 32, PS_TYPE_F32);
     65        psImage *image = psImageAlloc(32, 32, PS_TYPE_F64);
     66        ok(image != NULL, "psImage successfully allocated");
     67        skip_start(image == NULL, 5, "Skipping tests because psImageAlloc() failed");
     68
     69        for (int j = 0; j < image->numRows; j++) {
     70            for (int i = 0; i < image->numCols; i++) {
     71                image->data.F64[j][i] = i + 0.5;
     72            }
     73        }
     74
     75        // center of pixels is 0.5, 0.5
     76        double value;
     77
     78        psImageInterpolateOptions *interp = psImageInterpolateOptionsAlloc(PS_INTERPOLATE_BILINEAR,
     79                                                                           image, NULL, NULL, 0, 0.0, 0.0,
     80                                                                           0, 0, 0.0);
     81        ok(interp, "Interpolation options set");
     82
     83        ok(psImageInterpolate(&value, NULL, NULL, 2.5, 2.5, interp), "Interpolation");
     84        is_double_tol (value, 2.5, 5.0e-8, "pixel center value - %f", value);
     85
     86        ok(psImageInterpolate(&value, NULL, NULL, 2.2, 2.5, interp), "Interpolation");
     87        is_double_tol (value, 2.2, 5.0e-8, "coord: 2.2, 2.5, value: %f", value);
     88
     89        ok(psImageInterpolate(&value, NULL, NULL, 2.8, 2.5, interp), "Interpolation");
     90        is_double_tol (value, 2.8, 5.0e-8, "coord: 2.8, value: %f", value);
     91
     92        ok(psImageInterpolate(&value, NULL, NULL, 2.8, 2.2, interp), "Interpolation");
     93        is_double_tol (value, 2.8, 5.0e-8, "coord: 2.8, value: %f", value);
     94
     95        ok(psImageInterpolate(&value, NULL, NULL, 2.8, 2.8, interp), "Interpolation");
     96        is_double_tol (value, 2.8, 5.0e-8, "coord: 2.8, value: %f", value);
     97
     98        ok(psImageInterpolate(&value, NULL, NULL, 0.8, 2.8, interp), "Interpolation");
     99        is_double_tol (value, 0.8, 5.0e-8, "coord: 0.8, value: %f", value);
     100
     101        // no extrapolation
     102        ok(psImageInterpolate(&value, NULL, NULL, 0.3, 2.8, interp), "Interpolation");
     103        is_double (value, 0.0, "coord: 0.3, value: %f", value);
     104
     105        ok(psImageInterpolate(&value, NULL, NULL, -0.2, 2.8, interp), "Interpolation");
     106        is_double (value, 0.0, "coord: -0.2, value: %f", value);
     107
     108        psFree(interp);
     109
     110        skip_end();
     111
     112        psFree(image);
     113        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     114    }
     115
     116    // very simple tests: no mask, bilinear mode, yramp image only
     117    {
     118        psMemId id = psMemGetId();
     119
     120//        diag ("interpolate a y-ramp: ");
     121
     122        // generate simple image (y ramp)
     123        psImage *image = psImageAlloc(32, 32, PS_TYPE_F64);
    57124        ok(image != NULL, "psImage successfully allocated");
    58125        skip_start(image == NULL, 5, "Skipping tests because psImageAlloc() failed");
     
    61128        {
    62129            for (int i = 0; i < image->numCols; i++) {
    63                 image->data.F32[j][i] = i + 0.5;
    64             }
    65         }
    66 
    67         // center of pixels is 0.5, 0.5
    68         float value;
    69 
    70         value = psImagePixelInterpolate (image, 2.5, 2.5, NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR);
    71         is_float (value, 2.5, "pixel center value - %f", value);
    72 
    73         value = psImagePixelInterpolate (image, 2.2, 2.5, NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR);
    74         is_float (value, 2.2, "coord: 2.2, 2.5, value: %f", value);
    75 
    76         value = psImagePixelInterpolate (image, 2.8, 2.5, NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR);
    77         is_float (value, 2.8, "coord: 2.8, value: %f", value);
    78 
    79         value = psImagePixelInterpolate (image, 2.8, 2.2, NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR);
    80         is_float (value, 2.8, "coord: 2.8, value: %f", value);
    81 
    82         value = psImagePixelInterpolate (image, 2.8, 2.8, NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR);
    83         is_float (value, 2.8, "coord: 2.8, value: %f", value);
    84 
    85         value = psImagePixelInterpolate (image, 0.8, 2.8, NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR);
    86         is_float (value, 0.8, "coord: 0.8, value: %f", value);
    87 
    88         // no extrapolation
    89         value = psImagePixelInterpolate (image, 0.3, 2.8, NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR);
    90         is_float (value, 0.5, "coord: 0.3, value: %f", value);
    91 
    92         value = psImagePixelInterpolate (image, -0.2, 2.8, NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR);
    93         is_float (value, 0.5, "coord: -0.2, value: %f", value);
    94 
    95         skip_end();
    96 
    97         psFree(image);
    98         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    99     }
    100 
    101     // very simple tests: no mask, bilinear mode, yramp image only
    102     {
    103         psMemId id = psMemGetId();
    104 
    105 //        diag ("interpolate a y-ramp: ");
    106 
    107         // generate simple image (y ramp)
    108         psImage *image = psImageAlloc(32, 32, PS_TYPE_F32);
     130                image->data.F64[j][i] = j + 0.5;
     131            }
     132        }
     133
     134        // center of pixels is 0.5, 0.5
     135        double value;
     136
     137        psImageInterpolateOptions *interp = psImageInterpolateOptionsAlloc(PS_INTERPOLATE_BILINEAR,
     138                                                                           image, NULL, NULL, 0, 0.0, 0.0,
     139                                                                           0, 0, 0.0);
     140        ok(interp, "Interpolation options set");
     141
     142        ok(psImageInterpolate(&value, NULL, NULL, 2.5, 2.5, interp), "Interpolation");
     143        is_double_tol (value, 2.5, 5.0e-8, "pixel center value - %f", value);
     144
     145        ok(psImageInterpolate(&value, NULL, NULL, 2.2, 2.2, interp), "Interpolation");
     146        is_double_tol (value, 2.2, 5.0e-8, "coord: 2.2, 2.2, value: %f", value);
     147
     148        ok(psImageInterpolate(&value, NULL, NULL, 2.5, 2.8, interp), "Interpolation");
     149        is_double_tol (value, 2.8, 5.0e-8, "coord: 2.8, value: %f", value);
     150
     151        ok(psImageInterpolate(&value, NULL, NULL, 2.2, 2.8, interp), "Interpolation");
     152        is_double_tol (value, 2.8, 5.0e-8, "coord: 2.8, value: %f", value);
     153
     154        ok(psImageInterpolate(&value, NULL, NULL, 2.8, 2.8, interp), "Interpolation");
     155        is_double_tol (value, 2.8, 5.0e-8, "coord: 2.8, value: %f", value);
     156
     157        psFree(interp);
     158
     159        skip_end();
     160
     161        psFree(image);
     162        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     163    }
     164
     165    // very simple tests: no mask, bicube mode, xramp image only
     166    {
     167        psMemId id = psMemGetId();
     168
     169//        diag ("interpolate an x-ramp (bicube)");
     170
     171        // generate simple image (x ramp)
     172        psImage *image = psImageAlloc(32, 32, PS_TYPE_F64);
    109173        ok(image != NULL, "psImage successfully allocated");
    110174        skip_start(image == NULL, 5, "Skipping tests because psImageAlloc() failed");
     
    113177        {
    114178            for (int i = 0; i < image->numCols; i++) {
    115                 image->data.F32[j][i] = j + 0.5;
    116             }
    117         }
    118 
    119         // center of pixels is 0.5, 0.5
    120         float value;
    121 
    122         value = psImagePixelInterpolate (image, 2.5, 2.5, NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR);
    123         is_float (value, 2.5, "pixel center value - %f", value);
    124 
    125         value = psImagePixelInterpolate (image, 2.2, 2.2, NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR);
    126         is_float (value, 2.2, "coord: 2.2, 2.5, value: %f", value);
    127 
    128         value = psImagePixelInterpolate (image, 2.5, 2.8, NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR);
    129         is_float (value, 2.8, "coord: 2.8, value: %f", value);
    130 
    131         value = psImagePixelInterpolate (image, 2.2, 2.8, NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR);
    132         is_float (value, 2.8, "coord: 2.8, value: %f", value);
    133 
    134         value = psImagePixelInterpolate (image, 2.8, 2.8, NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR);
    135         is_float (value, 2.8, "coord: 2.8, value: %f", value);
    136 
    137         skip_end();
    138 
    139         psFree(image);
    140         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    141     }
    142 
    143     // very simple tests: no mask, bicube mode, xramp image only
    144     {
    145         psMemId id = psMemGetId();
    146 
    147 //        diag ("interpolate an x-ramp (bicube)");
    148 
    149         // generate simple image (x ramp)
    150         psImage *image = psImageAlloc(32, 32, PS_TYPE_F32);
     179                image->data.F64[j][i] = i + 0.5;
     180            }
     181        }
     182
     183        // center of pixels is 0.5, 0.5
     184        double value;
     185
     186        psImageInterpolateOptions *interp = psImageInterpolateOptionsAlloc(PS_INTERPOLATE_BICUBE,
     187                                                                           image, NULL, NULL, 0, 0.0, 0.0,
     188                                                                           0, 0, 0.0);
     189        ok(interp, "Interpolation options set");
     190
     191        ok(psImageInterpolate(&value, NULL, NULL, 2.5, 2.5, interp), "Interpolation");
     192        is_double_tol (value, 2.5, 5.0e-8, "coord; 2.5, 2.5, value - %f", value);
     193
     194        ok(psImageInterpolate(&value, NULL, NULL, 2.2, 2.5, interp), "Interpolation");
     195        is_double_tol (value, 2.2, 5.0e-8, "coord: 2.2, 2.5, value: %f", value);
     196
     197        ok(psImageInterpolate(&value, NULL, NULL, 2.8, 2.5, interp), "Interpolation");
     198        is_double_tol (value, 2.8, 5.0e-8, "coord: 2.8, 2.5, value: %f", value);
     199
     200        ok(psImageInterpolate(&value, NULL, NULL, 2.8, 2.2, interp), "Interpolation");
     201        is_double_tol (value, 2.8, 5.0e-8, "coord: 2.8, 2.2, value: %f", value);
     202
     203        ok(psImageInterpolate(&value, NULL, NULL, 2.8, 2.8, interp), "Interpolation");
     204        is_double_tol (value, 2.8, 5.0e-8, "coord: 2.8, 2.8, value: %f", value);
     205
     206//        diag ("coords outside of nominal range (1 < x < Nx - 2) return 'uncover'");
     207
     208        // no extrapolation: these return the 'uncover' value
     209        ok(psImageInterpolate(&value, NULL, NULL, 0.8, 2.8, interp), "Interpolation");
     210        is_double (value, 0.0, "coord: 0.8, 2.8, value: %f", value);
     211
     212        ok(psImageInterpolate(&value, NULL, NULL, 0.3, 2.8, interp), "Interpolation");
     213        is_double (value, 0.0, "coord: 0.3, 2.8, value: %f", value);
     214
     215        ok(psImageInterpolate(&value, NULL, NULL, -0.2, 2.8, interp), "Interpolation");
     216        is_double (value, 0.0, "coord: -0.2, 2.8, value: %f", value);
     217
     218        psFree(interp);
     219
     220        skip_end();
     221
     222        psFree(image);
     223        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     224    }
     225
     226    // very simple tests: no mask, bilinear mode, yramp image only
     227    {
     228        psMemId id = psMemGetId();
     229
     230//        diag ("interpolate a y-ramp (bicube)");
     231
     232        // generate simple image (y ramp)
     233        psImage *image = psImageAlloc(32, 32, PS_TYPE_F64);
    151234        ok(image != NULL, "psImage successfully allocated");
    152235        skip_start(image == NULL, 5, "Skipping tests because psImageAlloc() failed");
     
    155238        {
    156239            for (int i = 0; i < image->numCols; i++) {
    157                 image->data.F32[j][i] = i + 0.5;
    158             }
    159         }
    160 
    161         // center of pixels is 0.5, 0.5
    162         float value;
    163 
    164         value = psImagePixelInterpolate (image, 2.5, 2.5, NULL, 0, 0.0, PS_INTERPOLATE_BICUBE);
    165         is_float (value, 2.5, "coord; 2.5, 2.5, value - %f", value);
    166 
    167         value = psImagePixelInterpolate (image, 2.2, 2.5, NULL, 0, 0.0, PS_INTERPOLATE_BICUBE);
    168         is_float (value, 2.2, "coord: 2.2, 2.5, value: %f", value);
    169 
    170         value = psImagePixelInterpolate (image, 2.8, 2.5, NULL, 0, 0.0, PS_INTERPOLATE_BICUBE);
    171         is_float (value, 2.8, "coord: 2.8, 2.5, value: %f", value);
    172 
    173         value = psImagePixelInterpolate (image, 2.8, 2.2, NULL, 0, 0.0, PS_INTERPOLATE_BICUBE);
    174         is_float (value, 2.8, "coord: 2.8, 2.2, value: %f", value);
    175 
    176         value = psImagePixelInterpolate (image, 2.8, 2.8, NULL, 0, 0.0, PS_INTERPOLATE_BICUBE);
    177         is_float (value, 2.8, "coord: 2.8, 2.8, value: %f", value);
    178 
    179 //        diag ("coords outside of nominal range (1 < x < Nx - 2) return 'uncover'");
    180 
    181         // no extrapolation: these return the 'uncover' value
    182         value = psImagePixelInterpolate (image, 0.8, 2.8, NULL, 0, 0.0, PS_INTERPOLATE_BICUBE);
    183         is_float (value, 0.0, "coord: 0.8, 2.8, value: %f", value);
    184 
    185         value = psImagePixelInterpolate (image, 0.3, 2.8, NULL, 0, 0.0, PS_INTERPOLATE_BICUBE);
    186         is_float (value, 0.0, "coord: 0.3, 2.8, value: %f", value);
    187 
    188         value = psImagePixelInterpolate (image, -0.2, 2.8, NULL, 0, 0.0, PS_INTERPOLATE_BICUBE);
    189         is_float (value, 0.0, "coord: -0.2, 2.8, value: %f", value);
    190 
    191         skip_end();
    192 
    193         psFree(image);
    194         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    195     }
    196 
    197     // very simple tests: no mask, bilinear mode, yramp image only
    198     {
    199         psMemId id = psMemGetId();
    200 
    201 //        diag ("interpolate a y-ramp (bicube)");
    202 
    203         // generate simple image (y ramp)
    204         psImage *image = psImageAlloc(32, 32, PS_TYPE_F32);
     240                image->data.F64[j][i] = j + 0.5;
     241            }
     242        }
     243
     244        // center of pixels is 0.5, 0.5
     245        double value;
     246
     247        psImageInterpolateOptions *interp = psImageInterpolateOptionsAlloc(PS_INTERPOLATE_BICUBE,
     248                                                                           image, NULL, NULL, 0, 0.0, 0.0,
     249                                                                           0, 0, 0.0);
     250        ok(interp, "Interpolation options set");
     251
     252        ok(psImageInterpolate(&value, NULL, NULL, 2.5, 2.5, interp), "Interpolation");
     253        is_double_tol (value, 2.5, 5.0e-8, "pixel center value - %f", value);
     254
     255        ok(psImageInterpolate(&value, NULL, NULL, 2.2, 2.2, interp), "Interpolation");
     256        is_double_tol (value, 2.2, 5.0e-8, "coord: 2.2, 2.5, value: %f", value);
     257
     258        ok(psImageInterpolate(&value, NULL, NULL, 2.5, 2.8, interp), "Interpolation");
     259        is_double_tol (value, 2.8, 5.0e-8, "coord: 2.8, value: %f", value);
     260
     261        ok(psImageInterpolate(&value, NULL, NULL, 2.2, 2.8, interp), "Interpolation");
     262        is_double_tol (value, 2.8, 5.0e-8, "coord: 2.8, value: %f", value);
     263
     264        ok(psImageInterpolate(&value, NULL, NULL, 2.8, 2.8, interp), "Interpolation");
     265        is_double_tol (value, 2.8, 5.0e-8, "coord: 2.8, value: %f", value);
     266
     267        psFree(interp);
     268
     269        skip_end();
     270
     271        psFree(image);
     272        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     273    }
     274
     275    // very simple tests: no mask, bilinear mode, x,y 2nd order shape
     276    {
     277        psMemId id = psMemGetId();
     278
     279//        diag ("interpolate a quadratic shape (bicube)");
     280
     281        // generate simple image (x ramp)
     282        psImage *image = psImageAlloc(32, 32, PS_TYPE_F64);
    205283        ok(image != NULL, "psImage successfully allocated");
    206284        skip_start(image == NULL, 5, "Skipping tests because psImageAlloc() failed");
     
    209287        {
    210288            for (int i = 0; i < image->numCols; i++) {
    211                 image->data.F32[j][i] = j + 0.5;
    212             }
    213         }
    214 
    215         // center of pixels is 0.5, 0.5
    216         float value;
    217 
    218         value = psImagePixelInterpolate (image, 2.5, 2.5, NULL, 0, 0.0, PS_INTERPOLATE_BICUBE);
    219         is_float (value, 2.5, "pixel center value - %f", value);
    220 
    221         value = psImagePixelInterpolate (image, 2.2, 2.2, NULL, 0, 0.0, PS_INTERPOLATE_BICUBE);
    222         is_float (value, 2.2, "coord: 2.2, 2.5, value: %f", value);
    223 
    224         value = psImagePixelInterpolate (image, 2.5, 2.8, NULL, 0, 0.0, PS_INTERPOLATE_BICUBE);
    225         is_float (value, 2.8, "coord: 2.8, value: %f", value);
    226 
    227         value = psImagePixelInterpolate (image, 2.2, 2.8, NULL, 0, 0.0, PS_INTERPOLATE_BICUBE);
    228         is_float (value, 2.8, "coord: 2.8, value: %f", value);
    229 
    230         value = psImagePixelInterpolate (image, 2.8, 2.8, NULL, 0, 0.0, PS_INTERPOLATE_BICUBE);
    231         is_float (value, 2.8, "coord: 2.8, value: %f", value);
    232 
    233         skip_end();
    234 
    235         psFree(image);
    236         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    237     }
    238 
    239     // very simple tests: no mask, bilinear mode, x,y 2nd order shape
    240     {
    241         psMemId id = psMemGetId();
    242 
    243 //        diag ("interpolate a quadratic shape (bicube)");
    244 
    245         // generate simple image (x ramp)
    246         psImage *image = psImageAlloc(32, 32, PS_TYPE_F32);
    247         ok(image != NULL, "psImage successfully allocated");
    248         skip_start(image == NULL, 5, "Skipping tests because psImageAlloc() failed");
    249 
    250         for (int j = 0; j < image->numRows; j++)
    251         {
    252             for (int i = 0; i < image->numCols; i++) {
    253                 image->data.F32[j][i] = 0.25*PS_SQR(i + 0.5) + j + 0.5;
    254             }
    255         }
    256 
    257         // center of pixels is 0.5, 0.5
    258         float value;
    259 
    260         value = psImagePixelInterpolate (image, 2.5, 2.5, NULL, 0, 0.0, PS_INTERPOLATE_BICUBE);
    261         is_float (value, 4.0625, "pixel center value - %f", value);
    262 
    263         value = psImagePixelInterpolate (image, 2.2, 2.2, NULL, 0, 0.0, PS_INTERPOLATE_BICUBE);
    264         is_float (value, 3.41, "coord: 2.2, 2.5, value: %f", value);
    265 
    266         value = psImagePixelInterpolate (image, 2.5, 2.8, NULL, 0, 0.0, PS_INTERPOLATE_BICUBE);
    267         is_float (value, 4.3625002, "coord: 2.5, 2.8, value: %f", value);
    268 
    269         value = psImagePixelInterpolate (image, 2.2, 2.8, NULL, 0, 0.0, PS_INTERPOLATE_BICUBE);
    270         is_float (value, 4.010000229, "coord: 2.2, 2.8, value: %f", value);
    271 
    272         value = psImagePixelInterpolate (image, 2.8, 2.8, NULL, 0, 0.0, PS_INTERPOLATE_BICUBE);
    273         is_float (value, 4.75999975, "coord: 2.8, 2.8, value: %f", value);
     289                image->data.F64[j][i] = 0.25*PS_SQR(i + 0.5) + j + 0.5;
     290            }
     291        }
     292
     293        // center of pixels is 0.5, 0.5
     294        double value;
     295
     296        psImageInterpolateOptions *interp = psImageInterpolateOptionsAlloc(PS_INTERPOLATE_BICUBE,
     297                                                                           image, NULL, NULL, 0, 0.0, 0.0,
     298                                                                           0, 0, 0.0);
     299        ok(interp, "Interpolation options set");
     300
     301        ok(psImageInterpolate(&value, NULL, NULL, 2.5, 2.5, interp), "Interpolation");
     302        is_double_tol (value, 4.0625, 2.0e-7, "pixel center value - %f", value);
     303
     304        ok(psImageInterpolate(&value, NULL, NULL, 2.2, 2.2, interp), "Interpolation");
     305        is_double_tol (value, 3.41, 2.0e-7, "coord: 2.2, 2.5, value: %f", value);
     306
     307        ok(psImageInterpolate(&value, NULL, NULL, 2.5, 2.8, interp), "Interpolation");
     308        is_double_tol (value, 4.3625, 2.0e-7, "coord: 2.5, 2.8, value: %f", value);
     309
     310        ok(psImageInterpolate(&value, NULL, NULL, 2.2, 2.8, interp), "Interpolation");
     311        is_double_tol (value, 4.01, 2.0e-7, "coord: 2.2, 2.8, value: %f", value);
     312
     313        ok(psImageInterpolate(&value, NULL, NULL, 2.8, 2.8, interp), "Interpolation");
     314        is_double_tol (value, 4.76, 2.0e-7, "coord: 2.8, 2.8, value: %f", value);
     315
     316        psFree(interp);
    274317
    275318        skip_end();
Note: See TracChangeset for help on using the changeset viewer.