1d functions

sinfo_function1d_new

Allocates a new array of pixelvalues.

Parameters:
nsamples Number of values to store in the array.
Returns:
Pointer to newly allocated array of pixelvalues.

The returned array must be freed using sinfo_function1d_del(), not cpl_free(). This is in case some further housekeeping attributes are allocated together with the object in the future.

Returns NULL in case of error.



pixelvalue * sinfo_function1d_new (int nsamples)

sinfo_function1d_del

Deallocate an array of pixelvalues.

Parameters:
s Array to deallocate.
Returns:
void

Deallocates an array allocated by sinfo_function1d_new().



void sinfo_function1d_del (pixelvalue *s)

sinfo_function1d_dup

Copy an array of pixelvalues to a new array.

Parameters:
arr Array to copy.
ns Number of samples in the array.
Returns:
Pointer to newly allocated array of pixelvalues.

Creates a new array using sinfo_function1d_new(), with the same number of samples as the input signal, then copies over all values from source to destination array using memcpy().

The returned array must be freed using sinfo_function1d_del(), not cpl_free().



pixelvalue * sinfo_function1d_dup (pixelvalue *arr, int ns)

sinfo_function1d_find_centroid

Find out a line centroid to subpixel precision.

Parameters:
line Array of pixels.
npix Number of pixels in the array.
Returns:
Centroid position as a double.

The input signal is assumed to be flat almost everywhere, with a single peak somewhere around the middle. Other kinds of signals are not handled correctly.

The position of the peak is located to subpixel precision by simply weighting positions with pixelvalues.



double sinfo_function1d_find_centroid (pixelvalue *line, int npix)

sinfo_function1d_find_locmax

Find out a local maximum in a 1d signal around a position.

Parameters:
line Array of pixels.
npix Number of pixels in the array.
where Where to look around.
hs Half-size of the search domain.
Returns:
Local maximum position as a double.

The closest local maximum to the given position is located to subpixel precision. This precision is achieved by simply weighting positions with pixelvalues.

The 'where' parameter indicates where to look for a maximum as an index in the array, i.e. it must lie between 0 and npix-1 (inclusive). The 'hs' parameter indicates the half-size of the search domain, i.e. if hs=5 a local maximum will be searched +/-5 pixels around the requested position.

Returns a negative value if an error occurred.



double sinfo_function1d_find_locmax (pixelvalue *line, int npix, int where, int hs)

sinfo_function1d_filter_lowpass

Apply a low-pass filter to a 1d signal.

Parameters:
input_sig Input signal
samples Number of samples in the signal
filter_type Type of filter to use.
hw Filter half-width.
Returns:
Pointer to newly allocated array of pixels.

This kind of low-pass filtering consists in a convolution with a given kernel. The chosen filter type determines the kind of kernel to apply for convolution. Possible kernels and associated symbols can be found in function_1d.h.

Smoothing the signal is done by applying this kind of low-pass filter several times.

The returned smooth signal has been allocated using sinfo_function1d_new(), it must be freed using sinfo_function1d_del(). The returned signal has exactly as many samples as the input signal.



pixelvalue * sinfo_function1d_filter_lowpass (pixelvalue *input_sig, int samples, int filter_type, int hw)

sinfo_function1d_median_smooth

Apply a 1d sinfo_median filter of given half-width.

Parameters:
list List of input pixelvalues.
np Number of points in the list.
hw Filter half-width.
Returns:
Pointer to newly allocated array of pixelvalues.

This function applies a sinfo_median smoothing to a given signal and returns a newly allocated signal containing a sinfo_median-smoothed version of the input. The returned array has exactly as many samples as the input array. It has been allocated using sinfo_function1d_new() and must be deallocated using sinfo_function1d_del().

For half-widths of 1,2,3,4, the filtering is optimized for speed.



pixelvalue * sinfo_function1d_median_smooth (pixelvalue *list, int np, int hw)

sinfo_function1d_remove_lowfreq

Subtract low-frequency components from a signal.

Parameters:
pixel_signal Input signal.
ns Number of samples.
Returns:
Pointer to newly allocated array of pixelvalues.

The returned signal is such as: out = in - smooth(in).

The returned array has been allocated using sinfo_function1d_dup(), it must be deallocated using sinfo_function1d_del(). The returned array has exactly as many elements as the input array.



pixelvalue * sinfo_function1d_remove_lowfreq (pixelvalue *pixel_signal, int ns)
#define LOWFREQ_PASSES   5

sinfo_function1d_remove_thermalbg

Remove thermal background from a signal.

Parameters:
pixel_signal Input signal.
ns Number of samples in the input signal.
Returns:
Pointer to newly allocated array of pixelvalues.

Many assumptions are made about the input signal. What is expected is typically the a collapsed image taken in K band, where the thermal background is rising as an exponential of the wavelength.

This function tries to remove the thermal background contribution by first estimating it, then interpolating missing background values, and finally subtracting it from the input signal.

The returned array has been allocated using sinfo_function1d_new(), it must be freed using sinfo_function1d_del(). The returned array has exactly as many samples as the input array.



pixelvalue * sinfo_function1d_remove_thermalbg (pixelvalue *pixel_signal, int ns)
#define SAMPLE_BORDER   10

sinfo_function1d_interpolate_linear

Linear signal interpolation.

Parameters:
x Input list of x positions.
y Input list of y positions.
len Number of samples in x and y.
spl_x List of abscissas where the signal must be computed.
spl_y Output list of computed signal values.
spl_len Number of samples in spl_x and spl_y.
Returns:
void

To apply this interpolation, you need to provide a list of x and y positions, and a list of x positions where you want y to be computed (with linear interpolation).

The returned signal has spl_len samples. It has been allocated using sinfo_function1d_new() and must be deallocated using sinfo_function1d_del().



void sinfo_function1d_interpolate_linear (pixelvalue *x, pixelvalue *y, int len, pixelvalue *spl_x, pixelvalue *spl_y, int spl_len)

sinfo_function1d_natural_spline

Interpolate a sinfo_vector along new abscissas.

Parameters:
x List of x positions.
y List of y positions.
len Number of samples in x and y.
splX Input new list of x positions.
splY Output list of interpolated y positions.
splLen Number of samples in splX and splY.
Returns:
Int 0 if Ok, -1 if error.

Reference:

{verbatim} Numerical Analysis, R. Burden, J. Faires and A. Reynolds. Prindle, Weber & Schmidt 1981 pp 112 {verbatim}

Provide in input a known list of x and y values, and a list where you want the signal to be interpolated. The returned signal is written into splY.



int sinfo_function1d_natural_spline (pixelvalue *x, pixelvalue *y, int len, pixelvalue *splX, pixelvalue *splY, int splLen)

sinfo_function1d_average_reject

Sorts the input signal, takes out highest and lowest values, and returns the average of the remaining pixels.

Parameters:
line Input signal.
npix Number of samples in the input signal.
pix_low Number of lowest pixels to reject.
pix_high Number of highest pixels to reject.
Returns:
The filtered average of the input signal.

No input parameter is modified.

The input signal is first copied. This copy is then sorted, and the highest and lowest pixels are taken out of the list. Remaining pixelvalues are averaged and the result is returned.



pixelvalue sinfo_function1d_average_reject (pixelvalue *line, int npix, int pix_low, int pix_high)

sinfo_function1d_xcorrelate

Cross-sinfo_correlation of two 1d signals.

Parameters:
line_i The reference signal.
width_i Number of samples in reference signal.
line_t Candidate signal to compare.
width_t Number of samples in candidate signal.
half_search Half-size of the search domain.
delta Output sinfo_correlation offset.
Returns:
Maximum cross-sinfo_correlation value as a double.

Two signals are expected in input of this function: a reference signal and a candidate signal. They are expected to be roughly the same signal up to an offset.

A cross-sinfo_correlation is computed on 2*half_search+1 values. The maximum of likelihood is the maximum cross-sinfo_correlation value between signals. The offset corresponding to this position is returned.

Returns -100.0 in case of error. Normally, the cross-sinfo_correlation coefficient is normalized so it should stay between -1 and +1.



double sinfo_function1d_xcorrelate (pixelvalue *line_i, int width_i, pixelvalue *line_t, int width_t, int half_search, double *delta)
#define STEP_MIN   (-half_search)
#define STEP_MAX   (half_search)

Detailed Description

TBD


Generated on 8 Mar 2011 for SINFONI Pipeline Reference Manual by  doxygen 1.6.1