| 1 |
#include <math.h> |
| 2 |
#include <stdio.h> |
| 3 |
#include <stdlib.h> |
| 4 |
#include <string.h> |
| 5 |
#include <Python.h> |
| 6 |
#ifndef NPY_NO_DEPRECATED_API |
| 7 |
#define NPY_NO_DEPRECATED_API NPY_1_21_API_VERSION |
| 8 |
#endif |
| 9 |
|
| 10 |
#pragma GCC diagnostic push |
| 11 |
#pragma GCC diagnostic ignored "-Wpedantic" |
| 12 |
#include <numpy/arrayobject.h> |
| 13 |
#include <numpy/npy_math.h> |
| 14 |
|
| 15 |
#if !defined(__clang__) && defined(__GNUC__) |
| 16 |
#pragma GCC diagnostic ignored "-Wstringop-truncation" |
| 17 |
|
| 18 |
|
| 19 |
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" |
| 20 |
#endif |
| 21 |
|
| 22 |
#pragma GCC diagnostic ignored "-Wunused-function" |
| 23 |
|
| 24 |
#ifdef WIN32 |
| 25 |
#include "cextern/fct.h" |
| 26 |
#else |
| 27 |
#include "pandokia_fct.h" |
| 28 |
#endif |
| 29 |
|
| 30 |
#pragma GCC diagnostic pop |
| 31 |
|
| 32 |
#include "cdrizzlebox.h" |
| 33 |
#include "cdrizzleblot.h" |
| 34 |
#include "cdrizzlemap.h" |
| 35 |
#include "cdrizzleutil.h" |
| 36 |
#include "drizzletest.h" |
| 37 |
|
| 38 |
FILE *logptr = NULL; |
| 39 |
static integer_t image_size[2]; |
| 40 |
static PyArrayObject *test_data; |
| 41 |
static PyArrayObject *test_weights; |
| 42 |
static PyArrayObject *test_pixmap; |
| 43 |
static PyArrayObject *test_output_data; |
| 44 |
static PyArrayObject *test_output_counts; |
| 45 |
static PyArrayObject *test_context; |
| 46 |
|
| 47 |
static char log_file[] = ""; |
| 48 |
|
| 49 |
void |
| 50 |
set_test_arrays( |
| 51 |
PyArrayObject *dat, PyArrayObject *wei, PyArrayObject *map, PyArrayObject *odat, |
| 52 |
PyArrayObject *ocnt, PyArrayObject *ocon) |
| 53 |
{ |
| 54 |
test_data = dat; |
| 55 |
test_weights = wei; |
| 56 |
test_pixmap = map; |
| 57 |
test_output_data = odat; |
| 58 |
test_output_counts = ocnt; |
| 59 |
test_context = ocon; |
| 60 |
|
| 61 |
get_dimensions(test_data, image_size); |
| 62 |
return; |
| 63 |
} |
| 64 |
|
| 65 |
void |
| 66 |
set_pixmap(struct driz_param_t *p, int xmin, int xmax, int ymin, int ymax) |
| 67 |
{ |
| 68 |
int i, j; |
| 69 |
double xpix, ypix; |
| 70 |
|
| 71 |
ypix = ymin; |
| 72 |
for (j = ymin; j < ymax; j++) { |
| 73 |
xpix = xmin; |
| 74 |
for (i = xmin; i < xmax; i++) { |
| 75 |
get_pixmap(p->pixmap, i, j)[0] = xpix; |
| 76 |
get_pixmap(p->pixmap, i, j)[1] = ypix; |
| 77 |
xpix += 1.0; |
| 78 |
} |
| 79 |
ypix += 1.0; |
| 80 |
} |
| 81 |
|
| 82 |
return; |
| 83 |
} |
| 84 |
|
| 85 |
void |
| 86 |
init_pixmap(struct driz_param_t *p) |
| 87 |
{ |
| 88 |
set_pixmap(p, 0, image_size[0], 0, image_size[1]); |
| 89 |
return; |
| 90 |
} |
| 91 |
|
| 92 |
void |
| 93 |
stretch_pixmap(struct driz_param_t *p, double sx, double sy) |
| 94 |
{ |
| 95 |
int i, j; |
| 96 |
double xpix, ypix; |
| 97 |
|
| 98 |
ypix = 0.0; |
| 99 |
for (j = 0; j < image_size[1]; j++) { |
| 100 |
xpix = 0.0; |
| 101 |
for (i = 0; i < image_size[0]; i++) { |
| 102 |
get_pixmap(p->pixmap, i, j)[0] = sx * xpix; |
| 103 |
get_pixmap(p->pixmap, i, j)[1] = sy * ypix; |
| 104 |
xpix += 1.0; |
| 105 |
} |
| 106 |
ypix += 1.0; |
| 107 |
} |
| 108 |
|
| 109 |
return; |
| 110 |
} |
| 111 |
|
| 112 |
void |
| 113 |
nan_pixmap(struct driz_param_t *p) |
| 114 |
{ |
| 115 |
int i, j; |
| 116 |
|
| 117 |
for (j = 0; j < image_size[1]; j++) { |
| 118 |
for (i = 0; i < image_size[0]; i++) { |
| 119 |
get_pixmap(p->pixmap, i, j)[0] = NPY_NAN; |
| 120 |
get_pixmap(p->pixmap, i, j)[1] = NPY_NAN; |
| 121 |
} |
| 122 |
} |
| 123 |
|
| 124 |
return; |
| 125 |
} |
| 126 |
|
| 127 |
void |
| 128 |
nan_pixel(struct driz_param_t *p, int xpix, int ypix) |
| 129 |
{ |
| 130 |
int idim; |
| 131 |
for (idim = 0; idim < 2; ++idim) { |
| 132 |
get_pixmap(p->pixmap, xpix, ypix)[idim] = NPY_NAN; |
| 133 |
} |
| 134 |
} |
| 135 |
|
| 136 |
void |
| 137 |
offset_pixmap(struct driz_param_t *p, double x_offset, double y_offset) |
| 138 |
{ |
| 139 |
int i, j; |
| 140 |
double xpix, ypix; |
| 141 |
|
| 142 |
ypix = y_offset; |
| 143 |
for (j = 0; j < image_size[1]; j++) { |
| 144 |
xpix = x_offset; |
| 145 |
for (i = 0; i < image_size[0]; i++) { |
| 146 |
get_pixmap(p->pixmap, i, j)[0] = xpix; |
| 147 |
get_pixmap(p->pixmap, i, j)[1] = ypix; |
| 148 |
xpix += 1.0; |
| 149 |
} |
| 150 |
ypix += 1.0; |
| 151 |
} |
| 152 |
|
| 153 |
return; |
| 154 |
} |
| 155 |
|
| 156 |
void |
| 157 |
fill_image(PyArrayObject *image, double value) |
| 158 |
{ |
| 159 |
npy_intp *ndim = PyArray_DIMS(image); |
| 160 |
int ypix, xpix; |
| 161 |
|
| 162 |
for (ypix = 0; ypix < ndim[0]; ++ypix) { |
| 163 |
for (xpix = 0; xpix < ndim[1]; ++xpix) { |
| 164 |
set_pixel(image, xpix, ypix, value); |
| 165 |
} |
| 166 |
} |
| 167 |
|
| 168 |
return; |
| 169 |
} |
| 170 |
|
| 171 |
void |
| 172 |
fill_image_block(PyArrayObject *image, double value, int lo, int hi) |
| 173 |
{ |
| 174 |
int ypix, xpix; |
| 175 |
|
| 176 |
for (ypix = lo; ypix < hi; ++ypix) { |
| 177 |
for (xpix = lo; xpix < hi; ++xpix) { |
| 178 |
set_pixel(image, xpix, ypix, value); |
| 179 |
} |
| 180 |
} |
| 181 |
|
| 182 |
return; |
| 183 |
} |
| 184 |
void |
| 185 |
unset_context(PyArrayObject *context) |
| 186 |
{ |
| 187 |
npy_intp *ndim = PyArray_DIMS(context); |
| 188 |
int ypix, xpix; |
| 189 |
|
| 190 |
for (ypix = 0; ypix < ndim[0]; ++ypix) { |
| 191 |
for (xpix = 0; xpix < ndim[1]; ++xpix) { |
| 192 |
unset_bit(context, xpix, ypix); |
| 193 |
} |
| 194 |
} |
| 195 |
|
| 196 |
return; |
| 197 |
} |
| 198 |
|
| 199 |
void |
| 200 |
print_image(char *title, PyArrayObject *image, int lo, int hi) |
| 201 |
{ |
| 202 |
int j, i; |
| 203 |
|
| 204 |
if (logptr) { |
| 205 |
fprintf(logptr, "\n%s\n", title); |
| 206 |
for (j = lo; j < hi; ++j) { |
| 207 |
for (i = lo; i < hi; ++i) { |
| 208 |
fprintf(logptr, "%10.2f", get_pixel(image, i, j)); |
| 209 |
} |
| 210 |
fprintf(logptr, "\n"); |
| 211 |
} |
| 212 |
} |
| 213 |
|
| 214 |
return; |
| 215 |
} |
| 216 |
|
| 217 |
void |
| 218 |
print_status(char *title) |
| 219 |
{ |
| 220 |
if (logptr) { |
| 221 |
fprintf(logptr, "%s\n", title); |
| 222 |
} |
| 223 |
} |
| 224 |
|
| 225 |
void |
| 226 |
print_context(char *title, struct driz_param_t *p, int lo, int hi) |
| 227 |
{ |
| 228 |
int j, i; |
| 229 |
integer_t bv; |
| 230 |
if (!p->output_context) { |
| 231 |
return; |
| 232 |
} |
| 233 |
|
| 234 |
if (logptr) { |
| 235 |
bv = 1; |
| 236 |
fprintf(logptr, "\n%s\n", title); |
| 237 |
|
| 238 |
for (j = lo; j < hi; ++j) { |
| 239 |
for (i = lo; i < hi; ++i) { |
| 240 |
fprintf(logptr, "%4d", get_bit(p->output_context, i, j, bv)); |
| 241 |
} |
| 242 |
fprintf(logptr, "\n"); |
| 243 |
} |
| 244 |
} |
| 245 |
|
| 246 |
return; |
| 247 |
} |
| 248 |
|
| 249 |
void |
| 250 |
print_pixmap(char *title, struct driz_param_t *p, int lo, int hi) |
| 251 |
{ |
| 252 |
int i, j, k; |
| 253 |
char *axis[2] = {"x", "y"}; |
| 254 |
|
| 255 |
if (logptr) { |
| 256 |
for (k = 0; k < 2; k++) { |
| 257 |
fprintf(logptr, "\n%s %s axis\n", title, axis[k]); |
| 258 |
|
| 259 |
for (j = 0; j < image_size[1]; j++) { |
| 260 |
for (i = 0; i < image_size[0]; i++) { |
| 261 |
if (i >= lo && i < hi && j >= lo && j < hi) { |
| 262 |
fprintf(logptr, "%10.2f", get_pixmap(p->pixmap, i, j)[k]); |
| 263 |
} |
| 264 |
} |
| 265 |
|
| 266 |
if (j >= lo && j < hi) { |
| 267 |
fprintf(logptr, "\n"); |
| 268 |
} |
| 269 |
} |
| 270 |
} |
| 271 |
} |
| 272 |
|
| 273 |
return; |
| 274 |
} |
| 275 |
|
| 276 |
struct driz_param_t * |
| 277 |
setup_parameters(void) |
| 278 |
{ |
| 279 |
struct driz_error_t *error; |
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
struct driz_param_t *p; |
| 284 |
p = (struct driz_param_t *) malloc(sizeof(struct driz_param_t)); |
| 285 |
|
| 286 |
driz_param_init(p); |
| 287 |
|
| 288 |
p->uuid = 1; |
| 289 |
p->xmin = 0; |
| 290 |
p->xmax = image_size[0] - 1; |
| 291 |
p->ymin = 0; |
| 292 |
p->ymax = image_size[1] - 1; |
| 293 |
p->iscale = 1.0f; |
| 294 |
p->pscale_ratio = 1.0f; |
| 295 |
p->pixel_fraction = 1.0; |
| 296 |
p->exposure_time = 1.0; |
| 297 |
p->ef = p->exposure_time; |
| 298 |
p->kernel = kernel_square; |
| 299 |
p->interpolation = interp_poly5; |
| 300 |
p->weight_scale = 1.0; |
| 301 |
|
| 302 |
p->data = test_data; |
| 303 |
p->weights = test_weights; |
| 304 |
p->pixmap = test_pixmap; |
| 305 |
p->output_data = test_output_data; |
| 306 |
p->output_counts = test_output_counts; |
| 307 |
p->output_context = test_context; |
| 308 |
p->nmiss = 0; |
| 309 |
p->nskip = 0; |
| 310 |
|
| 311 |
error = (struct driz_error_t *) malloc(sizeof(struct driz_error_t)); |
| 312 |
driz_error_init(error); |
| 313 |
p->error = error; |
| 314 |
init_pixmap(p); |
| 315 |
|
| 316 |
fill_image(p->data, 0.0); |
| 317 |
fill_image(p->weights, 1.0); |
| 318 |
fill_image(p->output_data, 0.0); |
| 319 |
fill_image(p->output_counts, 0.0); |
| 320 |
unset_context(p->output_context); |
| 321 |
|
| 322 |
if (strlen(log_file)) { |
| 323 |
logptr = fopen(log_file, "a"); |
| 324 |
setbuf(logptr, NULL); |
| 325 |
} else { |
| 326 |
logptr = NULL; |
| 327 |
} |
| 328 |
return p; |
| 329 |
} |
| 330 |
|
| 331 |
void |
| 332 |
teardown_parameters(struct driz_param_t *p) |
| 333 |
{ |
| 334 |
if (logptr) { |
| 335 |
fclose(logptr); |
| 336 |
logptr = NULL; |
| 337 |
} |
| 338 |
|
| 339 |
free(p->error); |
| 340 |
free(p); |
| 341 |
} |
| 342 |
|
| 343 |
FCT_BGN_FN(utest_cdrizzle) |
| 344 |
{ |
| 345 |
FCT_FIXTURE_SUITE_BGN("unit tests for drizzle") |
| 346 |
{ |
| 347 |
FCT_SETUP_BGN() {} |
| 348 |
FCT_SETUP_END(); |
| 349 |
|
| 350 |
FCT_TEARDOWN_BGN() {} |
| 351 |
FCT_TEARDOWN_END(); |
| 352 |
|
| 353 |
FCT_TEST_BGN(utest_shrink_bbox) |
| 354 |
{ |
| 355 |
int xmin, xmax, ymin, ymax; |
| 356 |
struct driz_param_t *p; |
| 357 |
|
| 358 |
p = setup_parameters(); |
| 359 |
nan_pixmap(p); |
| 360 |
|
| 361 |
get_pixmap(p->pixmap, 16, 50)[0] = 16; |
| 362 |
get_pixmap(p->pixmap, 16, 50)[1] = 50; |
| 363 |
get_pixmap(p->pixmap, 85, 51)[0] = 85; |
| 364 |
get_pixmap(p->pixmap, 85, 51)[1] = 51; |
| 365 |
get_pixmap(p->pixmap, 57, 18)[0] = 57; |
| 366 |
get_pixmap(p->pixmap, 57, 18)[1] = 18; |
| 367 |
get_pixmap(p->pixmap, 47, 68)[0] = 47; |
| 368 |
get_pixmap(p->pixmap, 47, 68)[1] = 68; |
| 369 |
|
| 370 |
xmin = 11; |
| 371 |
xmax = 98; |
| 372 |
ymin = 7; |
| 373 |
ymax = 88; |
| 374 |
|
| 375 |
shrink_image_section(p->pixmap, &xmin, &xmax, &ymin, &ymax); |
| 376 |
|
| 377 |
fct_chk_eq_int(xmin, 16); |
| 378 |
fct_chk_eq_int(xmax, 85); |
| 379 |
fct_chk_eq_int(ymin, 18); |
| 380 |
fct_chk_eq_int(ymax, 68); |
| 381 |
|
| 382 |
teardown_parameters(p); |
| 383 |
} |
| 384 |
FCT_TEST_END(); |
| 385 |
|
| 386 |
FCT_TEST_BGN(utest_map_lookup_01) |
| 387 |
{ |
| 388 |
struct driz_param_t *p; |
| 389 |
p = setup_parameters(); |
| 390 |
stretch_pixmap(p, 1.0, 1000.0); |
| 391 |
|
| 392 |
double x = get_pixmap(p->pixmap, 1, 1)[0]; |
| 393 |
double y = get_pixmap(p->pixmap, 1, 1)[1]; |
| 394 |
|
| 395 |
fct_chk_eq_dbl(x, 1.0); |
| 396 |
fct_chk_eq_dbl(y, 1000.0); |
| 397 |
|
| 398 |
teardown_parameters(p); |
| 399 |
} |
| 400 |
FCT_TEST_END(); |
| 401 |
|
| 402 |
FCT_TEST_BGN(utest_map_lookup_02) |
| 403 |
{ |
| 404 |
struct driz_param_t *p; |
| 405 |
p = setup_parameters(); |
| 406 |
stretch_pixmap(p, 1.0, 1000.0); |
| 407 |
|
| 408 |
double x = get_pixmap(p->pixmap, 3, 0)[0]; |
| 409 |
double y = get_pixmap(p->pixmap, 3, 0)[1]; |
| 410 |
|
| 411 |
fct_chk_eq_dbl(x, 3.0); |
| 412 |
fct_chk_eq_dbl(y, 0.0); |
| 413 |
|
| 414 |
teardown_parameters(p); |
| 415 |
} |
| 416 |
FCT_TEST_END(); |
| 417 |
|
| 418 |
FCT_TEST_BGN(utest_map_lookup_03) |
| 419 |
{ |
| 420 |
struct driz_param_t *p; |
| 421 |
p = setup_parameters(); |
| 422 |
stretch_pixmap(p, 1.0, 1000.0); |
| 423 |
|
| 424 |
double x = get_pixmap(p->pixmap, 0, 1)[0]; |
| 425 |
double y = get_pixmap(p->pixmap, 0, 1)[1]; |
| 426 |
fct_chk_eq_dbl(x, 0.0); |
| 427 |
fct_chk_eq_dbl(y, 1000.0); |
| 428 |
|
| 429 |
teardown_parameters(p); |
| 430 |
} |
| 431 |
FCT_TEST_END(); |
| 432 |
|
| 433 |
FCT_TEST_BGN(utest_map_lookup_04) |
| 434 |
{ |
| 435 |
struct driz_param_t *p; |
| 436 |
p = setup_parameters(); |
| 437 |
stretch_pixmap(p, 1.0, 1000.0); |
| 438 |
|
| 439 |
double x = get_pixmap(p->pixmap, 3, 1)[0]; |
| 440 |
double y = get_pixmap(p->pixmap, 3, 1)[1]; |
| 441 |
fct_chk_eq_dbl(x, 3.0); |
| 442 |
fct_chk_eq_dbl(y, 1000.0); |
| 443 |
|
| 444 |
teardown_parameters(p); |
| 445 |
} |
| 446 |
FCT_TEST_END(); |
| 447 |
|
| 448 |
FCT_TEST_BGN(utest_compute_pscale_ratio) |
| 449 |
{ |
| 450 |
struct driz_param_t *p; |
| 451 |
struct polygon bp; |
| 452 |
float pscale_ratio; |
| 453 |
const float pscale_ratio_truth = sqrtf(1.2f * 1.7f); |
| 454 |
|
| 455 |
p = setup_parameters(); |
| 456 |
stretch_pixmap(p, 1.2, 1.7); |
| 457 |
bp.npv = 4; |
| 458 |
bp.v[0].x = 0.0; |
| 459 |
bp.v[0].y = 0.0; |
| 460 |
bp.v[1].x = (double) p->xmax; |
| 461 |
bp.v[1].y = 0.0; |
| 462 |
bp.v[2].x = (double) p->xmax; |
| 463 |
bp.v[2].y = (double) p->ymax; |
| 464 |
bp.v[2].x = 0.0; |
| 465 |
bp.v[2].y = (double) p->ymax; |
| 466 |
|
| 467 |
compute_pscale_ratio(p, &bp, &pscale_ratio); |
| 468 |
|
| 469 |
|
| 470 |
teardown_parameters(p); |
| 471 |
} |
| 472 |
FCT_TEST_END(); |
| 473 |
|
| 474 |
FCT_TEST_BGN(utest_map_point_01) |
| 475 |
{ |
| 476 |
double ix, iy, ox, oy; |
| 477 |
struct driz_param_t *p; |
| 478 |
|
| 479 |
p = setup_parameters(); |
| 480 |
stretch_pixmap(p, 1.0, 1000.0); |
| 481 |
|
| 482 |
ix = 2.5; |
| 483 |
iy = 1.5; |
| 484 |
|
| 485 |
map_point(p, ix, iy, &ox, &oy); |
| 486 |
|
| 487 |
fct_chk_eq_dbl(ox, 2.5); |
| 488 |
fct_chk_eq_dbl(oy, 1500.0); |
| 489 |
|
| 490 |
teardown_parameters(p); |
| 491 |
} |
| 492 |
FCT_TEST_END(); |
| 493 |
|
| 494 |
FCT_TEST_BGN(utest_map_point_02) |
| 495 |
{ |
| 496 |
double ix, iy, ox, oy; |
| 497 |
struct driz_param_t *p; |
| 498 |
|
| 499 |
p = setup_parameters(); |
| 500 |
stretch_pixmap(p, 1.0, 1000.0); |
| 501 |
|
| 502 |
ix = -1.0; |
| 503 |
iy = 0.5; |
| 504 |
|
| 505 |
map_point(p, ix, iy, &ox, &oy); |
| 506 |
|
| 507 |
fct_chk_eq_dbl(ox, -1.0); |
| 508 |
fct_chk_eq_dbl(oy, 500.0); |
| 509 |
|
| 510 |
teardown_parameters(p); |
| 511 |
} |
| 512 |
FCT_TEST_END(); |
| 513 |
|
| 514 |
FCT_TEST_BGN(utest_map_point_03) |
| 515 |
{ |
| 516 |
double ix, iy, ox, oy; |
| 517 |
int status; |
| 518 |
struct driz_param_t *p; |
| 519 |
|
| 520 |
p = setup_parameters(); |
| 521 |
stretch_pixmap(p, 1.0, 1000.0); |
| 522 |
|
| 523 |
ix = 3.25; |
| 524 |
iy = 5.0; |
| 525 |
|
| 526 |
status = map_point(p, ix, iy, &ox, &oy); |
| 527 |
|
| 528 |
fct_chk_int_return_status(status, 0); |
| 529 |
fct_chk_eq_dbl(ox, 3.25); |
| 530 |
fct_chk_eq_dbl(oy, 5000.0); |
| 531 |
|
| 532 |
nan_pixel(p, 3, 5); |
| 533 |
status = map_point(p, ix, iy, &ox, &oy); |
| 534 |
|
| 535 |
fct_chk_int_return_status(status, 1); |
| 536 |
fct_chk_neq_int(ox, ox); |
| 537 |
fct_chk_neq_int(oy, oy); |
| 538 |
|
| 539 |
teardown_parameters(p); |
| 540 |
} |
| 541 |
FCT_TEST_END(); |
| 542 |
|
| 543 |
FCT_TEST_BGN(utest_map_point_04) |
| 544 |
{ |
| 545 |
double ix, iy, ox, oy; |
| 546 |
int status; |
| 547 |
struct driz_param_t *p; |
| 548 |
|
| 549 |
p = setup_parameters(); |
| 550 |
|
| 551 |
stretch_pixmap(p, 1.0, 1000.0); |
| 552 |
|
| 553 |
ix = 0.25; |
| 554 |
iy = 5.0; |
| 555 |
|
| 556 |
status = map_point(p, ix, iy, &ox, &oy); |
| 557 |
|
| 558 |
fct_chk_int_return_status(status, 0); |
| 559 |
fct_chk_eq_dbl(ox, 0.25); |
| 560 |
fct_chk_eq_dbl(oy, 5000.0); |
| 561 |
|
| 562 |
nan_pixel(p, 0, 5); |
| 563 |
status = map_point(p, ix, iy, &ox, &oy); |
| 564 |
|
| 565 |
fct_chk_int_return_status(status, 1); |
| 566 |
fct_chk_neq_int(ox, ox); |
| 567 |
fct_chk_neq_int(oy, oy); |
| 568 |
|
| 569 |
teardown_parameters(p); |
| 570 |
} |
| 571 |
FCT_TEST_END(); |
| 572 |
|
| 573 |
FCT_TEST_BGN(utest_check_line_overlap_01) |
| 574 |
{ |
| 575 |
struct scanner s; |
| 576 |
int ymin, ymax, shift, status; |
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
const integer_t j = 0; |
| 581 |
integer_t xbounds[2]; |
| 582 |
struct driz_param_t *p; |
| 583 |
|
| 584 |
p = setup_parameters(); |
| 585 |
shift = 0; |
| 586 |
offset_pixmap(p, (double) shift, 0.0); |
| 587 |
|
| 588 |
init_image_scanner(p, &s, &ymin, &ymax); |
| 589 |
status = get_scanline_limits(&s, j, &xbounds[0], &xbounds[1]); |
| 590 |
|
| 591 |
fct_chk_eq_int(status, 0); |
| 592 |
fct_chk_eq_int(ymin, 0); |
| 593 |
fct_chk_eq_int(ymax, image_size[1] - 1); |
| 594 |
fct_chk_eq_int(xbounds[0], MIN(MAX(0, -shift), image_size[0] - 1)); |
| 595 |
fct_chk_eq_int(xbounds[1], MAX(0, MIN(image_size[0] - 1 - shift, image_size[0] - 1))); |
| 596 |
|
| 597 |
teardown_parameters(p); |
| 598 |
} |
| 599 |
FCT_TEST_END(); |
| 600 |
|
| 601 |
FCT_TEST_BGN(utest_check_line_overlap_02) |
| 602 |
{ |
| 603 |
struct scanner s; |
| 604 |
int ymin, ymax, shift, status; |
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
const integer_t j = 0; |
| 609 |
integer_t xbounds[2]; |
| 610 |
struct driz_param_t *p; |
| 611 |
|
| 612 |
p = setup_parameters(); |
| 613 |
shift = 70; |
| 614 |
offset_pixmap(p, (double) shift, 0.0); |
| 615 |
|
| 616 |
init_image_scanner(p, &s, &ymin, &ymax); |
| 617 |
status = get_scanline_limits(&s, j, &xbounds[0], &xbounds[1]); |
| 618 |
|
| 619 |
fct_chk_eq_int(status, 0); |
| 620 |
fct_chk_eq_int(ymin, 0); |
| 621 |
fct_chk_eq_int(ymax, image_size[1] - 1); |
| 622 |
fct_chk_eq_int(xbounds[0], MIN(MAX(0, -shift), image_size[0] - 1)); |
| 623 |
fct_chk_eq_int(xbounds[1], MAX(0, MIN(image_size[0] - 1 - shift, image_size[0] - 1))); |
| 624 |
|
| 625 |
teardown_parameters(p); |
| 626 |
} |
| 627 |
FCT_TEST_END(); |
| 628 |
|
| 629 |
FCT_TEST_BGN(utest_check_line_overlap_03) |
| 630 |
{ |
| 631 |
struct scanner s; |
| 632 |
int ymin, ymax, shift, status; |
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
const integer_t j = 0; |
| 637 |
integer_t xbounds[2]; |
| 638 |
struct driz_param_t *p; |
| 639 |
|
| 640 |
p = setup_parameters(); |
| 641 |
shift = -70; |
| 642 |
offset_pixmap(p, (double) shift, 0.0); |
| 643 |
|
| 644 |
init_image_scanner(p, &s, &ymin, &ymax); |
| 645 |
status = get_scanline_limits(&s, j, &xbounds[0], &xbounds[1]); |
| 646 |
|
| 647 |
fct_chk_eq_int(status, 0); |
| 648 |
fct_chk_eq_int(ymin, 0); |
| 649 |
fct_chk_eq_int(ymax, image_size[1] - 1); |
| 650 |
fct_chk_eq_int(xbounds[0], MIN(MAX(0, -shift), image_size[0] - 1)); |
| 651 |
fct_chk_eq_int(xbounds[1], MAX(0, MIN(image_size[0] - 1 - shift, image_size[0] - 1))); |
| 652 |
|
| 653 |
teardown_parameters(p); |
| 654 |
} |
| 655 |
FCT_TEST_END(); |
| 656 |
|
| 657 |
FCT_TEST_BGN(utest_check_image_overlap_02) |
| 658 |
{ |
| 659 |
struct scanner s; |
| 660 |
int ymin, ymax, shift; |
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
struct driz_param_t *p; |
| 665 |
|
| 666 |
p = setup_parameters(); |
| 667 |
shift = 70; |
| 668 |
offset_pixmap(p, 0.0, (double) shift); |
| 669 |
|
| 670 |
init_image_scanner(p, &s, &ymin, &ymax); |
| 671 |
|
| 672 |
fct_chk_eq_int(ymin, MIN(MAX(0, -shift), image_size[1] - 1)); |
| 673 |
fct_chk_eq_int(ymax, MAX(0, MIN(image_size[1] - 1 - shift, image_size[1] - 1))); |
| 674 |
|
| 675 |
teardown_parameters(p); |
| 676 |
} |
| 677 |
FCT_TEST_END(); |
| 678 |
|
| 679 |
FCT_TEST_BGN(utest_check_image_overlap_03) |
| 680 |
{ |
| 681 |
struct scanner s; |
| 682 |
int ymin, ymax, shift; |
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
struct driz_param_t *p; |
| 687 |
|
| 688 |
p = setup_parameters(); |
| 689 |
shift = -70; |
| 690 |
offset_pixmap(p, 0.0, (double) shift); |
| 691 |
|
| 692 |
init_image_scanner(p, &s, &ymin, &ymax); |
| 693 |
|
| 694 |
fct_chk_eq_int(ymin, MIN(MAX(0, -shift), image_size[1] - 1)); |
| 695 |
fct_chk_eq_int(ymax, MAX(0, MIN(image_size[1] - 1 - shift, image_size[1] - 1))); |
| 696 |
|
| 697 |
teardown_parameters(p); |
| 698 |
} |
| 699 |
FCT_TEST_END(); |
| 700 |
|
| 701 |
FCT_TEST_BGN(utest_compute_area_01) |
| 702 |
{ |
| 703 |
|
| 704 |
double area; |
| 705 |
double is, js, x[4], y[4]; |
| 706 |
|
| 707 |
is = 1.0; |
| 708 |
js = 1.0; |
| 709 |
|
| 710 |
x[0] = 0.75; |
| 711 |
y[0] = 1.25; |
| 712 |
x[1] = 0.75; |
| 713 |
y[1] = 0.75; |
| 714 |
x[2] = 1.25; |
| 715 |
y[2] = 0.75; |
| 716 |
x[3] = 1.25; |
| 717 |
y[3] = 1.25; |
| 718 |
|
| 719 |
area = compute_area(is, js, x, y); |
| 720 |
fct_chk_eq_dbl(area, 0.25); |
| 721 |
} |
| 722 |
FCT_TEST_END(); |
| 723 |
|
| 724 |
FCT_TEST_BGN(utest_compute_area_02) |
| 725 |
{ |
| 726 |
|
| 727 |
double area; |
| 728 |
double is, js, x[4], y[4]; |
| 729 |
|
| 730 |
is = 1.0; |
| 731 |
js = 1.0; |
| 732 |
|
| 733 |
x[0] = 1.0; |
| 734 |
y[0] = 1.25; |
| 735 |
x[1] = 0.75; |
| 736 |
y[1] = 1.0; |
| 737 |
x[2] = 1.0; |
| 738 |
y[2] = 0.75; |
| 739 |
x[3] = 1.25; |
| 740 |
y[3] = 1.0; |
| 741 |
|
| 742 |
area = compute_area(is, js, x, y); |
| 743 |
fct_chk_eq_dbl(area, 0.125); |
| 744 |
} |
| 745 |
FCT_TEST_END(); |
| 746 |
|
| 747 |
FCT_TEST_BGN(utest_compute_area_03) |
| 748 |
{ |
| 749 |
|
| 750 |
double area; |
| 751 |
double is, js, x[4], y[4]; |
| 752 |
|
| 753 |
is = 1.0; |
| 754 |
js = 1.0; |
| 755 |
|
| 756 |
x[0] = 0.0; |
| 757 |
y[0] = 0.0; |
| 758 |
x[1] = 1.0; |
| 759 |
y[1] = 0.0; |
| 760 |
x[2] = 1.0; |
| 761 |
y[2] = 1.0; |
| 762 |
x[3] = 0.0; |
| 763 |
y[3] = 1.0; |
| 764 |
|
| 765 |
area = compute_area(is, js, x, y); |
| 766 |
fct_chk_eq_dbl(area, 0.25); |
| 767 |
} |
| 768 |
FCT_TEST_END(); |
| 769 |
|
| 770 |
FCT_TEST_BGN(utest_compute_area_04) |
| 771 |
{ |
| 772 |
|
| 773 |
double area; |
| 774 |
double is, js, x[4], y[4]; |
| 775 |
|
| 776 |
is = 1.0; |
| 777 |
js = 1.0; |
| 778 |
|
| 779 |
x[0] = 1.0; |
| 780 |
y[0] = 1.75; |
| 781 |
x[1] = 0.75; |
| 782 |
y[1] = 1.5; |
| 783 |
x[2] = 1.0; |
| 784 |
y[2] = 1.25; |
| 785 |
x[3] = 1.25; |
| 786 |
y[3] = 1.5; |
| 787 |
|
| 788 |
area = compute_area(is, js, x, y); |
| 789 |
fct_chk_eq_dbl(area, 0.0625); |
| 790 |
} |
| 791 |
FCT_TEST_END(); |
| 792 |
|
| 793 |
FCT_TEST_BGN(utest_compute_area_05) |
| 794 |
{ |
| 795 |
|
| 796 |
int i, j; |
| 797 |
double is, js, x[4], y[4], area; |
| 798 |
double area_ok[7][7] = { |
| 799 |
{0.125000, 0.218750, 0.250000, 0.218750, 0.125000, 0.031250, 0.000000}, |
| 800 |
{0.218750, 0.375000, 0.437500, 0.375000, 0.218750, 0.062500, 0.000000}, |
| 801 |
{0.250000, 0.437500, 0.500000, 0.437500, 0.250000, 0.062500, 0.000000}, |
| 802 |
{0.218750, 0.375000, 0.437500, 0.375000, 0.218750, 0.062500, 0.000000}, |
| 803 |
{0.125000, 0.218750, 0.250000, 0.218750, 0.125000, 0.031250, 0.000000}, |
| 804 |
{0.031250, 0.062500, 0.062500, 0.062500, 0.031250, 0.000000, 0.000000}, |
| 805 |
{0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000}}; |
| 806 |
|
| 807 |
is = 1.0; |
| 808 |
js = 1.0; |
| 809 |
|
| 810 |
for (i = 0; i <= 6; ++i) { |
| 811 |
for (j = 0; j <= 6; ++j) { |
| 812 |
x[0] = 0.25 * (double) i; |
| 813 |
y[0] = 0.25 * (double) j + 0.5; |
| 814 |
x[1] = 0.25 * (double) i + 0.5; |
| 815 |
y[1] = 0.25 * (double) j; |
| 816 |
x[2] = 0.25 * (double) i + 1.0; |
| 817 |
y[2] = 0.25 * (double) j + 0.5; |
| 818 |
x[3] = 0.25 * (double) i + 0.5; |
| 819 |
y[3] = 0.25 * (double) j + 1.0; |
| 820 |
|
| 821 |
area = compute_area(is, js, x, y); |
| 822 |
|
| 823 |
|
| 824 |
fct_chk_eq_dbl(area, area_ok[i][j]); |
| 825 |
} |
| 826 |
} |
| 827 |
} |
| 828 |
FCT_TEST_END(); |
| 829 |
|
| 830 |
FCT_TEST_BGN(utest_do_kernel_square_01) |
| 831 |
{ |
| 832 |
|
| 833 |
|
| 834 |
integer_t x1; |
| 835 |
integer_t j, x2; |
| 836 |
struct driz_param_t *p; |
| 837 |
int n, status; |
| 838 |
|
| 839 |
n = 100; |
| 840 |
p = setup_parameters(); |
| 841 |
offset_pixmap(p, 0.0, 0.0); |
| 842 |
fill_image(p->data, 5.0); |
| 843 |
|
| 844 |
status = do_kernel_square(p); |
| 845 |
|
| 846 |
j = 3; |
| 847 |
x1 = 0; |
| 848 |
x2 = n; |
| 849 |
|
| 850 |
fct_chk_eq_int(status, 0); |
| 851 |
fct_chk_eq_dbl(get_pixel(p->output_data, x1, j), get_pixel(p->data, x1, j)); |
| 852 |
fct_chk_eq_dbl(get_pixel(p->output_data, x2 - 1, j), get_pixel(p->data, x2 - 1, j)); |
| 853 |
|
| 854 |
teardown_parameters(p); |
| 855 |
} |
| 856 |
FCT_TEST_END(); |
| 857 |
|
| 858 |
FCT_TEST_BGN(utest_do_kernel_square_02) |
| 859 |
{ |
| 860 |
|
| 861 |
|
| 862 |
struct driz_param_t *p; |
| 863 |
integer_t j; |
| 864 |
int k, n, status; |
| 865 |
double offset; |
| 866 |
|
| 867 |
n = 100; |
| 868 |
offset = 2.0; |
| 869 |
p = setup_parameters(); |
| 870 |
offset_pixmap(p, offset, 0.0); |
| 871 |
fill_image(p->data, 5.0); |
| 872 |
|
| 873 |
j = 3; |
| 874 |
status = do_kernel_square(p); |
| 875 |
|
| 876 |
fct_chk_eq_int(status, 0); |
| 877 |
for (k = 1; k < n - 2; k++) { |
| 878 |
fct_chk_eq_dbl(get_pixel(p->output_data, (k + 1), j), get_pixel(p->data, k, j)); |
| 879 |
} |
| 880 |
|
| 881 |
teardown_parameters(p); |
| 882 |
} |
| 883 |
FCT_TEST_END(); |
| 884 |
|
| 885 |
FCT_TEST_BGN(utest_do_kernel_square_03) |
| 886 |
{ |
| 887 |
|
| 888 |
|
| 889 |
struct driz_param_t *p; |
| 890 |
integer_t j; |
| 891 |
int k, n; |
| 892 |
double offset, value; |
| 893 |
|
| 894 |
n = 100; |
| 895 |
offset = 2.0; |
| 896 |
value = 5.0; |
| 897 |
p = setup_parameters(); |
| 898 |
offset_pixmap(p, offset, 0.0); |
| 899 |
|
| 900 |
for (j = 0; j < n; ++j) { |
| 901 |
set_pixel(p->data, j, j, value); |
| 902 |
} |
| 903 |
|
| 904 |
k = 3; |
| 905 |
do_kernel_square(p); |
| 906 |
|
| 907 |
fct_chk_eq_dbl(get_pixel(p->output_data, (k + 2), k), get_pixel(p->data, k, k)); |
| 908 |
|
| 909 |
teardown_parameters(p); |
| 910 |
} |
| 911 |
FCT_TEST_END(); |
| 912 |
|
| 913 |
FCT_TEST_BGN(utest_do_kernel_square_04) |
| 914 |
{ |
| 915 |
|
| 916 |
|
| 917 |
struct driz_param_t *p; |
| 918 |
integer_t i, j, k; |
| 919 |
double offset, value; |
| 920 |
|
| 921 |
offset = 2.5; |
| 922 |
value = 4.0; |
| 923 |
p = setup_parameters(); |
| 924 |
offset_pixmap(p, offset, offset); |
| 925 |
|
| 926 |
k = 1; |
| 927 |
set_pixel(p->data, k, k, value); |
| 928 |
|
| 929 |
do_kernel_square(p); |
| 930 |
|
| 931 |
for (i = 2; i <= 3; ++i) { |
| 932 |
for (j = 2; j <= 3; ++j) { |
| 933 |
fct_chk_eq_dbl(get_pixel(p->output_data, (i + k), (j + k)), value / 4.0); |
| 934 |
} |
| 935 |
} |
| 936 |
|
| 937 |
teardown_parameters(p); |
| 938 |
} |
| 939 |
FCT_TEST_END(); |
| 940 |
|
| 941 |
FCT_TEST_BGN(utest_do_kernel_square_05) |
| 942 |
{ |
| 943 |
|
| 944 |
|
| 945 |
struct driz_param_t *p; |
| 946 |
integer_t i, j; |
| 947 |
int n; |
| 948 |
double offset, value; |
| 949 |
|
| 950 |
n = 100; |
| 951 |
offset = 2.5; |
| 952 |
value = 4.0; |
| 953 |
p = setup_parameters(); |
| 954 |
offset_pixmap(p, offset, offset); |
| 955 |
|
| 956 |
for (j = 1; j < n - 1; ++j) { |
| 957 |
set_pixel(p->data, j, j, value); |
| 958 |
} |
| 959 |
|
| 960 |
do_kernel_square(p); |
| 961 |
|
| 962 |
for (i = 4; i < n - 2; ++i) { |
| 963 |
fct_chk_eq_dbl(get_pixel(p->output_data, i, i), value / 2.0); |
| 964 |
fct_chk_eq_dbl(get_pixel(p->output_data, i - 1, i), value / 4.0); |
| 965 |
fct_chk_eq_dbl(get_pixel(p->output_data, i, i - 1), value / 4.0); |
| 966 |
} |
| 967 |
|
| 968 |
teardown_parameters(p); |
| 969 |
} |
| 970 |
FCT_TEST_END(); |
| 971 |
|
| 972 |
FCT_TEST_BGN(utest_do_kernel_square_06) |
| 973 |
{ |
| 974 |
|
| 975 |
|
| 976 |
struct driz_param_t *p; |
| 977 |
integer_t i, j; |
| 978 |
int k; |
| 979 |
double offset, value; |
| 980 |
|
| 981 |
k = 2; |
| 982 |
offset = 2.0; |
| 983 |
value = 4.0; |
| 984 |
p = setup_parameters(); |
| 985 |
offset_pixmap(p, offset, offset); |
| 986 |
|
| 987 |
for (i = 0; i < k; ++i) { |
| 988 |
for (j = 0; j < k; ++j) { |
| 989 |
set_pixel(p->data, i, j, value); |
| 990 |
} |
| 991 |
} |
| 992 |
|
| 993 |
do_kernel_square(p); |
| 994 |
|
| 995 |
for (i = 0; i < k; ++i) { |
| 996 |
for (j = 0; j < k; ++j) { |
| 997 |
fct_chk_eq_dbl(get_pixel(p->output_data, (i + 2), (j + 2)), value); |
| 998 |
} |
| 999 |
} |
| 1000 |
|
| 1001 |
teardown_parameters(p); |
| 1002 |
} |
| 1003 |
FCT_TEST_END(); |
| 1004 |
|
| 1005 |
FCT_TEST_BGN(utest_do_kernel_square_07) |
| 1006 |
{ |
| 1007 |
|
| 1008 |
|
| 1009 |
struct driz_param_t *p; |
| 1010 |
integer_t i, j; |
| 1011 |
int k; |
| 1012 |
double offset, value; |
| 1013 |
|
| 1014 |
k = 2; |
| 1015 |
offset = 2.5; |
| 1016 |
value = 4.0; |
| 1017 |
p = setup_parameters(); |
| 1018 |
offset_pixmap(p, offset, offset); |
| 1019 |
|
| 1020 |
for (i = 1; i < k + 1; ++i) { |
| 1021 |
for (j = 1; j < k + 1; ++j) { |
| 1022 |
set_pixel(p->data, i, j, value); |
| 1023 |
} |
| 1024 |
} |
| 1025 |
|
| 1026 |
do_kernel_square(p); |
| 1027 |
|
| 1028 |
fct_chk_eq_dbl(get_pixel(p->output_data, 3, 3), 1.0); |
| 1029 |
fct_chk_eq_dbl(get_pixel(p->output_data, 3, 5), 1.0); |
| 1030 |
fct_chk_eq_dbl(get_pixel(p->output_data, 5, 3), 1.0); |
| 1031 |
fct_chk_eq_dbl(get_pixel(p->output_data, 5, 5), 1.0); |
| 1032 |
fct_chk_eq_dbl(get_pixel(p->output_data, 3, 4), 2.0); |
| 1033 |
fct_chk_eq_dbl(get_pixel(p->output_data, 4, 3), 2.0); |
| 1034 |
fct_chk_eq_dbl(get_pixel(p->output_data, 4, 5), 2.0); |
| 1035 |
fct_chk_eq_dbl(get_pixel(p->output_data, 5, 4), 2.0); |
| 1036 |
fct_chk_eq_dbl(get_pixel(p->output_data, 4, 4), 4.0); |
| 1037 |
|
| 1038 |
teardown_parameters(p); |
| 1039 |
} |
| 1040 |
FCT_TEST_END(); |
| 1041 |
|
| 1042 |
FCT_TEST_BGN(utest_dobox_01) |
| 1043 |
{ |
| 1044 |
|
| 1045 |
|
| 1046 |
struct driz_param_t *p; |
| 1047 |
int k; |
| 1048 |
double offset, value; |
| 1049 |
|
| 1050 |
k = 2; |
| 1051 |
offset = 2.0; |
| 1052 |
value = 44.0; |
| 1053 |
|
| 1054 |
p = setup_parameters(); |
| 1055 |
offset_pixmap(p, offset, offset); |
| 1056 |
p->kernel = kernel_turbo; |
| 1057 |
|
| 1058 |
set_pixel(p->data, k, k, value); |
| 1059 |
dobox(p); |
| 1060 |
|
| 1061 |
fct_chk_eq_dbl(get_pixel(p->output_data, (k + 2), (k + 2)), get_pixel(p->data, k, k)); |
| 1062 |
fct_chk_eq_int(p->nskip, 2); |
| 1063 |
} |
| 1064 |
FCT_TEST_END(); |
| 1065 |
|
| 1066 |
FCT_TEST_BGN(utest_dobox_02) |
| 1067 |
{ |
| 1068 |
|
| 1069 |
|
| 1070 |
struct driz_param_t *p; |
| 1071 |
int i, j, k; |
| 1072 |
double offset, value; |
| 1073 |
|
| 1074 |
k = 2; |
| 1075 |
offset = 2.5; |
| 1076 |
value = 44.0; |
| 1077 |
|
| 1078 |
p = setup_parameters(); |
| 1079 |
offset_pixmap(p, offset, offset); |
| 1080 |
p->kernel = kernel_turbo; |
| 1081 |
|
| 1082 |
set_pixel(p->data, k, k, value); |
| 1083 |
dobox(p); |
| 1084 |
|
| 1085 |
for (i = 2; i <= 3; ++i) { |
| 1086 |
for (j = 2; j <= 3; ++j) { |
| 1087 |
fct_chk_eq_dbl(get_pixel(p->output_data, (i + k), (j + k)), value / 4.0); |
| 1088 |
} |
| 1089 |
} |
| 1090 |
} |
| 1091 |
FCT_TEST_END(); |
| 1092 |
|
| 1093 |
FCT_TEST_BGN(utest_dobox_03) |
| 1094 |
{ |
| 1095 |
|
| 1096 |
|
| 1097 |
struct driz_param_t *p; |
| 1098 |
int i, j, n; |
| 1099 |
double offset, value; |
| 1100 |
|
| 1101 |
n = 100; |
| 1102 |
offset = 2.5; |
| 1103 |
value = 4.0; |
| 1104 |
|
| 1105 |
p = setup_parameters(); |
| 1106 |
offset_pixmap(p, offset, offset); |
| 1107 |
p->kernel = kernel_turbo; |
| 1108 |
|
| 1109 |
for (j = 1; j < n - 1; ++j) { |
| 1110 |
set_pixel(p->data, j, j, value); |
| 1111 |
} |
| 1112 |
|
| 1113 |
dobox(p); |
| 1114 |
|
| 1115 |
for (i = 4; i < n; ++i) { |
| 1116 |
fct_chk_eq_dbl(get_pixel(p->output_data, i, i), value / 2.0); |
| 1117 |
fct_chk_eq_dbl(get_pixel(p->output_data, i - 1, i), value / 4.0); |
| 1118 |
fct_chk_eq_dbl(get_pixel(p->output_data, i, i - 1), value / 4.0); |
| 1119 |
} |
| 1120 |
|
| 1121 |
teardown_parameters(p); |
| 1122 |
} |
| 1123 |
FCT_TEST_END(); |
| 1124 |
|
| 1125 |
FCT_TEST_BGN(utest_dobox_04) |
| 1126 |
{ |
| 1127 |
|
| 1128 |
|
| 1129 |
struct driz_param_t *p; |
| 1130 |
int i, j, n; |
| 1131 |
double offset, value; |
| 1132 |
integer_t bv; |
| 1133 |
|
| 1134 |
n = 100; |
| 1135 |
offset = 2.5; |
| 1136 |
value = 4.0; |
| 1137 |
|
| 1138 |
p = setup_parameters(); |
| 1139 |
offset_pixmap(p, offset, offset); |
| 1140 |
|
| 1141 |
|
| 1142 |
for (j = 1; j < n - 1; ++j) { |
| 1143 |
set_pixel(p->data, j, j, value); |
| 1144 |
} |
| 1145 |
|
| 1146 |
dobox(p); |
| 1147 |
bv = compute_bit_value(p->uuid); |
| 1148 |
for (i = 4; i < 100; ++i) { |
| 1149 |
fct_chk_eq_int(get_bit(p->output_context, i, i, bv), 1); |
| 1150 |
} |
| 1151 |
|
| 1152 |
teardown_parameters(p); |
| 1153 |
} |
| 1154 |
FCT_TEST_END(); |
| 1155 |
|
| 1156 |
FCT_TEST_BGN(utest_doblot_01) |
| 1157 |
{ |
| 1158 |
|
| 1159 |
|
| 1160 |
struct driz_param_t *p; |
| 1161 |
int k; |
| 1162 |
double offset, value; |
| 1163 |
|
| 1164 |
k = 2; |
| 1165 |
offset = -2.0; |
| 1166 |
value = 5.0; |
| 1167 |
|
| 1168 |
p = setup_parameters(); |
| 1169 |
p->interpolation = interp_bilinear; |
| 1170 |
|
| 1171 |
offset_pixmap(p, offset, offset); |
| 1172 |
|
| 1173 |
set_pixel(p->data, k, k, value); |
| 1174 |
doblot(p); |
| 1175 |
|
| 1176 |
fct_chk_eq_dbl(get_pixel(p->output_data, (k + 2), (k + 2)), get_pixel(p->data, k, k)); |
| 1177 |
} |
| 1178 |
FCT_TEST_END(); |
| 1179 |
|
| 1180 |
FCT_TEST_BGN(utest_doblot_02) |
| 1181 |
{ |
| 1182 |
|
| 1183 |
|
| 1184 |
struct driz_param_t *p; |
| 1185 |
int k; |
| 1186 |
double offset, value; |
| 1187 |
|
| 1188 |
k = 2; |
| 1189 |
offset = -2.0; |
| 1190 |
value = 5.0; |
| 1191 |
|
| 1192 |
p = setup_parameters(); |
| 1193 |
p->interpolation = interp_bilinear; |
| 1194 |
|
| 1195 |
offset_pixmap(p, offset, offset); |
| 1196 |
|
| 1197 |
set_pixel(p->data, k, k, value); |
| 1198 |
doblot(p); |
| 1199 |
|
| 1200 |
fct_chk_eq_dbl(get_pixel(p->output_data, (k + 2), (k + 2)), get_pixel(p->data, k, k)); |
| 1201 |
} |
| 1202 |
FCT_TEST_END(); |
| 1203 |
} |
| 1204 |
FCT_FIXTURE_SUITE_END(); |
| 1205 |
} |
| 1206 |
{ |
| 1207 |
FCT_END_FN(); |
| 1208 |
} |