ifw-odp  2.0.0-alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
Unit Testing Tools

Functions

void clipm_testlib_array_dump (const cpl_array *array, const char *name)
 Dump an array to stdout. More...
 
cpl_image * clipm_testlib_image_create_invalid (cpl_size xsize, cpl_size ysize)
 Create an image of type CPL_TYPE_INVALID. More...
 
cpl_matrix * clipm_testlib_generate_poisson_points (double xmin, double ymin, double xmax, double ymax, cpl_size homogeneity, cpl_size N, cpl_type type)
 Generate a list of N random points stored in a matrix. More...
 
cpl_image * clipm_testlib_image_create_gaussians (int xsize, int ysize, cpl_matrix *locations, cpl_type type, double weight, double sigma)
 Create an image containing a set of equal gaussian peaks. More...
 
cpl_error_code clipm_testlib_image_add_wgn (cpl_image *image, const cpl_size window_xxyy[4], double sigma, double noise_abs_limit)
 Add white gaussian noise to an image. More...
 
cpl_type clipm_testlib_ctype_2_cpltype (const char *ctype_str)
 Get CPL type from C-type identifier string. More...
 
const char * clipm_testlib_cpltype_2_literal (cpl_type type)
 Get CPL type as string. More...
 
int clipm_testlib_iterate_types_windows (int *iterator, cpl_type in_types_or, const cpl_size in_window_xxyy[4], const cpl_image *in_image, cpl_type *out_type, cpl_size **out_window_xxyy, cpl_image **out_image, cpl_size *out_ngoodpix)
 
cpl_error_code clipm_testlib_image_reject_pattern (cpl_image *img, const cpl_size window_xxyy[4], const char *pattern_name)
 Reject a pattern of pixels. More...
 
cpl_error_code clipm_testlib_image_reject_all (cpl_image *img, const cpl_size window_xxyy[4])
 Reject all pixels in image (window) More...
 
cpl_size clipm_testlib_image_count_bad (const cpl_image *img, const cpl_size window_xxyy[4])
 Count the bad pixels in an image (window). More...
 
cpl_size clipm_testlib_image_count_bad_wdw (const cpl_image *img, cpl_size x1, cpl_size y1, cpl_size x2, cpl_size y2)
 Count the bad pixels in an image (window). More...
 
cpl_image * clipm_testlib_image_conv_matrix (const cpl_image *img, const cpl_matrix *kernel, int extend_bpm)
 Simple reference convolution implementation. More...
 
cpl_error_code clipm_testlib_image_get_window_details (const cpl_image *img, const cpl_size window_xxyy[4], cpl_size ll[2], cpl_size ur[2], cpl_size size[2])
 Return the corners of a window and its size. More...
 
cpl_error_code _clipm_testlib_image_save_if_verbose (const cpl_image *img, const char *func, const char *identifier, int nr)
 Write an image to disk and print a message. More...
 

Detailed Description

Define here the tools used by more test programs.

Function Documentation

cpl_error_code _clipm_testlib_image_save_if_verbose ( const cpl_image *  img,
const char *  func,
const char *  identifier,
int  nr 
)

Write an image to disk and print a message.

Parameters
imgImage to write
funcFunction identifier string
identifier(Optional) user identifier string (short)
nr(Optional) number put at the end of the filename, omitted if < 0
Returns
CPL error code

The following error codes can occur:

  • CPL_ERROR_NULL_INPUT: img or func is NULL
void clipm_testlib_array_dump ( const cpl_array *  array,
const char *  name 
)

Dump an array to stdout.

Parameters
arrayArray
nameArray name
Returns
Nothing
const char* clipm_testlib_cpltype_2_literal ( cpl_type  type)

Get CPL type as string.

Parameters
type
Returns
String

The following strings can be returned:

  • type & CPL_TYPE_INT: "int"
  • type & CPL_TYPE_FLOAT: "float"
  • type & CPL_TYPE_DOUBLE: "double"
  • else: "invalid".
cpl_type clipm_testlib_ctype_2_cpltype ( const char *  ctype_str)

Get CPL type from C-type identifier string.

Parameters
ctype_str
Returns
The CPL type

The following types can be returned:

  • CPL_TYPE_INT if strcmp(ctype_str, "int") == 0,
  • CPL_TYPE_FLOAT if strcmp(ctype_str, "float") == 0,
  • CPL_TYPE_DOUBLE if strcmp(ctype_str, "double") == 0,
  • CPL_TYPE_INVALID else.

The following error codes can be set:

  • CPL_ERROR_INVALID_TYPE: ctype_str is not "int", "float" or "double"
  • CPL_ERROR_NULL_INPUT: ctype_str is NULL
Todo:
  • Modify unit tests to drop this function.
cpl_matrix* clipm_testlib_generate_poisson_points ( double  xmin,
double  ymin,
double  xmax,
double  ymax,
cpl_size  homogeneity,
cpl_size  N,
cpl_type  type 
)

Generate a list of N random points stored in a matrix.

Parameters
xminLeft limit
yminLower limit
xmaxRight limit
ymaxUpper limit
homogeneityHomogeneity factor
NNumber of points
typeOutput type, either CPL_TYPE_INT, or CPL_TYPE_DOUBLE
Returns
Matrix containing the 2-dimensional points in columns, NULL in the case of error.
See Also
clipm_math_rng_poisson_pointpattern_2d()
Error Handling:

The following error codes can be set and returned:

  • CPL_ERROR_ILLEGAL_INPUT: N <= 0
  • CPL_ERROR_INVALID_TYPE: type is not CPL_TYPE_DOUBLE or CPL_TYPE_INT
cpl_error_code clipm_testlib_image_add_wgn ( cpl_image *  image,
const cpl_size  window_xxyy[4],
double  sigma,
double  noise_abs_limit 
)

Add white gaussian noise to an image.

Parameters
imageImage
window_xxyy(Optional) Coordinate buffer of the form {xa, xb, ya, yb}, can be NULL, minimum/maximum order is irrelevant
sigmaNoise sigma
noise_abs_limit(Optional) limit to prevent infinite numbers, ignored if < 0
Returns
CPL error code
Bad Pixel Handling:
Bad pixels are ignored (the data buffer is not modified at these locations).
Error Handling:
  • CPL_ERROR_NULL_INPUT: image is NULL
  • CPL_ERROR_INVALID_TYPE: image is not of type CPL_TYPE_INT, CPL_TYPE_FLOAT or CPL_TYPE_DOUBLE
  • CPL_ERROR_ACCESS_OUT_OF_RANGE: window_xxyy specifies coordinates outside the image plane
cpl_image* clipm_testlib_image_conv_matrix ( const cpl_image *  img,
const cpl_matrix *  kernel,
int  extend_bpm 
)

Simple reference convolution implementation.

Parameters
imgInput image
kernelConvolution kernel
extend_bpmFlag whether to extend the bad pixel map
Returns
Output image of type CPL_TYPE_DOUBLE, NULL in the case of error
Error Handling:
The following errors can occur:
  • CPL_ERROR_NULL_INPUT: img or kernel is NULL
  • CPL_ERROR_ILLEGAL_INPUT:
    • the size of kernel is not odd
    • the sum of the kernel is close to zero and extend_bpm == false
cpl_size clipm_testlib_image_count_bad ( const cpl_image *  img,
const cpl_size  window_xxyy[4] 
)

Count the bad pixels in an image (window).

Parameters
imgInput image
window_xxyy(Optional) Coordinate buffer of the form {xa, xb, ya, yb}, can be NULL, minimum/maximum order is irrelevant
Returns
Number of rejected pixels, -1 in the case of error.
Error Handling:
The following error codes can occur:
  • CPL_ERROR_NULL_INPUT: img is NULL
  • CPL_ERROR_ACCESS_OUT_OF_RANGE: a window coordinate is outside the image range
cpl_size clipm_testlib_image_count_bad_wdw ( const cpl_image *  img,
cpl_size  x1,
cpl_size  y1,
cpl_size  x2,
cpl_size  y2 
)

Count the bad pixels in an image (window).

Parameters
imgInput image
window_xxyy(Optional) Coordinate buffer of the form {xa, xb, ya, yb}, can be NULL, minimum/maximum order is irrelevant
Returns
Number of rejected pixels, -1 in the case of error.
Error Handling:
The following error codes can occur:
  • CPL_ERROR_NULL_INPUT: img is NULL
  • CPL_ERROR_ACCESS_OUT_OF_RANGE: a window coordinate is outside the image range
cpl_image* clipm_testlib_image_create_gaussians ( int  xsize,
int  ysize,
cpl_matrix *  locations,
cpl_type  type,
double  weight,
double  sigma 
)

Create an image containing a set of equal gaussian peaks.

Parameters
xsizeHorizontal image size
ysizeVertical image size
locations2xN matrix containing the centre positions of the peaks in columns
typeCPL image type
weightGaussian peak weight (respectively)
sigmaGaussian peak sigma
Returns
The image containing peaks, NULL in the case of error
Error Handling:

The following error codes can be set:

  • CPL_ERROR_NULL_INPUT: locations = NULL
  • CPL_ERROR_ILLEGAL_INPUT: xsize < 1, or ysize < 1, or the number of rows in locations is not 2
  • CPL_ERROR_INVALID_TYPE: type is not CPL_TYPE_INT, CPL_TYPE_FLOAT, or CPL_TYPE_DOUBLE
cpl_image* clipm_testlib_image_create_invalid ( cpl_size  xsize,
cpl_size  ysize 
)

Create an image of type CPL_TYPE_INVALID.

Parameters
xsizeHorizontal size
ysizeVertical size
Returns
CPL image of type CPL_TYPE_INVALID containing an array of chars.

If xsize < 1 or ysize < 1, CPL_ERROR_ILLEGAL_INPUT is set and NULL is returned.

cpl_error_code clipm_testlib_image_get_window_details ( const cpl_image *  img,
const cpl_size  window_xxyy[4],
cpl_size  ll[2],
cpl_size  ur[2],
cpl_size  size[2] 
)

Return the corners of a window and its size.

Parameters
imgInput image
window_xxyy(Optional) Coordinate buffer of the form {x1a, x1b, y1a, y1b}, can be NULL, minimum/maximum order is irrelevant
ll(Optional output) lower left corner (buffer of size 2)
ur(Optional output) upper right corner (buffer of size 2)
size(Optional output) window size (buffer of size 2)
Returns
CPL error code
Error Handling:
The following errors can occur:
  • CPL_ERROR_NULL_INPUT: img is NULL
  • CPL_ERROR_ACCESS_OUT_OF_RANGE: a window coordinate is outside the image range
In the case of error, the output values are left unchanged.
cpl_error_code clipm_testlib_image_reject_all ( cpl_image *  img,
const cpl_size  window_xxyy[4] 
)

Reject all pixels in image (window)

Parameters
imgInput image
window_xxyy(Optional) Coordinate buffer of the form {x1a, x1b, y1a, y1b}, can be NULL, minimum/maximum order is irrelevant
Returns
CPL error code
Error Handling:
The following errors can occur:
  • CPL_ERROR_NULL_INPUT: img is NULL
cpl_error_code clipm_testlib_image_reject_pattern ( cpl_image *  img,
const cpl_size  window_xxyy[4],
const char *  pattern_name 
)

Reject a pattern of pixels.

Parameters
Inputimage
window_xxyy(Optional) Coordinate buffer of the form {xa, xb, ya, yb}, can be NULL, minimum/maximum order is irrelevant
pattern_nameString containing the pattern's name
Returns
CPL error code
int clipm_testlib_iterate_types_windows ( int *  iterator,
cpl_type  in_types_or,
const cpl_size  in_window_xxyy[4],
const cpl_image *  in_image,
cpl_type *  out_type,
cpl_size **  out_window_xxyy,
cpl_image **  out_image,
cpl_size *  out_ngoodpix 
)