VCLib Documentation  6.12.2

RLC Features

RLC Features

Modules

 RLC Moments
 

Functions

void rlc_feature (feature *f, U16 *rlc, I32 color)
 Calculate Compound Features in Unlabelled Run Length Code (RLC). More...
 
I32 rl_ftr2 (U16 *rlc, ftr *f, U32 n)
 Calculate Object Features in the Labelled RLC. More...
 
I32 rl_ftr3 (U16 *rlc, ftr *f, U32 n)
 Calculate Object Features in the Labelled RLC (Subpixel Version). More...
 
I32 rlc_feret (U16 *src, F32 alpha, F32 *fer)
 Calculate Feret Diameters of all Objects in Labelled RLC. More...
 
I32 rlc_minmax_feret (U16 *pRlc, I32 nsteps, F32 fMinAngleRad, F32 fMaxAngleRad, F32 *minferets, F32 *minangles, F32 *maxferets, F32 *maxangles)
 Calculate Minimum and Maximum Ferets for All Objects in Labelled RLC. More...
 

Detailed Description

For a description see the section Features.

Function Documentation

◆ rlc_feature()

void rlc_feature ( feature f,
U16 rlc,
I32  color 
)

The function calculates features in the unlabelled RLC. The parameter color can be used to specify if the features for all black (color = 0) or all white (color = 0xFFFF) pixels of the RLC should be calculated. All pixels of a given color (black or white) are included. There is no differentiation according to objects. The following features are calculated:

  • area: Pixel Count of the chosen Color.
  • x_center: x-Coordinate of the Center of Gravity.
  • y_center: y-Coordinate of the Center of Gravity.
  • x_min: Smallest x Coordinate (Bounding Box).
  • x_max: Largest x Coordinate (Bounding Box).
  • y_min: Smallest y Coordinate (Bounding Box).
  • y_max: Largest y Coordinate (Bounding Box, Contour Point Y).
  • x_lst: Last x-coordinate in the last line (Contour Point X).

The maximum and minimum values of x and y define the bounding box around the pixels chosen with color. rlc is the start address of the run length code in memory. f is a pointer to the feature list stored in the feature struct.

Memory Consumption
None.
See also
feature, rlc_area(), rl_ftr2().

◆ rl_ftr2()

I32 rl_ftr2 ( U16 src,
ftr f,
U32  n 
)

The function calculates object features of all objects in the labelled RLC. The following features are calculated:

  • area: Pixel Count.
  • x_center: x-Coordinate of the Center of Gravity.
  • y_center: y-Coordinate of the Center of Gravity.
  • x_min: Smallest x Coordinate (Bounding Box).
  • x_max: Largest x Coordinate (Bounding Box).
  • y_min: Smallest y Coordinate (Bounding Box).
  • y_max: Largest y Coordinate (Bounding Box, Contour Point Y).
  • x_lst: Last x-coordinate in the last line (Contour Point X).
  • x_lst: Last x-coordinate in the last line (Contour Point X).
  • color: Color (0=Black, 0xFFFF=White).

The maximum and minimum values of x and y define the bounding box around the chosen object. The object pixels are guaranteed to be contiguous. The coordinates (x_lst, y_max) specify a point which can serve as the initial value for contour following. Please make sure, that the connectedness of the object labelling (e.g. sgmt()) corresponds to the contour following algorithm. rlc is the start address of the labelled run length code in memory. f is a pointer to the feature list, ftr as struct array, n is the maximum number of objects, i.e. usually the dimension of the struct array. A pointer to the struct array is passed to this function. The pointer need not be initialized before you call this function. The struct array is provided with the correct features of all objects after the function is called.

The return value of the function is the number of objects in the labelled RLC.

See also
rl_area2(), rlc_feature().
Memory Consumption
None.
Return values
ERR_SLCif RLC is Unlabelled.
ERR_RLC_ONOVRif an Object Number Overrun occured.
Object Counton Success.

◆ rl_ftr3()

I32 rl_ftr3 ( U16 src,
ftr f,
U32  n 
)

The function calculates object features of all objects in the labelled RLC. The following features are calculated:

  • area: Pixel Count.
  • x_center: x-Coordinate of the Center of Gravity.
  • y_center: y-Coordinate of the Center of Gravity.
  • x_cf: x-Coordinate of the Center of Gravity (Subpixel accurate).
  • y_cf: y-Coordinate of the Center of Gravity (Subpixel accurate).
  • x_min: Smallest x Coordinate (Bounding Box).
  • x_max: Largest x Coordinate (Bounding Box).
  • y_min: Smallest y Coordinate (Bounding Box).
  • y_max: Largest y Coordinate (Bounding Box, Contour Point Y).
  • x_lst: Last x-coordinate in the last line (Contour Point X).
  • color: Color (0=Black, 0xFFFF=White).

The maximum and minimum values of x and y define the bounding box around the chosen object. The object pixels are guaranteed to be contiguous. The coordinates (x_lst, y_max) specify a point which can serve as the initial value for contour following. Please make sure, that the connectedness of the object labelling (e.g. sgmt()) corresponds to the contour following algorithm.

In contrast to function rl_ftr2() which calculates the center of gravity only with pixel resolution, the function rl_ftr3() calculates it also in subpixel resolution and places the result in two additional variables in the data structure which are not used otherwise. rlc is the start address of the labelled run length code in memory. f is a pointer to the feature list (here: a struct array), n is the maximum number of objects, i.e. usually the dimension of the struct array. The struct used has the following structure:

typedef struct {
U32 area; // object area
U32 x_center; // x_center - normalized
U32 y_center; // y_center - normalized
I32 x_min; // x_min
I32 x_max; // x_max
I32 y_min; // y_min
I32 y_max; // y_max
I32 x_lst; // last x
I32 color; // object color 0 = black
float x_cf; // x_center, normalized, float
float y_cf; // y_center, normalized, float
} ftr;

A pointer to the struct array is passed to this function. The pointer need not be initialized before you call this function. The struct array is provided with the correct features of all objects after the function is called.

The function returns the standard error code or, if no error occurred, the number of objects in the labelled RLC.

Memory Consumption
None.
See also
rl_area2(), rlc_feature(), rl_ftr2().
Return values
ERR_SLCif RLC is Unlabelled.
ERR_RLC_ONOVRif Object Count exceeds n, or is Invalid.
Object CountCount of Objects in the Labelled RLC.

◆ rlc_feret()

I32 rlc_feret ( U16 src,
float  alpha,
float *  fer 
)
feret.png

The function calculates the feret diameter for all objects and the projection of all objects with respect to angle alpha. The feret diameter is the size of the projection of the object into a certain angular direction, comparable to the measurement with a caliper held in that direction. For this purpose, the boundary of the object is projected into the direction alpha. The feret diameters of all objects is output as an array of float values.

The float array for the result (pointer fer) must have a size of at least nobj elements. (nobj = number of objects in RLC/SLC)

Parameters
srcLabelled Source RLC.
alphaThe projection angle in rad [0..PI].
ferThe result array pointer (size = nobj elements).
Memory Consumption
None.
See also
rlc_minmax_feret().
Return values
ERR_SLCif RLC is unlabelled.
ERR_RLC_ONOVRif SLC object count is inappropriate.
ERR_MEMORYif internal feret list cannot be allocated.
ERR_NONEon success.

◆ rlc_minmax_feret()

I32 rlc_minmax_feret ( U16 pRlc,
I32  nsteps,
float  fMinAngleRad,
float  fMaxAngleRad,
float *  minferets,
float *  minangles,
float *  maxferets,
float *  maxangles 
)
feret.png

The function calculates the feret diameter for all objects. The feret diameter is the size of the projection of the object into a certain angular direction, comparable to the measurement with a caliper held in that direction. For this purpose, the boundary of the object is projected into the direction of nsteps angles in the range of [fMinAngleRad .. fMaxAngleRad). The feret diameters of all objects are output as arrays of float values.

Unlike the function rlc_feret(), the function rlc_minmax_feret() calculates the minimum and maximum feret diameters for all objects. This is done by calling the function rlc_feret() nsteps times and sweeping the projection angle starting at angle = fMinAngleRad incresing angle from step to step by delta = (fMaxAngleRad - fMinAngleRad)/nsteps.

In addition to the minimum and maximum diameters, the angles where the maximum and minimum were detected are also provided for earch object.

The float arrays for the result ferets and angles must have a size of at least nobj elements each. (nobj = number of objects in RLC/SLC)

All angles are in rad.

Parameters
pRlcLabelled Source RLC.
nstepsnumber of steps for feret calculation (angular resolution)
fMinAngleRadthe minimum angle for the interation [rad].
fMaxAngleRadthe maximum angle for the interation [rad].
minferetsresult array pointer for minimum feret or NULL.
minanglesresult array pointer for minimum angle or NULL.
maxferetsresult array pointer for maximum feret or NULL.
maxanglesresult array pointer for maximum angle or NULL.
Memory Consumption
None.
See also
rlc_feret().
Return values
ERR_SLCfor unlabelled RLC.
ERR_SLC_INCONif SLC object count is inappropriate.
ERR_PARAMfor fMinAngleRad >= fMaxAngleRad.
ERR_PARAMfor fMinAngleRad < -PI.
ERR_PARAMfor fMinAngleRad >= 2*PI.
ERR_MEMORYif out ou memory.