High-Level Data Reduction Library 1.6.0
High-Level data reduction routines for ESO pipelines
Loading...
Searching...
No Matches
hdrl_elemop.c File Reference
#include "hdrl_utils.h"
#include "hdrl_types.h"
#include "hdrl_elemop.h"
#include <cpl.h>
#include <math.h>
Include dependency graph for hdrl_elemop.c:

Macros

#define SQR(a)   ((a) * (a))
 

Typedefs

typedef cpl_error_code() hdrl_math_op_f(hdrl_data_t *a, hdrl_error_t *ea, size_t na, const hdrl_data_t *b, const hdrl_error_t *eb, size_t nb, const cpl_binary *mask)
 
typedef cpl_error_code() hdrl_math_op_image_f(cpl_image *a, cpl_image *ae, const cpl_image *b, const cpl_image *be)
 
typedef cpl_error_code() hdrl_math_op_image_scalar_f(cpl_image *a, cpl_image *ae, const hdrl_data_t b, const hdrl_error_t be)
 

Functions

cpl_error_code hdrl_elemop_add (hdrl_data_t *a, hdrl_error_t *ea, size_t na, const hdrl_data_t *b, const hdrl_error_t *eb, size_t nb, const cpl_binary *mask)
 add two arrays of with error propagation in place
 
cpl_error_code hdrl_elemop_sub (hdrl_data_t *a, hdrl_error_t *ea, size_t na, const hdrl_data_t *b, const hdrl_error_t *eb, size_t nb, const cpl_binary *mask)
 subtract two arrays of with error propagation in place
 
cpl_error_code hdrl_elemop_mul (hdrl_data_t *a, hdrl_error_t *ea, size_t na, const hdrl_data_t *b, const hdrl_error_t *eb, size_t nb, const cpl_binary *mask)
 multiply two arrays of with error propagation in place
 
cpl_error_code hdrl_elemop_div (hdrl_data_t *a, hdrl_error_t *ea, size_t na, const hdrl_data_t *b, const hdrl_error_t *eb, size_t nb, const cpl_binary *mask)
 divide two arrays of with error propagation in place
 
cpl_error_code hdrl_elemop_pow (hdrl_data_t *a, hdrl_error_t *ea, size_t na, const hdrl_data_t *b, const hdrl_error_t *eb, size_t nb, const cpl_binary *mask)
 power of two arrays of with error propagation in place
 
cpl_error_code hdrl_elemop_pow_inverted (hdrl_data_t *a, hdrl_error_t *ea, size_t na, const hdrl_data_t *b, const hdrl_error_t *eb, size_t nb, const cpl_binary *mask)
 power of two arrays of with error propagation in place
 
cpl_error_code hdrl_elemop_image_add_scalar (cpl_image *a, cpl_image *ae, const hdrl_data_t b, const hdrl_error_t be)
 add/subtract/multiply/divide image and scalar with error propagation
 
cpl_error_code hdrl_elemop_image_sub_scalar (cpl_image *a, cpl_image *ae, const hdrl_data_t b, const hdrl_error_t be)
 
cpl_error_code hdrl_elemop_image_mul_scalar (cpl_image *a, cpl_image *ae, const hdrl_data_t b, const hdrl_error_t be)
 
cpl_error_code hdrl_elemop_image_div_scalar (cpl_image *a, cpl_image *ae, const hdrl_data_t b, const hdrl_error_t be)
 
cpl_error_code hdrl_elemop_image_pow_scalar (cpl_image *a, cpl_image *ae, const hdrl_data_t b, const hdrl_error_t be)
 
cpl_error_code hdrl_elemop_image_exp_scalar (cpl_image *a, cpl_image *ae, const hdrl_data_t b, const hdrl_error_t be)
 
cpl_error_code hdrl_elemop_image_add_image (cpl_image *a, cpl_image *ae, const cpl_image *b, const cpl_image *be)
 add/subtract/multiply/divide two images with error propagation
 
cpl_error_code hdrl_elemop_image_sub_image (cpl_image *a, cpl_image *ae, const cpl_image *b, const cpl_image *be)
 
cpl_error_code hdrl_elemop_image_mul_image (cpl_image *a, cpl_image *ae, const cpl_image *b, const cpl_image *be)
 
cpl_error_code hdrl_elemop_image_div_image (cpl_image *a, cpl_image *ae, const cpl_image *b, const cpl_image *be)
 
cpl_error_code hdrl_elemop_image_pow_image (cpl_image *a, cpl_image *ae, const cpl_image *b, const cpl_image *be)
 
cpl_error_code hdrl_elemop_imagelist_add_vector (cpl_imagelist *a, cpl_imagelist *ae, const cpl_vector *b, const cpl_vector *be)
 add/subtract/multiply/divide each image of an imagelist and a scalar from a vector with error propagation
 
cpl_error_code hdrl_elemop_imagelist_sub_vector (cpl_imagelist *a, cpl_imagelist *ae, const cpl_vector *b, const cpl_vector *be)
 
cpl_error_code hdrl_elemop_imagelist_mul_vector (cpl_imagelist *a, cpl_imagelist *ae, const cpl_vector *b, const cpl_vector *be)
 
cpl_error_code hdrl_elemop_imagelist_div_vector (cpl_imagelist *a, cpl_imagelist *ae, const cpl_vector *b, const cpl_vector *be)
 
cpl_error_code hdrl_elemop_imagelist_pow_vector (cpl_imagelist *a, cpl_imagelist *ae, const cpl_vector *b, const cpl_vector *be)
 
cpl_error_code hdrl_elemop_imagelist_add_image (cpl_imagelist *a, cpl_imagelist *ae, const cpl_image *b, const cpl_image *be)
 add/subtract/multiply/divide each image of an imagelist and an image with error propagation
 
cpl_error_code hdrl_elemop_imagelist_sub_image (cpl_imagelist *a, cpl_imagelist *ae, const cpl_image *b, const cpl_image *be)
 
cpl_error_code hdrl_elemop_imagelist_mul_image (cpl_imagelist *a, cpl_imagelist *ae, const cpl_image *b, const cpl_image *be)
 
cpl_error_code hdrl_elemop_imagelist_div_image (cpl_imagelist *a, cpl_imagelist *ae, const cpl_image *b, const cpl_image *be)
 
cpl_error_code hdrl_elemop_imagelist_pow_image (cpl_imagelist *a, cpl_imagelist *ae, const cpl_image *b, const cpl_image *be)
 
cpl_error_code hdrl_elemop_imagelist_add_imagelist (cpl_imagelist *a, cpl_imagelist *ae, const cpl_imagelist *b, const cpl_imagelist *be)
 add/subtract/multiply/divide two imagelists and scalar with error propagation
 
cpl_error_code hdrl_elemop_imagelist_sub_imagelist (cpl_imagelist *a, cpl_imagelist *ae, const cpl_imagelist *b, const cpl_imagelist *be)
 
cpl_error_code hdrl_elemop_imagelist_mul_imagelist (cpl_imagelist *a, cpl_imagelist *ae, const cpl_imagelist *b, const cpl_imagelist *be)
 
cpl_error_code hdrl_elemop_imagelist_div_imagelist (cpl_imagelist *a, cpl_imagelist *ae, const cpl_imagelist *b, const cpl_imagelist *be)
 
cpl_error_code hdrl_elemop_imagelist_pow_imagelist (cpl_imagelist *a, cpl_imagelist *ae, const cpl_imagelist *b, const cpl_imagelist *be)
 

Macro Definition Documentation

◆ SQR

#define SQR (   a)    ((a) * (a))

Typedef Documentation

◆ hdrl_math_op_f

typedef cpl_error_code() hdrl_math_op_f(hdrl_data_t *a, hdrl_error_t *ea, size_t na, const hdrl_data_t *b, const hdrl_error_t *eb, size_t nb, const cpl_binary *mask)

◆ hdrl_math_op_image_f

typedef cpl_error_code() hdrl_math_op_image_f(cpl_image *a, cpl_image *ae, const cpl_image *b, const cpl_image *be)

◆ hdrl_math_op_image_scalar_f

typedef cpl_error_code() hdrl_math_op_image_scalar_f(cpl_image *a, cpl_image *ae, const hdrl_data_t b, const hdrl_error_t be)

Function Documentation

◆ hdrl_elemop_add()

cpl_error_code hdrl_elemop_add ( hdrl_data_t a,
hdrl_error_t ea,
size_t  na,
const hdrl_data_t b,
const hdrl_error_t eb,
size_t  nb,
const cpl_binary *  mask 
)

add two arrays of with error propagation in place

Parameters
aarray of values of size na
eaarray of errors of a
nasize of a arrays
barray of values of size nb
ebarray of errors of b
nbsize of b array, must be equal to na or 1
maskbad pixel mask, positions where it is true are not modified

a = a + b e = hypot(ea, eb) error propagation of first order, correlations not considered except for the a === b case (correlation = 1)

◆ hdrl_elemop_div()

cpl_error_code hdrl_elemop_div ( hdrl_data_t a,
hdrl_error_t ea,
size_t  na,
const hdrl_data_t b,
const hdrl_error_t eb,
size_t  nb,
const cpl_binary *  mask 
)

divide two arrays of with error propagation in place

Parameters
aarray of values of size na
eaarray of errors of a
nasize of a arrays
barray of values of size nb
ebarray of errors of b
nbsize of b array, must be equal to na or 1
maskbad pixel mask, positions where it is true are not modified

a = a / b e = hypot(ea / b, eb * a / (b * b)) error propagation of first order, correlations not considered except for the a === b case (correlation = 1)

unlike cpl_image_divide pixels which are divided by zero are set to NAN and not marked as bad.

◆ hdrl_elemop_image_add_image()

cpl_error_code hdrl_elemop_image_add_image ( cpl_image *  a,
cpl_image *  ae,
const cpl_image *  b,
const cpl_image *  be 
)

add/subtract/multiply/divide two images with error propagation

Parameters
aimage, modified in place
aeerrors of image a, modified in place
bimage
beerrors of image b

Gaussian error propagation of first order, no accounting correlation besides a == b. Divisions by zero will be marked as bad pixels and set to NAN

◆ hdrl_elemop_image_add_scalar()

cpl_error_code hdrl_elemop_image_add_scalar ( cpl_image *  a,
cpl_image *  ae,
const hdrl_data_t  b,
const hdrl_error_t  be 
)

add/subtract/multiply/divide image and scalar with error propagation

Parameters
aimage, modified in place
aeerrors of image a, modified in place
bscalar
beerror of scalar b

Gaussian error propagation of first order, no accounting correlation besides a == b. Divisions by zero will be marked as bad pixels and set to NAN

◆ hdrl_elemop_image_div_image()

cpl_error_code hdrl_elemop_image_div_image ( cpl_image *  a,
cpl_image *  ae,
const cpl_image *  b,
const cpl_image *  be 
)

◆ hdrl_elemop_image_div_scalar()

cpl_error_code hdrl_elemop_image_div_scalar ( cpl_image *  a,
cpl_image *  ae,
const hdrl_data_t  b,
const hdrl_error_t  be 
)

◆ hdrl_elemop_image_exp_scalar()

cpl_error_code hdrl_elemop_image_exp_scalar ( cpl_image *  a,
cpl_image *  ae,
const hdrl_data_t  b,
const hdrl_error_t  be 
)

◆ hdrl_elemop_image_mul_image()

cpl_error_code hdrl_elemop_image_mul_image ( cpl_image *  a,
cpl_image *  ae,
const cpl_image *  b,
const cpl_image *  be 
)

◆ hdrl_elemop_image_mul_scalar()

cpl_error_code hdrl_elemop_image_mul_scalar ( cpl_image *  a,
cpl_image *  ae,
const hdrl_data_t  b,
const hdrl_error_t  be 
)

◆ hdrl_elemop_image_pow_image()

cpl_error_code hdrl_elemop_image_pow_image ( cpl_image *  a,
cpl_image *  ae,
const cpl_image *  b,
const cpl_image *  be 
)

◆ hdrl_elemop_image_pow_scalar()

cpl_error_code hdrl_elemop_image_pow_scalar ( cpl_image *  a,
cpl_image *  ae,
const hdrl_data_t  b,
const hdrl_error_t  be 
)

◆ hdrl_elemop_image_sub_image()

cpl_error_code hdrl_elemop_image_sub_image ( cpl_image *  a,
cpl_image *  ae,
const cpl_image *  b,
const cpl_image *  be 
)

◆ hdrl_elemop_image_sub_scalar()

cpl_error_code hdrl_elemop_image_sub_scalar ( cpl_image *  a,
cpl_image *  ae,
const hdrl_data_t  b,
const hdrl_error_t  be 
)

◆ hdrl_elemop_imagelist_add_image()

cpl_error_code hdrl_elemop_imagelist_add_image ( cpl_imagelist *  a,
cpl_imagelist *  ae,
const cpl_image *  b,
const cpl_image *  be 
)

add/subtract/multiply/divide each image of an imagelist and an image with error propagation

Parameters
aimagelist, modified in place
aeerrors of imagelist a, modified in place
bimage
beerror of image b

Gaussian error propagation of first order, no accounting correlation besides a == b. Divisions by zero will be marked as bad pixels and set to NAN

◆ hdrl_elemop_imagelist_add_imagelist()

cpl_error_code hdrl_elemop_imagelist_add_imagelist ( cpl_imagelist *  a,
cpl_imagelist *  ae,
const cpl_imagelist *  b,
const cpl_imagelist *  be 
)

add/subtract/multiply/divide two imagelists and scalar with error propagation

Parameters
aimagelist, modified in place
aeerrors of imagelist a, modified in place
bimagelist
beerror of imagelist b

Gaussian error propagation of first order, no accounting correlation besides a == b. Divisions by zero will be marked as bad pixels and set to NAN

◆ hdrl_elemop_imagelist_add_vector()

cpl_error_code hdrl_elemop_imagelist_add_vector ( cpl_imagelist *  a,
cpl_imagelist *  ae,
const cpl_vector *  b,
const cpl_vector *  be 
)

add/subtract/multiply/divide each image of an imagelist and a scalar from a vector with error propagation

Parameters
aimagelist, modified in place
aeerrors of imagelist a, modified in place
bvector
beerror of vector b

Gaussian error propagation of first order, no accounting correlation besides a == b. Divisions by zero will be marked as bad pixels and set to NAN

◆ hdrl_elemop_imagelist_div_image()

cpl_error_code hdrl_elemop_imagelist_div_image ( cpl_imagelist *  a,
cpl_imagelist *  ae,
const cpl_image *  b,
const cpl_image *  be 
)

◆ hdrl_elemop_imagelist_div_imagelist()

cpl_error_code hdrl_elemop_imagelist_div_imagelist ( cpl_imagelist *  a,
cpl_imagelist *  ae,
const cpl_imagelist *  b,
const cpl_imagelist *  be 
)

◆ hdrl_elemop_imagelist_div_vector()

cpl_error_code hdrl_elemop_imagelist_div_vector ( cpl_imagelist *  a,
cpl_imagelist *  ae,
const cpl_vector *  b,
const cpl_vector *  be 
)

◆ hdrl_elemop_imagelist_mul_image()

cpl_error_code hdrl_elemop_imagelist_mul_image ( cpl_imagelist *  a,
cpl_imagelist *  ae,
const cpl_image *  b,
const cpl_image *  be 
)

◆ hdrl_elemop_imagelist_mul_imagelist()

cpl_error_code hdrl_elemop_imagelist_mul_imagelist ( cpl_imagelist *  a,
cpl_imagelist *  ae,
const cpl_imagelist *  b,
const cpl_imagelist *  be 
)

◆ hdrl_elemop_imagelist_mul_vector()

cpl_error_code hdrl_elemop_imagelist_mul_vector ( cpl_imagelist *  a,
cpl_imagelist *  ae,
const cpl_vector *  b,
const cpl_vector *  be 
)

◆ hdrl_elemop_imagelist_pow_image()

cpl_error_code hdrl_elemop_imagelist_pow_image ( cpl_imagelist *  a,
cpl_imagelist *  ae,
const cpl_image *  b,
const cpl_image *  be 
)

◆ hdrl_elemop_imagelist_pow_imagelist()

cpl_error_code hdrl_elemop_imagelist_pow_imagelist ( cpl_imagelist *  a,
cpl_imagelist *  ae,
const cpl_imagelist *  b,
const cpl_imagelist *  be 
)

◆ hdrl_elemop_imagelist_pow_vector()

cpl_error_code hdrl_elemop_imagelist_pow_vector ( cpl_imagelist *  a,
cpl_imagelist *  ae,
const cpl_vector *  b,
const cpl_vector *  be 
)

◆ hdrl_elemop_imagelist_sub_image()

cpl_error_code hdrl_elemop_imagelist_sub_image ( cpl_imagelist *  a,
cpl_imagelist *  ae,
const cpl_image *  b,
const cpl_image *  be 
)

◆ hdrl_elemop_imagelist_sub_imagelist()

cpl_error_code hdrl_elemop_imagelist_sub_imagelist ( cpl_imagelist *  a,
cpl_imagelist *  ae,
const cpl_imagelist *  b,
const cpl_imagelist *  be 
)

◆ hdrl_elemop_imagelist_sub_vector()

cpl_error_code hdrl_elemop_imagelist_sub_vector ( cpl_imagelist *  a,
cpl_imagelist *  ae,
const cpl_vector *  b,
const cpl_vector *  be 
)

◆ hdrl_elemop_mul()

cpl_error_code hdrl_elemop_mul ( hdrl_data_t a,
hdrl_error_t ea,
size_t  na,
const hdrl_data_t b,
const hdrl_error_t eb,
size_t  nb,
const cpl_binary *  mask 
)

multiply two arrays of with error propagation in place

Parameters
aarray of values of size na
eaarray of errors of a
nasize of a arrays
barray of values of size nb
ebarray of errors of b
nbsize of b array, must be equal to na or 1
maskbad pixel mask, positions where it is true are not modified

a = a * b e = hypot(a * eb, b * ea) error propagation of first order, correlations not considered except for the a === b case (correlation = 1)

◆ hdrl_elemop_pow()

cpl_error_code hdrl_elemop_pow ( hdrl_data_t a,
hdrl_error_t ea,
size_t  na,
const hdrl_data_t b,
const hdrl_error_t eb,
size_t  nb,
const cpl_binary *  mask 
)

power of two arrays of with error propagation in place

Parameters
aarray of values of size na
eaarray of errors of a
nasize of a arrays
barray of values of size nb
ebarray of errors of b
nbsize of b array, must be equal to na or 1
maskbad pixel mask, positions where it is true are not modified

a = pow(a, b) e = pow(a, b) * sqrt((a / b * ea)^2 + (ln(a) * eb)^2) error propagation of first order, correlations not considered except for the a === b case (correlation = 1)

if b < 0 and a == 0 the result is NAN for a < 0 and eb != 0 the error is not well defined

◆ hdrl_elemop_pow_inverted()

cpl_error_code hdrl_elemop_pow_inverted ( hdrl_data_t a,
hdrl_error_t ea,
size_t  na,
const hdrl_data_t b,
const hdrl_error_t eb,
size_t  nb,
const cpl_binary *  mask 
)

power of two arrays of with error propagation in place

Parameters
aarray of values of size na
eaarray of errors of a
nasize of a arrays
barray of values of size nb
ebarray of errors of b
nbsize of b array, must be equal to na or 1
maskbad pixel mask, positions where it is true are not modified

a = pow(b, a) e = pow(b, a) * sqrt((b / a * eb)^2 + (ln(b) * ea)^2) error propagation of first order, correlations not considered except for the a === b case (correlation = 1)

if a < 0 and b == 0 the result is NAN for b < 0 and ea != 0 the error is not well defined

◆ hdrl_elemop_sub()

cpl_error_code hdrl_elemop_sub ( hdrl_data_t a,
hdrl_error_t ea,
size_t  na,
const hdrl_data_t b,
const hdrl_error_t eb,
size_t  nb,
const cpl_binary *  mask 
)

subtract two arrays of with error propagation in place

Parameters
aarray of values of size na
eaarray of errors of a
nasize of a arrays
barray of values of size nb
ebarray of errors of b
nbsize of b array, must be equal to na or 1
maskbad pixel mask, positions where it is true are not modified

a = a - b e = hypot(ea, eb) error propagation of first order, correlations not considered except for the a === b case (correlation = 1)