Defines | |
#define | CONCAT(a, b) a ## _ ## b |
#define | CONCAT2X(a, b) CONCAT(a,b) |
#define | CPL_TYPE double |
#define | CPL_TYPE float |
#define | CPL_TYPE int |
Functions | |
static double | irplib_tools_ipow (double x, int p) |
Compute x to the power of p. | |
static cpl_vector * | irplib_vector_transform_mean (const cpl_vector *x, double *pm) |
Transform: xhat = x - mean(x). | |
static cpl_matrix * | irplib_matrix_product_normal_create (const cpl_matrix *self) |
Create and compute A = B * transpose(B). | |
static cpl_error_code | irplib_matrix_product_transpose (cpl_matrix *self, const cpl_matrix *ma, const cpl_matrix *mb) |
Fill a matrix with the product of A * B'. | |
static cpl_error_code | irplib_matrix_solve_chol_transpose (const cpl_matrix *self, cpl_matrix *rhs) |
Solve a L*transpose(L)-system with a transposed Right Hand Side. | |
static void | irplib_fit_imagelist_polynomial_double (cpl_imagelist *, const cpl_matrix *, const cpl_matrix *, const cpl_vector *, const cpl_imagelist *, const cpl_vector *, double, int, int, cpl_image *) |
static void | irplib_fit_imagelist_polynomial_float (cpl_imagelist *, const cpl_matrix *, const cpl_matrix *, const cpl_vector *, const cpl_imagelist *, const cpl_vector *, double, int, int, cpl_image *) |
static void | irplib_fit_imagelist_polynomial_int (cpl_imagelist *, const cpl_matrix *, const cpl_matrix *, const cpl_vector *, const cpl_imagelist *, const cpl_vector *, double, int, int, cpl_image *) |
static void | irplib_fit_imagelist_residual_double (cpl_image *, int, const cpl_vector *, const cpl_vector *, const cpl_matrix *, const cpl_matrix *) |
static void | irplib_fit_imagelist_residual_float (cpl_image *, int, const cpl_vector *, const cpl_vector *, const cpl_matrix *, const cpl_matrix *) |
static void | irplib_fit_imagelist_residual_int (cpl_image *, int, const cpl_vector *, const cpl_vector *, const cpl_matrix *, const cpl_matrix *) |
static void | irplib_polynomial_shift_double (double *coeffs, int n, double u) |
Given p and u, modify the polynomial to p(x) := p(x+u). | |
cpl_imagelist * | xsh_fit_imagelist_polynomial (const cpl_vector *x_pos, const cpl_imagelist *values, int mindeg, int maxdeg, cpl_boolean is_eqdist, cpl_image *fiterror) |
Fit a polynomial to each pixel in a list of images. | |
cpl_error_code | xsh_image_find_barycenter (const cpl_image *im, int xpos, int ypos, int size, double *norm, double *xcen, double *ycen, double *sig_x, double *sig_y, double *fwhm_x, double *fwhm_y) |
Apply a gaussian fit on an image sub window. |
static void irplib_fit_imagelist_polynomial_double | ( | cpl_imagelist * | , | |
const cpl_matrix * | , | |||
const cpl_matrix * | , | |||
const cpl_vector * | , | |||
const cpl_imagelist * | , | |||
const cpl_vector * | , | |||
double | , | |||
int | , | |||
int | , | |||
cpl_image * | ||||
) | [static] |
Referenced by xsh_fit_imagelist_polynomial().
static void irplib_fit_imagelist_polynomial_float | ( | cpl_imagelist * | , | |
const cpl_matrix * | , | |||
const cpl_matrix * | , | |||
const cpl_vector * | , | |||
const cpl_imagelist * | , | |||
const cpl_vector * | , | |||
double | , | |||
int | , | |||
int | , | |||
cpl_image * | ||||
) | [static] |
Referenced by xsh_fit_imagelist_polynomial().
static void irplib_fit_imagelist_polynomial_int | ( | cpl_imagelist * | , | |
const cpl_matrix * | , | |||
const cpl_matrix * | , | |||
const cpl_vector * | , | |||
const cpl_imagelist * | , | |||
const cpl_vector * | , | |||
double | , | |||
int | , | |||
int | , | |||
cpl_image * | ||||
) | [static] |
Referenced by xsh_fit_imagelist_polynomial().
static void irplib_fit_imagelist_residual_double | ( | cpl_image * | , | |
int | , | |||
const cpl_vector * | , | |||
const cpl_vector * | , | |||
const cpl_matrix * | , | |||
const cpl_matrix * | ||||
) | [static] |
Referenced by irplib_fit_imagelist_polynomial().
static void irplib_fit_imagelist_residual_float | ( | cpl_image * | , | |
int | , | |||
const cpl_vector * | , | |||
const cpl_vector * | , | |||
const cpl_matrix * | , | |||
const cpl_matrix * | ||||
) | [static] |
Referenced by irplib_fit_imagelist_polynomial().
static void irplib_fit_imagelist_residual_int | ( | cpl_image * | , | |
int | , | |||
const cpl_vector * | , | |||
const cpl_vector * | , | |||
const cpl_matrix * | , | |||
const cpl_matrix * | ||||
) | [static] |
Referenced by irplib_fit_imagelist_polynomial().
static cpl_matrix * irplib_matrix_product_normal_create | ( | const cpl_matrix * | self | ) | [static] |
Create and compute A = B * transpose(B).
self | M x N Matrix |
NULL
on error. CPL_ERROR_NULL_INPUT | Any input matrix is a |
To destroy the new matrix the function cpl_matrix_delete()
should be used.
FIXME: Improved from cpl_matrix_product_normal_create().
Definition at line 519 of file xsh_fit.c.
Referenced by xsh_fit_imagelist_polynomial().
static cpl_error_code irplib_matrix_product_transpose | ( | cpl_matrix * | self, | |
const cpl_matrix * | ma, | |||
const cpl_matrix * | mb | |||
) | [static] |
Fill a matrix with the product of A * B'.
self | The matrix to fill, is or else will be set to size M x N | |
ma | The matrix A, of size M x K | |
mb | The matrix B, of size N x K |
Definition at line 384 of file xsh_fit.c.
Referenced by irplib_fit_imagelist_polynomial().
static cpl_error_code irplib_matrix_solve_chol_transpose | ( | const cpl_matrix * | self, | |
cpl_matrix * | rhs | |||
) | [static] |
Solve a L*transpose(L)-system with a transposed Right Hand Side.
self | N by N L*transpose(L)-matrix from cpl_matrix_decomp_chol() | |
rhs | M right-hand-sides to be replaced by their solution |
CPL_ERROR_NULL_INPUT | An input pointer is |
CPL_ERROR_ILLEGAL_INPUT | self is not an n by n matrix. |
CPL_ERROR_INCOMPATIBLE_INPUT | Selfs number of rows differs from rhs' number of columns. |
CPL_ERROR_DIVISION_BY_ZERO | The main diagonal of L contains a zero. This error can only occur if the L*transpose(L)-matrix does not come from a successful call to cpl_matrix_decomp_chol(). |
Definition at line 600 of file xsh_fit.c.
References n.
Referenced by irplib_fit_imagelist_polynomial().
static void irplib_polynomial_shift_double | ( | double * | coeffs, | |
int | n, | |||
double | u | |||
) | [static] |
Given p and u, modify the polynomial to p(x) := p(x+u).
coeffs | The polynomial coefficients to be modified in place | |
n | The number of coefficients | |
u | The shift |
FIXME: Duplicated from cpl_polynomial_shift_double().
Definition at line 445 of file xsh_fit.c.
Referenced by irplib_fit_imagelist_polynomial().
static double irplib_tools_ipow | ( | double | x, | |
int | p | |||
) | [static] |
Compute x to the power of p.
x | The base | |
p | The non-negative power |
Apart from a possible difference in round-off the result equals pow(x, p).
Definition at line 348 of file xsh_fit.c.
Referenced by xsh_fit_imagelist_polynomial().
static cpl_vector * irplib_vector_transform_mean | ( | const cpl_vector * | x, | |
double * | pm | |||
) | [static] |
Transform: xhat = x - mean(x).
x | The vector to be transformed | |
pm | On return, *pm is the mean of x |
FIXME: Duplicated from cpl_vector_transform_mean().
Definition at line 474 of file xsh_fit.c.
Referenced by xsh_fit_imagelist_polynomial().
cpl_imagelist* xsh_fit_imagelist_polynomial | ( | const cpl_vector * | x_pos, | |
const cpl_imagelist * | values, | |||
int | mindeg, | |||
int | maxdeg, | |||
cpl_boolean | is_eqdist, | |||
cpl_image * | fiterror | |||
) |
Fit a polynomial to each pixel in a list of images.
x_pos | The vector of positions to fit | |
values | The list of images with values to fit | |
mindeg | The smallest degree with a non-zero coefficient | |
maxdeg | The polynomial degree of the fit, at least mindeg | |
is_eqdist | True iff the x_pos values are known to be equidistant | |
fiterror | When non-NULL, the error of the fit |
For each pixel, a polynomial representing the relation value = P(x) is computed where: P(x) = x^{mindeg} * (a_0 + a_1 * x + ... + a_{nc-1} * x^{nc-1}), where mindeg >= 0 and maxdeg >= mindeg, and nc is the number of polynomial coefficients to determine, nc = 1 + (maxdeg - mindeg).
The returned image list thus contains nc coefficient images, a_0, a_1, ..., a_{nc-1}.
np is the number of sample points, i.e. the number of elements in x_pos and number of images in the image list.
is_eqdist is ignored if mindeg is nonzero, otherwise is_eqdist may to be set to CPL_TRUE if and only if the values in x_pos are known a-priori to be equidistant when sorted, eg. (1,2,3,4) and (1,3,2,4), but not (1,2,4,6). Setting is_eqdist to CPL_TRUE is faster and eliminates certain round-off errors.
Even though it is not an error, it is hardly useful to use an image of pixel type integer for the fitting error. An image of pixel type float should on the other hand be sufficient for most fitting errors.
The call requires the following number of FLOPs, where nz is the number of pixels in any one image in the imagelist:
2 * nz * nc * (nc + np) + np * nc^2 + nc^3/3 + O(nc * (nc + np)).
If mindeg is zero an additional nz * nc^2 FLOPs are required.
If fiterror is non-NULL an additional 2 * nz * nc * np FLOPs are required.
Possible _cpl_error_code_ set in this function:
Definition at line 171 of file xsh_fit.c.
References irplib_fit_imagelist_polynomial_double(), irplib_fit_imagelist_polynomial_float(), irplib_fit_imagelist_polynomial_int(), irplib_matrix_product_normal_create(), irplib_tools_ipow(), irplib_vector_transform_mean(), nx, and ny.
Referenced by xsh_compute_linearity(), and xsh_fit_imagelist_polynomial_tests().
cpl_error_code xsh_image_find_barycenter | ( | const cpl_image * | im, | |
int | xpos, | |||
int | ypos, | |||
int | size, | |||
double * | norm, | |||
double * | xcen, | |||
double * | ycen, | |||
double * | sig_x, | |||
double * | sig_y, | |||
double * | fwhm_x, | |||
double * | fwhm_y | |||
) |
Apply a gaussian fit on an image sub window.
im | the input image | |
xpos | the x position of the center (1 for the first pixel) | |
ypos | the y position of the center (1 for the first pixel) | |
size | the window size in pixels | |
norm | the norm of the gaussian or NULL | |
xcen | the x center of the gaussian or NULL | |
ycen | the y center of the gaussian or NULL | |
sig_x | the sigma in x of the gaussian or NULL | |
sig_y | the sigma in y of the gaussian or NULL | |
fwhm_x | the FHHM in x or NULL | |
fwhm_y | the FHHM in y or NULL |
The computed norm, xcen, ycen, sig_x, sig_y coefficients are defining the gaussian:
f(x, y) = (norm/(2*pi*sig_x*sig_y)) * exp(-(x-xcen)^2/(2*sig_x^2)) * exp(-(y-ycen)^2/(2*sig_y^2))
fwhm_x and fwhm_y are derived from sig_x and sig_y like: fwhm = 2 * sqrt(2*ln(2)) * sigma
Images can be CPL_TYPE_INT, CPL_TYPE_FLOAT or CPL_TYPE_DOUBLE.
Possible _cpl_error_code_ set in this function:
Definition at line 696 of file xsh_fit.c.
References llx, lly, nx, ny, urx, and ury.
Referenced by xsh_detect_arclines(), xsh_detect_arclines_dan(), and xsh_gfit_tests().