28#include "hdrl_bpm_3d.h"
29#include "hdrl_image.h"
41void test_parlist(
void)
44 hdrl_parameter * hpar;
45 hdrl_parameter * deflts;
49 "RECIPE",
"bpm", deflts);
51 cpl_test_error(CPL_ERROR_NONE);
52 cpl_test_nonnull(parse);
55 cpl_parameterlist_delete(pos);
60 cpl_test_error(CPL_ERROR_NONE);
61 cpl_test_eq(cpl_parameterlist_get_size(pos), 3);
65 cpl_test_error(CPL_ERROR_DATA_NOT_FOUND);
68 cpl_parameterlist_delete(pos);
69 cpl_test_error(CPL_ERROR_NONE);
72 HDRL_BPM_3D_THRESHOLD_RELATIVE);
84static cpl_error_code hdrl_bpm_3d_test_compute(
void)
86 cpl_image * img_tmp = NULL;
87 cpl_imagelist * result_data = NULL;
90 hdrl_parameter * bpm_param ;
91 for (
int var = 0; var <5 ; ++var) {
92 cpl_image * data = cpl_image_new(200, 300, CPL_TYPE_DOUBLE);
93 cpl_mask * data_bpm = cpl_mask_new(200, 300);
95 cpl_image_fill_noise_uniform(data, 82, 118);
98 cpl_image_set(data, 10, 10, 20.);
99 cpl_mask_set(data_bpm, 10, 10, CPL_BINARY_1);
102 cpl_image_set(data, 50, 50, 300.);
103 cpl_mask_set(data_bpm, 50, 50, CPL_BINARY_1);
106 cpl_image_set(data, 60, 60, 300.);
107 cpl_image_set(data, 61, 61, 300.);
108 cpl_image_set(data, 62, 62, 300.);
111 cpl_image_set(data, 70, 70, 20.);
112 cpl_image_set(data, 71, 71, 20.);
113 cpl_image_set(data, 72, 72, 20.);
116 cpl_mask_set(data_bpm, 80, 80, CPL_BINARY_1);
117 cpl_mask_set(data_bpm, 81, 80, CPL_BINARY_1);
118 cpl_mask_set(data_bpm, 82, 80, CPL_BINARY_1);
120 }
else if (var == 3) {
121 cpl_image_set(data, 150, 150, 300.);
122 cpl_image_set(data, 110, 260, 300.);
123 cpl_mask_set(data_bpm, 70, 70, CPL_BINARY_1);
124 cpl_mask_set(data_bpm, 80, 80, CPL_BINARY_1);
127 cpl_image_reject_from_mask(data, data_bpm);
128 cpl_image * errors=cpl_image_power_create(data, 0.5);
133 cpl_mask_delete(data_bpm);
134 cpl_image_delete(data);
135 cpl_image_delete(errors);
140 HDRL_BPM_3D_THRESHOLD_ABSOLUTE) ;
145 img_tmp = cpl_imagelist_get(result_data, 0);
146 cpl_test_eq(cpl_image_get(img_tmp, 10, 10, &bad), 0);
147 cpl_test_eq(cpl_image_get(img_tmp, 50, 50, &bad), 0);
148 cpl_test_eq(cpl_image_get(img_tmp, 60, 60, &bad), 1);
149 cpl_test_eq(cpl_image_get(img_tmp, 61, 61, &bad), 1);
150 cpl_test_eq(cpl_image_get(img_tmp, 62, 62, &bad), 1);
151 cpl_test_eq(cpl_image_get(img_tmp, 70, 70, &bad), 1);
152 cpl_test_eq(cpl_image_get(img_tmp, 71, 71, &bad), 1);
153 cpl_test_eq(cpl_image_get(img_tmp, 72, 72, &bad), 1);
154 cpl_test_eq(cpl_image_get(img_tmp, 80, 80, &bad), 0);
155 cpl_test_eq(cpl_image_get(img_tmp, 81, 80, &bad), 0);
156 cpl_test_eq(cpl_image_get(img_tmp, 82, 80, &bad), 0);
157 cpl_imagelist_delete(result_data);
162 HDRL_BPM_3D_THRESHOLD_RELATIVE) ;
165 img_tmp = cpl_imagelist_get(result_data, 0);
166 cpl_test_eq(cpl_image_get(img_tmp, 10, 10, &bad), 0);
167 cpl_test_eq(cpl_image_get(img_tmp, 50, 50, &bad), 0);
168 cpl_test_eq(cpl_image_get(img_tmp, 60, 60, &bad), 1);
169 cpl_test_eq(cpl_image_get(img_tmp, 61, 61, &bad), 1);
170 cpl_test_eq(cpl_image_get(img_tmp, 62, 62, &bad), 1);
171 cpl_test_eq(cpl_image_get(img_tmp, 70, 70, &bad), 1);
172 cpl_test_eq(cpl_image_get(img_tmp, 71, 71, &bad), 1);
173 cpl_test_eq(cpl_image_get(img_tmp, 72, 72, &bad), 1);
174 cpl_test_eq(cpl_image_get(img_tmp, 80, 80, &bad), 0);
175 cpl_test_eq(cpl_image_get(img_tmp, 81, 80, &bad), 0);
176 cpl_test_eq(cpl_image_get(img_tmp, 82, 80, &bad), 0);
177 cpl_imagelist_delete(result_data);
182 HDRL_BPM_3D_THRESHOLD_ERROR) ;
185 cpl_test_error(CPL_ERROR_NONE);
187 img_tmp = cpl_imagelist_get(result_data, 0);
189 cpl_test_eq(cpl_image_get(img_tmp, 10, 10, &bad), 0);
190 cpl_test_eq(cpl_image_get(img_tmp, 50, 50, &bad), 0);
191 cpl_test_eq(cpl_image_get(img_tmp, 60, 60, &bad), 1);
192 cpl_test_eq(cpl_image_get(img_tmp, 61, 61, &bad), 1);
193 cpl_test_eq(cpl_image_get(img_tmp, 62, 62, &bad), 1);
194 cpl_test_eq(cpl_image_get(img_tmp, 70, 70, &bad), 1);
195 cpl_test_eq(cpl_image_get(img_tmp, 71, 71, &bad), 1);
196 cpl_test_eq(cpl_image_get(img_tmp, 72, 72, &bad), 1);
197 cpl_test_eq(cpl_image_get(img_tmp, 80, 80, &bad), 0);
198 cpl_test_eq(cpl_image_get(img_tmp, 81, 80, &bad), 0);
199 cpl_test_eq(cpl_image_get(img_tmp, 82, 80, &bad), 0);
202 cpl_imagelist_delete(result_data);
207 HDRL_BPM_3D_THRESHOLD_ERROR) ;
210 cpl_test_error(CPL_ERROR_NONE);
212 img_tmp = cpl_imagelist_get(result_data, 0);
214 cpl_test_eq(cpl_image_get(img_tmp, 10, 10, &bad), 0);
215 cpl_test_eq(cpl_image_get(img_tmp, 50, 50, &bad), 0);
216 cpl_test_eq(cpl_image_get(img_tmp, 60, 60, &bad), 1);
217 cpl_test_eq(cpl_image_get(img_tmp, 61, 61, &bad), 1);
218 cpl_test_eq(cpl_image_get(img_tmp, 62, 62, &bad), 1);
219 cpl_test_eq(cpl_image_get(img_tmp, 70, 70, &bad), 0);
220 cpl_test_eq(cpl_image_get(img_tmp, 71, 71, &bad), 0);
221 cpl_test_eq(cpl_image_get(img_tmp, 72, 72, &bad), 0);
222 cpl_test_eq(cpl_image_get(img_tmp, 80, 80, &bad), 0);
223 cpl_test_eq(cpl_image_get(img_tmp, 81, 80, &bad), 0);
224 cpl_test_eq(cpl_image_get(img_tmp, 82, 80, &bad), 0);
225 cpl_imagelist_delete(result_data);
229 HDRL_BPM_3D_THRESHOLD_ERROR) ;
232 cpl_test_null(result_data);
233 cpl_test_error(CPL_ERROR_NULL_INPUT);
235 HDRL_BPM_3D_THRESHOLD_ABSOLUTE) ;
238 cpl_test_null(result_data);
239 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
241 HDRL_BPM_3D_THRESHOLD_RELATIVE) ;
244 cpl_test_null(result_data);
245 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
247 HDRL_BPM_3D_THRESHOLD_ERROR) ;
249 cpl_test_null(result_data);
251 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
253 HDRL_BPM_3D_THRESHOLD_ERROR) ;
256 cpl_test_null(result_data);
257 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
261 return cpl_error_get_code();
272 cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
273 hdrl_bpm_3d_test_compute();
275 cpl_test_error(CPL_ERROR_NONE);
276 return cpl_test_end(0);
double hdrl_bpm_3d_parameter_get_kappa_high(const hdrl_parameter *p)
Access the kappa_high in the BPM_3D parameter.
double hdrl_bpm_3d_parameter_get_kappa_low(const hdrl_parameter *p)
Access the kappa_low in the BPM_3D parameter.
cpl_parameterlist * hdrl_bpm_3d_parameter_create_parlist(const char *base_context, const char *prefix, const hdrl_parameter *defaults)
Create a parameter list for the BPM_3D computation.
cpl_imagelist * hdrl_bpm_3d_compute(const hdrl_imagelist *imglist, const hdrl_parameter *params)
detect bad pixels on a stack of identical images
hdrl_parameter * hdrl_bpm_3d_parameter_parse_parlist(const cpl_parameterlist *parlist, const char *prefix)
Parse a parameterlist to create input parameters for the BPM_3D.
hdrl_bpm_3d_method hdrl_bpm_3d_parameter_get_method(const hdrl_parameter *p)
Access the method in the BPM_3D parameter.
hdrl_parameter * hdrl_bpm_3d_parameter_create(double kappa_low, double kappa_high, hdrl_bpm_3d_method method)
Creates BPM Parameters object for the imagelist method.
cpl_boolean hdrl_bpm_3d_parameter_check(const hdrl_parameter *self)
Check that the parameter is a BPM_3D parameter.
hdrl_image * hdrl_image_create(const cpl_image *image, const cpl_image *error)
create a new hdrl_image from to existing images by copying them
cpl_error_code hdrl_imagelist_set(hdrl_imagelist *himlist, hdrl_image *himg, cpl_size pos)
Insert an image into an imagelist.
void hdrl_imagelist_delete(hdrl_imagelist *himlist)
Free all memory used by a hdrl_imagelist object including the images.
hdrl_imagelist * hdrl_imagelist_new(void)
Create an empty imagelist.
void hdrl_parameter_delete(hdrl_parameter *obj)
shallow delete of a parameter