46static cpl_error_code hdrl_catalogue_test_compute(
void)
48 cpl_image * img, * cnf, * flat_img, * peak_img;
51 hdrl_catalogue_result * r;
52 cpl_size nx = 1001, ny = 753;
54 img = cpl_image_new(nx, ny, CPL_TYPE_DOUBLE);
55 cnf = cpl_image_new(nx, ny, CPL_TYPE_INT);
58 flat_img = cpl_image_new(nx, ny, CPL_TYPE_DOUBLE);
59 cpl_test_nonnull(flat_img);
60 cpl_image_add_scalar(flat_img, 1.0);
61 cpl_test_error(CPL_ERROR_NONE);
65 peak_img = cpl_image_new(nx, ny, CPL_TYPE_DOUBLE);
66 cpl_test_nonnull(peak_img);
67 cpl_image_fill_gaussian(peak_img, 100, 100, 1000.0, 1.0, 1.0);
68 cpl_test_error(CPL_ERROR_NONE);
69 cpl_image_add_scalar(peak_img, 1.0);
70 cpl_test_error(CPL_ERROR_NONE);
72 cpl_propertylist * pl = cpl_propertylist_new();
73 cpl_propertylist_update_string(pl,
"CTYPE1",
"RA---TAN");
74 cpl_propertylist_update_string(pl,
"CTYPE2",
"DEC--TAN");
75 cpl_propertylist_update_double(pl,
"CRVAL1", 30.0);
76 cpl_propertylist_update_double(pl,
"CRVAL2", 12.0);
77 cpl_propertylist_update_double(pl,
"CRPIX1", 512.0);
78 cpl_propertylist_update_double(pl,
"CRPIX2", 512.0);
79 cpl_propertylist_update_double(pl,
"CD1_1", -1.0 / 3600);
80 cpl_propertylist_update_double(pl,
"CD1_2", 0.0);
81 cpl_propertylist_update_double(pl,
"CD2_1", 0.0);
82 cpl_propertylist_update_double(pl,
"CD2_2", 1.0 / 3600);
83 cpl_propertylist_update_int(pl,
"NAXIS1", nx);
84 cpl_propertylist_update_int(pl,
"NAXIS2", ny);
85 wcs = cpl_wcs_new_from_propertylist(pl);
86 cpl_propertylist_delete(pl);
89 2., 2.0, HDRL_SATURATION_INIT,
93 for (
size_t i = 0; i < 2; i++) {
94 for (
size_t j = 0; j < 2; j++) {
95 for (
size_t k = 0; k < 2; k++) {
96 for (
size_t l = 0; l < 2; l++) {
105 cpl_test_error(CPL_ERROR_NULL_INPUT);
121 3., 1.0, HDRL_SATURATION_INIT,
123 cpl_image *bkg = cpl_image_new(nx, ny, CPL_TYPE_DOUBLE);
124 double sigma = 2., sky = 500.;
125 double norm2 = 2.0 * CPL_MATH_PI * sigma * sigma;
126 cpl_image_add_scalar(cnf, 100.);
127 double xpos[] = {100.0,200.0,300.0,400.0,500.0,600.0,700.0,800.0,900.0,
129 double ypos[] = {100.0,200.0,300.0,400.0,550.0,600.0,650.0,700.0,230.0,
131 double norm[] = {1000.0,100.0,200.0,500.0,550.0,600.0,650.0,700.0,
133 size_t nobj =
sizeof(xpos) /
sizeof(xpos[0]);
134 for (
size_t i = 0; i < nobj; i++) {
135 cpl_image_fill_gaussian(bkg, xpos[i], ypos[i], norm[i] * norm2, sigma,
137 cpl_image_add(img, bkg);
139 cpl_image_fill_noise_uniform(bkg, -10.0, 10.0);
140 cpl_image_add_scalar(bkg, sky);
141 cpl_image_add(img, bkg);
142 cpl_image_delete(bkg);
146 cpl_test_error(CPL_ERROR_NONE);
147 cpl_test_nonnull(r->catalogue);
148 cpl_test_eq(cpl_table_get_nrow(r->catalogue), nobj);
149 cpl_test_nonnull(r->segmentation_map);
150 cpl_test_eq(cpl_image_get_max(r->segmentation_map), nobj);
151 cpl_test_eq(cpl_image_get_min(r->segmentation_map), 0);
152 cpl_test_nonnull(r->background);
153 cpl_test_abs(cpl_image_get_mean(r->background), sky, 5);
154 cpl_test_nonnull(r->qclist);
159 hdrl_parameter * bpar =
161 3., 1.0, HDRL_SATURATION_INIT,
163 cpl_image * imgcor = cpl_image_subtract_scalar_create(img, sky);
166 cpl_test_error(CPL_ERROR_NONE);
167 cpl_test_nonnull(r->catalogue);
168 cpl_test_eq(cpl_table_get_nrow(r->catalogue), nobj);
169 cpl_test_nonnull(r->segmentation_map);
170 cpl_test_eq(cpl_image_get_max(r->segmentation_map), nobj);
171 cpl_test_eq(cpl_image_get_min(r->segmentation_map), 0);
172 cpl_test_null(r->background);
173 cpl_test_nonnull(r->qclist);
174 cpl_image_delete(imgcor);
181 HDRL_SATURATION_INIT,
190 cpl_test_error(CPL_ERROR_NULL_INPUT);
193 cpl_test_error(CPL_ERROR_NONE);
196 cpl_test_error(CPL_ERROR_NONE);
200 cpl_parameterlist *plCat;
203 cpl_test_error(CPL_ERROR_NULL_INPUT);
204 cpl_test_null(plCat);
207 cpl_test_error(CPL_ERROR_NULL_INPUT);
208 cpl_test_null(plCat);
211 cpl_test_error(CPL_ERROR_NULL_INPUT);
212 cpl_test_null(plCat);
215 cpl_test_error(CPL_ERROR_NONE);
216 cpl_test_nonnull(plCat);
220 hdrl_parameter *check;
223 cpl_test_error(CPL_ERROR_NULL_INPUT);
224 cpl_test_null(check);
227 cpl_test_error(CPL_ERROR_NULL_INPUT);
228 cpl_test_null(check);
231 cpl_test_error(CPL_ERROR_NONE);
232 cpl_test_nonnull(check);
235 cpl_parameterlist_delete(plCat);
243 cpl_test_error(CPL_ERROR_NONE);
248 cpl_image_subtract_scalar(cnf, 200);
251 cpl_test_error(CPL_ERROR_INCOMPATIBLE_INPUT);
252 cpl_image_add_scalar(cnf, 200);
255 cpl_image * dcnf = cpl_image_cast(cnf, CPL_TYPE_DOUBLE);
258 cpl_test_nonnull(r->catalogue);
259 cpl_test_nonnull(r->segmentation_map);
260 cpl_test_nonnull(r->background);
261 cpl_test_error(CPL_ERROR_NONE);
265 cpl_image_reject(img, 60, 23);
268 cpl_test_error(CPL_ERROR_NONE);
274 cpl_test_nonnull(r->catalogue);
275 cpl_test_nonnull(r->segmentation_map);
276 cpl_test_nonnull(r->background);
277 cpl_test_error(CPL_ERROR_NONE);
283 cpl_test_nonnull(r->catalogue);
284 cpl_test_nonnull(r->segmentation_map);
285 cpl_test_nonnull(r->background);
286 cpl_test_error(CPL_ERROR_NONE);
288 cpl_image_delete(dcnf);
291 cpl_image_accept_all(img);
294 cpl_test_error(CPL_ERROR_NONE);
298 cpl_image_accept_all(img);
301 cpl_test_nonnull(r->catalogue);
302 cpl_test_nonnull(r->segmentation_map);
303 cpl_test_nonnull(r->background);
304 cpl_test_error(CPL_ERROR_NONE);
308 cpl_image * dimg = cpl_image_cast(img, CPL_TYPE_DOUBLE);
309 cpl_image_accept_all(img);
312 cpl_test_nonnull(r->catalogue);
313 cpl_test_nonnull(r->segmentation_map);
314 cpl_test_nonnull(r->background);
315 cpl_test_error(CPL_ERROR_NONE);
316 cpl_image_delete(dimg);
322 3., 1.0, HDRL_SATURATION_INIT,
323 HDRL_CATALOGUE_CAT_COMPLETE);
326 cpl_test_nonnull(r->catalogue);
327 cpl_test_null(r->segmentation_map);
328 cpl_test_null(r->background);
329 cpl_test_error(CPL_ERROR_NONE);
335 3., 1.0, HDRL_SATURATION_INIT,
336 HDRL_CATALOGUE_CAT_COMPLETE |
340 cpl_test_nonnull(r->catalogue);
341 cpl_test_null(r->segmentation_map);
342 cpl_test_nonnull(r->background);
343 cpl_test_error(CPL_ERROR_NONE);
349 3., 1.0, HDRL_SATURATION_INIT,
350 HDRL_CATALOGUE_CAT_COMPLETE |
351 HDRL_CATALOGUE_SEGMAP);
354 cpl_test_error(CPL_ERROR_NONE);
355 cpl_test_nonnull(r->catalogue);
356 cpl_test_nonnull(r->segmentation_map);
357 cpl_test_null(r->background);
363 3., 1.0, HDRL_SATURATION_INIT,
364 HDRL_CATALOGUE_SEGMAP |
368 cpl_test_nonnull(r->catalogue);
369 cpl_test_eq(cpl_table_get_nrow(r->catalogue), 0);
370 cpl_test_nonnull(r->segmentation_map);
371 cpl_test_nonnull(r->background);
372 cpl_test_error(CPL_ERROR_NONE);
378 3., 1.0, HDRL_SATURATION_INIT,
379 HDRL_CATALOGUE_CAT_COMPLETE |
380 HDRL_CATALOGUE_SEGMAP |
382 cpl_test_nonnull(par);
384 cpl_test_error(CPL_ERROR_DATA_NOT_FOUND);
391 3., 1.0, HDRL_SATURATION_INIT,
392 HDRL_CATALOGUE_CAT_COMPLETE |
393 HDRL_CATALOGUE_SEGMAP |
395 cpl_test_nonnull(par);
398 cpl_test_error(CPL_ERROR_NONE);
399 cpl_test_nonnull(r->catalogue);
400 cpl_test_nonnull(r->segmentation_map);
401 cpl_test_nonnull(r->background);
404 cpl_image_delete(flat_img);
405 cpl_image_delete(peak_img);
406 cpl_image_delete(img);
407 cpl_image_delete(cnf);
410 return cpl_error_get_code();
421 cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
423 hdrl_catalogue_test_compute();
424 cpl_test_error(CPL_ERROR_NONE);
427 return cpl_test_end(0);
hdrl_catalogue_result * hdrl_catalogue_compute(const cpl_image *image_, const cpl_image *confidence_map, const cpl_wcs *wcs, hdrl_parameter *param_)
build object catalog
void hdrl_catalogue_result_delete(hdrl_catalogue_result *result)
delete hdrl parameter result object
hdrl_parameter * hdrl_catalogue_parameter_create(int obj_min_pixels, double obj_threshold, cpl_boolean obj_deblending, double obj_core_radius, cpl_boolean bkg_estimate, int bkg_mesh_size, double bkg_smooth_fwhm, double det_eff_gain, double det_saturation, hdrl_catalogue_options resulttype)
Creates catalogue Parameters object.
cpl_boolean hdrl_catalogue_parameter_check(const hdrl_parameter *self)
Check that the parameter is a catalogue parameter.
hdrl_parameter * hdrl_catalogue_parameter_parse_parlist(const cpl_parameterlist *parlist, const char *prefix)
Parse parameter list to create input parameters for the catalogue.
cpl_parameterlist * hdrl_catalogue_parameter_create_parlist(const char *base_context, const char *prefix, hdrl_parameter *defaults)
Create parameter list for the catalogue computation.
cpl_error_code hdrl_catalogue_parameter_set_option(hdrl_parameter *par, hdrl_catalogue_options opt)
set result option of catalogue parameter
void hdrl_parameter_destroy(hdrl_parameter *obj)
deep delete of a parameter
void hdrl_parameter_delete(hdrl_parameter *obj)
shallow delete of a parameter