00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifdef HAVE_CONFIG_H
00021 # include <config.h>
00022 #endif
00023
00024
00025
00026
00027
00028 #include <cpl.h>
00029
00030 #include <visir_utils.h>
00031 #include <string.h>
00032 #include <stdlib.h>
00033
00034 #include "visir_serialize.c"
00035
00036
00040
00041
00042 #define CONCAT(a,b) a ## _ ## b
00043 #define CONCAT2X(a,b) CONCAT(a,b)
00044
00045 #define PIXEL_TYPE double
00046 #define STDEV_TYPE CPL_TYPE_DOUBLE
00047 #define PIXEL_TYPE_CPL CPL_TYPE_DOUBLE
00048 static int prnok_nz = 0;
00049 static double * prnok = NULL;
00050 #include "../recipes/visir_util_clip_body.c"
00051 #undef PIXEL_TYPE
00052 #undef STDEV_TYPE
00053 #undef PIXEL_TYPE_CPL
00054
00055
00056 #define IND(x,y,nx) ((x) + (y) * (nx))
00057
00058 size_t visir_get_next_regular(size_t a);
00059
00060 static void visir_serialize_test(void);
00061 static void visir_macro_test(void);
00062 static void visir_bound_test(void);
00063 static void visir_get_kth_test(void);
00064 static void visir_clip_kappa_sigma_test(void);
00065 static void visir_fftxcorrelate_test(void);
00066 static void visir_interpolate_rejected_test(void);
00067 static void visir_num_threads_test(void);
00068 static void visir_mean_fast_test(void);
00069 static void visir_next_regular_test(void);
00070 static void visir_test_parallel_median(void);
00071 static void visir_test_linintp_values(void);
00072 #include <cxlist.h>
00073 #include <stdlib.h>
00074
00075
00079
00080
00081 #define LEN(a) sizeof((a))/sizeof((a)[0])
00082
00083 int main(void)
00084 {
00085
00086 cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
00087 visir_serialize_test();
00088 visir_macro_test();
00089 visir_bound_test();
00090 visir_get_kth_test();
00091 visir_clip_kappa_sigma_test();
00092 visir_fftxcorrelate_test();
00093 visir_interpolate_rejected_test();
00094 visir_num_threads_test();
00095 visir_mean_fast_test();
00096 visir_next_regular_test();
00097 visir_test_parallel_median();
00098 visir_test_linintp_values();
00099
00100 return cpl_test_end(0);
00101 }
00102
00103
00104 static void visir_num_threads_test(void)
00105 {
00106 FILE * stream;
00107
00108 stream = cpl_msg_get_level() > CPL_MSG_INFO
00109 ? fopen("/dev/null", "a") : stdout;
00110
00111 {
00112 const char * orig = getenv("OMP_NUM_THREADS");
00113 unsetenv("OMP_NUM_THREADS");
00114 cpl_test_lt(0, visir_get_num_threads(CPL_FALSE));
00115 unsetenv("OMP_NUM_THREADS");
00116 cpl_test_lt(0, visir_get_num_threads(CPL_FALSE));
00117 setenv("OMP_NUM_THREADS", "1", 1);
00118 cpl_test_eq(visir_get_num_threads(CPL_FALSE), 1);
00119 setenv("OMP_NUM_THREADS", "3", 1);
00120 cpl_test_eq(visir_get_num_threads(CPL_FALSE), 3);
00121 setenv("OMP_NUM_THREADS", "-3", 1);
00122 cpl_test_eq(visir_get_num_threads(CPL_FALSE), 1);
00123 setenv("OMP_NUM_THREADS", "4ghdsg", 1);
00124 cpl_test_eq(visir_get_num_threads(CPL_FALSE), 4);
00125 setenv("OMP_NUM_THREADS", "ghdsg", 1);
00126 cpl_test_eq(visir_get_num_threads(CPL_FALSE), 1);
00127 setenv("OMP_NUM_THREADS", "490348563984693763894", 1);
00128 cpl_test_lt(0, visir_get_num_threads(CPL_FALSE));
00129 setenv("OMP_NUM_THREADS", "20000", 1);
00130 cpl_test_lt(0, visir_get_num_threads(CPL_TRUE));
00131 cpl_test_lt(visir_get_num_threads(CPL_TRUE), 20000);
00132 if (orig)
00133 setenv("OMP_NUM_THREADS", orig, 1);
00134 else
00135 unsetenv("OMP_NUM_THREADS");
00136 }
00137
00138 cpl_test_nonnull( stream );
00139 if (stream != stdout) cpl_test_zero( fclose(stream) );
00140 }
00141
00142 static void visir_serialize_test(void)
00143 {
00144 FILE * stream;
00145
00146 stream = cpl_msg_get_level() > CPL_MSG_INFO
00147 ? fopen("/dev/null", "a") : stdout;
00148
00149 {
00150 char * block = cpl_malloc(5);
00151 visir_stream * wstream = visir_stream_new(block, 5);
00152 serialize_string(wstream, "12345");
00153 serialize_uint32(wstream, 12345);
00154 visir_stream * rstream =
00155 visir_stream_new(wstream->base_buffer, 0);
00156 cpl_free(wstream);
00157 char * rs = deserialize_string(rstream);
00158 int ri = deserialize_uint32(rstream);
00159 cpl_test(strcmp(rs, "12345") == 0);
00160 cpl_test_eq(ri, 12345);
00161 cpl_free(rs);
00162 cpl_free(rstream->base_buffer);
00163 cpl_free(rstream);
00164 }
00165
00166 {
00167 cpl_frameset * frames = cpl_frameset_new();
00168 size_t size;
00169 char * s = visir_frameset_serialize(frames, NULL);
00170 cpl_test_eq_ptr(s, NULL);
00171 cpl_test_error(CPL_ERROR_NULL_INPUT);
00172
00173 s = visir_frameset_serialize(frames, &size);
00174 cpl_frameset * d = visir_frameset_deserialize(s, NULL);
00175 cpl_test_eq(cpl_frameset_get_size(frames), cpl_frameset_get_size(d));
00176 cpl_frameset_delete(d);
00177 cpl_free(s);
00178
00179
00180 for (int i = 0; i < 17; i++) {
00181 cpl_frame * frm = cpl_frame_new();
00182 cpl_frame_set_tag(frm, "test");
00183 cpl_frame_set_group(frm, CPL_FRAME_GROUP_PRODUCT);
00184 cpl_frame_set_level(frm, CPL_FRAME_LEVEL_FINAL);
00185 cpl_frame_set_type(frm, CPL_FRAME_TYPE_TABLE);
00186 cpl_frame_set_filename(frm, "filename.fits");
00187 cpl_frameset_insert(frames, frm);
00188
00189 frm = cpl_frame_new();
00190 cpl_frame_set_tag(frm, "tsdfasfijiotw3ty");
00191 cpl_frame_set_group(frm, CPL_FRAME_GROUP_PRODUCT);
00192 cpl_frame_set_level(frm, CPL_FRAME_LEVEL_INTERMEDIATE);
00193 cpl_frame_set_type(frm, CPL_FRAME_TYPE_IMAGE);
00194 cpl_frame_set_filename(frm, "folder/fiename.fits");
00195 cpl_frameset_insert(frames, frm);
00196
00197 frm = cpl_frame_new();
00198 cpl_frame_set_tag(frm, "TSDFASFIJIOTW3TY");
00199 cpl_frame_set_group(frm, CPL_FRAME_GROUP_RAW);
00200 cpl_frame_set_level(frm, CPL_FRAME_LEVEL_TEMPORARY);
00201 cpl_frame_set_type(frm, CPL_FRAME_TYPE_PAF);
00202 cpl_frame_set_filename(frm, "/folder/fiename.fits");
00203 cpl_frameset_insert(frames, frm);
00204 }
00205
00206 s = visir_frameset_serialize(frames, &size);
00207 cpl_test_lt(0, size);
00208 size_t size2;
00209 d = visir_frameset_deserialize(s, &size2);
00210 cpl_test_eq(cpl_frameset_get_size(frames), cpl_frameset_get_size(d));
00211 cpl_test_eq(size, size2);
00212
00213 for (cpl_size i = 0; i < cpl_frameset_get_size(d); i++) {
00214 const cpl_frame * nfrm = cpl_frameset_get_position_const(d, i);
00215 const cpl_frame * ofrm = cpl_frameset_get_position_const(frames, i);
00216 cpl_test_eq(cpl_frame_get_group(ofrm), cpl_frame_get_group(nfrm));
00217 cpl_test_eq(cpl_frame_get_level(ofrm), cpl_frame_get_level(nfrm));
00218 cpl_test_eq(cpl_frame_get_type(ofrm), cpl_frame_get_type(nfrm));
00219 cpl_test_zero(strcmp(cpl_frame_get_tag(ofrm),
00220 cpl_frame_get_tag(nfrm)));
00221 cpl_test_zero(strcmp(cpl_frame_get_filename(ofrm),
00222 cpl_frame_get_filename(nfrm)));
00223 }
00224
00225 cpl_free(s);
00226 cpl_frameset_delete(frames);
00227 cpl_frameset_delete(d);
00228 }
00229
00230 cpl_test_nonnull( stream );
00231
00232 if (stream != stdout) cpl_test_zero( fclose(stream) );
00233
00234 }
00235
00236 static void visir_macro_test(void)
00237 {
00238 FILE * stream;
00239
00240 stream = cpl_msg_get_level() > CPL_MSG_INFO
00241 ? fopen("/dev/null", "a") : stdout;
00242
00243 {
00244 double a[10];
00245 size_t i = 0;
00246
00247 cx_list * l = cx_list_new();
00248 for (i = 0; i < LEN(a); i++)
00249 cx_list_push_back(l, (void*)&a[i]);
00250
00251 i = 0;
00252 FOR_EACH(it, l)
00253 cpl_test_eq_ptr(&a[i++], cx_list_get(l, it));
00254
00255 cpl_test_eq(i, LEN(a));
00256 cpl_test_eq((size_t)cx_list_size(l), LEN(a));
00257
00258 i = 0;
00259 FOR_EACH_T(void * p, l)
00260 cpl_test_eq_ptr(&a[i++], p);
00261
00262 cpl_test_eq(i, LEN(a));
00263 cpl_test_eq((size_t)cx_list_size(l), LEN(a));
00264
00265 cx_list_delete(l);
00266 }
00267
00268 cpl_test_nonnull( stream );
00269
00270 if (stream != stdout) cpl_test_zero( fclose(stream) );
00271
00272 }
00273
00274
00275 static void visir_bound_test(void)
00276 {
00277 FILE * stream;
00278
00279 stream = cpl_msg_get_level() > CPL_MSG_INFO
00280 ? fopen("/dev/null", "a") : stdout;
00281
00282 {
00283 cpl_vector * v = cpl_vector_new(10);
00284 cpl_vector_fill(v, 0.);
00285 cpl_test_eq(visir_lower_bound(v, 0.), 0);
00286 cpl_test_eq(visir_upper_bound(v, 0.), 10);
00287 cpl_vector_delete(v);
00288 }
00289 {
00290 double d[] = {1., 1., 2., 3., 3., 4., 5., 5.};
00291 cpl_vector * v = cpl_vector_wrap(LEN(d), d);
00292 cpl_test_eq(visir_lower_bound(v, 0.), 0);
00293 cpl_test_eq(visir_lower_bound(v, 1.), 0);
00294 cpl_test_eq(visir_lower_bound(v, 1.1), 2);
00295 cpl_test_eq(visir_lower_bound(v, 2.), 2);
00296 cpl_test_eq(visir_lower_bound(v, 2.1), 3);
00297 cpl_test_eq(visir_lower_bound(v, 5.), LEN(d) - 2);
00298 cpl_test_eq(visir_lower_bound(v, 6.), LEN(d));
00299
00300 cpl_test_eq(visir_upper_bound(v, 0.), 0);
00301 cpl_test_eq(visir_upper_bound(v, 1.), 2);
00302 cpl_test_eq(visir_upper_bound(v, 1.1), 2);
00303 cpl_test_eq(visir_upper_bound(v, 2.), 3);
00304 cpl_test_eq(visir_upper_bound(v, 2.1), 3);
00305 cpl_test_eq(visir_upper_bound(v, 4.), LEN(d) - 2);
00306 cpl_test_eq(visir_upper_bound(v, 5.), LEN(d));
00307 cpl_test_eq(visir_upper_bound(v, 6.), LEN(d));
00308 cpl_vector_unwrap(v);
00309 }
00310
00311 cpl_test_nonnull( stream );
00312
00313 if (stream != stdout) cpl_test_zero( fclose(stream) );
00314
00315 }
00316
00317 static void visir_get_kth_test(void)
00318 {
00319 FILE * stream;
00320 double res = -1;
00321
00322 stream = cpl_msg_get_level() > CPL_MSG_INFO
00323 ? fopen("/dev/null", "a") : stdout;
00324
00325 {
00326 double a[10];
00327
00328 for (size_t i = 0; i < LEN(a); i++)
00329 a[i] = 0;
00330 for (size_t i = 0; i < LEN(a); i++) {
00331 res = cpl_tools_get_kth_double(a, LEN(a), i);
00332 cpl_test_eq(0, res);
00333 }
00334
00335 for (size_t i = 0; i < LEN(a); i++)
00336 a[i] = i;
00337 for (size_t i = 0; i < LEN(a); i++) {
00338 res = cpl_tools_get_kth_double(a, LEN(a), i);
00339 cpl_test_eq(i, res);
00340 }
00341
00342 for (size_t i = 0; i < LEN(a); i++)
00343 a[i] = -(int)i;
00344 for (size_t i = 0; i < LEN(a); i++) {
00345 res = cpl_tools_get_kth_double(a, LEN(a), i);
00346 cpl_test_eq((double)i - LEN(a) + 1., res);
00347 }
00348 }
00349
00350 {
00351 double a[] = {3,1,4,2,0,9,7,8,6,5};
00352 res = cpl_tools_get_kth_double(a, LEN(a), 4);
00353 cpl_test_eq(4, res);
00354 for (size_t i = 0; i < LEN(a) / 2; i++)
00355 cpl_test_leq(a[i], 4);
00356 for (size_t i = LEN(a)/2; i < LEN(a); i++)
00357 cpl_test_lt(4, a[i]);
00358 }
00359
00360 {
00361 double a[] = {8,5,9,2,0,4,6,3,7,1};
00362 res = cpl_tools_get_kth_double(a, LEN(a), 2);
00363 cpl_test_eq(2, res);
00364 res = cpl_tools_get_kth_double(a, LEN(a), 7);
00365 cpl_test_eq(7, res);
00366
00367 cpl_test_eq(9, a[LEN(a) - 1]);
00368 cpl_test_eq(8, a[LEN(a) - 2]);
00369 cpl_test_eq(0, a[0]);
00370 cpl_test_eq(1, a[1]);
00371 }
00372
00373 {
00374 double a[] = {8,5,9,2,0,4,6,3,7,1};
00375 res = cpl_tools_get_kth_double(a, LEN(a), 7);
00376 cpl_test_eq(7, res);
00377 res = cpl_tools_get_kth_double(a, LEN(a), 2);
00378 cpl_test_eq(2, res);
00379
00380 cpl_test_eq(9, a[LEN(a) - 1]);
00381 cpl_test_eq(8, a[LEN(a) - 2]);
00382 cpl_test_eq(0, a[0]);
00383 cpl_test_eq(1, a[1]);
00384 }
00385
00386 cpl_test_nonnull( stream );
00387
00388 if (stream != stdout) cpl_test_zero( fclose(stream) );
00389
00390 }
00391
00392 static void visir_clip_kappa_sigma_test(void)
00393 {
00394 FILE * stream;
00395 int dump;
00396
00397 stream = cpl_msg_get_level() > CPL_MSG_INFO
00398 ? fopen("/dev/null", "a") : stdout;
00399
00400 cpl_test_nonnull( stream );
00401
00402 {
00403 double * pixels = cpl_calloc(9, sizeof(double));
00404 int shifts[3 * 2] = {0};
00405 pixels[1 + 3 * 1] = 1;
00406
00407 cpl_imagelist * list = cpl_imagelist_new();
00408 cpl_imagelist * dev = cpl_imagelist_new();
00409
00410 cpl_image* img = cpl_image_wrap_double(3, 3, pixels);
00411 cpl_imagelist_set(list, img, 0);
00412 img = cpl_image_duplicate(img);
00413 cpl_imagelist_set(list, img, 1);
00414 img = cpl_image_duplicate(img);
00415 cpl_imagelist_set(list, img, 2);
00416
00417 visir_util_clip_kappa_sigma_double(list, dev, 1.0, 3, 3, shifts);
00418
00419 cpl_image * map = cpl_image_new_from_accepted(list);
00420 cpl_test_eq(3, cpl_image_get(map, 2, 2, &dump));
00421
00422 cpl_image_delete(map);
00423 cpl_imagelist_delete(list);
00424 cpl_imagelist_delete(dev);
00425 }
00426
00427
00428 {
00429 double * pixels = cpl_calloc(9, sizeof(double));
00430
00431 int values[] = {92, 93, 94, 94, 95, 95, 96, 96, 96, 97,
00432 97, 97, 97, 98, 98, 98, 98, 99, 99, 99,
00433 99, 100, 100, 100, 100, 100, 101, 101, 101, 101,
00434 102, 102, 102, 102, 103, 103, 103, 103, 104, 104,
00435 104, 105, 105, 106, 106, 107, 108 };
00436 int shifts[LEN(values) * 2] = {0};
00437
00438 cpl_imagelist * list = cpl_imagelist_new();
00439 cpl_imagelist * dev = cpl_imagelist_new();
00440
00441 cpl_image* img = cpl_image_wrap_double(3, 3, pixels);
00442 for (size_t i = 0; i < LEN(values); i++) {
00443 cpl_image_set(img, 2, 2, values[i]);
00444 cpl_imagelist_set(list, img, i);
00445 img = cpl_image_duplicate(img);
00446 }
00447 cpl_image_delete(img);
00448
00449 visir_util_clip_kappa_sigma_double(list, dev, 1.0, 3, 3, shifts);
00450
00451 cpl_image * map = cpl_image_new_from_accepted(list);
00452 cpl_test_eq(LEN(values), cpl_image_get(map, 2, 2, &dump));
00453
00454 cpl_image_delete(map);
00455 cpl_imagelist_delete(list);
00456 cpl_imagelist_delete(dev);
00457 }
00458
00459 {
00460 double * pixels = cpl_calloc(9, sizeof(double));
00461
00462 int values[] = {1, 150, 94, 94, 95, 95, 96, 96, 96, 97,
00463 97, 97, 97, 98, 98, 98, 98, 99, 99, 99,
00464 99, 100, 100, 100, 100, 100, 101, 101, 101, 101,
00465 102, 102, 102, 102, 103, 103, 103, 103, 104, 104,
00466 104, 105, 105, 106, 106, 107, 108 };
00467 int shifts[LEN(values) * 2] = {0};
00468
00469 cpl_imagelist * list = cpl_imagelist_new();
00470 cpl_imagelist * dev = cpl_imagelist_new();
00471
00472 cpl_image* img = cpl_image_wrap_double(3, 3, pixels);
00473 for (size_t i = 0; i < LEN(values); i++) {
00474 cpl_image_set(img, 2, 2, values[i]);
00475 cpl_imagelist_set(list, img, i);
00476 img = cpl_image_duplicate(img);
00477 }
00478 cpl_image_delete(img);
00479
00480 visir_util_clip_kappa_sigma_double(list, dev, 1.0, 3, 3, shifts);
00481
00482 cpl_image * map = cpl_image_new_from_accepted(list);
00483
00484
00485
00486 cpl_test_eq(LEN(values) - 2, cpl_image_get(map, 2, 2, &dump));
00487
00488 cpl_image_delete(map);
00489 cpl_imagelist_delete(list);
00490 cpl_imagelist_delete(dev);
00491 }
00492
00493 {
00494 double * pixels = cpl_calloc(9, sizeof(double));
00495 cpl_msg_info(cpl_func, "-----------------");
00496 int values[] = { -3, 10, 10, 10, 10, 10, 10, 10 };
00497 int shifts[LEN(values) * 2] = {0};
00498
00499 cpl_imagelist * list = cpl_imagelist_new();
00500 cpl_imagelist * dev = cpl_imagelist_new();
00501
00502 cpl_image* origimg = cpl_image_wrap_double(3, 3, pixels);
00503 for (size_t i = 0; i < LEN(values); i++) {
00504 cpl_image * img = cpl_image_duplicate(origimg);
00505 if (i == 1) {
00506 cpl_image_set(img, 1, 2, values[i]);
00507 shifts[i * 2] = -1;
00508 }
00509 else if (i == 2) {
00510 cpl_image_set(img, 2, 3, values[i]);
00511 shifts[i * 2 + 1] = 1;
00512 }
00513 else if (i == 3) {
00514 cpl_image_set(img, 3, 1, values[i]);
00515 shifts[i * 2] = 1;
00516 shifts[i * 2 + 1] = -1;
00517 }
00518 else
00519 cpl_image_set(img, 2, 2, values[i]);
00520 cpl_imagelist_set(list, img, i);
00521 }
00522 cpl_image_delete(origimg);
00523
00524 visir_util_clip_kappa_sigma_double(list, dev, 1.0, 2, 2, shifts);
00525
00526 cpl_image * map = cpl_image_new_from_accepted(list);
00527
00528
00529
00530 if (0) {
00531 cpl_test_eq(LEN(values) - 2, cpl_image_get(map, 1, 1, &dump));
00532 cpl_test_eq(LEN(values) - 1, cpl_image_get(map, 1, 2, &dump));
00533 cpl_test_eq(LEN(values) - 2, cpl_image_get(map, 1, 3, &dump));
00534 cpl_test_eq(LEN(values) - 1, cpl_image_get(map, 2, 1, &dump));
00535 cpl_test_eq(LEN(values) - 1, cpl_image_get(map, 2, 2, &dump));
00536 cpl_test_eq(LEN(values) - 1, cpl_image_get(map, 2, 3, &dump));
00537 cpl_test_eq(LEN(values) - 1, cpl_image_get(map, 3, 1, &dump));
00538 cpl_test_eq(LEN(values) - 1, cpl_image_get(map, 3, 2, &dump));
00539 cpl_test_eq(LEN(values) - 2, cpl_image_get(map, 3, 3, &dump));
00540 }
00541 else
00542 cpl_test_eq(LEN(values) - 1, cpl_image_get(map, 2, 2, &dump));
00543
00544 cpl_image_delete(map);
00545 cpl_imagelist_delete(list);
00546 cpl_imagelist_delete(dev);
00547 }
00548
00549
00550 {
00551 double * pixels = cpl_calloc(9, sizeof(double));
00552
00553 int values[] = {1, 150, -94, 94, 95, 95, 96, 96, 96, 97,
00554 97, 97, 97, 98, 98, 98, 98, 99, 99, 99,
00555 99, 100, 100, 100, 100, 100, 101, 101, 101, 101,
00556 102, 102, 102, 102, 103, 103, 103, 103, 104, 104,
00557 104, 105, 105, 106, 106, 107, 108 };
00558 int shifts[LEN(values) * 2] = {0};
00559 shifts[2] = 1;
00560 shifts[4] = 1;
00561 cpl_image * out1, * out2;
00562
00563 cpl_imagelist * list = cpl_imagelist_new();
00564 cpl_imagelist * dev = cpl_imagelist_new();
00565
00566 cpl_image* img = cpl_image_wrap_double(3, 3, pixels);
00567 for (size_t i = 0; i < LEN(values); i++) {
00568 cpl_image_set(img, 2, 2, values[i]);
00569 cpl_imagelist_set(list, img, i);
00570 img = cpl_image_duplicate(img);
00571 }
00572 cpl_image_delete(img);
00573 out1 = cpl_imagelist_get(list, 1);
00574 out2 = cpl_imagelist_get(list, 2);
00575 cpl_image_set(out1, 2, 2, 0);
00576 cpl_image_set(out1, 3, 2, -94);
00577 cpl_image_set(out2, 2, 2, 0);
00578 cpl_image_set(out2, 3, 2, 150);
00579
00580 visir_util_clip_kappa_sigma_double(list, dev, 1.0, 3, 3, shifts);
00581
00582 cpl_image * map = cpl_image_new_from_accepted(list);
00583
00584
00585
00586 cpl_test_eq(LEN(values) - 1, cpl_image_get(map, 2, 2, &dump));
00587 cpl_test_eq(LEN(values) - 2, cpl_image_get(map, 3, 2, &dump));
00588 dump = 0;
00589 cpl_image_get(out1, 3, 2, &dump);
00590 cpl_test_eq(dump, 1);
00591 dump = 0;
00592 cpl_image_get(out2, 3, 2, &dump);
00593 cpl_test_eq(dump, 1);
00594
00595 cpl_image_delete(map);
00596 cpl_imagelist_delete(list);
00597 cpl_imagelist_delete(dev);
00598 }
00599 cpl_free(prnok);
00600 prnok_nz = 0;
00601
00602 if (stream != stdout) cpl_test_zero( fclose(stream) );
00603
00604 }
00605
00606 static void visir_fftxcorrelate_test(void)
00607 {
00608 FILE * stream;
00609
00610 stream = cpl_msg_get_level() > CPL_MSG_INFO
00611 ? fopen("/dev/null", "a") : stdout;
00612
00613 cpl_test_nonnull( stream );
00614 {
00615 double xshift = 0, yshift = 0;
00616 double max_correlation;
00617 double * values = cpl_calloc(16, sizeof(double));
00618 cpl_error_code err;
00619
00620 values[IND(2,2,4)] = 1;
00621 cpl_image * tmp = cpl_image_wrap_double(4, 4, values);
00622 values = cpl_calloc(16, sizeof(double));
00623 values[IND(3,3,4)] = 1;
00624 cpl_image * img2 = cpl_image_wrap_double(4, 4, values);
00625
00626 err = visir_fftxcorrelate(tmp, img2, CPL_TRUE, &xshift, &yshift,
00627 &max_correlation, NULL);
00628 cpl_test_eq(CPL_ERROR_NONE, err);
00629
00630 cpl_test_rel(1, xshift, 0.05);
00631 cpl_test_rel(1, yshift, 0.05);
00632
00633 err = visir_fftxcorrelate(tmp, img2, CPL_TRUE,
00634 &xshift, NULL, NULL, NULL);
00635 cpl_test_eq(CPL_ERROR_NONE, err);
00636 cpl_test_rel(1, xshift, 0.05);
00637
00638 err = visir_fftxcorrelate(tmp, img2, CPL_TRUE,
00639 NULL, &yshift, NULL, NULL);
00640 cpl_test_eq(CPL_ERROR_NONE, err);
00641 cpl_test_rel(1, yshift, 0.05);
00642
00643 err = visir_fftxcorrelate(tmp, img2, CPL_TRUE, NULL, NULL,
00644 &max_correlation, NULL);
00645 cpl_test_eq(CPL_ERROR_NONE, err);
00646 cpl_test_lt(0.91, max_correlation);
00647
00648 err = visir_fftxcorrelate(tmp, img2, CPL_FALSE,
00649 NULL, NULL, NULL, NULL);
00650 cpl_test_eq(CPL_ERROR_NONE, err);
00651
00652 cpl_image_delete(tmp);
00653 cpl_image_delete(img2);
00654 }
00655
00656 {
00657 cpl_size N = 10;
00658 double xshift = 0, yshift = 0;
00659 double max_correlation;
00660 double * values = cpl_calloc(N*(N+5), sizeof(double));
00661 cpl_error_code err;
00662
00663 values[IND(5,5,N)] = 1;
00664 values[IND(5,6,N)] = 9;
00665 values[IND(3,5,N)] = 2;
00666 values[IND(3,7,N)] = -3;
00667 cpl_image * tmp = cpl_image_wrap_double(N,N+5, values);
00668 cpl_image * img2 = cpl_image_duplicate(tmp);
00669
00670 err = visir_fftxcorrelate(tmp, img2, CPL_TRUE, &xshift, &yshift,
00671 &max_correlation, NULL);
00672 cpl_test_eq(CPL_ERROR_NONE, err);
00673
00674 cpl_test_rel(1, xshift + 1, 0.05);
00675 cpl_test_rel(1, yshift + 1, 0.05);
00676 cpl_test_rel(1.00, max_correlation, 0.02);
00677
00678 cpl_image_delete(tmp);
00679 cpl_image_delete(img2);
00680 }
00681
00682 {
00683 cpl_size N = 5;
00684 double xshift = 0, yshift = 0;
00685 double * values = cpl_calloc(N*N, sizeof(double));
00686 cpl_error_code err;
00687
00688 values[IND(2,1,N)] = 1;
00689 values[IND(2,2,N)] = 3;
00690 values[IND(2,3,N)] = 2;
00691 cpl_image * tmp = cpl_image_wrap_double(N, N, values);
00692 values = cpl_calloc(N*N, sizeof(double));
00693 values[IND(2,1,N)] = 0.5;
00694 values[IND(2,2,N)] = 2;
00695 values[IND(2,3,N)] = 2.5;
00696 values[IND(2,4,N)] = 1;
00697 cpl_image * img2 = cpl_image_wrap_double(N, N, values);
00698
00699 err = visir_fftxcorrelate(tmp, img2, CPL_TRUE, &xshift, &yshift,
00700 NULL, NULL);
00701 cpl_test_eq(CPL_ERROR_NONE, err);
00702
00703 cpl_test_rel(1, xshift+1, 0.05);
00704
00705 cpl_test_rel(0.5, yshift, 0.15);
00706
00707 cpl_image_delete(tmp);
00708 cpl_image_delete(img2);
00709 }
00710
00711 {
00712 cpl_size N = 5;
00713 double xshift = 0, yshift = 0;
00714 double max_correlation;
00715 double * values = cpl_calloc(N*N, sizeof(double));
00716 cpl_error_code err;
00717
00718 values[IND(2,1,N)] = 1;
00719 values[IND(2,2,N)] = 3;
00720 values[IND(2,3,N)] = 2;
00721 cpl_image * tmp = cpl_image_wrap_double(N, N, values);
00722 values = cpl_calloc(N*N, sizeof(double));
00723 values[IND(3,0,N)] = 2;
00724 values[IND(3,1,N)] = 2.5;
00725 values[IND(3,2,N)] = 1;
00726 cpl_image * img2 = cpl_image_wrap_double(N, N, values);
00727
00728 err = visir_fftxcorrelate(tmp, img2, CPL_TRUE, &xshift, &yshift,
00729 &max_correlation, NULL);
00730 cpl_test_eq(CPL_ERROR_NONE, err);
00731
00732 cpl_test_rel(1, xshift, 0.05);
00733
00734 cpl_test_rel(-1.5, yshift, 0.1);
00735
00736 cpl_image_delete(tmp);
00737 cpl_image_delete(img2);
00738 }
00739
00740 {
00741 double xshift = 0, yshift = 0;
00742 double max_correlation;
00743 double * values = cpl_calloc(16, sizeof(double));
00744 cpl_error_code err;
00745
00746 values[IND(2,2,4)] = 1;
00747 cpl_image * tmp = cpl_image_wrap_double(4, 4, values);
00748 values = cpl_calloc(16, sizeof(double));
00749 values[IND(3,1,4)] = 2;
00750 values[IND(1,1,4)] = 200;
00751 cpl_image * img2 = cpl_image_wrap_double(4, 4, values);
00752
00753 cpl_mask * m = cpl_mask_threshold_image_create(img2, 10, FLT_MAX);
00754 cpl_image_reject_from_mask(img2, m);
00755 cpl_mask_delete(m);
00756
00757 err = visir_fftxcorrelate(tmp, img2, CPL_TRUE, &xshift, &yshift,
00758 &max_correlation, NULL);
00759 cpl_test_eq(CPL_ERROR_NONE, err);
00760
00761 cpl_test_rel(1, xshift, 0.05);
00762 cpl_test_rel(-1, yshift, 0.05);
00763
00764 cpl_image_delete(tmp);
00765 cpl_image_delete(img2);
00766 }
00767
00768 {
00769 cpl_size Nx = 8, Ny = 4;
00770 double xshift = 0, yshift = 0;
00771 double max_correlation;
00772 double * values = cpl_calloc(Nx*Ny, sizeof(double));
00773 cpl_error_code err;
00774
00775 values[IND(2,1,Nx)] = 1;
00776 values[IND(2,2,Nx)] = 3;
00777 values[IND(2,3,Nx)] = 2;
00778 cpl_image * tmp = cpl_image_wrap_double(Nx, Ny, values);
00779 values = cpl_calloc(Nx*Ny, sizeof(double));
00780 values[IND(3,0,Nx)] = 2;
00781 values[IND(3,1,Nx)] = 2.5;
00782 values[IND(3,2,Nx)] = 1;
00783 cpl_image * img2 = cpl_image_wrap_double(Nx, Ny, values);
00784
00785 err = visir_fftxcorrelate(tmp, img2, CPL_TRUE, &xshift, &yshift,
00786 &max_correlation, NULL);
00787 cpl_test_eq(CPL_ERROR_NONE, err);
00788
00789 cpl_test_rel(1, xshift, 0.05);
00790
00791 cpl_test_rel(-1.5, yshift, 0.1);
00792
00793 cpl_image_delete(tmp);
00794 cpl_image_delete(img2);
00795 }
00796
00797 {
00798 cpl_size Nx = 18, Ny = 27;
00799 double xshift = 0, yshift = 0;
00800 double max_correlation = 0;
00801 double * values = cpl_calloc(Nx*Ny, sizeof(double));
00802 cpl_error_code err;
00803
00804 values[IND(5, 8,Nx)] = 1;
00805 values[IND(5, 9,Nx)] = 3;
00806 values[IND(5,10,Nx)] = 2;
00807 values[IND(4, 9,Nx)] = 1;
00808 values[IND(5, 9,Nx)] = 3;
00809 values[IND(6, 9,Nx)] = 2;
00810 cpl_image * tmp = cpl_image_wrap_double(Nx, Ny, values);
00811 values = cpl_calloc(Nx*Ny, sizeof(double));
00812 values[IND(4, 9,Nx)] = 1;
00813 values[IND(4,10,Nx)] = 3;
00814 values[IND(4,11,Nx)] = 2;
00815 values[IND(3,10,Nx)] = 1;
00816 values[IND(4,10,Nx)] = 3;
00817 values[IND(5,10,Nx)] = 2;
00818 cpl_image * img2 = cpl_image_wrap_double(Nx, Ny, values);
00819 visir_fftx_cache * cache = visir_new_fftx_cache();
00820
00821 err = visir_fftxcorrelate(tmp, img2, CPL_TRUE, &xshift, &yshift,
00822 &max_correlation, cache);
00823 cpl_test_eq(CPL_ERROR_NONE, err);
00824 cpl_test_rel(-1, xshift, 0.05);
00825 cpl_test_rel(1, yshift, 0.05);
00826 cpl_test_rel(1, max_correlation, 0.05);
00827
00828 double xshift2 = 0, yshift2 = 0;
00829 double max_correlation2 = 0;
00830 err = visir_fftxcorrelate(tmp, img2, CPL_TRUE, &xshift2, &yshift2,
00831 &max_correlation2, cache);
00832 cpl_test_eq(CPL_ERROR_NONE, err);
00833 cpl_test_eq(xshift, xshift2);
00834 cpl_test_eq(yshift, yshift2);
00835 cpl_test_eq(max_correlation, max_correlation2);
00836
00837 cpl_image_delete(tmp);
00838 visir_delete_fftx_cache(cache);
00839 cpl_image_delete(img2);
00840 }
00841
00842 if (stream != stdout) cpl_test_zero( fclose(stream) );
00843 }
00844
00845 static void visir_interpolate_rejected_test(void)
00846 {
00847 FILE * stream;
00848
00849 stream = cpl_msg_get_level() > CPL_MSG_INFO
00850 ? fopen("/dev/null", "a") : stdout;
00851
00852 cpl_test_nonnull( stream );
00853
00854 {
00855 float input[] = {
00856 1,9,3,9,
00857 0,9,4,1,
00858 9,2,0,1,
00859 1,0,3,0};
00860 cpl_binary bpmdata[] = {
00861 0,1,0,1,
00862 0,1,0,0,
00863 1,0,1,0,
00864 1,1,0,0};
00865 float expected[] = {
00866 1.0, 2.0, 3.0, 2.0,
00867 0.0, 2.0, 4.0, 1.0,
00868 1.0, 2.0, 2.5, 1.0,
00869 1.5, 2.5, 3.0, 0.0};
00870
00871
00872 cpl_image * in = cpl_image_wrap(4, 4, CPL_TYPE_FLOAT, input);
00873 cpl_mask * bpm = cpl_mask_wrap(4, 4, bpmdata);
00874
00875 cpl_image_reject_from_mask(in, bpm);
00876 cpl_image * in2 = cpl_image_duplicate(in);
00877 cpl_image * in3 = cpl_image_duplicate(in);
00878 cpl_image * ex = cpl_image_wrap(4, 4, CPL_TYPE_FLOAT, expected);
00879 size_t *buffer = NULL;
00880 size_t n;
00881 visir_interpolate_rejected(in, &buffer, &n);
00882 cpl_test_error(CPL_ERROR_NONE);
00883
00884 cpl_test_image_abs(in, ex, 1e-6);
00885
00886 visir_interpolate_rejected(in2, &buffer, &n);
00887 cpl_test_error(CPL_ERROR_NONE);
00888
00889 cpl_test_image_abs(in2, ex, 1e-6);
00890 cpl_test_image_abs(in2, in, 1e-6);
00891
00892 visir_interpolate_rejected(in3, NULL, NULL);
00893 cpl_test_error(CPL_ERROR_NONE);
00894
00895 cpl_test_image_abs(in3, ex, 1e-6);
00896 cpl_test_image_abs(in3, in, 1e-6);
00897
00898 cpl_image_unwrap(in);
00899 cpl_image_delete(in2);
00900 cpl_image_delete(in3);
00901 cpl_mask_unwrap(bpm);
00902 cpl_image_unwrap(ex);
00903 cpl_free(buffer);
00904 }
00905 {
00906 float input[] = {
00907 1,7,3,9,9,9,
00908 0,9,4,1,1,1,
00909 9,2,0,2,2,2,
00910 1,0,3,3,0,2,
00911 1,1,3,0,1,0};
00912 cpl_binary bpmdata[] = {
00913 0,0,0,0,0,0,
00914 0,1,1,0,0,0,
00915 0,1,1,0,0,0,
00916 0,1,1,0,0,0,
00917 0,0,0,0,0,0};
00918 float expected[] = {
00919 1.0,7.0,3.0,9.0,9.0,9.0,
00920 0.0,8./3.,4./3.,1.0,1.0,1.0,
00921 9.0,4.75,4.25,2.0,2.0,2.0,
00922 1.0,5./3.,7./3.,3.0,0.0,2.0,
00923 1.0,1.0,3.0,0.0,1.0,0.0};
00924
00925
00926 cpl_image * in = cpl_image_wrap(6, 5, CPL_TYPE_FLOAT, input);
00927 cpl_mask * bpm = cpl_mask_wrap(6, 5, bpmdata);
00928 cpl_image * ex = cpl_image_wrap(6, 5, CPL_TYPE_FLOAT, expected);
00929
00930 cpl_image_reject_from_mask(in, bpm);
00931 visir_interpolate_rejected(in, NULL, NULL);
00932 cpl_test_error(CPL_ERROR_NONE);
00933
00934 cpl_test_image_abs(in, ex, 1e-6);
00935
00936 cpl_image_unwrap(in);
00937 cpl_mask_unwrap(bpm);
00938 cpl_image_unwrap(ex);
00939 }
00940 {
00941 float input[] = {
00942 1,7,3,9,9,9,
00943 0,9,4,1,1,1,
00944 9,2,0,2,2,2,
00945 1,0,3,3,0,2,
00946 1,1,3,0,1,0};
00947 cpl_binary bpmdata[] = {
00948 0,0,0,0,0,0,
00949 0,1,1,1,1,0,
00950 0,1,1,1,1,1,
00951 0,0,0,0,0,0,
00952 1,1,1,1,1,1};
00953 float expected[] = {
00954 1.0,7.0,3.0,9.0,9.0,9.0,
00955 0.0,7./3.,2.0,13./3.,10./3.,1.0,
00956 9.0,16./3.,5.0,6.0,4.5,1.5,
00957 1.0,0.0,3.0,3.0,0.0,2.0,
00958 1.0,0.0,3.0,3.0,0.0,2.0};
00959
00960
00961 cpl_image * in = cpl_image_wrap(6, 5, CPL_TYPE_FLOAT, input);
00962 cpl_mask * bpm = cpl_mask_wrap(6, 5, bpmdata);
00963 cpl_image * ex = cpl_image_wrap(6, 5, CPL_TYPE_FLOAT, expected);
00964
00965 cpl_image_reject_from_mask(in, bpm);
00966 cpl_image * in2 = cpl_image_duplicate(in);
00967 size_t *buffer = NULL;
00968 size_t n;
00969 visir_interpolate_rejected(in, &buffer, &n);
00970 cpl_test_error(CPL_ERROR_NONE);
00971
00972 cpl_test_image_abs(in, ex, 1e-6);
00973
00974 visir_interpolate_rejected(in, &buffer, &n);
00975 cpl_test_error(CPL_ERROR_NONE);
00976
00977 cpl_test_image_abs(in2, ex, 1e-6);
00978 cpl_test_image_abs(in2, in, 1e-6);
00979
00980 cpl_image_unwrap(in);
00981 cpl_image_delete(in2);
00982 cpl_mask_unwrap(bpm);
00983 cpl_image_unwrap(ex);
00984 cpl_free(buffer);
00985 }
00986
00987 if (stream != stdout) cpl_test_zero( fclose(stream) );
00988 }
00989
00990 static void visir_mean_fast_test(void)
00991 {
00992 FILE * stream;
00993
00994 stream = cpl_msg_get_level() > CPL_MSG_INFO
00995 ? fopen("/dev/null", "a") : stdout;
00996
00997 cpl_test_nonnull( stream );
00998
00999 {
01000 cpl_image * im = cpl_image_new(3, 43, CPL_TYPE_FLOAT);
01001 cpl_image_add_scalar(im, 3.2);
01002 cpl_test_abs(visir_image_get_mean_fast(im), 3.2, FLT_EPSILON);
01003 cpl_image_delete(im);
01004 }
01005 {
01006 cpl_image * im = cpl_image_new(4, 4, CPL_TYPE_FLOAT);
01007 cpl_image_add_scalar(im, 3.2);
01008 cpl_test_abs(visir_image_get_mean_fast(im), 3.2, FLT_EPSILON);
01009 cpl_image_delete(im);
01010 }
01011 {
01012 float val[] =
01013 {0.99226231, 0.6164352, 0.04541705, 0.94691027, 0.68742416};
01014 cpl_image * im = cpl_image_wrap(5, 1, CPL_TYPE_FLOAT, val);
01015 cpl_image_reject(im, 3, 1);
01016 cpl_test_abs(visir_image_get_mean_fast(im), 0.810758, FLT_EPSILON);
01017 cpl_image_unwrap(im);
01018 }
01019 {
01020 for (size_t i = 1; i < 17; i++) {
01021 cpl_image * im = cpl_image_new(1, i, CPL_TYPE_FLOAT);
01022 cpl_image_add_scalar(im, 3.2);
01023 cpl_test_abs(visir_image_get_mean_fast(im), 3.2, FLT_EPSILON);
01024 cpl_image_reject(im, 1, i);
01025 if (i == 1) {
01026 cpl_test_eq(visir_image_get_mean_fast(im), 0.);
01027 }
01028 else {
01029 cpl_test_abs(visir_image_get_mean_fast(im), 3.2, FLT_EPSILON);
01030 }
01031 cpl_image_delete(im);
01032 }
01033 }
01034
01035 if (stream != stdout) cpl_test_zero( fclose(stream) );
01036 }
01037
01038 static void visir_next_regular_test(void)
01039 {
01040 FILE * stream;
01041
01042 stream = cpl_msg_get_level() > CPL_MSG_INFO
01043 ? fopen("/dev/null", "a") : stdout;
01044
01045 cpl_test_nonnull( stream );
01046
01047 cpl_test_eq(visir_get_next_regular(6), 6);
01048 cpl_test_eq(visir_get_next_regular(7), 8);
01049 cpl_test_eq(visir_get_next_regular(9), 9);
01050 cpl_test_eq(visir_get_next_regular(11), 12);
01051 cpl_test_eq(visir_get_next_regular(15), 15);
01052 cpl_test_eq(visir_get_next_regular(64), 64);
01053 cpl_test_eq(visir_get_next_regular(65), 72);
01054 cpl_test_eq(visir_get_next_regular(66), 72);
01055 cpl_test_eq(visir_get_next_regular(67), 72);
01056 cpl_test_eq(visir_get_next_regular(111), 120);
01057 cpl_test_eq(visir_get_next_regular(128), 128);
01058 cpl_test_eq(visir_get_next_regular(129), 135);
01059 cpl_test_eq(visir_get_next_regular(250), 250);
01060 cpl_test_eq(visir_get_next_regular(256), 256);
01061 cpl_test_eq(visir_get_next_regular(257), 270);
01062 cpl_test_eq(visir_get_next_regular(1023), 1024);
01063 cpl_test_eq(visir_get_next_regular(1024), 1024);
01064 cpl_test_eq(visir_get_next_regular(1025), 1080);
01065 cpl_test_eq(visir_get_next_regular(SIZE_MAX - 100), SIZE_MAX - 100);
01066 cpl_test_eq(visir_get_next_regular(SIZE_MAX), SIZE_MAX);
01067
01068 for (cpl_size i = 0; i < 2048; i++) {
01069 size_t r = visir_get_next_regular(i);
01070 cpl_test(r >= (size_t)i);
01071 size_t d = 2;
01072 int large_primes = 0;
01073 while(r > 1) {
01074 while (r % d == 0) {
01075 large_primes += (d > 5);
01076 r /= d;
01077 }
01078 d++;
01079 if (d * d > r || large_primes) {
01080 large_primes += (r > 1) && (d > 5);
01081 break;
01082 }
01083 }
01084
01085 cpl_test_eq(large_primes, 0);
01086 }
01087 if (stream != stdout) cpl_test_zero( fclose(stream) );
01088 }
01089
01090 static void visir_test_parallel_median(void)
01091 {
01092 FILE * stream;
01093
01094 stream = cpl_msg_get_level() > CPL_MSG_INFO
01095 ? fopen("/dev/null", "a") : stdout;
01096
01097 cpl_test_nonnull( stream );
01098 cpl_size nys[] = {1, 3, 4, 100, 105, 217};
01099 for (size_t j = 0; j < sizeof(nys)/sizeof(nys[0]); j++) {
01100 cpl_size ny = nys[j];
01101 cpl_imagelist * l = cpl_imagelist_new();
01102 size_t n = 57;
01103 cpl_size nx = 100;
01104 for (size_t i = 0; i < n; i++) {
01105 cpl_image * img = cpl_image_new(nx, ny, CPL_TYPE_FLOAT);
01106 float * d = cpl_image_get_data_float(img);
01107 for (size_t k = 0; k < (size_t)(nx * ny); k++) {
01108 d[i] = rand() % nx;
01109
01110 cpl_image_reject(img, 1, 1);
01111
01112 if ((rand() % 25) == 0) {
01113 cpl_image_reject(img, k % nx + 1, k / nx + 1);
01114 }
01115 }
01116 cpl_imagelist_set(l, img, i);
01117 }
01118 cpl_msg_info(cpl_func, "parallel median test ny: %ld", (long)ny);
01119 cpl_image * r1 = cpl_imagelist_collapse_median_create(l);
01120 cpl_image * r2 = visir_parallel_median_collapse(l);
01121 cpl_test_image_abs(r1, r2, 0);
01122 cpl_imagelist_delete(l);
01123 cpl_image_delete(r1);
01124 cpl_image_delete(r2);
01125 }
01126 cpl_test_eq_ptr(visir_parallel_median_collapse(NULL), NULL);
01127 cpl_test_error(CPL_ERROR_NULL_INPUT);
01128
01129 cpl_imagelist * elist = cpl_imagelist_new();
01130 cpl_test_eq_ptr(visir_parallel_median_collapse(elist), NULL);
01131 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
01132 cpl_imagelist_delete(elist);
01133
01134 if (stream != stdout) cpl_test_zero( fclose(stream) );
01135 }
01136
01137 static void visir_test_linintp_values(void)
01138 {
01139 FILE * stream;
01140
01141 stream = cpl_msg_get_level() > CPL_MSG_INFO
01142 ? fopen("/dev/null", "a") : stdout;
01143 cpl_image * inp, * eimg, * res;
01144 double refx[] = {10, 20, 30};
01145 double refy[] = {1, 2, 1.5};
01146 size_t nref = sizeof(refx)/sizeof(refx[0]);
01147 cpl_vector * vrefx = cpl_vector_wrap(nref, refx);
01148 cpl_vector * vrefy = cpl_vector_wrap(nref, refy);
01149 cpl_bivector * ref = cpl_bivector_wrap_vectors(vrefx, vrefy);
01150
01151 {
01152 double data[] = {10, 20, 30, 40, 15, 25, 12, 0, 5};
01153
01154 double edat[] = {1, 2, 1.5, 1.5, 1.5, 1.75, 1.2, 1, 1.0};
01155 inp = cpl_image_wrap(2, 4, CPL_TYPE_DOUBLE, data);
01156 eimg = cpl_image_wrap(2, 4, CPL_TYPE_DOUBLE, edat);
01157 res = visir_linintp_values(inp, ref);
01158 cpl_test_image_abs(eimg, res, 1e-7);
01159 cpl_image_unwrap(inp);
01160 cpl_image_unwrap(eimg);
01161 cpl_image_delete(res);
01162 }
01163 cpl_bivector_unwrap_vectors(ref);
01164 cpl_vector_unwrap(vrefx);
01165 cpl_vector_unwrap(vrefy);
01166
01167 if (stream != stdout) cpl_test_zero( fclose(stream) );
01168 }