28#include "hdrl_imagelist.h"
29#include "hdrl_utils.h"
30#include "hdrl_image.h"
50 cpl_imagelist * data = cpl_imagelist_new();
51 cpl_imagelist * errs = cpl_imagelist_new();
52 cpl_image * img = cpl_image_new(64, 64, CPL_TYPE_DOUBLE);
53 cpl_image * err = cpl_image_new(64, 64, CPL_TYPE_DOUBLE);
54 cpl_image_add_scalar(img, 1. );
55 cpl_image_add_scalar(err, 0.05);
59 for (
size_t i = 0; i < n; i++) {
60 cpl_imagelist_set(data, cpl_image_duplicate(img), cpl_imagelist_get_size(data));
61 cpl_imagelist_set(errs, cpl_image_duplicate(err), cpl_imagelist_get_size(errs));
67 cpl_test_error(CPL_ERROR_NONE);
70 cpl_image_delete(img);
71 cpl_image_delete(err);
72 cpl_imagelist_delete(data);
73 cpl_imagelist_delete(errs);
79 hdrl_imagelist * hl = NULL;
81 cpl_test_error(CPL_ERROR_NULL_INPUT);
83 cpl_test_error(CPL_ERROR_NULL_INPUT);
85 cpl_test_error(CPL_ERROR_NULL_INPUT);
89 cpl_test_error(CPL_ERROR_NONE);
91 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
93 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
97 cpl_test_error(CPL_ERROR_NONE);
99 cpl_test_error(CPL_ERROR_NONE);
101 cpl_test_error(CPL_ERROR_NONE);
106cpl_error_code test_interface(
void)
111 hdrl_iter * it = hdrl_imagelist_get_iter_row_slices(hl, 1, 0,
112 HDRL_ITER_OWNS_DATA);
113 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
116 it = hdrl_imagelist_get_iter_row_slices(NULL, 1, 0, HDRL_ITER_OWNS_DATA);
117 cpl_test_error(CPL_ERROR_NULL_INPUT);
121 it = hdrl_imagelist_get_iter_row_slices(hl, 0, 0, HDRL_ITER_OWNS_DATA);
122 cpl_test_error(CPL_ERROR_NONE);
123 cpl_test_nonnull(it);
124 for (h = hdrl_iter_next(it); h != NULL; h = hdrl_iter_next(it)) {
128 hdrl_iter_delete(it);
131 it = hdrl_imagelist_get_iter_row_slices(hl, 3, 0, 0);
132 cpl_test_error(CPL_ERROR_NONE);
133 cpl_test_nonnull(it);
135 for (h = hdrl_iter_next(it); h != NULL; h = hdrl_iter_next(it)) {
140 hdrl_iter_delete(it);
143 it = hdrl_imagelist_get_iter_row_slices(hl, 3000, 0, HDRL_ITER_OWNS_DATA);
144 cpl_test_error(CPL_ERROR_NONE);
145 cpl_test_nonnull(it);
147 for (h = hdrl_iter_next(it); h != NULL; h = hdrl_iter_next(it)) {
151 hdrl_iter_delete(it);
155 return cpl_error_get_code();
159cpl_error_code test_iter(
void)
161 const cpl_size nx = 500;
162 const cpl_size ny = 571;
163 const cpl_size nz = 121;
164 const cpl_size yslice = 23;
166 for (cpl_size i = 0; i < nz; i++) {
176 for (cpl_size y = 1; y < ny + 1; y++) {
178 hdrl_imagelist * lview = hdrl_imagelist_row_view(hl, y, y);
184 cpl_msg_debug(cpl_func,
"Imagelist consistent? %d", isConsistent);
206 cpl_image * slicecontrib = cpl_image_new(nx, ny, CPL_TYPE_INT);
208 hdrl_iter * it = hdrl_imagelist_get_iter_row_slices(hl, yslice, 0,
209 HDRL_ITER_OWNS_DATA);
210 for (hdrl_imagelist * h = hdrl_iter_next(it); h != NULL;
211 h = hdrl_iter_next(it)) {
220 cpl_image_copy(slicecontrib, c, 1, ysum);
226 cpl_test_eq(ysum - 1, ny);
227 hdrl_test_image_abs(slicemean, mean, nx * ny * DBL_EPSILON);
228 cpl_test_image_abs(slicecontrib, contrib, 0);
229 hdrl_iter_delete(it);
233 cpl_size overlap = 5;
234 cpl_image_multiply_scalar(slicecontrib, 0);
236 it = hdrl_imagelist_get_iter_row_slices(hl, yslice, overlap,
237 HDRL_ITER_OWNS_DATA);
238 for (hdrl_imagelist * h = hdrl_iter_next(it); h != NULL;
239 h = hdrl_iter_next(it)) {
253 hdrl_il_rowsliceiter_data pdata =
254 hdrl_imagelist_iter_row_slices_get_data(it);
257 cpl_image * rc = cpl_image_extract(c, 1, pdata.ly, nx, pdata.uy);
261 cpl_image_copy(slicecontrib, rc, 1, ysum);
264 cpl_image_delete(rc);
268 cpl_test_eq(ysum - 1, ny);
269 hdrl_test_image_abs(slicemean, mean, nx * ny * DBL_EPSILON);
270 cpl_test_image_abs(slicecontrib, contrib, 0);
272 hdrl_iter_delete(it);
275 cpl_image_delete(slicecontrib);
277 cpl_image_delete(contrib);
279 return cpl_error_get_code();
289 cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
296 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.