22#include "../hdrl_cat_apio.h"
23#include "../hdrl_cat_background.h"
28 cpl_test_init(PACKAGE_BUGREPORT,CPL_MSG_WARNING);
34 ap.inframe = cpl_image_new(2048, 2048, CPL_TYPE_DOUBLE);
35 ap.conframe = cpl_image_new(2048, 2048, CPL_TYPE_DOUBLE);
40 ap.indata = cpl_image_get_data_double(ap.inframe);
41 ap.confdata = cpl_image_get_data_double(ap.conframe);
42 ap.mflag = cpl_malloc(ap.lsiz * ap.csiz *
sizeof(*ap.mflag));
44 double null_value = -100.;
45 for (cpl_size i = 0; i < ap.lsiz * ap.csiz; i++) {
46 ap.mflag[i] = null_value;
50 cpl_image_fill_noise_uniform(ap.inframe, -10., 10.);
51 cpl_image_add_scalar( ap.inframe, 5000.);
52 cpl_image_fill_noise_uniform(ap.conframe, 99, 101);
57 cpl_test_eq(
hdrl_backstats(&ap, &skymed, &skysig), CPL_ERROR_NONE);
58 cpl_test_rel(skymed, 5000., 0.01);
59 cpl_test_rel(skysig, 20 / sqrt(12), 0.1);
62 hdrl_casu_result *res = cpl_malloc(
sizeof(hdrl_casu_result));
63 res->background = cpl_image_new(ap.lsiz, ap.csiz, CPL_TYPE_DOUBLE);
66 for (cpl_size j = 0; j < ap.backmap.nby; j++) {
67 for (cpl_size i = 0; i < ap.backmap.nbx; i++) {
68 cpl_test_rel((ap.backmap.bvals)[i][j], 5000., 0.01);
71 cpl_test_rel(cpl_image_get_median(ap.inframe), 5000., 0.1);
75 cpl_test_rel(skymed, 5000., 0.01);
76 cpl_test_lt(0., skysig);
77 cpl_image_delete(res->background);
83 cpl_image_delete(ap.inframe);
84 cpl_image_delete(ap.conframe);
87 return cpl_test_end(0);
void hdrl_apinit(ap_t *ap)
Initialize the ap structure.
void hdrl_apclose(ap_t *ap)
Close ap structure.
void hdrl_backest(ap_t *ap, double x, double y, double *skylev, double *skyrms)
Work out estimated sky for a pixel position.
cpl_error_code hdrl_background(ap_t *ap, cpl_size nbsize, cpl_size bkg_subtr, hdrl_casu_result *res)
Model and create background map.
cpl_error_code hdrl_backstats(ap_t *ap, double *skymed, double *skysig)
Work out robust background estimate over a whole input image.