Utility functions (low level)

Functions

static cpl_image * filter_median (const cpl_image *image, int radx, int rady, bool extrapolate_border)
 Median filter.
const cpl_property * uves_find_property_const (const uves_propertylist *plist, const char *name, int number)
 Find named property.
cpl_property * uves_find_property (uves_propertylist *plist, const char *name, int number)
cpl_error_code uves_filter_image_average (cpl_image *image, int radius_x, int radius_y)
 Average filter.
cpl_error_code uves_filter_image_median (cpl_image **image, int xwindow, int ywindow, bool extrapolate_border)
 Median filter.
double uves_utils_get_kth_double (double *a, int n, int k)
 returns the kth value of an array
double uves_tools_get_median (double *a, int n)
 returns median (not CPL median) of an array
cpl_error_code uves_fit_gaussian_2d_image (const cpl_image *image, const cpl_image *noise, int x1, int y_1, int x2, int y2, double *x0, double *y_0, double *sigmax, double *sigmay, double *amplitude, double *dx0, double *dy0)
 Fit a 2d gaussian to an image sub-window.

Detailed Description

This module contains low level library functions that can be removed if/when the corresponding functionality is in the CPL.


Function Documentation

static cpl_image * filter_median ( const cpl_image *  image,
int  radx,
int  rady,
bool  extrapolate_border 
) [static]

Median filter.

Parameters:
image Image to filter
radx x-radius of median window
rady y-radius of median window
extrapolate_border If false (which should be considered the default value), a smaller window is used at the image borders (where the full window would be partially outside of the image). If true, the median is calculated only for points where the full window is inside the image, and the border region is obtained by constant extrapolation.
Returns:
Filtered image, or NULL on error.

Apply a radx by rady median filter to the input image. Each pixel is replaced by the median of a local window of size (2* radx + 1)* (2 * rady + 1) centered on the pixel.

Definition at line 511 of file uves_utils_cpl.c.

References assure_mem, uves_max_int(), uves_min_int(), uves_tostring_cpl_type(), and uves_utils_get_kth_double().

Referenced by uves_filter_image_median().

const cpl_property* uves_find_property_const ( const uves_propertylist plist,
const char *  name,
int  number 
)

Find named property.

Parameters:
plist propertylist to search
name property name
number number of property to find (counting from zero). E.g. setting number=1 would return the 2nd property with matching name
Returns:
first property with given name, or NULL if not found

No error is set if the property is not found

Definition at line 196 of file uves_utils_cpl.c.

References uves_propertylist_get_const(), and uves_propertylist_get_size().

cpl_error_code uves_filter_image_average ( cpl_image *  image,
int  radius_x,
int  radius_y 
)

Average filter.

Parameters:
image Image to filter
radius_x width of filter window is 2*radius_x + 1
radius_y height of filter window is 2*radius_y + 1
Returns:
CPL_ERROR_NONE iff OK.

The image must be of type CPL_TYPE_DOUBLE.

There is currently no handling of bad pixels.

Definition at line 247 of file uves_utils_cpl.c.

References uves_msg_debug, and uves_tostring_cpl_type().

cpl_error_code uves_filter_image_median ( cpl_image **  image,
int  xwindow,
int  ywindow,
bool  extrapolate_border 
)

Median filter.

Parameters:
image Image to filter
xwindow x-radius of filter window
ywindow y-radius of filter window
extrapolate_border See filter_median()
Returns:
CPL_ERROR_NONE iff OK.

If the median window is large, this function is rather inefficient, because cpl_image_get_median_window() is called for each pixel. A more clever implementation would keep track of the running window.

Definition at line 372 of file uves_utils_cpl.c.

References check, and filter_median().

Referenced by uves_get_blaze_ratio(), uves_rcosmic(), and uves_response_efficiency().

double uves_utils_get_kth_double ( double *  a,
int  n,
int  k 
)

returns the kth value of an array

Parameters:
a array
n array size
k component to evaluate

The array is modified

Definition at line 434 of file uves_utils_cpl.c.

Referenced by filter_median(), and uves_tools_get_median().

double uves_tools_get_median ( double *  a,
int  n 
)

returns median (not CPL median) of an array

Parameters:
a array
n array size

The array is modified

Definition at line 470 of file uves_utils_cpl.c.

References uves_utils_get_kth_double().

Referenced by opt_get_noise_median(), and opt_get_sky().

cpl_error_code uves_fit_gaussian_2d_image ( const cpl_image *  image,
const cpl_image *  noise,
int  x1,
int  y_1,
int  x2,
int  y2,
double *  x0,
double *  y_0,
double *  sigmax,
double *  sigmay,
double *  amplitude,
double *  dx0,
double *  dy0 
)

Fit a 2d gaussian to an image sub-window.

Parameters:
image The image to fit.
noise The uncertainty (one sigma, gaussian errors assumed) associated with the image. If NULL, constant uncertainties are assumed, and then dx0 and dy0 cannot be determined.
x1 Lower left corner (inclusive, FITS convention).
y_1 Lower left corner (inclusive, FITS convention).
x2 Upper right corner (inclusive, FITS convention).
y2 Upper right corner (inclusive, FITS convention).
x0 (output) x-center of best fit gaussian.
y_0 (output) y-center of best fit gaussian.
sigmax (output) x-width of best fit gaussian. Positive on success.
sigmay (output) y-width of best fit gaussian. Positive on success.
amplitude (output) Height of the best fit gaussian, relative to the background level. May be NULL.
dx0 (output) Uncertainty of x0. May be NULL.
dy0 (output) Uncertainty of y_0. May be NULL.

The function does not make a 2d gaussian fit, but fits a one-dimensional gaussian to the marginal distributions in x and y. See also uves_fit_gaussian_1d_image().

Note:
A CPL_ERROR_CONTINUE is set in the case (and only in that case) that the fitting algorithm fails to converge or converges to a non-sensical result.

Definition at line 639 of file uves_utils_cpl.c.

References check, uves_gauss(), and uves_gauss_derivative().

Referenced by test_gaussian_fitting().


Generated on 9 Mar 2012 for UVES Pipeline Reference Manual by  doxygen 1.6.1