29#include "hdrl_utils.h"
31#include "hdrl_overscan_defs.h"
33#include "hdrl_collapse.h"
44 HDRL_OSCAN_COLLAPSE_TEST_MEAN,
45 HDRL_OSCAN_COLLAPSE_TEST_MEDIAN,
46 HDRL_OSCAN_COLLAPSE_TEST_WEIGHTED_MEAN,
47 HDRL_OSCAN_COLLAPSE_TEST_SIGCLIP,
48 HDRL_OSCAN_COLLAPSE_TEST_MINMAX
49} hdrl_oscan_collapse_test ;
57void test_parlist(
void)
60 hdrl_parameter * hpar;
61 hdrl_parameter * rect_region_def =
63 hdrl_parameter * sigclip_def =
65 hdrl_parameter * minmax_def =
67 hdrl_parameter * mode_def =
71 "RECIPE",
"oscan",
"alongX", 10, 10., rect_region_def,
72 "MINMAX", sigclip_def, minmax_def, mode_def);
77 cpl_test_error(CPL_ERROR_NONE);
83 cpl_test_eq(cpl_parameterlist_get_size(pos), 13 + 5);
87 cpl_test_error(CPL_ERROR_DATA_NOT_FOUND);
90 cpl_parameterlist_delete(pos);
91 cpl_test_error(CPL_ERROR_NONE);
120static cpl_error_code hdrl_overscan_test_null_input(
void)
122 hdrl_parameter * os_region;
123 hdrl_parameter * os_collapse;
124 hdrl_parameter * os_param;
125 hdrl_overscan_compute_result * overscan_computation;
131 os_collapse, os_region) ;
140 cpl_test_null(overscan_computation);
143 return cpl_error_get_code();
152static cpl_error_code hdrl_overscan_test_null_region(
void)
154 cpl_image * image_data;
155 hdrl_parameter * os_region = NULL;
156 hdrl_parameter * os_collapse;
157 hdrl_parameter * os_param;
158 hdrl_overscan_compute_result * overscan_computation;
161 image_data = cpl_image_new(1, 1, CPL_TYPE_DOUBLE);
166 os_collapse, os_region) ;
170 cpl_image_delete(image_data);
173 cpl_test_null(overscan_computation);
177 return cpl_error_get_code();
186static cpl_error_code hdrl_overscan_test_null_sigclip(
void)
188 cpl_image * image_data;
189 hdrl_parameter * os_region;
190 hdrl_parameter * os_collapse = NULL;
191 hdrl_parameter * os_param;
192 hdrl_overscan_compute_result * overscan_computation;
195 image_data = cpl_image_new(1, 1, CPL_TYPE_DOUBLE);
200 os_collapse, os_region) ;
204 cpl_image_delete(image_data);
207 cpl_test_null(overscan_computation);
211 return cpl_error_get_code();
220static cpl_error_code hdrl_overscan_test_null_params(
void)
222 cpl_image* image_data = cpl_image_new(1, 1, CPL_TYPE_DOUBLE);
223 hdrl_overscan_compute_result * overscan_computation;
227 cpl_test_null(overscan_computation);
230 cpl_image_delete(image_data);
232 return cpl_error_get_code();
241static cpl_error_code hdrl_overscan_test_wrong_region(
void)
243 hdrl_parameter * os_region;
244 hdrl_parameter * os_collapse;
245 hdrl_parameter * os_param;
246 cpl_image * image_data;
247 hdrl_overscan_compute_result * computation;
250 image_data = cpl_image_new(5, 10, CPL_TYPE_DOUBLE);
257 os_collapse, os_region) ;
263 cpl_test_null(computation);
264 cpl_test_eq_error(cpl_error_get_code(), CPL_ERROR_ILLEGAL_INPUT);
278 cpl_image_delete(image_data);
280 return cpl_error_get_code();
289static double hdrl_overscan_test_uniform_image(
const double inp_value)
291 double out_value = 0;
292 cpl_image * image_data;
293 cpl_image * image_errs;
295 hdrl_overscan_compute_result * comp_res;
296 hdrl_overscan_correct_result * overscan_correction;
297 hdrl_parameter * os_region;
298 hdrl_parameter * os_collapse;
299 hdrl_parameter * os_param;
302 image_data = cpl_image_new(100, 100, HDRL_TYPE_DATA);
303 cpl_image_add_scalar(image_data, inp_value);
304 image_errs = cpl_image_new(100, 100, HDRL_TYPE_ERROR);
305 cpl_image_add_scalar(image_errs, inp_value);
306 cpl_image_power(image_errs, 0.5);
307 image = hdrl_image_wrap(image_data, image_errs, NULL, CPL_FALSE);
313 os_collapse, os_region) ;
317 cpl_test_nonnull(comp_res);
323 out_value = cpl_image_get_mean(
325 cpl_test_abs(out_value, inp_value, HDRL_EPS_DATA);
328 cpl_test_nonnull(overscan_correction);
342static cpl_error_code hdrl_overscan_test_dir(cpl_size Nx, cpl_size Ny,
int hbox)
344 const double error = 10;
348 hdrl_parameter * os_region = NULL;
349 hdrl_parameter * os_collapse = NULL;
350 hdrl_parameter * os_param = NULL;
351 hdrl_overscan_compute_result * res_os_comp = NULL;
352 hdrl_overscan_compute_result * res_os_comp_turn = NULL;
353 hdrl_overscan_correct_result * res_os_cor = NULL;
354 hdrl_overscan_correct_result * res_os_cor_turn = NULL;
357 cpl_msg_info(cpl_func,
"check mean hbox %d, Nx %ld, Ny %ld",
358 hbox, (
long)Nx, (
long)Ny);
361 for (cpl_size x = 0; x < Nx; x++) {
362 for (cpl_size y = 0; y < Ny; y++) {
363 cpl_image_set(image_data, x + 1, y + 1, x);
364 cpl_image_set(image_errs, x + 1, y + 1, x);
367 cpl_image_power(image_errs, 0.5);
373 error * sqrt(Ny * (1 + 2 * hbox)), hbox, os_collapse, os_region) ;
377 cpl_test_error(CPL_ERROR_NONE);
381 cpl_image * ex = cpl_image_extract(image_data, 1, 1, Nx, 1);
384 2 * (1 + 2 * hbox) * Ny * HDRL_EPS_DATA);
388 cpl_image_subtract(ex, ex);
389 cpl_test_image_abs(ex, res_os_comp->red_chi2,
390 2 * (1 + 2 * hbox) * Ny * HDRL_EPS_DATA);
394 cpl_image_subtract(ex, ex);
395 cpl_image_add_scalar(ex, error);
397 for (
int i = 0; i < hbox; i++) {
398 double cor = sqrt((1 + 2. * (hbox)) / (1 + 2 * i));
399 cpl_image_set(ex, 1 + i, 1, error * cor);
400 cpl_image_set(ex, Nx - i, 1, error * cor);
403 Ny * HDRL_EPS_ERROR);
405 cpl_image_delete(ex);
412 error * sqrt(Nx * (1 + 2 * hbox)), hbox, os_collapse, os_region) ;
419 cpl_test_error(CPL_ERROR_NONE);
423 cpl_image * ex = cpl_image_new(1, Ny, HDRL_TYPE_DATA);
424 cpl_image_add_scalar(ex, (Nx - 1.) / 2.);
425 cpl_test_image_abs(ex,
427 2 * (1 + 2 * hbox) * Nx * HDRL_EPS_DATA);
430 cpl_image_subtract(ex, ex);
431 cpl_image_add_scalar(ex, cpl_image_get(res_os_comp_turn->red_chi2,
433 cpl_test_image_abs(ex, res_os_comp_turn->red_chi2,
434 2 * (1 + 2 * hbox) * Nx * HDRL_EPS_DATA);
437 cpl_image_subtract(ex, ex);
438 cpl_image_add_scalar(ex, error);
440 for (
int i = 0; i < hbox; i++) {
441 double cor = sqrt((1 + 2. * (hbox)) / (1 + 2 * i));
442 cpl_image_set(ex, 1, 1 + i, error * cor);
443 cpl_image_set(ex, 1, Ny - i, error * cor);
445 cpl_test_image_abs(ex,
447 3 * Nx * HDRL_EPS_ERROR);
449 cpl_image_delete(ex);
455 cpl_test_error(CPL_ERROR_NONE);
459 cpl_image * ex = cpl_image_new(Nx, Ny, HDRL_TYPE_DATA);
462 2 * (1 + 2 * hbox) * Ny * HDRL_EPS_DATA);
465 for (cpl_size y = 0; y < Ny; y++) {
466 for (cpl_size x = 0; x < Nx; x++) {
467 double val = cpl_image_get(image_errs, x + 1, y + 1, &rej);
468 cpl_image_set(ex, x + 1, y + 1, hypot(error, val));
471 for (
int i = 0; i < hbox; i++) {
472 double cor = sqrt((1 + 2. * (hbox)) / (1 + 2 * i));
473 double val = cpl_image_get(image_errs, 1 + i, y + 1, &rej);
474 cpl_image_set(ex, 1 + i, y + 1, hypot(error * cor, val));
475 val = cpl_image_get(image_errs, Nx - i, y + 1, &rej);
476 cpl_image_set(ex, Nx - i, y + 1, hypot(error * cor, val));
481 Ny * HDRL_EPS_ERROR);
483 cpl_image_delete(ex);
487 cpl_test_error(CPL_ERROR_NONE);
491 cpl_image * ex = cpl_image_duplicate(image_data);
492 cpl_image_subtract_scalar(ex,
496 2 * (1 + 2 * hbox) * Nx * HDRL_EPS_DATA);
499 for (cpl_size x = 0; x < Nx; x++) {
500 for (cpl_size y = 0; y < Ny; y++) {
501 double val = cpl_image_get(image_errs, x + 1, y + 1, &rej);
502 cpl_image_set(ex, x + 1, y + 1, hypot(error, val));
505 for (
int i = 0; i < hbox; i++) {
506 double cor = sqrt((1 + 2. * (hbox)) / (1 + 2 * i));
507 double val = cpl_image_get(image_errs, 1 + x, 1 + i, &rej);
508 cpl_image_set(ex, x + 1, 1 + i, hypot(error * cor, val));
509 val = cpl_image_get(image_errs, x + 1, Ny - i, &rej);
510 cpl_image_set(ex, x + 1, Ny - i, hypot(error * cor, val));
514 cpl_test_image_abs(ex,
516 3 * Nx * HDRL_EPS_ERROR);
518 cpl_image_delete(ex);
527 return cpl_error_get_code();
536static cpl_error_code hdrl_overscan_test_full_hbox(
540 const double error = 10;
544 hdrl_parameter * os_region = NULL;
545 hdrl_parameter * os_collapse = NULL;
546 hdrl_parameter * os_param = NULL;
547 hdrl_overscan_compute_result * res_os_comp;
548 hdrl_overscan_correct_result * res_os_cor = NULL;
551 cpl_msg_info(cpl_func,
"check mean full box, Nx %ld, Ny %ld",
555 for (cpl_size x = 0; x < Nx; x++) {
556 for (cpl_size y = 0; y < Ny; y++) {
557 cpl_image_set(image_data, x + 1, y + 1, x);
558 cpl_image_set(image_errs, x + 1, y + 1, x);
561 cpl_image_power(image_errs, 0.5);
569 error * sqrt(Nx * Ny), -2, os_collapse, os_region);
572 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
577 error * sqrt(Nx * Ny),
578 HDRL_OVERSCAN_FULL_BOX,
579 os_collapse, os_region);
586 cpl_test_error(CPL_ERROR_NONE);
595 hdrl_test_image_abs(ex, res_os_comp->correction,
596 2 * Nx * Ny * HDRL_EPS_DATA);
597 hdrl_test_image_abs(ex, res_os_comp->correction,
598 Nx * Ny * HDRL_EPS_DATA);
608 return cpl_error_get_code();
617static cpl_error_code hdrl_overscan_test_turn_eq(
621 hdrl_oscan_collapse_test method)
623 cpl_ensure_code(method == HDRL_OSCAN_COLLAPSE_TEST_MEAN ||
624 method == HDRL_OSCAN_COLLAPSE_TEST_MEDIAN ||
625 method == HDRL_OSCAN_COLLAPSE_TEST_WEIGHTED_MEAN ||
626 method == HDRL_OSCAN_COLLAPSE_TEST_SIGCLIP ||
627 method == HDRL_OSCAN_COLLAPSE_TEST_MINMAX,
628 CPL_ERROR_ILLEGAL_INPUT);
630 hdrl_parameter *os_collapse = NULL;
631 if (method == HDRL_OSCAN_COLLAPSE_TEST_MEAN) {
632 cpl_msg_info(cpl_func,
"Mean method hbox %d, Nx %ld, Ny %ld",
633 hbox, (
long)Nx, (
long)Ny);
635 }
else if (method == HDRL_OSCAN_COLLAPSE_TEST_MEDIAN) {
636 cpl_msg_info(cpl_func,
"Median method hbox %d, Nx %ld, Ny %ld",
637 hbox, (
long)Nx, (
long)Ny);
639 }
else if (method == HDRL_OSCAN_COLLAPSE_TEST_WEIGHTED_MEAN) {
640 cpl_msg_info(cpl_func,
"Weighted Median method hbox %d, Nx %ld, Ny %ld",
641 hbox, (
long)Nx, (
long)Ny);
643 }
else if (method == HDRL_OSCAN_COLLAPSE_TEST_SIGCLIP) {
644 cpl_msg_info(cpl_func,
"Sigma-Clipping method hbox %d, Nx %ld, Ny %ld",
645 hbox, (
long)Nx, (
long)Ny);
647 }
else if (method == HDRL_OSCAN_COLLAPSE_TEST_MINMAX) {
648 cpl_msg_info(cpl_func,
"MinMax method hbox %d, Nx %ld, Ny %ld",
649 hbox, (
long)Nx, (
long)Ny);
654 const double error = 10;
662 hdrl_parameter *os_region = NULL;
663 hdrl_parameter *os_param = NULL;
665 hdrl_overscan_compute_result *res_os_comp = NULL;
666 hdrl_overscan_compute_result *res_os_comp_turn = NULL;
667 hdrl_overscan_correct_result *res_os_cor = NULL;
668 hdrl_overscan_correct_result *res_os_cor_turn = NULL;
670 for (cpl_size x = 0; x < Nx; x++) {
671 for (cpl_size y = 0; y < Ny; y++) {
673 double v = (50 - rand() % 100) / (
double)((rand() % 50) + 1);
674 cpl_image_set(image_data, x + 1, y + 1, v);
675 cpl_image_set(image_errs, x + 1, y + 1, fabs(v));
678 cpl_image_power(image_errs, 0.5);
687 error * sqrt(Ny * (1 + 2 * hbox)), hbox, os_collapse, os_region) ;
691 cpl_test_error(CPL_ERROR_NONE);
697 error * sqrt(Ny * (1 + 2 * hbox)), hbox, os_collapse, os_region) ;
700 cpl_test_error(CPL_ERROR_NONE);
708 cpl_image * con_t = cpl_image_duplicate(res_os_comp_turn->contribution);
709 cpl_image * chi_t = cpl_image_duplicate(res_os_comp_turn->red_chi2);
711 cpl_image_turn(con_t, -1);
712 cpl_image_turn(chi_t, -1);
713 hdrl_test_image_abs(res_os_comp->correction,
714 cor_t, (1 + hbox) * Ny * HDRL_EPS_DATA);
715 cpl_test_image_abs(res_os_comp->red_chi2, chi_t,
716 (1 + hbox) * Ny * HDRL_EPS_DATA);
717 cpl_test_image_abs(res_os_comp->contribution, con_t, 0);
719 cpl_image_delete(con_t);
720 cpl_image_delete(chi_t);
725 cpl_test_error(CPL_ERROR_NONE);
728 cpl_test_error(CPL_ERROR_NONE);
731 hdrl_test_image_abs(res_os_cor->corrected, res_os_cor_turn->corrected,
732 (1 + hbox) * Ny * HDRL_EPS_DATA);
736 cpl_test_error(CPL_ERROR_NONE);
737 cpl_test_nonnull(imgCorrected1);
739 cpl_test_error(CPL_ERROR_NONE);
740 cpl_test_nonnull(imgCorrected2);
745 cpl_test_error(CPL_ERROR_NONE);
746 cpl_test_nonnull(cpImgBadMask_1);
748 cpl_test_error(CPL_ERROR_NONE);
749 cpl_test_nonnull(cpImgBadMask_2);
750 cpl_image_delete(cpImgBadMask_2);
760 return cpl_error_get_code();
769static cpl_error_code hdrl_overscan_test_empty_box(
770 hdrl_oscan_collapse_test method)
773 cpl_ensure_code(method == HDRL_OSCAN_COLLAPSE_TEST_MEAN ||
774 method == HDRL_OSCAN_COLLAPSE_TEST_MEDIAN ||
775 method == HDRL_OSCAN_COLLAPSE_TEST_WEIGHTED_MEAN ||
776 method == HDRL_OSCAN_COLLAPSE_TEST_SIGCLIP ||
777 method == HDRL_OSCAN_COLLAPSE_TEST_MINMAX,
778 CPL_ERROR_ILLEGAL_INPUT);
781 hdrl_parameter *os_collapse = NULL;
782 if(method == HDRL_OSCAN_COLLAPSE_TEST_MEAN) {
783 cpl_msg_info(cpl_func,
"check empty box MEAN");
785 }
else if (method == HDRL_OSCAN_COLLAPSE_TEST_MEDIAN) {
786 cpl_msg_info(cpl_func,
"check empty box MEDIAN");
788 }
else if (method == HDRL_OSCAN_COLLAPSE_TEST_WEIGHTED_MEAN) {
789 cpl_msg_info(cpl_func,
"check empty box WEIGHTED_MEAN");
791 }
else if (method == HDRL_OSCAN_COLLAPSE_TEST_SIGCLIP) {
792 cpl_msg_info(cpl_func,
"check empty box SIGCLIP");
794 }
else if (method == HDRL_OSCAN_COLLAPSE_TEST_MINMAX) {
795 cpl_msg_info(cpl_func,
"check empty box MINMAX");
801 cpl_image *image_data = cpl_image_new(Nx, Ny, HDRL_TYPE_DATA);
805 HDRL_Y_AXIS, 1., 0, os_collapse, os_region);
808 for (cpl_size i = 0; i < Ny; i++) cpl_image_reject(image_data, 2, i + 1);
811 hdrl_overscan_compute_result *res_os_comp;
813 cpl_test_error(CPL_ERROR_NONE);
822 cpl_test_eq(cpl_image_get(res_os_comp->contribution, 2, 1, &rej), 0);
824 cpl_test(cpl_image_is_rejected(res_os_comp->red_chi2, 2, 1));
828 cpl_test_error(CPL_ERROR_NONE);
829 cpl_test_nonnull(img1);
831 cpl_test_error(CPL_ERROR_NONE);
832 cpl_test_nonnull(img2);
837 cpl_test_error(CPL_ERROR_NONE);
838 cpl_test_nonnull(cpImg1);
840 cpl_test_error(CPL_ERROR_NONE);
841 cpl_test_nonnull(cpImg2);
842 cpl_image_delete(cpImg2);
846 cpl_test_error(CPL_ERROR_NONE);
847 cpl_test_nonnull(cpImgCh2_1);
849 cpl_test_error(CPL_ERROR_NONE);
850 cpl_test_nonnull(cpImgCh2_2);
851 cpl_image_delete(cpImgCh2_2);
855 cpl_test_error(CPL_ERROR_NONE);
856 cpl_test_nonnull(cpImgRedCh2_1);
858 cpl_test_error(CPL_ERROR_NONE);
859 cpl_test_nonnull(cpImgRedCh2_2);
860 cpl_image_delete(cpImgRedCh2_2);
865 if (method == HDRL_OSCAN_COLLAPSE_TEST_SIGCLIP) {
869 cpl_test_error(CPL_ERROR_NONE);
870 cpl_test_nonnull(cpImgSGLow_1);
872 cpl_test_error(CPL_ERROR_NONE);
873 cpl_test_nonnull(cpImgSGLow_2);
874 cpl_image_delete(cpImgSGLow_2);
878 cpl_test_error(CPL_ERROR_NONE);
879 cpl_test_nonnull(cpImgSGHigh_1);
881 cpl_test_error(CPL_ERROR_NONE);
882 cpl_test_nonnull(cpImgSGHigh_2);
883 cpl_image_delete(cpImgSGHigh_2);
885 }
else if (method == HDRL_OSCAN_COLLAPSE_TEST_MINMAX) {
889 cpl_test_error(CPL_ERROR_NONE);
890 cpl_test_nonnull(cpImgMMLow_1);
892 cpl_test_error(CPL_ERROR_NONE);
893 cpl_test_nonnull(cpImgMMLow_2);
894 cpl_image_delete(cpImgMMLow_2);
898 cpl_test_error(CPL_ERROR_NONE);
899 cpl_test_nonnull(cpImgMMHigh_1);
901 cpl_test_error(CPL_ERROR_NONE);
902 cpl_test_nonnull(cpImgMMHigh_2);
903 cpl_image_delete(cpImgMMHigh_2);
908 cpl_image_delete(image_data);
911 return cpl_error_get_code();
921 cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
923 double inp_value = 0;
929 code = hdrl_overscan_test_null_input();
930 cpl_test_eq_error(code, CPL_ERROR_NULL_INPUT);
933 code = hdrl_overscan_test_null_region();
934 cpl_test_eq_error(code, CPL_ERROR_ILLEGAL_INPUT);
937 code = hdrl_overscan_test_null_sigclip();
938 cpl_test_eq_error(code, CPL_ERROR_ILLEGAL_INPUT);
941 code = hdrl_overscan_test_null_params();
942 cpl_test_eq_error(code, CPL_ERROR_NULL_INPUT);
945 code = hdrl_overscan_test_wrong_region();
946 cpl_test_eq_error(code, CPL_ERROR_NONE);
949 hdrl_overscan_test_uniform_image(inp_value);
951 cpl_size anx[] = {97, 45, 200};
952 cpl_size any[] = {575, 34, 200};
954 hdrl_overscan_test_turn_eq(0, 0, 0, -1);
955 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
957 for (
size_t i = 0; i <
sizeof(anx) /
sizeof(anx[0]); i++) {
958 cpl_size nx = anx[i];
959 cpl_size ny = any[i];
961 for (
int hbox = 0; hbox < 12; hbox++) {
962 hdrl_overscan_test_dir(nx, ny, hbox);
965 for (
int hbox = 0; hbox < 6; hbox+=2) {
967 hdrl_overscan_test_turn_eq(nx, ny, hbox,
968 HDRL_OSCAN_COLLAPSE_TEST_MEAN);
969 cpl_test_error(CPL_ERROR_NONE);
970 hdrl_overscan_test_turn_eq(nx, ny, hbox,
971 HDRL_OSCAN_COLLAPSE_TEST_MEDIAN);
972 cpl_test_error(CPL_ERROR_NONE);
973 hdrl_overscan_test_turn_eq(nx, ny, hbox,
974 HDRL_OSCAN_COLLAPSE_TEST_WEIGHTED_MEAN);
975 cpl_test_error(CPL_ERROR_NONE);
976 hdrl_overscan_test_turn_eq(nx, ny, hbox,
977 HDRL_OSCAN_COLLAPSE_TEST_SIGCLIP);
978 cpl_test_error(CPL_ERROR_NONE);
979 hdrl_overscan_test_turn_eq(nx, ny, hbox,
980 HDRL_OSCAN_COLLAPSE_TEST_MINMAX);
981 cpl_test_error(CPL_ERROR_NONE);
984 hdrl_overscan_test_full_hbox(nx, ny);
987 hdrl_overscan_test_empty_box(-1);
988 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
989 hdrl_overscan_test_empty_box(HDRL_OSCAN_COLLAPSE_TEST_MEAN);
990 cpl_test_error(CPL_ERROR_NONE);
991 hdrl_overscan_test_empty_box(HDRL_OSCAN_COLLAPSE_TEST_MEDIAN);
992 cpl_test_error(CPL_ERROR_NONE);
993 hdrl_overscan_test_empty_box(HDRL_OSCAN_COLLAPSE_TEST_WEIGHTED_MEAN);
994 cpl_test_error(CPL_ERROR_NONE);
995 hdrl_overscan_test_empty_box(HDRL_OSCAN_COLLAPSE_TEST_SIGCLIP);
996 cpl_test_error(CPL_ERROR_NONE);
997 hdrl_overscan_test_empty_box(HDRL_OSCAN_COLLAPSE_TEST_MINMAX);
998 cpl_test_error(CPL_ERROR_NONE);
1008 return cpl_test_end(0);
hdrl_parameter * hdrl_collapse_mean_parameter_create(void)
create a parameter object for mean
hdrl_parameter * hdrl_collapse_sigclip_parameter_create(double kappa_low, double kappa_high, int niter)
create a parameter object for sigclipped mean
hdrl_parameter * hdrl_collapse_weighted_mean_parameter_create(void)
create a parameter object for weighted mean
cpl_boolean hdrl_collapse_parameter_is_mean(const hdrl_parameter *self)
check if parameter is a mean parameter
cpl_boolean hdrl_collapse_parameter_is_minmax(const hdrl_parameter *self)
check if parameter is a minmax mean parameter
double hdrl_collapse_minmax_parameter_get_nlow(const hdrl_parameter *p)
get low value
hdrl_parameter * hdrl_collapse_median_parameter_create(void)
create a parameter object for median
hdrl_parameter * hdrl_collapse_mode_parameter_create(double histo_min, double histo_max, double bin_size, hdrl_mode_type mode_method, cpl_size error_niter)
create a parameter object for the mode
hdrl_parameter * hdrl_collapse_minmax_parameter_create(double nlow, double nhigh)
create a parameter object for min-max rejected mean
double hdrl_collapse_minmax_parameter_get_nhigh(const hdrl_parameter *p)
get high value
hdrl_value hdrl_image_get_pixel(const hdrl_image *self, cpl_size xpos, cpl_size ypos, int *pis_rejected)
get pixel values of hdrl_image
int hdrl_image_is_rejected(hdrl_image *self, cpl_size xpos, cpl_size ypos)
return if pixel is marked bad
cpl_error_code hdrl_image_turn(hdrl_image *self, int rot)
Rotate an image by a multiple of 90 degrees clockwise.
hdrl_image * hdrl_image_duplicate(const hdrl_image *himg)
copy hdrl_image
cpl_error_code hdrl_image_add_scalar(hdrl_image *self, hdrl_value value)
Elementwise addition of a scalar to an image.
cpl_image * hdrl_image_get_error(hdrl_image *himg)
get error as cpl image
cpl_image * hdrl_image_get_image(hdrl_image *himg)
get data as cpl image
hdrl_image * hdrl_image_new(cpl_size nx, cpl_size ny)
create new zero filled hdrl image
void hdrl_image_delete(hdrl_image *himg)
delete hdrl_image
void hdrl_overscan_compute_result_delete(hdrl_overscan_compute_result *result)
Deletes the Overscan Computation Result Structure.
cpl_image * hdrl_overscan_correct_result_get_badmask(const hdrl_overscan_correct_result *res)
Access the bad pixels mask in the Overscan Correction result object.
cpl_image * hdrl_overscan_compute_result_unset_red_chi2(hdrl_overscan_compute_result *res)
Unset the reduced CHI2 in the Overscan Computation result object.
cpl_image * hdrl_overscan_correct_result_unset_badmask(hdrl_overscan_correct_result *res)
Unset the bad pixels mask in the Overscan Correction result object.
cpl_image * hdrl_overscan_compute_result_get_minmax_reject_high(const hdrl_overscan_compute_result *res)
Access the high threshold in the Overscan Computation result object.
cpl_boolean hdrl_overscan_parameter_check(const hdrl_parameter *self)
Check that the parameter is an Overscan parameter.
hdrl_image * hdrl_overscan_correct_result_unset_corrected(hdrl_overscan_correct_result *res)
Unset the corrected image in the Overscan Correction result object.
cpl_image * hdrl_overscan_compute_result_get_red_chi2(const hdrl_overscan_compute_result *res)
Access the reduced CHI2 in the Overscan Computation result object.
cpl_image * hdrl_overscan_compute_result_get_sigclip_reject_low(const hdrl_overscan_compute_result *res)
Access the low threshold in the Overscan Computation result object.
cpl_image * hdrl_overscan_compute_result_get_chi2(const hdrl_overscan_compute_result *res)
Access the CHI2 in the Overscan Computation result object.
hdrl_overscan_compute_result * hdrl_overscan_compute(const cpl_image *source, const hdrl_parameter *params)
Overscan correction computation.
cpl_image * hdrl_overscan_compute_result_unset_chi2(hdrl_overscan_compute_result *res)
Unset the CHI2 in the Overscan Computation result object.
cpl_image * hdrl_overscan_compute_result_unset_minmax_reject_high(hdrl_overscan_compute_result *res)
Unset the high threshold in the Overscan Computation result object.
cpl_image * hdrl_overscan_compute_result_unset_contribution(hdrl_overscan_compute_result *res)
Unset the contribution in the Overscan Computation result object.
cpl_image * hdrl_overscan_compute_result_get_minmax_reject_low(const hdrl_overscan_compute_result *res)
Access the low threshold in the Overscan Computation result object.
hdrl_image * hdrl_overscan_compute_result_unset_correction(hdrl_overscan_compute_result *res)
Unset the correction in the Overscan Computation result object.
hdrl_image * hdrl_overscan_correct_result_get_corrected(const hdrl_overscan_correct_result *res)
Access the corrected image in the Overscan Correction result object.
hdrl_parameter * hdrl_overscan_parameter_get_rect_region(const hdrl_parameter *p)
Access the Overscan Region parameters in the Overscan Parameter.
hdrl_parameter * hdrl_overscan_parameter_get_collapse(const hdrl_parameter *p)
Access the collapse method parameters in the Overscan Parameter.
hdrl_parameter * hdrl_overscan_parameter_create(hdrl_direction correction_direction, double ccd_ron, int box_hsize, hdrl_parameter *collapse, hdrl_parameter *rect_region)
Creates Overscan Parameters object.
hdrl_image * hdrl_overscan_compute_result_get_correction(const hdrl_overscan_compute_result *res)
Access the correction in the Overscan Computation result object.
double hdrl_overscan_parameter_get_ccd_ron(const hdrl_parameter *p)
Access the CCD read out noise in the Overscan Parameter.
hdrl_direction hdrl_overscan_parameter_get_correction_direction(const hdrl_parameter *p)
Access the Correction Direction in the Overscan Parameter.
hdrl_overscan_correct_result * hdrl_overscan_correct(const hdrl_image *source, const hdrl_parameter *region, const hdrl_overscan_compute_result *os_computation)
Overscan correction.
hdrl_parameter * hdrl_overscan_parameter_parse_parlist(const cpl_parameterlist *parlist, const char *prefix)
Parse parameterlist to create input parameters for the Overscan method.
cpl_image * hdrl_overscan_compute_result_get_contribution(const hdrl_overscan_compute_result *res)
Access the contribution in the Overscan Computation result object.
int hdrl_overscan_parameter_get_box_hsize(const hdrl_parameter *p)
Access the Box Half Size in the Overscan Parameter.
cpl_image * hdrl_overscan_compute_result_unset_minmax_reject_low(hdrl_overscan_compute_result *res)
Unset the low threshold in the Overscan Computation result object.
cpl_image * hdrl_overscan_compute_result_get_sigclip_reject_high(const hdrl_overscan_compute_result *res)
Access the high threshold in the Overscan Computation result object.
void hdrl_overscan_correct_result_delete(hdrl_overscan_correct_result *result)
Delete the Overscan Correction Result Structure.
cpl_image * hdrl_overscan_compute_result_unset_sigclip_reject_low(hdrl_overscan_compute_result *res)
Unset the low threshold in the Overscan Computation result object.
cpl_image * hdrl_overscan_compute_result_unset_sigclip_reject_high(hdrl_overscan_compute_result *res)
Unset the high threshold in the Overscan Computation result object.
cpl_parameterlist * hdrl_overscan_parameter_create_parlist(const char *base_context, const char *prefix, const char *corr_dir_def, int box_hsize_def, double ccd_ron_def, hdrl_parameter *rect_region_def, const char *method_def, hdrl_parameter *sigclip_def, hdrl_parameter *minmax_def, hdrl_parameter *mode_def)
Create parameter list for the Overscan computation.
void hdrl_parameter_destroy(hdrl_parameter *obj)
deep delete of a parameter
void hdrl_parameter_delete(hdrl_parameter *obj)
shallow delete of a parameter
cpl_error_code hdrl_rect_region_parameter_update(hdrl_parameter *rect_region, cpl_size llx, cpl_size lly, cpl_size urx, cpl_size ury)
Update Rect Region Parameters object.
hdrl_parameter * hdrl_rect_region_parameter_create(cpl_size llx, cpl_size lly, cpl_size urx, cpl_size ury)
Creates Rect Region Parameters object.
cpl_size hdrl_rect_region_get_llx(const hdrl_parameter *p)
get lower left x coordinate of rectangual region
cpl_size hdrl_rect_region_get_urx(const hdrl_parameter *p)
get upper right x coordinate of rectangular region
cpl_size hdrl_rect_region_get_lly(const hdrl_parameter *p)
get lower left y coordinate of rectangual region
cpl_size hdrl_rect_region_get_ury(const hdrl_parameter *p)
get upper right y coordinate of rectangual region