Main Page   Modules   Alphabetical List   Compound List   Compound Members  

1D function


Functions

cpl_1dfunction * cpl_1dfunction_new (int n)
 Create a new cpl_1dfunction. More...

cpl_1dfunction * cpl_1dfunction_duplicate (cpl_1dfunction *in)
 Duplicate a cpl_1dfunction. More...

void cpl_1dfunction_delete (cpl_1dfunction *f)
 Delete a cpl_1dfunction. More...

void cpl_1dfunction_dump (cpl_1dfunction *f, FILE *out)
 Dump a cpl_1dfunction in a file or stdout. More...

cpl_1dfunction * cpl_1dfunction_read (char *filename)
 Read a list of points from an ASCII file, create cpl_1dfunction. More...

int cpl_1dfunction_size (cpl_1dfunction *in)
 Get the size of the function. More...

cpl_vector * cpl_1dfunction_get_x (cpl_1dfunction *in)
 Get a pointer to the x vector of the function. More...

cpl_vector * cpl_1dfunction_get_y (cpl_1dfunction *in)
 Get a pointer to the y vector of the function. More...

double * cpl_1dfunction_get_x_data (cpl_1dfunction *in)
 Get a pointer to the x data part of the function. More...

double * cpl_1dfunction_get_y_data (cpl_1dfunction *in)
 Get a pointer to the y data part of the function. More...

double cpl_1dfunction_centroid (cpl_1dfunction *f)
 Find out a function centroid to subpixel precision. More...

double cpl_1dfunction_locmax (cpl_1dfunction *f, int where, int hs)
 Find out a local maximum in a function around a position. More...

cpl_error_code cpl_1dfunction_interpolate_linear (cpl_1dfunction *f1, cpl_1dfunction *f2)
 Linear functions interpolation. More...

cpl_error_code cpl_1dfunction_natural_spline (cpl_1dfunction *f1, cpl_1dfunction *f2)
 Interpolate a function along new abscissas. More...

double cpl_1dfunction_xcorrelate (cpl_1dfunction *f1, cpl_1dfunction *f2, int half_search, double *delta)
 Cross-correlation of two functions. More...

cpl_1dfunction * cpl_1dfunction_gen_rect_poisson (const int *r, const int np, const int homog)
 Generate points with a Poisson scattering property in a rectangle. More...


Detailed Description

This module provides functions to handle cpl_1dfunction.

A cpl_1dfunction is composed of two vectors of the same size, the first one containing the x-coordinates and the second ond the y-coordinates of the signal (or function). This module provides the possibility to compute a local maximum, to cross-correlate two signals, etc... The cpl_1dfunction can also be used to store lists of offsets (in x and y) or any list of points positions in an image.

Synopsis:
   #include "cpl_1dfunction.h"

Define Documentation

#define RANDOM_INITIALIZE_CHK
 

Value:

do if (random_initialized==0) \
  { \
     srand48((long)(getenv("CPL_SRAND_CONST") != NULL ? 1 : getpid())) ; \
     random_initialized = 1 ; \
  } while (0)


Function Documentation

double cpl_1dfunction_centroid cpl_1dfunction *    f
 

Find out a function centroid to subpixel precision.

Parameters:
f  a 1d function
Returns:
Centroid position as a double.
The position of the peak is located to subpixel precision by simply weighting positions with values as indicated here :

In case of error, the _cpl_error_code_ code is set, and the returned double is undefined.

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT
  • CPL_ERROR_DIVISION_BY_ZERO

void cpl_1dfunction_delete cpl_1dfunction *    f
 

Delete a cpl_1dfunction.

Parameters:
f  cpl_1dfunction to delete
Returns:
void

void cpl_1dfunction_dump cpl_1dfunction *    f,
FILE *    out
 

Dump a cpl_1dfunction in a file or stdout.

Parameters:
f  cpl_1dfunction to dump
out  File where the cpl_1dfunction is written
Returns:
void
Dump a function in a file specified by the second parameter. It accepts stdout or stderr.

cpl_1dfunction* cpl_1dfunction_duplicate cpl_1dfunction *    in
 

Duplicate a cpl_1dfunction.

Parameters:
in  cpl_1dfunction to duplicate
Returns:
1 newly allocated cpl_1dfunction or NULL in error case
The returned object must be deallocated using cpl_1dfunction_delete()

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT

cpl_1dfunction* cpl_1dfunction_gen_rect_poisson const int *    r,
const int    np,
const int    homog
 

Generate points with a Poisson scattering property in a rectangle.

Parameters:
r  Array of 4 integers as [xmin,xmax,ymin,ymax]
np  Number of points to generate.
homog  Homogeneity factor.
Returns:
Newly allocated cpl_1dfunction object or NULL in error case
The returned object must be deallocated using cpl_1dfunction_delete().

POISSON POINT GENERATION

Without homogeneity factor, the idea is to generate a set of np points within a given rectangle defined by (xmin xmax ymin ymax). All these points obey a Poisson law, i.e. no couple of points is closer to each other than a minimal distance. This minimal distance is defined as a function of the input requested rectangle and the requested number of points to generate. We apply the following formula:

Where W and H stand for the rectangle width and height. Notice that the system in which the rectangle vertices are given is completely left unspecified, generated points will have coordinates in the specified x and y ranges.

With a specified homogeneity factor h (0 < h <= np), the generation algorithm is different.

the Poisson law applies for any h consecutive points in the final output, but not for the whole point set. This enables us to generate groups of points which statisfy the Poisson law, without constraining the whole set. This actually is equivalent to dividing the rectangle in h regions of equal surface, and generate points randomly in each of these regions, changing region at each point.

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT

cpl_vector* cpl_1dfunction_get_x cpl_1dfunction *    in
 

Get a pointer to the x vector of the function.

Parameters:
in  a function
Returns:
Pointer to the x vector or NULL in error case
The returned pointer refers to already allocated data.

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT

double* cpl_1dfunction_get_x_data cpl_1dfunction *    in
 

Get a pointer to the x data part of the function.

Parameters:
in  a function
Returns:
Pointer to the double x array or NULL in error case
The returned pointer refers to already allocated data.

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT

cpl_vector* cpl_1dfunction_get_y cpl_1dfunction *    in
 

Get a pointer to the y vector of the function.

Parameters:
in  a function
Returns:
Pointer to the y vector or NULL in error case
The returned pointer refers to already allocated data.

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT

double* cpl_1dfunction_get_y_data cpl_1dfunction *    in
 

Get a pointer to the y data part of the function.

Parameters:
in  a function
Returns:
Pointer to the double y array or NULL in error case
The returned pointer refers to already allocated data.

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT

cpl_error_code cpl_1dfunction_interpolate_linear cpl_1dfunction *    f1,
cpl_1dfunction *    f2
 

Linear functions interpolation.

Parameters:
f1  Input function
f2  Interpolated function
Returns:
the _cpl_error_code_ or CPL_ERROR_NONE
To apply this interpolation, you need to provide a reference cpl_1dfunction f1 and a cpl_1dfunction f2 with only the x fields (where you want the interpolation to be done). The y values of f2 are computed frome the y values of f1 with a linear nterpolation.

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT

double cpl_1dfunction_locmax cpl_1dfunction *    f,
int    where,
int    hs
 

Find out a local maximum in a function around a position.

Parameters:
f  1d function
where  Centre of search domain
hs  Half-size of the search domain
Returns:
Local maximum position as a double. Negative value in error case
The closest local maximum to the given position is located to subpixel precision. This precision is achieved by simply weighting positions with values. The 'where' indice indicates where to look for a maximum (it must lie between 0 and the number of points-1 inclusive). The 'hs' parameter indicates the half-size of the search domain, i.e. if where=3 and hs=2 a local maximum will be searched among the pixels 1, 2, 3, 4, 5.

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT
  • CPL_ERROR_DIVISION_BY_ZERO

cpl_error_code cpl_1dfunction_natural_spline cpl_1dfunction *    f1,
cpl_1dfunction *    f2
 

Interpolate a function along new abscissas.

Parameters:
f1  Input cpl_1dfunction
f2  Interpolated cpl_1dfunction
Returns:
the _cpl_error_code_ or CPL_ERROR_NONE
Reference: Numerical Analysis, R. Burden, J. Faires and A. Reynolds. Prindle, Weber & Schmidt 1981 p 112

Provide in input a complete function, and a function with only x positions. The y values are computed by interpolation.

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT

cpl_1dfunction* cpl_1dfunction_new int    n
 

Create a new cpl_1dfunction.

Parameters:
n  Number of points of the function
Returns:
1 newly allocated cpl_1dfunction or NULL in error case
The returned object must be deallocated using cpl_1dfunction_delete().

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_ILLEGAL_INPUT

cpl_1dfunction* cpl_1dfunction_read char *    filename
 

Read a list of points from an ASCII file, create cpl_1dfunction.

Parameters:
filename  Name of the input ASCII file
Returns:
1 newly allocated cpl_1dfunction or NULL in error case
Parse an input ASCII file values and fill a newly created cpl_1dfunction with it. Lines beginning with a hash are ignored, blank lines also. The returned object must be deallocated using cpl_1dfunction_delete().

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_FILE_IO

int cpl_1dfunction_size cpl_1dfunction *    in
 

Get the size of the function.

Parameters:
in  the input function
Returns:
The size or -1 in error case
Possible _cpl_error_code_ set in this function:
  • CPL_ERROR_NULL_INPUT

double cpl_1dfunction_xcorrelate cpl_1dfunction *    f1,
cpl_1dfunction *    f2,
int    half_search,
double *    delta
 

Cross-correlation of two functions.

Parameters:
f1  Reference function
f2  Candidate function to compare
half_search  Half-size of the search domain.
delta  Output correlation offset.
Returns:
Maximum cross-correlation offset value as a double.
Two signals are expected as input to this function: a reference signal and a candidate signal. They are expected to be roughly the same signal up to an offset. A cross-correlation is computed on 2*half_search+1 values. The maximum of likelihood is the maximum cross-correlation value between signals. The offset corresponding to this position is returned. In case of error, the _cpl_error_code_ code is set, and the returned double is undefined.

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT


Generated on Mon May 24 14:58:04 2004 for Common Pipeline Library Reference Manual by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002