28#include "hdrl_imagelist.h"
29#include "hdrl_utils.h"
30#include "hdrl_image.h"
51 cpl_imagelist * data = cpl_imagelist_new();
52 cpl_imagelist * errs = cpl_imagelist_new();
53 cpl_image * img = cpl_image_new(64, 64, CPL_TYPE_DOUBLE);
54 cpl_image * err = cpl_image_new(64, 64, CPL_TYPE_DOUBLE);
55 cpl_image_add_scalar(img, 1. );
56 cpl_image_add_scalar(err, 0.05);
60 for (
size_t i = 0; i < n; i++) {
61 cpl_imagelist_set(data, cpl_image_duplicate(img), cpl_imagelist_get_size(data));
62 cpl_imagelist_set(errs, cpl_image_duplicate(err), cpl_imagelist_get_size(errs));
68 cpl_test_error(CPL_ERROR_NONE);
71 cpl_image_delete(img);
72 cpl_image_delete(err);
73 cpl_imagelist_delete(data);
74 cpl_imagelist_delete(errs);
80 hdrl_imagelist * hl = NULL;
82 cpl_test_error(CPL_ERROR_NULL_INPUT);
84 cpl_test_error(CPL_ERROR_NULL_INPUT);
86 cpl_test_error(CPL_ERROR_NULL_INPUT);
90 cpl_test_error(CPL_ERROR_NONE);
92 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
94 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
98 cpl_test_error(CPL_ERROR_NONE);
100 cpl_test_error(CPL_ERROR_NONE);
102 cpl_test_error(CPL_ERROR_NONE);
107cpl_error_code test_interface(
void)
112 hdrl_iter * it = hdrl_imagelist_get_iter_row_slices(hl, 1, 0,
113 HDRL_ITER_OWNS_DATA);
114 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
117 it = hdrl_imagelist_get_iter_row_slices(NULL, 1, 0, HDRL_ITER_OWNS_DATA);
118 cpl_test_error(CPL_ERROR_NULL_INPUT);
122 it = hdrl_imagelist_get_iter_row_slices(hl, 0, 0, HDRL_ITER_OWNS_DATA);
123 cpl_test_error(CPL_ERROR_NONE);
124 cpl_test_nonnull(it);
125 for (h = hdrl_iter_next(it); h != NULL; h = hdrl_iter_next(it)) {
129 hdrl_iter_delete(it);
132 it = hdrl_imagelist_get_iter_row_slices(hl, 3, 0, 0);
133 cpl_test_error(CPL_ERROR_NONE);
134 cpl_test_nonnull(it);
136 for (h = hdrl_iter_next(it); h != NULL; h = hdrl_iter_next(it)) {
141 hdrl_iter_delete(it);
144 it = hdrl_imagelist_get_iter_row_slices(hl, 3000, 0, HDRL_ITER_OWNS_DATA);
145 cpl_test_error(CPL_ERROR_NONE);
146 cpl_test_nonnull(it);
148 for (h = hdrl_iter_next(it); h != NULL; h = hdrl_iter_next(it)) {
152 hdrl_iter_delete(it);
156 return cpl_error_get_code();
160cpl_error_code test_iter(
void)
162 const cpl_size nx = 500;
163 const cpl_size ny = 571;
164 const cpl_size nz = 121;
165 const cpl_size yslice = 23;
167 for (cpl_size i = 0; i < nz; i++) {
177 for (cpl_size y = 1; y < ny + 1; y++) {
179 hdrl_imagelist * lview = hdrl_imagelist_row_view(hl, y, y);
185 cpl_msg_debug(cpl_func,
"Imagelist consistent? %d", isConsistent);
207 cpl_image * slicecontrib = cpl_image_new(nx, ny, CPL_TYPE_INT);
209 hdrl_iter * it = hdrl_imagelist_get_iter_row_slices(hl, yslice, 0,
210 HDRL_ITER_OWNS_DATA);
211 for (hdrl_imagelist * h = hdrl_iter_next(it); h != NULL;
212 h = hdrl_iter_next(it)) {
221 cpl_image_copy(slicecontrib, c, 1, ysum);
227 cpl_test_eq(ysum - 1, ny);
228 hdrl_test_image_abs(slicemean, mean, nx * ny * DBL_EPSILON);
229 cpl_test_image_abs(slicecontrib, contrib, 0);
230 hdrl_iter_delete(it);
234 cpl_size overlap = 5;
235 cpl_image_multiply_scalar(slicecontrib, 0);
237 it = hdrl_imagelist_get_iter_row_slices(hl, yslice, overlap,
238 HDRL_ITER_OWNS_DATA);
239 for (hdrl_imagelist * h = hdrl_iter_next(it); h != NULL;
240 h = hdrl_iter_next(it)) {
254 hdrl_il_rowsliceiter_data pdata =
255 hdrl_imagelist_iter_row_slices_get_data(it);
258 cpl_image * rc = cpl_image_extract(c, 1, pdata.ly, nx, pdata.uy);
262 cpl_image_copy(slicecontrib, rc, 1, ysum);
265 cpl_image_delete(rc);
269 cpl_test_eq(ysum - 1, ny);
270 hdrl_test_image_abs(slicemean, mean, nx * ny * DBL_EPSILON);
271 cpl_test_image_abs(slicecontrib, contrib, 0);
273 hdrl_iter_delete(it);
276 cpl_image_delete(slicecontrib);
278 cpl_image_delete(contrib);
280 return cpl_error_get_code();
290 cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
297 return cpl_test_end(0);
cpl_error_code hdrl_image_mul_scalar(hdrl_image *self, hdrl_value value)
Elementwise multiplication of an image with a scalar.
cpl_error_code hdrl_image_copy(hdrl_image *dst, const hdrl_image *src, cpl_size xpos, cpl_size ypos)
Copy one image into another.
hdrl_image * hdrl_image_extract(const hdrl_image *self, cpl_size llx, cpl_size lly, cpl_size urx, cpl_size ury)
extract copy of window from image
cpl_error_code hdrl_image_add_scalar(hdrl_image *self, hdrl_value value)
Elementwise addition of a scalar to an image.
cpl_size hdrl_image_get_size_y(const hdrl_image *self)
return size of Y dimension of image
cpl_size hdrl_image_get_size_x(const hdrl_image *self)
return size of X dimension of image
cpl_error_code hdrl_image_reject(hdrl_image *self, cpl_size xpos, cpl_size ypos)
mark pixel as bad
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
cpl_error_code hdrl_imagelist_add_scalar(hdrl_imagelist *himlist, hdrl_value value)
Elementwise addition of a scalar to each image in the himlist.
cpl_error_code hdrl_imagelist_collapse_mean(const hdrl_imagelist *himlist, hdrl_image **out, cpl_image **contrib)
Mean collapsing of image list.
cpl_error_code hdrl_imagelist_set(hdrl_imagelist *himlist, hdrl_image *himg, cpl_size pos)
Insert an image into an imagelist.
cpl_size hdrl_imagelist_get_size_y(const hdrl_imagelist *himlist)
Get number of rows of images in the imagelist.
hdrl_imagelist * hdrl_imagelist_create(cpl_imagelist *imlist, cpl_imagelist *errlist)
Create an hdrl_imagelist out of 2 cpl_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.
int hdrl_imagelist_is_consistent(const hdrl_imagelist *himlist)
Determine if an imagelist contains images of equal size and type.
cpl_error_code hdrl_imagelist_dump_window(const hdrl_imagelist *himlist, cpl_size llx, cpl_size lly, cpl_size urx, cpl_size ury, FILE *stream)
Dump pixel values of images in a imagelist.
cpl_error_code hdrl_imagelist_sub_scalar(hdrl_imagelist *himlist, hdrl_value value)
Elementwise subtraction of a scalar to each image in the himlist.
hdrl_imagelist * hdrl_imagelist_new(void)
Create an empty imagelist.
cpl_size hdrl_imagelist_get_size_x(const hdrl_imagelist *himlist)
Get number of colums of images in the imagelist.
cpl_error_code hdrl_imagelist_dump_structure(const hdrl_imagelist *himlist, FILE *stream)
Dump structural information of images in an imagelist.
hdrl_image * hdrl_imagelist_get(const hdrl_imagelist *himlist, cpl_size inum)
Get an image from a list of images.