28#include "hdrl_elemop.h"
29#include "hdrl_image.h"
30#include "hdrl_collapse.h"
61 cpl_ensure_code(self, CPL_ERROR_NULL_INPUT);
62 cpl_ensure_code(other, CPL_ERROR_NULL_INPUT);
119 cpl_ensure_code(self, CPL_ERROR_NULL_INPUT);
123 value.data, value.error);
139 cpl_ensure_code(self, CPL_ERROR_NULL_INPUT);
140 cpl_ensure_code(other, CPL_ERROR_NULL_INPUT);
183 cpl_ensure_code(self, CPL_ERROR_NULL_INPUT);
187 value.data, value.error);
203 cpl_ensure_code(self, CPL_ERROR_NULL_INPUT);
204 cpl_ensure_code(other, CPL_ERROR_NULL_INPUT);
247 cpl_ensure_code(self, CPL_ERROR_NULL_INPUT);
251 value.data, value.error);
275 cpl_ensure_code(self, CPL_ERROR_NULL_INPUT);
276 cpl_ensure_code(other, CPL_ERROR_NULL_INPUT);
331 cpl_ensure_code(self, CPL_ERROR_NULL_INPUT);
335 value.data, value.error);
345hdrl_image_collapse(hdrl_collapse_imagelist_to_vector_t * red,
346 const hdrl_image * self,
347 hdrl_data_t * result, hdrl_error_t * error,
348 int * contrib,
void * eout)
350 cpl_imagelist * ld = cpl_imagelist_new();
351 cpl_imagelist * le = cpl_imagelist_new();
352 cpl_vector * od = NULL, * oe = NULL;
353 cpl_array * oc = NULL;
356 CPL_DIAG_PRAGMA_PUSH_IGN(-Wcast-qual);
361 fail = hdrl_collapse_imagelist_to_vector_call(red, ld, le, &od, &oe, &oc,
363 cpl_imagelist_unwrap(ld);
364 cpl_imagelist_unwrap(le);
366 if (fail == CPL_ERROR_NONE) {
368 *result = cpl_vector_get(od, 0);
371 *error = cpl_vector_get(oe, 0);
374 *contrib = cpl_array_get_int(oc, 0, NULL);
386 cpl_vector_delete(od);
387 cpl_vector_delete(oe);
388 cpl_array_delete(oc);
404 hdrl_collapse_imagelist_to_vector_t * red =
405 hdrl_collapse_imagelist_to_vector_mean();
407 hdrl_image_collapse(red, self, &res.data, &res.error, NULL, NULL);
408 hdrl_collapse_imagelist_to_vector_delete(red);
426 double kappa_high,
int niter)
428 hdrl_collapse_imagelist_to_vector_t * red =
429 hdrl_collapse_imagelist_to_vector_sigclip(kappa_low, kappa_high, niter);
431 hdrl_image_collapse(red, self, &res.data, &res.error, NULL, NULL);
432 hdrl_collapse_imagelist_to_vector_delete(red);
451 hdrl_collapse_imagelist_to_vector_t * red =
452 hdrl_collapse_imagelist_to_vector_minmax(nlow, nhigh);
454 hdrl_image_collapse(red, self, &res.data, &res.error, NULL, NULL);
455 hdrl_collapse_imagelist_to_vector_delete(red);
475 double histo_max,
double bin_size,
476 hdrl_mode_type method, cpl_size error_niter)
478 hdrl_collapse_imagelist_to_vector_t * red =
479 hdrl_collapse_imagelist_to_vector_mode(histo_min, histo_max, bin_size,
480 method, error_niter);
482 hdrl_image_collapse(red, self, &res.data, &res.error, NULL, NULL);
483 hdrl_collapse_imagelist_to_vector_delete(red);
503 hdrl_collapse_imagelist_to_vector_t * red =
504 hdrl_collapse_imagelist_to_vector_median();
506 hdrl_image_collapse(red, self, &res.data, &res.error, NULL, NULL);
507 hdrl_collapse_imagelist_to_vector_delete(red);
522 hdrl_collapse_imagelist_to_vector_t * red =
523 hdrl_collapse_imagelist_to_vector_weighted_mean();
525 hdrl_image_collapse(red, self, &res.data, &res.error, NULL, NULL);
526 hdrl_collapse_imagelist_to_vector_delete(red);
559 hdrl_collapse_imagelist_to_vector_t * red =
560 hdrl_collapse_imagelist_to_vector_mean();
561 cpl_error_code err = hdrl_image_collapse(red, self, &res.data, &res.error,
563 if (err == CPL_ERROR_NONE) {
565 res.error *= contrib;
571 hdrl_collapse_imagelist_to_vector_delete(red);
608 cpl_ensure_code(self, CPL_ERROR_NULL_INPUT);
612 exponent.data, exponent.error);
651 cpl_ensure_code(self, CPL_ERROR_NULL_INPUT);
655 base.data, base.error);
hdrl_image * hdrl_image_pow_scalar_create(const hdrl_image *self, const hdrl_value exponent)
computes the power of an image by a scalar creating a new image
cpl_error_code hdrl_image_sub_image(hdrl_image *self, const hdrl_image *other)
Subtract two images, store the result in the first image.
cpl_error_code hdrl_image_div_scalar(hdrl_image *self, hdrl_value value)
Elementwise division of an image with a scalar.
hdrl_value hdrl_image_get_median(const hdrl_image *self)
computes the median and associated error of an image.
hdrl_value hdrl_image_get_sqsum(const hdrl_image *self)
computes the sum of all pixel values and the error of a squared image.
hdrl_value hdrl_image_get_mode(const hdrl_image *self, double histo_min, double histo_max, double bin_size, hdrl_mode_type method, cpl_size error_niter)
computes the mode and the associated error of an image.
hdrl_image * hdrl_image_sub_image_create(const hdrl_image *self, const hdrl_image *other)
Subtract two images.
cpl_error_code hdrl_image_pow_scalar(hdrl_image *self, const hdrl_value exponent)
computes the power of an image by a scalar
cpl_error_code hdrl_image_add_image(hdrl_image *self, const hdrl_image *other)
Add two images, store the result in the first image.
cpl_error_code hdrl_image_div_image(hdrl_image *self, const hdrl_image *other)
Divide two images, store the result in the first image.
cpl_error_code hdrl_image_mul_scalar(hdrl_image *self, hdrl_value value)
Elementwise multiplication of an image with a scalar.
hdrl_image * hdrl_image_duplicate(const hdrl_image *himg)
copy hdrl_image
hdrl_value hdrl_image_get_minmax_mean(const hdrl_image *self, double nlow, double nhigh)
computes the minmax rejected mean and the associated error of an image.
hdrl_value hdrl_image_get_sigclip_mean(const hdrl_image *self, double kappa_low, double kappa_high, int niter)
computes the sigma-clipped mean 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_image * hdrl_image_div_image_create(const hdrl_image *self, const hdrl_image *other)
Divide two images and return the resulting image.
cpl_error_code hdrl_image_add_scalar(hdrl_image *self, hdrl_value value)
Elementwise addition of a scalar to an image.
cpl_error_code hdrl_image_mul_image(hdrl_image *self, const hdrl_image *other)
Multiply two images, store the result in the first 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_error_code hdrl_image_exp_scalar(hdrl_image *self, const hdrl_value base)
computes the exponential of an image by a scalar
cpl_image * hdrl_image_get_error(hdrl_image *himg)
get error as cpl image
hdrl_value hdrl_image_get_mean(const hdrl_image *self)
computes mean pixel value and associated error of an image.
hdrl_value hdrl_image_get_weighted_mean(const hdrl_image *self)
computes the weighted mean and associated error of an image.
const cpl_image * hdrl_image_get_error_const(const hdrl_image *himg)
get error as cpl image
hdrl_image * hdrl_image_add_image_create(const hdrl_image *self, const hdrl_image *other)
Add two images.
hdrl_image * hdrl_image_mul_image_create(const hdrl_image *self, const hdrl_image *other)
Multiply two images.
cpl_image * hdrl_image_get_image(hdrl_image *himg)
get data as cpl image
const cpl_image * hdrl_image_get_image_const(const hdrl_image *himg)
get data as cpl image
hdrl_image * hdrl_image_exp_scalar_create(const hdrl_image *self, const hdrl_value base)
computes the exponential of an image by a scalar creating a new image
void hdrl_image_delete(hdrl_image *himg)
delete hdrl_image
cpl_error_code hdrl_image_sub_scalar(hdrl_image *self, hdrl_value value)
Elementwise subtraction of a scalar from an image.