CR2RE Pipeline Reference Manual 1.6.2
hdrl_flat-test.c
1/*
2 * This file is part of the HDRL
3 * Copyright (C) 2013,2014 European Southern Observatory
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifdef HAVE_CONFIG_H
21#include <config.h>
22#endif
23
24/*-----------------------------------------------------------------------------
25 Includes
26 -----------------------------------------------------------------------------*/
27
28#include "hdrl_flat.h"
29#include "hdrl_image.h"
30#include "hdrl_parameter.h"
31
32#include <cpl.h>
33#include <math.h>
34#include <string.h>
35
36/*----------------------------------------------------------------------------*/
40/*----------------------------------------------------------------------------*/
41/*----------------------------------------------------------------------------*/
46/*----------------------------------------------------------------------------*/
47void hdrl_flat_test_parlist(void)
48{
49 /* parameter parsing smoketest */
50 hdrl_parameter * hpar;
51 cpl_size filter_size_x=5;
52 cpl_size filter_size_y=5;
53 hdrl_flat_method method=HDRL_FLAT_FREQ_LOW;
54
55 hdrl_parameter * deflts = hdrl_flat_parameter_create(filter_size_x,
56 filter_size_y, method);
57 cpl_test(hdrl_flat_parameter_check(deflts));
58 cpl_test_error(CPL_ERROR_NONE);
59
60 cpl_parameterlist * pflat = hdrl_flat_parameter_create_parlist("RECIPE",
61 "flat", deflts);
62 hdrl_parameter_delete(deflts) ;
63 cpl_test_error(CPL_ERROR_NONE);
64 cpl_test_eq(cpl_parameterlist_get_size(pflat), 3);
65
66 hpar = hdrl_flat_parameter_parse_parlist(pflat, "RECIPE.invalid");
67 cpl_test_null(hpar);
68 cpl_test_error(CPL_ERROR_DATA_NOT_FOUND);
69
70 hpar = hdrl_flat_parameter_parse_parlist(pflat, "RECIPE.flat");
71 cpl_parameterlist_delete(pflat);
72 cpl_test_error(CPL_ERROR_NONE);
73
74 cpl_test_eq(hdrl_flat_parameter_get_method(hpar),
75 HDRL_FLAT_FREQ_LOW);
76 cpl_test_eq(hdrl_flat_parameter_get_filter_size_x(hpar), filter_size_x);
77 cpl_test_eq(hdrl_flat_parameter_get_filter_size_y(hpar), filter_size_x);
79
80 /* filter size x < 0 : CPL_ERROR_ILLEGAL_INPUT */
81 /* filter size y < 0 : CPL_ERROR_ILLEGAL_INPUT */
82 /* method: HDRL_FLAT_FREQ_LOW || HDRL_FLAT_FREQ_HIGH =>
83 * 2==> CPL_ERROR_ILLEGAL_INPUT */
84 deflts = hdrl_flat_parameter_create(-1, filter_size_y, method);
85 cpl_test_null(deflts);
86 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
87 hdrl_parameter_delete(deflts) ;
88
89 deflts = hdrl_flat_parameter_create(filter_size_x, -1, method);
90 cpl_test_null(deflts);
91 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
92 hdrl_parameter_delete(deflts) ;
93
94 deflts = hdrl_flat_parameter_create(filter_size_x, filter_size_y, 2);
95 cpl_test_null(deflts);
96 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
97 hdrl_parameter_delete(deflts) ;
98
99 deflts = hdrl_flat_parameter_create(2, filter_size_y, method);
100 cpl_test_null(deflts);
101 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
102 hdrl_parameter_delete(deflts) ;
103
104 deflts = hdrl_flat_parameter_create(filter_size_x, 2, method);
105 cpl_test_null(deflts);
106 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
107 hdrl_parameter_delete(deflts) ;
108
109 deflts = hdrl_flat_parameter_create(2, 2, method);
110 cpl_test_null(deflts);
111 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
112 hdrl_parameter_delete(deflts) ;
113}
114
115/* not yet used, comment it out (may be will be used later)
116static cpl_error_code
117hdrl_flat_flag_pixel_set(cpl_image * data, cpl_mask * data_bpm, const int var )
118{
119 cpl_mask_set(data_bpm, 10, 10, CPL_BINARY_1);
120 if(var == 0) {
121 // Negative outlier set and marked as bad
122 cpl_image_set(data, 10, 10, 20.);
123 cpl_mask_set(data_bpm, 10, 10, CPL_BINARY_1);
124
125 // Positive outlier set and marked as bad
126 cpl_image_set(data, 50, 50, 300.);
127 cpl_mask_set(data_bpm, 50, 50, CPL_BINARY_1);
128
129 // Positive outliers set
130 cpl_image_set(data, 60, 60, 300.);
131 cpl_image_set(data, 61, 61, 300.);
132 cpl_image_set(data, 62, 62, 300.);
133
134 // Negative outliers set
135 cpl_image_set(data, 70, 70, 20.);
136 cpl_image_set(data, 71, 71, 20.);
137 cpl_image_set(data, 72, 72, 20.);
138
139 // Some pixels marked as bad
140 cpl_mask_set(data_bpm, 80, 80, CPL_BINARY_1);
141 cpl_mask_set(data_bpm, 81, 80, CPL_BINARY_1);
142 cpl_mask_set(data_bpm, 82, 80, CPL_BINARY_1);
143
144 } else if (var == 3) {
145 cpl_image_set(data, 150, 150, 300.);
146 cpl_image_set(data, 110, 260, 300.);
147 cpl_mask_set(data_bpm, 70, 70, CPL_BINARY_1);
148 cpl_mask_set(data_bpm, 80, 80, CPL_BINARY_1);
149 }
150 return cpl_error_get_code();
151
152}
153*/
154
155/* the following function flag as bad data points over a given region */
156static cpl_error_code
157hdrl_flat_imlist_flag_region(hdrl_imagelist * imglist,
158 const hdrl_parameter * rect,
159 const double outlier,
160 const int mask_sw)
161{
162 const int nima=hdrl_imagelist_get_size(imglist);
163
164 const cpl_size b_llx = hdrl_rect_region_get_llx(rect);
165 const cpl_size b_lly = hdrl_rect_region_get_lly(rect);
166 const cpl_size b_urx = hdrl_rect_region_get_urx(rect);
167 const cpl_size b_ury = hdrl_rect_region_get_ury(rect);
168
169 hdrl_image * hima = hdrl_imagelist_get(imglist , 0);
170
171 cpl_size ima_sx = cpl_image_get_size_x(hdrl_image_get_image(hima));
172 cpl_size ima_sy = cpl_image_get_size_y(hdrl_image_get_image(hima));
173
174 for (int var = 0; var < nima ; ++var) {
175
176 hima = hdrl_imagelist_get(imglist, var);
177 cpl_image * data = hdrl_image_get_image(hima);
178 cpl_mask * data_bpm = cpl_mask_new(ima_sx, ima_sy);
179 // STDEV is about 10 for these images
180 //cpl_image_fill_noise_uniform(data, 82, 118);
181
182 //cpl_image_fill_window(data, b_llx, b_lly, b_urx, b_ury, outlier);
183 for(int j = b_lly; j < b_ury; j++) {
184 for(int i = b_llx; i < b_urx; i++) {
185 cpl_image_set(data, i, j, outlier);
186 }
187 }
188
189 if(mask_sw == 1) {
190 for(int j = b_lly; j < b_ury; j++) {
191 for(int i = b_llx; i < b_urx; i++) {
192 cpl_mask_set(data_bpm, i, j, CPL_BINARY_1);
193 }
194 }
195 }
196 /*
197 hdrl_flat_flag_pixel_set(data, data_bpm, var);
198 */
199 cpl_image_reject_from_mask(data, data_bpm);
200
201 cpl_image * errors=cpl_image_power_create(data, 0.5);
202 hdrl_image * image = hdrl_image_create(data, errors);
203 /*
204 if(var == 0) {
205
206 cpl_mask_save(cpl_image_get_bpm(data), "m_mask_flagged_region.fits",
207 NULL, CPL_IO_CREATE);
208 cpl_mask_save(cpl_image_get_bpm(hdrl_image_get_image(image)),
209 "h_mask_flagged_region.fits", NULL, CPL_IO_CREATE);
210
211 cpl_image_save(data, "data_flagged_region.fits",CPL_TYPE_FLOAT,
212 NULL, CPL_IO_DEFAULT);
213 cpl_image_save(errors, "errs_flagged_region.fits",CPL_TYPE_FLOAT,
214 NULL, CPL_IO_DEFAULT);
215 cpl_mask_save(data_bpm, "mask_flagged_region.fits", NULL,
216 CPL_IO_CREATE);
217
218 }
219 */
220 hdrl_imagelist_set(imglist, image, var);
221 // free the memory
222 cpl_mask_delete(data_bpm);
223 //cpl_image_delete(data);
224 cpl_image_delete(errors);
225 }
226
227
228 cpl_imagelist* iml_data = NULL;
229 cpl_imagelist* iml_errs = NULL;
230 hdrl_imagelist_to_cplwrap(imglist, &iml_data, &iml_errs);
231 /*
232 cpl_imagelist_save(iml_data, "cube_data.fits", CPL_TYPE_FLOAT, NULL,
233 CPL_IO_DEFAULT);
234 cpl_imagelist_save(iml_errs, "cube_errs.fits", CPL_TYPE_FLOAT, NULL,
235 CPL_IO_DEFAULT);
236 */
237 cpl_imagelist_unwrap(iml_data);
238 cpl_imagelist_unwrap(iml_errs);
239
240 return cpl_error_get_code();
241}
242
243/* the following function generates a list of uniform images of given size
244 * and values */
245static hdrl_imagelist*
246hdrl_flat_create_uniform_images(
247 const cpl_size nima,
248 const cpl_size ima_sx,
249 const cpl_size ima_sy,
250 const cpl_vector* values)
251{
252 hdrl_imagelist * imglist = hdrl_imagelist_new();
253
254 for (int var = 0; var < nima ; ++var) {
255
256 cpl_image * data = cpl_image_new(ima_sx, ima_sy, CPL_TYPE_DOUBLE);
257 cpl_mask * data_bpm = cpl_mask_new(ima_sx, ima_sy);
258 // STDEV is about 10 for these images
259 //cpl_image_fill_noise_uniform(data, 82, 118);
260 cpl_image_add_scalar(data, cpl_vector_get(values, var));
261 cpl_image * errors = cpl_image_power_create(data, 0.5);
262 /*
263 if(var == 0) {
264 cpl_image_save(data, "image_data.fits",CPL_TYPE_FLOAT, NULL,
265 CPL_IO_DEFAULT);
266 cpl_image_save(errors, "image_errs.fits",CPL_TYPE_FLOAT, NULL,
267 CPL_IO_DEFAULT);
268 }
269 */
270 hdrl_image * image = hdrl_image_create(data, errors);
271
272 hdrl_imagelist_set(imglist, image, var);
273 // free the memory
274 cpl_mask_delete(data_bpm);
275 cpl_image_delete(data);
276 cpl_image_delete(errors);
277
278 }
279
280 cpl_imagelist* iml_data = NULL;
281 cpl_imagelist* iml_errs = NULL;
282 hdrl_imagelist_to_cplwrap(imglist, &iml_data, &iml_errs);
283 /*
284 cpl_imagelist_save(iml_data, "cube_data.fits", CPL_TYPE_FLOAT, NULL,
285 CPL_IO_DEFAULT);
286 cpl_imagelist_save(iml_errs, "cube_errs.fits", CPL_TYPE_FLOAT, NULL,
287 CPL_IO_DEFAULT);
288 */
289 cpl_imagelist_unwrap(iml_data);
290 cpl_imagelist_unwrap(iml_errs);
291 return imglist;
292}
293
294static cpl_mask*
295hdrl_flat_crea_static_mask(const cpl_size ima_sx,
296 const cpl_size ima_sy,
297 const hdrl_parameter * rect)
298{
299 const cpl_size b_llx = hdrl_rect_region_get_llx(rect);
300 const cpl_size b_lly = hdrl_rect_region_get_lly(rect);
301 const cpl_size b_urx = hdrl_rect_region_get_urx(rect);
302 const cpl_size b_ury = hdrl_rect_region_get_ury(rect);
303
304 cpl_mask * stat_mask = cpl_mask_new(ima_sx, ima_sy);
305 for(int j = b_lly; j < b_ury; j++) {
306 for(int i = b_llx; i < b_urx; i++) {
307 cpl_mask_set(stat_mask, i, j, CPL_BINARY_1);
308 }
309 }
310 return stat_mask;
311
312}
313
314/*
315static cpl_error_code
316hdrl_flat_save_results(hdrl_image* master, cpl_image* cmap, cpl_mask* stat_mask)
317{
318
319 cpl_image_save(hdrl_image_get_image(master), "master_data.fits",
320 CPL_TYPE_FLOAT, NULL, CPL_IO_DEFAULT);
321 cpl_image_save(hdrl_image_get_error(master), "master_errs.fits",
322 CPL_TYPE_FLOAT, NULL, CPL_IO_DEFAULT);
323 cpl_image_save(cmap, "master_map.fits", CPL_TYPE_FLOAT, NULL,
324 CPL_IO_DEFAULT);
325
326 if (stat_mask != NULL) {
327 cpl_mask_save(stat_mask, "static_mask.fits", NULL, CPL_IO_DEFAULT);
328 }
329
330 return cpl_error_get_code();
331}
332 */
333
334/* this function is to verify that the image and error values in the
335 * lower left corner and at a given data point are as expected
336 */
337static cpl_error_code
338hdrl_flat_test_case(hdrl_imagelist* imglist,
339 const hdrl_parameter * rect,
340 const hdrl_flat_method method,
341 const cpl_size fsx,
342 const cpl_size fsy,
343 const hdrl_parameter* collapse_params,
344 const int mask_sw,
345 const double val1,
346 const double err1,
347 const double val2,
348 const double err2)
349
350{
351 hdrl_parameter * fparam ;
352 cpl_mask * stat_mask = NULL;
353 hdrl_image * hima;
354 cpl_size ima_sx;
355 cpl_size ima_sy;
356
357 const cpl_size b_llx = hdrl_rect_region_get_llx(rect);
358 const cpl_size b_lly = hdrl_rect_region_get_lly(rect);
359 const cpl_size b_urx = hdrl_rect_region_get_urx(rect);
360 const cpl_size b_ury = hdrl_rect_region_get_ury(rect);
361
362 cpl_size b_cx = (int)(0.5 * (b_llx + b_urx) + 0.5);
363 cpl_size b_cy = (int)(0.5 * (b_lly + b_ury) + 0.5);
364 hima = hdrl_imagelist_get(imglist,0);
365 ima_sx = hdrl_image_get_size_x(hima);
366 ima_sy = hdrl_image_get_size_y(hima);
367 int bad;
368 hdrl_image * master = NULL;
369 cpl_image * contrib_map = NULL;
370
371 fparam = hdrl_flat_parameter_create(fsx, fsy, method);
372
373 if(mask_sw) {
374 stat_mask=hdrl_flat_crea_static_mask(ima_sx, ima_sy, rect);
375 }
376
377 hdrl_flat_compute(imglist, stat_mask, collapse_params,
378 fparam, &master, &contrib_map);
379 //hdrl_flat_save_results(master, contrib_map, stat_mask);
380
381 cpl_test_eq(cpl_image_get(hdrl_image_get_image(master), 1, 1, &bad), val1);
382 cpl_test_eq(cpl_image_get(hdrl_image_get_error(master), 1, 1, &bad), err1);
383
384 cpl_test_eq(cpl_image_get(hdrl_image_get_image(master), b_cx, b_cy, &bad),
385 val2);
386
387 cpl_msg_warning(cpl_func,"Check for err2 = %g still to be implemented",
388 err2);
389
390 /*
391 cpl_msg_warning(cpl_func,"check sub data=%g %g",
392 cpl_image_get(hdrl_image_get_image(master), 1, 1, &bad), val1); //ok
393 cpl_msg_warning(cpl_func,"check2 sub data=%g %g",
394 cpl_image_get(hdrl_image_get_image(master),
395 b_cx, b_cy, &bad),val2);//ok
396
397 cpl_msg_warning(cpl_func,"check sub error=%g %g",
398 cpl_image_get(hdrl_image_get_error(master), 1, 1, &bad), err1);//nok
399 cpl_msg_warning(cpl_func,"check2 sub error=%g %g",
400 cpl_image_get(hdrl_image_get_error(master),
401 b_cx, b_cy, &bad),err2);
402 */
403
404 /* Note: HDRL fully propagates errors. The error on the mean is not per
405 * pixel but for uniform error image it is divided by sqrt(npix).
406 * Thus one cannot compare the pixel values of the image with the error
407 * computed on the image.
408 */
409
410
411 hdrl_parameter_delete(fparam);
412 hdrl_image_delete(master);
413 cpl_mask_delete(stat_mask);
414 cpl_image_delete(contrib_map);
415
416 return cpl_error_get_code();
417}
418
419/*----------------------------------------------------------------------------*/
424/*----------------------------------------------------------------------------*/
425static cpl_error_code hdrl_flat_test_multi_options(void)
426{
427 /* input data */
428 const cpl_size ima_sx = 200;
429 const cpl_size ima_sy = 300;
430 const cpl_size b_llx = 100;
431 const cpl_size b_lly = 100;
432 const cpl_size b_urx = 200;
433 const cpl_size b_ury = 200;
434 const cpl_size nima = 5;
435 const double outlier = 100000;
436 hdrl_parameter * rect_region_bad_area_def =
437 hdrl_rect_region_parameter_create(b_llx, b_lly, b_urx,
438 b_ury);
439
440 /* image intensity values distributed as 2^n */
441 cpl_vector * vals = cpl_vector_new(nima);
442 cpl_vector * valserr_rel = cpl_vector_new(nima); //relative error
443 const double base = 2;
444
445 for (int i = 0; i < nima ; ++i) {
446 double intensity = pow(base, i);
447 cpl_vector_set(vals, i, intensity);
448 cpl_vector_set(valserr_rel, i, sqrt(intensity)/intensity);
449 }
450
451 hdrl_imagelist * imglist = hdrl_flat_create_uniform_images(nima, ima_sx,
452 ima_sy, vals);
453 hdrl_flat_imlist_flag_region(imglist, rect_region_bad_area_def, outlier, 0);
454
455 /* flat parameters */
456 cpl_size filter_size_x = 1;
457 cpl_size filter_size_y = 1;
458 const double r_median = 25000;
459 const double r_mean = 38750;
460 /* case 1:
461 *
462 * flat method=HDRL_FLAT_FREQ_LOW,
463 * stat_mask=NULL,
464 * colapse_method: median
465 */
466
467 /* Error propagation for pixel 1,1 */
468 cpl_vector_power(valserr_rel, 2);
469
470 double error_expected_pix1_mean = sqrt(cpl_vector_get_sum(valserr_rel))/nima;
471 double error_expected_pix1_median = error_expected_pix1_mean* sqrt(CPL_MATH_PI_2);
472
473
474 hdrl_parameter *collapse_pMean = hdrl_collapse_mean_parameter_create();
475 hdrl_parameter *collapse_pMedian = hdrl_collapse_median_parameter_create();
476
477
478 /* in the following cases (2-8) it is difficult to verify the error value at
479 * the image centre because the image intensities are on purpose distributed
480 * with complex values.
481 */
482 hdrl_flat_test_case(imglist, rect_region_bad_area_def, HDRL_FLAT_FREQ_LOW,
483 filter_size_x, filter_size_y, collapse_pMedian, 0,
484 1, error_expected_pix1_median, r_median, 91.4844);
485
486 /* case 2:
487 *
488 * flat method=HDRL_FLAT_FREQ_LOW,
489 * stat_mask!=NULL,
490 * colapse_method: median
491 */
492
493 hdrl_flat_test_case(imglist, rect_region_bad_area_def, HDRL_FLAT_FREQ_LOW,
494 filter_size_x, filter_size_y, collapse_pMedian, 1,
495 1, error_expected_pix1_median, r_median, 91.4844);
496
497 /* case 3:
498 *
499 * flat method=HDRL_FLAT_FREQ_LOW,
500 * stat_mask=NULL,
501 * colapse_method: mean
502 */
503
504 hdrl_flat_test_case(imglist, rect_region_bad_area_def, HDRL_FLAT_FREQ_LOW,
505 filter_size_x, filter_size_y, collapse_pMean, 0,
506 1, error_expected_pix1_mean, r_mean, 72.994);
507
508 /* case 4:
509 *
510 * flat method=HDRL_FLAT_FREQ_LOW,
511 * stat_mask!=NULL,
512 * colapse_method: mean
513 */
514
515 hdrl_flat_test_case(imglist, rect_region_bad_area_def, HDRL_FLAT_FREQ_LOW,
516 filter_size_x, filter_size_y, collapse_pMean, 1,
517 1, error_expected_pix1_mean,r_mean,72.994);// error TBV
518
519 /* case 5:
520 *
521 * flat method=HDRL_FLAT_FREQ_HIGH,
522 * stat_mask=NULL,
523 * colapse_method: median
524 */
525
526 hdrl_flat_test_case(imglist, rect_region_bad_area_def, HDRL_FLAT_FREQ_HIGH,
527 filter_size_x, filter_size_y, collapse_pMedian, 0,
528 1, error_expected_pix1_median, 1, 0.00177245);
529
530 /* case 6:
531 *
532 * flat method=HDRL_FLAT_FREQ_HIGH,
533 * stat_mask!=NULL,
534 * colapse_method: median
535 */
536
537 hdrl_flat_test_case(imglist, rect_region_bad_area_def, HDRL_FLAT_FREQ_HIGH,
538 filter_size_x, filter_size_y, collapse_pMedian, 1,
539 1, error_expected_pix1_median, 1, 0.00177245);
540
541 /* case 7:
542 *
543 * flat method=HDRL_FLAT_FREQ_HIGH,
544 * stat_mask=NULL,
545 * colapse_method: mean
546 */
547
548 hdrl_flat_test_case(imglist, rect_region_bad_area_def, HDRL_FLAT_FREQ_HIGH,
549 filter_size_x, filter_size_y, collapse_pMean, 0,
550 1, error_expected_pix1_mean, 1, 0.00141421);
551
552 /* case 8:
553 *
554 * flat method=HDRL_FLAT_FREQ_HIGH,
555 * stat_mask!=NULL,
556 * colapse_method: mean
557 */
558
559 hdrl_flat_test_case(imglist, rect_region_bad_area_def, HDRL_FLAT_FREQ_HIGH,
560 filter_size_x, filter_size_y, collapse_pMean, 1,
561 1, error_expected_pix1_mean, 1, 0.00141421);
562
563 /* free memory */
564 hdrl_parameter_delete(collapse_pMean);
565 hdrl_parameter_delete(collapse_pMedian);
566
567 hdrl_parameter_delete(rect_region_bad_area_def);
568 hdrl_imagelist_delete(imglist);
569 cpl_vector_delete(vals);
570 cpl_vector_delete(valserr_rel);
571 return cpl_error_get_code();
572}
573
574/*----------------------------------------------------------------------------*/
579/*----------------------------------------------------------------------------*/
580static cpl_error_code hdrl_flat_test_static_mask(void)
581{
582 /* input data */
583 const cpl_size ima_sx = 200;
584 const cpl_size ima_sy = 300;
585
586 const cpl_size r1_llx = 50;
587 const cpl_size r1_lly = 50;
588 const cpl_size r1_urx = 80;
589 const cpl_size r1_ury = 250;
590 const double outlier1 = 100000;
591
592 const cpl_size r2_llx = 100;
593 const cpl_size r2_lly = 90;
594 const cpl_size r2_urx = 130;
595 const cpl_size r2_ury = 260;
596 const double outlier2 = 200000;
597
598 const cpl_size r3_llx = 150;
599 const cpl_size r3_lly = 80;
600 const cpl_size r3_urx = 180;
601 const cpl_size r3_ury = 270;
602 const double outlier3 = 300000;
603
604 const cpl_size nima = 5;
605 hdrl_parameter * rect1 = hdrl_rect_region_parameter_create(r1_llx, r1_lly,
606 r1_urx, r1_ury);
607
608 hdrl_parameter * rect2 = hdrl_rect_region_parameter_create(r2_llx, r2_lly,
609 r2_urx, r2_ury);
610
611 hdrl_parameter * rect3 = hdrl_rect_region_parameter_create(r3_llx, r3_lly,
612 r3_urx, r3_ury);
613
614 /* image intensity values distributed as 2^n */
615 cpl_vector * vals = cpl_vector_new(nima);
616
617 const double base = 2;
618 for (int i = 0; i < nima ; ++i) {
619 double intensity = pow(base, i);
620 cpl_vector_set(vals, i, intensity);
621 }
622
623 hdrl_imagelist* imglist = hdrl_flat_create_uniform_images(nima, ima_sx,
624 ima_sy, vals);
625 hdrl_flat_imlist_flag_region(imglist, rect1, outlier1, 1);
626 hdrl_flat_imlist_flag_region(imglist, rect2, outlier2, 1);
627 hdrl_flat_imlist_flag_region(imglist, rect3, outlier3, 1);
628
629 /* flat parameters */
630 cpl_size filter_size_x = 1;
631 cpl_size filter_size_y = 1;
632 const double r_mean = 38750;
633 const double e_mean = 72.994; //TBV
634 //const double r_mean=25000;
635
636
637
638
639 hdrl_parameter *collapse_pMean = hdrl_collapse_mean_parameter_create();
640 hdrl_parameter *collapse_pMedian = hdrl_collapse_median_parameter_create();
641
642 /* case 1:
643 *
644 * flat method=HDRL_FLAT_FREQ_LOW,
645 * stat_mask=NULL,
646 * colapse_method: mean
647 */
648
649 hdrl_flat_test_case(imglist, rect1, HDRL_FLAT_FREQ_LOW,
650 filter_size_x, filter_size_y, collapse_pMean, 0,
651 1, 0.278388, r_mean, e_mean);
652
653
654
655
656 /* case 2:
657 *
658 * flat method=HDRL_FLAT_FREQ_HIGH,
659 * stat_mask=NULL,
660 * colapse_method: mean
661 */
662
663 hdrl_flat_test_case(imglist, rect1, HDRL_FLAT_FREQ_HIGH,
664 filter_size_x, filter_size_y, collapse_pMean, 0,
665 1, 0.278388, 1, 0.00141421); // error TBV
666
667 /* case 3:
668 *
669 * flat method=HDRL_FLAT_FREQ_HIGH,
670 * stat_mask=NULL,
671 * colapse_method: median
672 */
673
674 hdrl_flat_test_case(imglist, rect1, HDRL_FLAT_FREQ_HIGH,
675 filter_size_x, filter_size_y, collapse_pMedian, 0,
676 1, 0.278388, 1, 0.00141421); // error TBV
677
678
679 /* free memory */
680 hdrl_parameter_delete(collapse_pMean);
681 hdrl_parameter_delete(collapse_pMedian);
682
686 hdrl_imagelist_delete(imglist);
687 cpl_vector_delete(vals);
688
689 return cpl_error_get_code();
690}
691
692
693/*----------------------------------------------------------------------------*/
698/*----------------------------------------------------------------------------*/
699static cpl_error_code hdrl_flat_test_data_value_basic(void)
700{
701 /* input data */
702 const cpl_size ima_sx = 51;
703 const cpl_size ima_sy = 31;
704 int npix = ima_sx * ima_sy;
705 const cpl_size filter_size_x = 1;
706 const cpl_size filter_size_y = 1;
707 const cpl_size nima = 9;
708
709 /* image intensity values distributed as 2^n */
710 cpl_vector * vals = cpl_vector_new(nima);
711 double value = 9;
712 double error = sqrt(value);
713 cpl_vector_fill(vals, value);
714
715 hdrl_imagelist * imglist = hdrl_flat_create_uniform_images(nima, ima_sx,
716 ima_sy, vals);
717 cpl_vector_delete(vals);
718
719 hdrl_parameter * flat_params;
720 hdrl_image * master = NULL;
721 cpl_image * contrib_map = NULL;
722 hdrl_value res;
723 double expected_error;
724 /* case 1:
725 * 9 images each of value 9,
726 * flat method=HDRL_FLAT_FREQ_LOW,
727 * stat_mask=NULL,
728 * colapse_method: mean
729 *
730 * expected results:
731 * master should have value 1 (master is normalised),
732 * error 3./9./math.sqrt(9) / math.sqrt(51*31)
733 * contribution map should be NULL.
734 */
735 flat_params = hdrl_flat_parameter_create(filter_size_x, filter_size_y,
736 HDRL_FLAT_FREQ_LOW);
737
738 hdrl_parameter * collapse_params = hdrl_collapse_mean_parameter_create();
739 hdrl_flat_compute(imglist, NULL, collapse_params, flat_params, &master,
740 &contrib_map);
741 hdrl_parameter_delete(flat_params);
742
743 //hdrl_flat_save_results(master, contrib_map, NULL);
744
745 expected_error = error / value / sqrt(nima) / sqrt(ima_sx * ima_sy);
746
747 res = hdrl_image_get_mean(master);
748 cpl_test_abs( res.data, 1, HDRL_EPS_ERROR);
749 cpl_test_abs( res.error, expected_error, HDRL_EPS_ERROR);
750 /* Note: HDRL fully propagates errors. The error on the mean is not per
751 * pixel but for uniform error image it is divided by sqrt(npix).
752 * Thus one cannot compare the pixel values of the image with the error
753 * computed on the image.
754 */
755
756 res = hdrl_image_get_median(master);
757 cpl_test_abs( res.data, 1, HDRL_EPS_ERROR);
758 /* here error changes with respect to mean case by a
759 * factor sqrt(CPL_MATH_PI_2), see HDRL documentation, section on
760 * Statistical estimators
761 */
762 cpl_test_abs( res.error, expected_error * sqrt(CPL_MATH_PI_2),
763 HDRL_EPS_ERROR);
764
765 /* TODO: why not stdev does not return hdrl_value (with stdev of error) */
766 cpl_test_abs( hdrl_image_get_stdev(master), 0, HDRL_EPS_ERROR);
767
768 res = hdrl_image_get_sum(master);
769 cpl_test_abs( res.data, npix, HDRL_EPS_ERROR);
770 /* Error associated to not normalised image is: sqrt (npix*err^2).
771 * As the data are normalised error is sqrt (npix*err_norm^2)/ ndata
772 * error = sqrt(npix) / ndata
773 */
774 cpl_test_abs( res.error, sqrt(npix) / nima, npix * HDRL_EPS_ERROR);
775
776 cpl_test_abs( cpl_image_get_mean(contrib_map), nima, HDRL_EPS_ERROR );
777 hdrl_image_delete(master);
778 cpl_image_delete(contrib_map);
779
780
781 /* case 2:
782 * 9 images each of value 9,
783 * flat method=HDRL_FLAT_FREQ_HIGH,
784 * stat_mask=NULL,
785 * colapse_method: mean
786 *
787 * expected results:
788 * master should have value 1 (master is normalised),
789 * error 3,
790 * contribution map should be NULL.
791 */
792 flat_params = hdrl_flat_parameter_create(filter_size_x, filter_size_y,
793 HDRL_FLAT_FREQ_HIGH);
794
795 hdrl_flat_compute(imglist, NULL, collapse_params, flat_params, &master,
796 &contrib_map);
797 hdrl_parameter_delete(flat_params);
798
799 //hdrl_flat_save_results(master, contrib_map, NULL);
800
801 expected_error = error / value / sqrt(nima) / sqrt(ima_sx * ima_sy);
802 res = hdrl_image_get_mean(master);
803 cpl_test_abs( res.data, 1, HDRL_EPS_ERROR);
804 cpl_test_abs( res.error, expected_error, HDRL_EPS_ERROR);
805
806 res = hdrl_image_get_median(master);
807 cpl_test_abs( res.data, 1, HDRL_EPS_ERROR);
808 cpl_test_abs( res.error, expected_error * sqrt(CPL_MATH_PI_2),
809 HDRL_EPS_ERROR);
810
811 cpl_test_abs( hdrl_image_get_stdev(master), 0, HDRL_EPS_ERROR);
812
813 res = hdrl_image_get_sum(master);
814 cpl_test_abs( res.data, npix, HDRL_EPS_ERROR);
815 /* Error associated to not normalised image is: sqrt (npix*err^2).
816 * As the data are normalised error is sqrt (npix*err_norm^2)/ ndata
817 * error = sqrt(npix) / ndata
818 */
819 cpl_test_abs( res.error, sqrt(npix) / nima, npix * HDRL_EPS_ERROR);
820
821 cpl_test_abs( cpl_image_get_mean(contrib_map), nima, HDRL_EPS_ERROR);
822 hdrl_image_delete(master);
823 cpl_image_delete(contrib_map);
824
825 /* free memory */
826 hdrl_imagelist_delete(imglist);
827 hdrl_parameter_delete(collapse_params);
828
829 return cpl_error_get_code();
830}
831
832
833/*----------------------------------------------------------------------------*/
838/*----------------------------------------------------------------------------*/
839static cpl_error_code hdrl_flat_test_data_value_bpm(void)
840{
841 /* input data */
842 const cpl_size ima_sx = 51;
843 const cpl_size ima_sy = 31;
844
845 const cpl_size filter_size_x = 1;
846 const cpl_size filter_size_y = 1;
847
848 const cpl_size nima = 9;
849
850 /* image intensity values distributed as 2^n */
851 cpl_vector * vals = cpl_vector_new(nima);
852 double value = 9;
853 double error = sqrt(value);
854 cpl_vector_fill(vals, value);
855
856 hdrl_imagelist * imglist = hdrl_flat_create_uniform_images(nima, ima_sx,
857 ima_sy, vals);
858 cpl_vector_delete(vals);
859 const cpl_size r1_llx = 11;
860 const cpl_size r1_lly = 11;
861 const cpl_size r1_urx = 31;
862 const cpl_size r1_ury = 23;
863 cpl_size xsam=0;
864 cpl_size ysam=0;
865 const double outlier1 = 10000;
866
867 hdrl_parameter * rect1 =
868 hdrl_rect_region_parameter_create(r1_llx, r1_lly, r1_urx,
869 r1_ury);
870 hdrl_flat_imlist_flag_region(imglist, rect1, outlier1, 1);
872
873 hdrl_parameter * flat_params;
874 hdrl_image * master = NULL;
875 cpl_image * contrib_map = NULL;
876 hdrl_value res;
877 double expected_error;
878 double expected_value;
879 /* case 1:
880 * 9 images each of value 9,
881 * flat method=HDRL_FLAT_FREQ_LOW,
882 * stat_mask=NULL,
883 * colapse_method: mean
884 *
885 * expected results:
886 * master should have value 1 (master is normalised),
887 * error 3./9./math.sqrt(9) / math.sqrt(51*31)
888 * contribution map should be NULL.
889 */
890 flat_params = hdrl_flat_parameter_create(filter_size_x, filter_size_y,
891 HDRL_FLAT_FREQ_LOW);
892
893 hdrl_parameter * collapse_params = hdrl_collapse_mean_parameter_create();
894 hdrl_flat_compute(imglist, NULL, collapse_params, flat_params, &master,
895 &contrib_map);
896 hdrl_parameter_delete(flat_params);
897 //hdrl_flat_save_results(master, contrib_map, NULL);
898
899 xsam = 0.5 * (r1_llx+r1_urx);
900 ysam = 0.5 * (r1_lly+r1_ury);
901 int status;
902 expected_value = cpl_image_get(contrib_map, xsam, ysam, &status);
903 res = hdrl_image_get_pixel(master, xsam, ysam, NULL);
904
905 cpl_test( isnan(res.data));
906 cpl_test( isnan(res.error));
907 cpl_test_abs( expected_value, 0, HDRL_EPS_ERROR );
908
909 /* 3./9./math.sqrt(9) */
910
911 xsam = 0.5 * (ima_sx+r1_urx);
912 ysam = 0.5 * (ima_sy+r1_ury);
913 expected_error = error / value / sqrt(nima);
914 expected_value = cpl_image_get(contrib_map, xsam, ysam, &status);
915
916 res = hdrl_image_get_pixel(master, xsam, ysam, NULL);
917
918 cpl_test_abs(res.data, 1, HDRL_EPS_ERROR);
919 cpl_test_abs(res.error, expected_error, HDRL_EPS_ERROR);
920 cpl_test_abs( expected_value, nima, HDRL_EPS_ERROR );
921
922 hdrl_image_delete(master);
923 cpl_image_delete(contrib_map);
924
925 /* case 2:
926 * 9 images each of value 9,
927 * flat method=HDRL_FLAT_FREQ_HIGH,
928 * stat_mask=NULL,
929 * colapse_method: mean
930 *
931 * expected results:
932 * master should have value 1 (master is normalised),
933 * error 3,
934 * contribution map should be NULL.
935 */
936 flat_params = hdrl_flat_parameter_create(filter_size_x, filter_size_y,
937 HDRL_FLAT_FREQ_HIGH);
938
939 hdrl_flat_compute(imglist, NULL, collapse_params, flat_params, &master,
940 &contrib_map);
941 hdrl_parameter_delete(flat_params);
942 //hdrl_flat_save_results(master, contrib_map, NULL);
943
944 xsam = 0.5 * (r1_llx+r1_urx);
945 ysam = 0.5 * (r1_lly+r1_ury);
946
947 expected_value = cpl_image_get(contrib_map, xsam, ysam, &status);
948 res = hdrl_image_get_pixel(master, xsam, ysam, NULL);
949
950 cpl_test( isnan(res.data));
951 cpl_test( isnan(res.error));
952
953 cpl_test_abs( expected_value, 0, HDRL_EPS_ERROR );
954 /* 3./9./math.sqrt(9) */
955
956 xsam = 0.5 * (ima_sx+r1_urx);
957 ysam = 0.5 * (ima_sy+r1_ury);
958 expected_error = error / value / sqrt(nima);
959 expected_value = cpl_image_get(contrib_map, xsam, ysam, &status);
960
961 res = hdrl_image_get_pixel(master, xsam, ysam, NULL);
962
963 cpl_test_abs(res.data, 1, HDRL_EPS_ERROR);
964 cpl_test_abs(res.error, expected_error, HDRL_EPS_ERROR);
965 cpl_test_abs( expected_value, nima, HDRL_EPS_ERROR );
966
967
968 hdrl_image_delete(master);
969 cpl_image_delete(contrib_map);
970
971 /* free memory */
972 hdrl_imagelist_delete(imglist);
973 hdrl_parameter_delete(collapse_params);
974
975 return cpl_error_get_code();
976}
977
978/*----------------------------------------------------------------------------*/
983/*----------------------------------------------------------------------------*/
984static cpl_error_code hdrl_flat_test_data_value_bpm_static(void)
985{
986 /* input data */
987 const cpl_size ima_sx = 51;
988 const cpl_size ima_sy = 31;
989
990 const cpl_size filter_size_x = 1;
991 const cpl_size filter_size_y = 1;
992 const cpl_size nima = 9;
993
994 /* image intensity values distributed as 2^n */
995 cpl_vector * vals = cpl_vector_new(nima);
996 double value = 9;
997 double error = sqrt(value);
998 cpl_vector_fill(vals, value);
999
1000 hdrl_imagelist * imglist = hdrl_flat_create_uniform_images(nima, ima_sx,
1001 ima_sy, vals);
1002 cpl_vector_delete(vals);
1003 const cpl_size r1_llx = 11;
1004 const cpl_size r1_lly = 11;
1005 const cpl_size r1_urx = 31;
1006 const cpl_size r1_ury = 23;
1007 cpl_size xsam=0;
1008 cpl_size ysam=0;
1009 const double outlier1 = 10000;
1010
1011 hdrl_parameter * rect1 =
1012 hdrl_rect_region_parameter_create(r1_llx, r1_lly, r1_urx,
1013 r1_ury);
1014 hdrl_flat_imlist_flag_region(imglist, rect1, outlier1, 0);
1015 hdrl_parameter_delete(rect1);
1016
1017 hdrl_parameter * flat_params;
1018 hdrl_image * master = NULL;
1019 cpl_image * contrib_map = NULL;
1020 hdrl_value res;
1021 double expected_error;
1022 double expected_value;
1023 /* case 1:
1024 * 9 images each of value 9,
1025 * flat method=HDRL_FLAT_FREQ_LOW,
1026 * stat_mask=NULL,
1027 * colapse_method: mean
1028 *
1029 * expected results:
1030 * master has value 1 (master is normalised) where points are not masked,
1031 * and outlier/nima=111.11 where points are masked
1032 * error 3./9./math.sqrt(9) / math.sqrt(51*31)
1033 * contribution map should be NULL.
1034 */
1035 flat_params = hdrl_flat_parameter_create(filter_size_x, filter_size_y,
1036 HDRL_FLAT_FREQ_LOW);
1037
1038 hdrl_parameter * collapse_params = hdrl_collapse_mean_parameter_create();
1039
1040 /* creates and fill static mask */
1041 cpl_mask* static_bpm=cpl_mask_new(ima_sx,ima_sy);
1042 for(int j = r1_lly; j < r1_ury; j++) {
1043 for(int i = r1_llx; i < r1_urx; i++) {
1044 cpl_mask_set(static_bpm, i, j, CPL_BINARY_1);
1045 }
1046 }
1047
1048 hdrl_flat_compute(imglist, static_bpm, collapse_params, flat_params,
1049 &master, &contrib_map);
1050 hdrl_parameter_delete(flat_params);
1051 //hdrl_flat_save_results(master, contrib_map, NULL);
1052
1053 xsam = 0.5 * (r1_llx+r1_urx);
1054 ysam = 0.5 * (r1_lly+r1_ury);
1055 int status;
1056 expected_value = cpl_image_get(contrib_map, xsam, ysam, &status);
1057 res = hdrl_image_get_pixel(master, xsam, ysam, NULL);
1058 //expected_error = error / value / sqrt(nima);
1059 expected_error = sqrt(outlier1) / value / sqrt(nima);
1060
1061 cpl_test_abs( res.data, outlier1/nima, 13 * 21 * nima * HDRL_EPS_DATA);
1062 cpl_test_abs( res.error, expected_error, 3 * HDRL_EPS_ERROR);
1063 cpl_test_abs( expected_value, nima, HDRL_EPS_ERROR );
1064
1065
1066 /* 3./9./math.sqrt(9) */
1067
1068 xsam = 0.5 * (ima_sx+r1_urx);
1069 ysam = 0.5 * (ima_sy+r1_ury);
1070 expected_error = error / value / sqrt(nima);
1071 expected_value = cpl_image_get(contrib_map, xsam, ysam, &status);
1072
1073 res = hdrl_image_get_pixel(master, xsam, ysam, NULL);
1074
1075 cpl_test_abs(res.data, 1, HDRL_EPS_ERROR);
1076 cpl_test_abs(res.error, expected_error, HDRL_EPS_ERROR);
1077 cpl_test_abs( expected_value, nima, HDRL_EPS_ERROR );
1078
1079 hdrl_image_delete(master);
1080 cpl_image_delete(contrib_map);
1081
1082 /* case 2:
1083 * 9 images each of value 9,
1084 * flat method=HDRL_FLAT_FREQ_HIGH,
1085 * stat_mask=NULL,
1086 * colapse_method: mean
1087 *
1088 * expected results:
1089 * master should have value 1 (master is normalised),
1090 * error 3,
1091 * contribution map should be NULL.
1092 */
1093 flat_params = hdrl_flat_parameter_create(filter_size_x, filter_size_y,
1094 HDRL_FLAT_FREQ_HIGH);
1095
1096 hdrl_flat_compute(imglist, static_bpm, collapse_params, flat_params,
1097 &master, &contrib_map);
1098 hdrl_parameter_delete(flat_params);
1099 //hdrl_flat_save_results(master, contrib_map, NULL);
1100
1101 xsam = 0.5 * (r1_llx+r1_urx);
1102 ysam = 0.5 * (r1_lly+r1_ury);
1103
1104 expected_value = cpl_image_get(contrib_map, xsam, ysam, &status);
1105 res = hdrl_image_get_pixel(master, xsam, ysam, NULL);
1106
1107 expected_error = sqrt(outlier1) / outlier1 / sqrt(nima);
1108
1109 cpl_test_abs( res.data, 1, HDRL_EPS_ERROR);
1110 cpl_test_abs( res.error, expected_error, 3 * HDRL_EPS_ERROR);
1111 cpl_test_abs( expected_value, nima, HDRL_EPS_ERROR );
1112
1113
1114
1115 /* 3./9./math.sqrt(9) */
1116
1117 xsam = 0.5 * (ima_sx+r1_urx);
1118 ysam = 0.5 * (ima_sy+r1_ury);
1119 expected_error = error / value / sqrt(nima);
1120 expected_value = cpl_image_get(contrib_map, xsam, ysam, &status);
1121
1122 res = hdrl_image_get_pixel(master, xsam, ysam, NULL);
1123
1124 cpl_test_abs(res.data, 1, HDRL_EPS_ERROR);
1125 cpl_test_abs(res.error, expected_error, HDRL_EPS_ERROR);
1126 cpl_test_abs( expected_value, nima, HDRL_EPS_ERROR );
1127
1128 hdrl_image_delete(master);
1129 cpl_image_delete(contrib_map);
1130
1131 /* free memory */
1132 hdrl_imagelist_delete(imglist);
1133 cpl_mask_delete(static_bpm);
1134 hdrl_parameter_delete(collapse_params);
1135
1136 return cpl_error_get_code();
1137}
1138
1139/*----------------------------------------------------------------------------*/
1143/*----------------------------------------------------------------------------*/
1144int main(void)
1145{
1146 cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
1147
1148 hdrl_flat_test_data_value_bpm();
1149 hdrl_flat_test_data_value_bpm_static();
1150 hdrl_flat_test_data_value_basic();
1151 hdrl_flat_test_multi_options();
1152 hdrl_flat_test_static_mask();
1153 hdrl_flat_test_parlist();
1154
1155 cpl_test_error(CPL_ERROR_NONE);
1156 return cpl_test_end(0);
1157}
hdrl_parameter * hdrl_collapse_mean_parameter_create(void)
create a parameter object for mean
hdrl_parameter * hdrl_collapse_median_parameter_create(void)
create a parameter object for median
cpl_size hdrl_flat_parameter_get_filter_size_x(const hdrl_parameter *p)
Access the filter_size_x in the FLAT parameter.
Definition: hdrl_flat.c:209
hdrl_parameter * hdrl_flat_parameter_create(cpl_size filter_size_x, cpl_size filter_size_y, hdrl_flat_method method)
Creates FLAT Parameters object.
Definition: hdrl_flat.c:173
cpl_size hdrl_flat_parameter_get_filter_size_y(const hdrl_parameter *p)
Access the filter_size_y in the FLAT parameter.
Definition: hdrl_flat.c:223
cpl_error_code hdrl_flat_compute(hdrl_imagelist *hdrl_data, const cpl_mask *stat_mask, const hdrl_parameter *collapse_params, hdrl_parameter *flat_params, hdrl_image **master, cpl_image **contrib_map)
compute high or low frequency master flat with median filtering
Definition: hdrl_flat.c:405
hdrl_flat_method hdrl_flat_parameter_get_method(const hdrl_parameter *p)
Access the method in the FLAT parameter.
Definition: hdrl_flat.c:237
hdrl_parameter * hdrl_flat_parameter_parse_parlist(const cpl_parameterlist *parlist, const char *prefix)
Parse a parameterlist to create input parameters for the FLAT.
Definition: hdrl_flat.c:331
cpl_parameterlist * hdrl_flat_parameter_create_parlist(const char *base_context, const char *prefix, const hdrl_parameter *defaults)
Create a parameter list for the FLAT computation.
Definition: hdrl_flat.c:258
cpl_boolean hdrl_flat_parameter_check(const hdrl_parameter *self)
Check that the parameter is a FLAT parameter.
Definition: hdrl_flat.c:197
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
Definition: hdrl_image.c:559
hdrl_value hdrl_image_get_median(const hdrl_image *self)
computes the median and associated error of an image.
double hdrl_image_get_stdev(const hdrl_image *self)
computes the standard deviation of the data of an image
hdrl_value hdrl_image_get_sum(const hdrl_image *self)
computes the sum of all pixel values and the associated error of an image.
cpl_image * hdrl_image_get_error(hdrl_image *himg)
get error as cpl image
Definition: hdrl_image.c:131
hdrl_value hdrl_image_get_mean(const hdrl_image *self)
computes mean pixel value and associated error of an image.
cpl_size hdrl_image_get_size_y(const hdrl_image *self)
return size of Y dimension of image
Definition: hdrl_image.c:540
cpl_size hdrl_image_get_size_x(const hdrl_image *self)
return size of X dimension of image
Definition: hdrl_image.c:525
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
Definition: hdrl_image.c:295
cpl_image * hdrl_image_get_image(hdrl_image *himg)
get data as cpl image
Definition: hdrl_image.c:105
void hdrl_image_delete(hdrl_image *himg)
delete hdrl_image
Definition: hdrl_image.c:379
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.
cpl_size hdrl_imagelist_get_size(const hdrl_imagelist *himlist)
Get the number of images in the imagelist.
hdrl_imagelist * hdrl_imagelist_new(void)
Create an empty imagelist.
hdrl_image * hdrl_imagelist_get(const hdrl_imagelist *himlist, cpl_size inum)
Get an image from a list of images.
void hdrl_parameter_delete(hdrl_parameter *obj)
shallow delete of a parameter
hdrl_parameter * hdrl_rect_region_parameter_create(cpl_size llx, cpl_size lly, cpl_size urx, cpl_size ury)
Creates Rect Region Parameters object.
Definition: hdrl_utils.c:459
cpl_size hdrl_rect_region_get_llx(const hdrl_parameter *p)
get lower left x coordinate of rectangual region
Definition: hdrl_utils.c:518
cpl_size hdrl_rect_region_get_urx(const hdrl_parameter *p)
get upper right x coordinate of rectangular region
Definition: hdrl_utils.c:536
cpl_size hdrl_rect_region_get_lly(const hdrl_parameter *p)
get lower left y coordinate of rectangual region
Definition: hdrl_utils.c:527
cpl_size hdrl_rect_region_get_ury(const hdrl_parameter *p)
get upper right y coordinate of rectangual region
Definition: hdrl_utils.c:545