Functions | |
U16 * | rlcmk (image *a, I32 thr, U16 *rlc, I32 size) |
Creates Run Length Code from Pixel Images. More... | |
U16 * | rlcmk2 (image *src, I32 lowthr, I32 hithr, U16 *rlc, I32 size) |
Creates Run Length Code from Pixel Images Using 2 Thresholds. More... | |
U16 * | rlcmkv (image *src, I32 thr, U16 *rlc, I32 size) |
Creates Vertical Run Length Code from Pixel Images. More... | |
U16 * | rlcmkbit (image *a, I32 bit, U16 *rlc, I32 size) |
Creates Run Length Code of a Bitplane from a Pixel Image. More... | |
U16 * | rlcmk_sub (image *a, image *b, I32 thr, U16 *rlc, I32 size) |
Subtract 2 Images and Create Run Length Code from Difference Image. More... | |
U16 * | hysteresis_RLC (image *src, U16 *rlc, I32 size, I32 thr, I32 seed) |
Creates RLC Based on Canny Type Hysteresis Thresholding Binarization. More... | |
I32 | rlcout (image *a, U16 *rlc, U32 dark, U32 bright) |
Outputs Run Length Code to a Pixel Image. More... | |
I32 | rlcout_transparent (image *a, U16 *rlc, U8 plotBrightIff1, U8 color) |
Outputs Run Length Code to a Pixel Image (Transparent Mode). More... | |
I32 | rlcout_pixellist (I32 *lstPx, I32 *lstPxCnt, I32 lstPxMaxCnt, U16 colIn, U16 *rlc) |
Outputs Run Length Code to a Pixel List. More... | |
I32 | dispobj (image *a, U16 *rlc) |
Outputs Labelled Run Length Code with Objects in different Grey Values. More... | |
I32 | rlc_mask_image (image *src, image *dst, U16 *rlc, I32 *objs, U8 color, I32 offsetX, I32 offsetY) |
Fills Regions of selected RLC Objects in Pixel Image with Color. More... | |
I32 | vc_slc_out (image *img, U8 ch, U16 *rlc, U32 *lstColOfObj, I32 oneObjNrOrNegative, I32 oneObjCol, I32 oneObjColBg) |
Outputs SLC Object(s) to a channel of an image. More... | |
void | vc_slc_print (U16 *rlc, U16 *slc, I32 indent) |
Prints out SLC Objects aligned to RLC. More... | |
void | vc_slc_print_px (U16 *rlc, U16 *slc, I32 indent) |
Prints out SLC Objects Pixel by Pixel. More... | |
U16 * | rlc2 (U16 *rlca, U16 *rlcb, U16 *dest, U16 *(*func)()) |
Logically Linking of Two Images in Run Length Code (RLC). More... | |
U16 * | rlc_inv (U16 *rlc) |
In-Place Inversion of RLC. More... | |
U16 * | rlc_move (U16 *src, U16 *dst, I32 mx, I32 my) |
Translate RLC. More... | |
U16 * | rlc_cutframe (U16 *src, U16 *dst, I32 dxDst, I32 dyDst, I32 mx, I32 my) |
Translate RLC and adjust image size to different RLC format. More... | |
U16 * | rlc90 (U16 *src, U16 *dst, I32 size) |
Rotate Run Length Code by 90 Degrees. More... | |
U16 * | rlc180 (U16 *src, U16 *dst) |
Rotate Run Length Code by 180 Degrees. More... | |
U16 * | rlc_mirrorH (U16 *src, U16 *dst) |
Mirror RLC horizontally. More... | |
U16 * | rlc_mirrorV (U16 *src, U16 *dst) |
Mirror RLC vertically. More... | |
I32 | rlc_shear_x (U16 *src, U16 *dst, I32 shearDx) |
Shears Run Length Code in Horizontal Direction. More... | |
U16 * | erxdi (U16 *src, U16 *dst, U16 *(*fc1)(), U16 *(*fc2)()) |
Square shaped Erosion/Dilation of Run Length Code. More... | |
U16 * | erxdi2 (U16 *src, U16 *dst, U16 *(*fc1)(), U16 *(*fc2)()) |
Diamond shaped Erosion/Dilation of Run Length Code (RLC). More... | |
U16 * | rlc_mf (U16 *src, U16 *dst, I32 col, I32 lng) |
Horizontal 'median filter' for RLC. More... | |
U32 | rlc_area (U16 *rlc, I32 color) |
Count of Identically Coloured Pixels at Unlabelled Run Length Code (RLC). More... | |
U16 * | fread_rlc (char *path, U16 *rlc) |
Reads (unlabelled) RLC from File. More... | |
I32 | fwrite_rlc (char *path, U16 *rlc) |
Writes (unlabelled) RLC to File. More... | |
U16 * | rlc_label_fast (U16 *rlc, U16 *rlcEnd, U16 *slc, I32 mode) |
Segment Run Length Code (Object Labelling) Sped up for Small Images. More... | |
U16 * | rlc_label (U16 *rlc, U16 *slc, I32 mode) |
Segment Run Length Code (Object Labelling). More... | |
U16 * | rlc_cut (U16 *src, U16 *dst, I32 objnum) |
Extract an Object out of the Labelled RLC. More... | |
I32 | rl_area2 (U16 *rlc, U32 *area, U32 n) |
Calculate the Object Areas in the Labelled RLC. More... | |
I32 | rlc_qin (U16 *rlc, I32 QIN[], U32 n) |
Object Inclusion Property for Labelled RLC. More... | |
I32 | rlc_nhls (U16 *rlc, U32 holes[], U32 n) |
Number of Holes Property for Labelled RLC. More... | |
I32 | rlc_arf (U16 *src, U16 *dst, U32 min_area) |
RLC Object Area Filter for Small Objects (works on labelled RLC). More... | |
I32 | rlc_arf2 (U16 *src, U16 *dst, I32 col, U32 min_area, U32 max_area) |
RLC Object Area Filter using Minimum and Maximum Area.. More... | |
I32 | rlc_select (U16 *rlc, U16 *rlc2, I32 selector[], U32 n, I32 mode) |
RLC Object Selection with Guide Image. More... | |
I32 | rlc_select_by_polygon_simple (U16 *rlc, I32 *xyLst, U32 xyCnt, I32 *selector, U32 maxSelector) |
RLC Object Selection by Simple Polygon. More... | |
U16 * | rlc_delete (U16 *src, U16 *dst, I32 keep[]) |
Delete RLC Objects using a Selection List. More... | |
I32 | rlc_getobject (U16 *rlc, I32 x, I32 y) |
RLC object number retrieval using image coordinates within an input RLC. More... | |
I32 | rlc_keep_object (U16 *src, U16 *dst, I32 x, I32 y) |
RLC Extract an object from labelled RLC using x,y-coordinates. More... | |
U16 * | rlcmk_seed (image *src, U16 *seed, U16 *rlc, I32 thresh, I32 size, I32 mode) |
Make RLC using seed RLC. More... | |
U16 * | rlcmk_seed2 (image *src, U16 *seed, U16 *rlc, I32 thr1, I32 thr2, I32 size, I32 mode) |
Make RLC using seed RLC using a high and a low threshold. More... | |
U16 * | rlcand_slc (U16 *rlca, U16 *slca, U16 *rlcb, U16 *rlcOut, U16 *slcOut, I32 *newObjNrOrNULL) |
Logically Anding of Two Images in Run Length Code, preserving SLC Objects. More... | |
U16 * | rlc_zoom (U16 *src, U16 *dst, I32 magX, I32 magY) |
Zoom up RLC. More... | |
I32 | rlc_rect (U16 *rlc, U16 rlcDx, U16 rlcDy, I32 rlcMaxBytes, U16 x0, U16 y0, U16 x1, U16 y1, U16 col) |
Generates a RLC image with a Rectangle at it. More... | |
U16 * | rlc_drawline (U16 *rlc, U16 rlcDx, U16 rlcDy, float cx, float cy, float b, I32 col) |
Draws a Line in Normalized Floatingpoint Form into RLC. More... | |
U16 * | rlc_drawlinesegment (U16 *rlc, U16 rlcDx, U16 rlcDy, I32 x0In, I32 y0In, I32 x1In, I32 y1In, I32 col) |
Draws a Line into RLC. More... | |
I32 | rlc_draw_polygon (U16 *rlcOut, U16 rlcDx, U16 rlcDy, I32 *pi32PxLst, U32 u32CornerCount, I32 col) |
Draws a Polyline Contour. More... | |
I32 | rlc_fill_polygons_simple (U16 *rlc, U16 rlcDx, U16 rlcDy, U32 rlcMaxBytes, U32 lstCnt, I32 *xyLst, U32 *xyCnt) |
I32 | rlc_objectaverage (image *src, U16 *rlc, U32 *average, U32 n) |
RLC feature: grey value average of RLC objects in image variable. More... | |
I32 | rlc_objectmaxval (U32 *lstObjMaxVal, image *src, U8 ch, U16 *rlc, U16 *slcOrNULL) |
Gets Maximum Value of each SLC Object. More... | |
U16 * | testrlc (U16 *rlc, I32 dx, I32 dy, I32 size) |
Generates a RLC Test Image (Chessboard). More... | |
I32 | chkrlc (U16 *rlc) |
Checks for Errors in Labelled or Unlabelled RLC. More... | |
U16 * | parse_rlc (U16 *rlc) |
Returns the Next Available Address by Parsing (unlabelled) RLC. More... | |
void | vc_clc_print (U16 *rlc, U16 *clc, I32 indent) |
Prints out CLC aligned with RLC. More... | |
void | vc_clc_print_px (U16 *rlc, U16 *clc, I32 indent) |
Prints out CLC Color Pixel by Pixel. More... | |
U16 * | vc_clcmk (image *src, I32 thr, U16 *rlc, U16 *clc, U16 colCircularMax, U16 colBg, I32 fastModeIff1, I32 rlcMaxBytes) |
Color Run Length Code (CLC) generation. More... | |
U16 * | vc_clc_label (U16 *rlc, U16 *rlcEnd, U16 *clc, U16 *slc, I32 mode) |
Segment Color Length Code (Object Labelling). More... | |
I32 | vc_cyclic_colrange (U16 *colRangeLen, U16 *colRangeSt, U8 *wrapsIff1, U16 objRef, U16 *colOfObj, I32 colCircularMax, I32 colBg, U32 *eqv_tbl, U16 objCnt) |
Get Color Range over Equivalent Objects. More... | |
I32 | vc_clc_merge_objs_by_colTol (U16 *rlcOut, U16 *clcOut, U16 *slcOut, U16 *rlc, U16 *clc, U16 *slc, I32 maxColTol, I32 mergedMaxColTol) |
Merge Objects of CLC by Color. More... | |
I32 | vc_clc_remove_objs_by_area (U16 *rlcOut, U16 *clcOut, U16 *slcOut, U16 *rlc, U16 *clc, U16 *slc, I32 minArea) |
Remove Objects of CLC by Area. More... | |
I32 | vc_clc_to_rgb (image *imgRgb, U16 *rlc, U16 *clc) |
Writes CLC Image Content to an RGB image. More... | |
I32 | fwrite_image_clc (char *path, U16 *rlc, U16 *clc) |
Writes CLC Image Content to a Color Bitmap File (BMP). More... | |
I32 | mask_polygon (image *psImgIn, image *psImgOut, U8 color, U32 u32CornerCount, I32 *pi32PxLst, U8 u8OutputSizeToSelectionIff1) |
Masks All but a Polygon Shaped Image Region. More... | |
U16 * | rlc_fill (U16 *rlc, I32 dx, I32 dy, I32 color) |
Generates a Single Coloured RLC. More... | |
#define | erode(a, b) erxdi(a, b, (U16 *(*)())rlc_xero, (U16 *(*)())rlc_orf) |
Erodes Run Length encoded Images using a Square Shape. More... | |
#define | dilate(a, b) erxdi(a, b, (U16 *(*)())rlc_xdil, (U16 *(*)())rlc_andf) |
Dilates Run Length encoded Images using a Square Shape. More... | |
#define | erode2(a, b) erxdi2(a, b, (U16 *(*)())rlc_xero, (U16 *(*)())rlc_orf) |
Erodes Run Length encoded Images using a Diamond Shape. More... | |
#define | dilate2(a, b) erxdi2(a, b, (U16 *(*)())rlc_xdil, (U16 *(*)())rlc_andf) |
Dilates Run Length encoded Images using a Diamond Shape. More... | |
#define | rlcand(a, b, c) rlc2(a, b, c, (U16 * (*)())rlc_andf ) |
Pixelwise AND of Two RLC Images (Macro). More... | |
#define | rlcor(a, b, c) rlc2(a, b, c, (U16 * (*)())rlc_orf ) |
Pixelwise OR of Two RLC Images (Macro). More... | |
#define | rlcxor(a, b, c) rlc2(a, b, c, (U16 * (*)())rlc_xorf ) |
Pixelwise XOR of Two RLC Images (Macro). More... | |
#define | rlcnand(a, b, c) rlc2(a, b, c, (U16 * (*)())rlc_nandf ) |
Pixelwise NAND of Two RLC Images (Macro). More... | |
#define | rlcnor(a, b, c) rlc2(a, b, c, (U16 * (*)())rlc_norf ) |
Pixelwise NOR of Two RLC Images (Macro). More... | |
#define | rlcequiv(a, b, c) rlc2(a, b, c, (U16 * (*)())rlc_equivf ) |
Pixelwise Equivalence Test Value of Two RLC Images (Macro). More... | |
#define | rlcandnot(a, b, c) rlc2(a, b, c, (U16 * (*)())rlc_andnotf) |
Pixelwise AND NOT of Two RLC Images (Macro). More... | |
#define | rlcornot(a, b, c) rlc2(a, b, c, (U16 * (*)())rlc_ornotf) |
Pixelwise OR NOT of Two RLC Images (Macro). More... | |
#define | rlcnandnot(a, b, c) rlc2(a, b, c, (U16 * (*)())rlc_nandnotf) |
Pixelwise NAND NOT of Two RLC Images (Macro). More... | |
#define | rlcnornot(a, b, c) rlc2(a, b, c, (U16 * (*)())rlc_nornotf) |
Pixelwise NOR NOT of Two RLC Images (Macro). More... | |
#define | rlc_copy(src, dst) rlc_move(src, dst, 0, 0) |
Copies RLC Code. More... | |
#define | label44(rlc, slc) rlc_label(rlc, slc, 0) /* white: 4-connected, black: 4-connected */ |
4/4-Type Segment Run Length Code (Object Labelling) (Macro). More... | |
#define | label88(rlc, slc) rlc_label(rlc, slc, 1) /* white: 8-connected, black: 8-connected */ |
8/8-Type Segment Run Length Code (Object Labelling) (Macro). More... | |
#define | label84(rlc, slc) rlc_label(rlc, slc, 2) /* white: 8-connected, black: 4-connected */ |
8/4-Type Segment Run Length Code (Object Labelling) (Macro). More... | |
#define | label48(rlc, slc) rlc_label(rlc, slc, 3) /* white: 4-connected, black: 8-connected */ |
4/8-Type Segment Run Length Code (Object Labelling) (Macro). More... | |
Functions in this group operate on run length encoded image data, for example functions doing erosion/dilation, blob generation, feature extraction and more.
rlc
refer to Run Length encoded Images (RLC). For a description of the SLC format of the (U16*) slc
refer to Segment Label Code (SLC). The pixelwise logical equivalence test value of the two RLC images a
and b
is written to RLC image dest
.
dest
must be different from a
and b
.
rlcequiv() is a macro which calls rlc2() with basic function rlc_equivf() as an argument.
The pixelwise logical AND NOT value of the two RLC images a
and b
is written to RLC image dest
.
dest
must be different from a
and b
.
rlcandnot() is a macro which calls rlc2() with basic function rlc_andnotf() as an argument.
The pixelwise logical OR NOT value of the two RLC images a
and b
is written to RLC image dest
.
dest
must be different from a
and b
.
rlcornot() is a macro which calls rlc2() with basic function rlc_ornotf() as an argument.
The pixelwise logical NAND NOT value of the two RLC images a
and b
is written to RLC image dest
.
dest
must be different from a
and b
.
rlcnandnot() is a macro which calls rlc2() with basic function rlc_nandnotf() as an argument.
The pixelwise logical NOR NOT value of the two RLC images a
and b
is written to RLC image dest
.
dest
must be different from a
and b
.
rlcnornot() is a macro which calls rlc2() with basic function rlc_nornotf() as an argument.
The macro erodes the image by one pixel using a square shape. Erosion means that all white areas in the RLC become one pixel wider in each direction, while all black areas are narrowed one pixel.
erode() is a macro which calls erxdi() with basic functions rlc_xero() and rlc_orf() as arguments.
See the documentation of the called function for further information.
The macro dilates the image by one pixel using a square shape. Dilation means that all black areas in the RLC become one pixel wider in each direction, while all white areas are narrowed one pixel.
dilate() is a macro which calls erxdi() with basic functions rlc_xdil() and rlc_andf() as arguments.
See the documentation of the called function for further information.
The macro erodes the image by one pixel using a diamond shape. Erosion means that all white areas in the RLC become one pixel wider in each direction, while all black areas are narrowed one pixel.
erode2() is a macro which calls erxdi2() with basic functions rlc_xero() and rlc_orf() as arguments.
See the documentation of the called function for further information.
The macro dilates the image by one pixel using a diamond shape. Dilation means that all black areas in the RLC become one pixel wider in each direction, while all white areas are narrowed one pixel.
dilate2() is a macro which calls erxdi2() with basic functions rlc_xdil() and rlc_andf() as arguments.
See the documentation of the called function for further information.
#define label44 | ( | rlc, | |
slc | |||
) | rlc_label(rlc, slc, 0) /* white: 4-connected, black: 4-connected */ |
Segments the run length encoded image in rlc
using the 4/4-connectedness model: White and black pixels connect to one object horizontally, vertically but not diagonally, Further information can be found at the main function rlc_label().
label44() is a macro which calls rlc_label() with mode=0
as an argument.
#define label88 | ( | rlc, | |
slc | |||
) | rlc_label(rlc, slc, 1) /* white: 8-connected, black: 8-connected */ |
Segments the run length encoded image in rlc
using the 8/8-connectedness model: White and black pixels connect to one object horizontally, vertically and diagonally, Further information can be found at the main function rlc_label().
label88() is a macro which calls rlc_label() with mode=1
as an argument.
#define label84 | ( | rlc, | |
slc | |||
) | rlc_label(rlc, slc, 2) /* white: 8-connected, black: 4-connected */ |
Segments the run length encoded image in rlc
using the 8/4-connectedness model: White pixels connect to one object horizontally, vertically and diagonally, Black pixels connect to one object horizontally, vertically but not diagonally. Further information can be found at the main function rlc_label().
label84() is a macro which calls rlc_label() with mode=2
as an argument.
#define label48 | ( | rlc, | |
slc | |||
) | rlc_label(rlc, slc, 3) /* white: 4-connected, black: 8-connected */ |
Segments the run length encoded image in rlc
using the 4/8-connectedness model: White pixels connect to one object horizontally, vertically but not diagonally, Black pixels connect to one object horizontally, vertically and diagonally. Further information can be found at the main function rlc_label().
label48() is a macro which calls rlc_label() with mode=3
as an argument.
#define rlc_copy | ( | src, | |
dst | |||
) | rlc_move(src, dst, 0, 0) |
The macro copies RLC code. The destination RLC must have been allocated.
rlc_copy() is a macro which calls rlc_zoom().
The function creates run length code (RLC) for the image variable a
and stores it in memory. thr
is the threshold value used for binarization, 0 ≤ thr
< 256. A pixel with a gray scale g ≥ thr
is interpreted as white, otherwise as black. rlc
is the starting address at which the RLC is stored in memory, size
is the number of words in memory available for the RLC. If there is not enough space here, creation of the RLC is aborted and the function returns NULL
.
This function returns a pointer (U16 *) to the next memory address which is not yet written with RLC Data. The pointer is aligned to the next integer address. In case of error, the function returns NULL.
a | Input Image. |
thr | Binarization Threshold. |
rlc | Pointer to RLC memory to be written by the function. |
size | Maximum Size (in Bytes) allowed for Code. |
The function creates run length code (RLC) for the image variable a
and stores it in memory. lowthr
and hithr
are the low and high binarization thresholds, 0 ≤ lowthr
< hithr
≤ 256. A pixel with a gray scale in between the 2 thresholds is interpreted as white, otherwise as black. Precisely, a pixel value belonging to the set [lowthr
, hithr
) is considered white. rlc
is the starting address at which the RLC is stored in memory, size
is the number of words in memory available for the RLC. If there is not enough space here, creation of the RLC is aborted and the function returns NULL
.
This function returns a pointer (U16 *) to the next memory address which is not yet written with RLC Data. The pointer is aligned to the next integer address. In case of error, the function returns NULL.
if lowthr
≥ hithr
, the function returns NULL
src | Input Image. |
lowthr | Low Binarization Threshold. |
hithr | High Binarization Threshold. |
rlc | Pointer to Memory to be written by Function. |
size | Maximum Size (in Bytes) allowed for Code. |
This function generates vertical run length code from a given image. src->dx must be > 6 for highspeed RLC routine.
src | Source Image. |
thr | Binarization Threshold. |
rlc | Pointer to RLC to be Written by Function. |
size | Maximum Byte Count allowed for rlc . |
NULL | if src->dx < 6. |
NULL | if size is too low. |
NULL | if Memory Allocation Fails. |
Address | Pointer Past End of Output RLC (Aligned). |
The function creates run length code for the image variable a
and stores it in memory. bit
indicates the bitplane for which the run length code is created. It should be a power of two. A pixel with the corresponding bit being set (pixel & bit
≠ 0) is interpreted as white, otherwise as black. rlc
is the starting address at which the RLC is stored in memory, size
is the number of words in memory available for the RLC. If there is not enough space here, creation of the RLC is aborted and the function returns NULL. This function returns a pointer (U16 *) to the next memory address which is not yet written with RLC. The pointer is aligned to the next integer address. In case of error, it returns NULL.
a | Input Image. |
bit | Bit Value for Bitplane Comparison 1 if White. |
rlc | Pointer to RLC to be Written by Function. |
size | Maximum Size (in Bytes) Allowed for Code. |
NULL | if size is too low. |
Address | Pointer past end of output RLC (aligned). |
The function first subtracts 2 images using Absolute Difference (function FL_sub2f). The run length code (RLC) for the difference image is created and stored in memory. thr
is the threshold value used for binarization, 0 ≤ thr
< 256. A pixel with a gray scale g ≥ thr
is interpreted as white, otherwise as black. rlc
is the starting address at which the RLC is stored in memory, size
is the number of words in memory available for the RLC. If there is not enough space here, creation of the RLC is aborted and the function returns NULL
.
This function returns a pointer (U16 *) to the next memory address which is not yet written with RLC Data. The pointer is aligned to the next integer address. In case of error, the function returns NULL.
a,b | Input Images. |
thr | Binarization Threshold. |
rlc | Pointer to RLC memory to be written by the function. |
size | Maximum Size (in Bytes) allowed for Code. |
This function performs a Canny type hysteresis thresholding. The seed
threshold is used to generate seed points which are then used to select connected areas of the threshold thr
which qualify for output. The selection is done using the function rlc_select() to select objects in a selection table. All other objects that are not selected are deleted from the low-threshold-RLC afterwards using the function rlc_delete(). If seed
is higher than thr
, the function does Canny-type hyteresis thresholding for bright objects with even brighter seed points. If seed
is lower than thr
, the function switches to thresholding for dark objects with even darker seed points.
src | Source Image. |
rlc | RLC Output. |
rlclength | Maximum Count of Words for rlc . |
thr | Object Threshold used for Object Based Extension. |
seed | Seed Threshold. |
The function converts a run length code image into a gray image. This is mostly used to display the run length code on the screen. However, this function can also be used to prepare for image processing operations which are not possible directly at the run length code, or which would be difficult in it. The image variable a
provides the start address and the pitch for the output. The function immediately aborts with error code ERR_FORMAT if the image format (dx
, dy
) implicitly contained in the run length code does not agree with a->dx and a->dy of the image variable. rlc
is the start address of the run length code in memory, dark
is the gray scale for the black areas of the RLC, bright
is the gray scale for the white areas - here, values between 0 and 255 are possible.
a | Input Image. |
rlc | Pointer to RLC (Labelled or Unlabelled). |
dark | Pixel value for RLC Color "0". |
bright | Pixel value for RLC Color "-1". |
ERR_FORMAT | if RLC (dx, dy) differs from output image (dx, dy). |
ERR_NONE | on Success. |
The function converts a run length code image into a gray image. Contrary to the function rlcout(), the function rlcout_transparent() only plots bright or dark parts of the image as selected by plotBrightIff1
and leaves the rest transparent. Please make sure to initialize the input image a
appropriately before calling the function. The function can be used to display the run length code on the screen or writing it to the overlay. This function can also be used to prepare for image processing operations which are not possible directly at the run length code, or which would be difficult in it. If used in this way, rlc
provides a mask for the regions where rlcout_transparent() sets the pixels of image to
a constant value (color
).
The image variable a
provides the start address and the pitch for the output. The function immediately aborts with error code ERR_FORMAT if the image format (dx
, dy
) implicitly contained in the run length code does not agree with a->dx and a->dy of the image variable. rlc
is the start address of the run length code in memory, color
is the grey value drawn at the regions selected by the parameter plotBrightIff1
.
a | Input Image. |
rlc | Pointer to RLC (Labelled or Unlabelled). |
plotBrightIff1 | nothing is plotted at dark regions if 1, and vice versa. |
color | pixel value for the color to plot |
ERR_FORMAT | if RLC (dx, dy) differs from output image (dx, dy). |
ERR_NONE | on Success. |
The function converts a run length code image into a pixellist. lstPx
has 2 * lstPxMaxCnt I32 values, i.e. x[i] = lstPx[2*i+0] and y[i] = lstPx[2*i+1].
lstPx | Output Pixel List (preallocated). |
lstPxCnt | Pixel List elements written. |
lstPxMaxCnt | Maximum allowed Pixel List elements. |
colIn | pixel coordinates of this color are added to list. |
rlc | Pointer to RLC (Labelled or Unlabelled). |
ERR_OVERRUN | if lstPxMaxCnt is exceeded. |
The function serves to output the labelled RLC for test purposes. The various objects contained in the labelled RLC are drawn with different gray scales. Otherwise, the output is basically equivalent to the function rlcout().
a | Destination Pixel Image. |
rlc | Labelled Source RLC. |
ERR_FORMAT | if RLC is Unlabelled. |
ERR_FORMAT | if Object Number Overruns. |
ERR_FORMAT | if Input RLC dx/y differs from Output Image dx/y. |
ERR_NONE | on Success. |
I32 rlc_mask_image | ( | image * | src, |
image * | dst, | ||
U16 * | rlc, | ||
I32 * | objs, | ||
U8 | color, | ||
I32 | offsetX, | ||
I32 | offsetY | ||
) |
The function fills the dst
image grey value of all objects selected by objs
with the constant value color
. All other pixel values remain unchanged. It is possible to add offsetX
and offsetY
to the coordinates of the destination image which results in a movement of the image. Pixels out of the scope of the original image will also be filled with color
. The purpose of the function is the selection of the grey values only for a number of objects for which features need to be calculated e.g. the mean grey value of the object pixels. The content of the source image moves left (or up) in the destination image with raising offsetX
(or offsetY
).
src | The Source Image of Type IMAGE_GREY. |
dst | The Destination Image (may be equal to src ). |
rlc | The Segmented Run Length Code. |
color | The Fill Color. |
objs | Points to Object Selection List; Object Number is Array Index, a Value of 0 means "Object Unselected" i.e., the Grey Value is Unchanged. |
offsetX,offsetY | src Coordinate of the Top-Left Point in dst Image. |
ERR_PARAM | if (RLC is not segmented) or (src.type != IMAGE_GREY) or (dst.type != IMAGE_GREY) or (src.dx != rlc dx) or (src.dy != rlc dy) or (offsetX not in [0, src->dx-1]) or (offsety not in [0, src->dy-1]) |
ERR_NONE | on Success. |
I32 vc_slc_out | ( | image * | img, |
U8 | ch, | ||
U16 * | rlc, | ||
U32 * | lstColOfObj, | ||
I32 | oneObjNrOrNegative, | ||
I32 | oneObjCol, | ||
I32 | oneObjColBg | ||
) |
This function outputs regions of SLC objects to a channel of an image.
img | The Output image. |
ch | The Output image channel to be written to. |
rlc | The labelled RLC |
lstColOfObj | An array with grey values used for and assigned over each object nr, may be NULL for a varying color based on the object number (not necessarily unique), unused if oneObjNrOrNegative is >= 0. |
oneObjNrOrNegative,oneObjCol,oneObjColBg | give a single object number for setting the values to either oneObjCol or oneObjColBg , or to use the lstColOfObj . |
ERR_TYPE | if src is of unknown type or unsupported |
ERR_PARAM | if ch exceeds image src components. |
This function prints out SLC object numbers parallel to its RLC positions for debugging.
rlc | The RLC of the SLC |
slc | The SLC to be used |
indent | Left indentation used for printing. |
This function prints out SLC object numbers per Pixel, so it is only meaningful for debugging small images.
rlc | The RLC of the SLC |
slc | The SLC to be used |
indent | Left indentation used for printing. |
The function makes it possible to calculate any operations between two run length codes. rlca
and rlcb
pass the memory address of both RLCs. The memory address of the resulting RLC is passed by dest
. dest
must be different from rlca
and rlcb
. The RLCs to be linked must have the identical format (dx
, dy
). If this is not the case, then the function returns NULL
. Otherwise, the function rlc2() returns the next not yet written memory address for the resulting RLC dest
(integer aligned).
For execution, it does not matter if the RLC is labelled or unlabelled. In both cases, the result is an unlabelled RLC. A pointer to the basic function to be executed specifies the nature of the operation. The following macros use this function:
Operation | Call | Basic function |
---|---|---|
AND | rlcand(a, b, dest) | rlc_andf() |
OR | rlcor(a, b, dest) | rlc_orf() |
XOR | rlcxor(a, b, dest) | rlc_xorf() |
NAND | rlcnand(a, b, dest) | rlc_nandf() |
NOR | rlcnor(a, b, dest) | rlc_norf() |
EQUIV | rlcequiv(a, b, dest) | rlc_equivf() |
AND_NOT | rlcandnot(a, b, dest) | rlc_andnotf() |
OR_NOT | rlcornot(a, b, dest) | rlc_ornotf() |
NAND_NOT | rlcnandnot(a, b, dest) | rlc_nandnotf() |
NOR_NOT | rlcnornot(a, b, dest) | rlc_nornotf() |
Of course, you can write your own basic functions. Pass them as function pointer to rlc2().
rlca | First RLC Source. |
rlcb | Second RLC Source. |
dest | RLC Output. |
func | RLC Basic Function Pointer (Performs the Actual Operation). |
NULL | if rlca and rlcb have different formats. |
Address | Pointer past end of output RLC (aligned). |
The function performs the in-place inversion of RLC stored at address rlc
in memory (interpretable as logical NOT).
Inversion means, that black segments are changed to white and vice versa. The inversion is obtained by negating the color information at the start of each line. rlc_inv() returns the address of the next item to follow the RLC code (integer aligned).
rlc | Source and Destination RLC. |
Address | Pointer Past End of Output RLC (Aligned). |
The function reads RLC line at memory address src
, moves all RLC items horizontally by mx
pixels (mx
negative: move left), vertically by my
lines (my
negative: move up) and outputs the result to dest
. src
and dest must be different for this operation. Black space (color=0) is added for the regions outside the original window.
src | Pointer to Source RLC. |
dst | Pointer to Destination RLC. |
mx | x Coordinate of Movement Vector. |
my | y Coordinate of Movement Vector. |
Address | Pointer Past End of Output RLC (Aligned). |
The function reads RLC line at memory address src
, moves all RLC items horizontally by mx
pixels (mx
negative: move left), vertically by my
lines (my
negative: move up) and outputs the result to dest
. src
and dest must be different for this operation. Black space (color=0) is added for the regions outside the original window.
src | Pointer to Source RLC. |
dst | Pointer to Destination RLC. |
dxDst | Horizontal size for destination RLC. |
dyDst | Vertical size for destination RLC. |
mx | x Coordinate of Movement Vector. |
my | y Coordinate of Movement Vector. |
src | Source RLC Pointer. |
dst | Destination RLC Pointer. |
size | Maximum Count of Bytes Allowed for dst . |
dx
* dy
+ 6 * dx
+ 2) Bytes of Heap Memory. Address | Pointer past end of output RLC (aligned). |
src | Source RLC Pointer. |
dst | Destination RLC Pointer. |
dy
) Bytes of Heap Memory. Address | Pointer past end of output RLC (aligned). |
do not use in-place
src | Source RLC Pointer. |
dst | Destination RLC Pointer. |
dy
) Bytes of Heap Memory. Address | Pointer past end of output RLC (aligned). |
do not use in-place
src | Source RLC Pointer. |
dst | Destination RLC Pointer. |
dy
) Bytes of Heap Memory. Address | Pointer past end of output RLC (aligned). |
This function shears RLC in horizontal direction. Due to the pixel quantization, there may be approximations in the positioning: If the Bresenham Algorithm has due to the shearing factor more than one possible position for one row, the center position will be used, eventually floored against 0. Also formerly connected area parts may disconnect through this operation.
Be sure to have correct colors at the border of the source RLC, since the border values will be the fill color for out-of-image regions!
src | Source RLC Pointer. |
dst | Destination RLC Pointer, allocated size >= src. |
shearDx | Horizontal Pixel Deviation between uppermost and lowermost RLC Line (approx.). |
The function erodes/dilates the image by one pixel. Erosion means that all white areas in the RLC become one pixel wider in each direction, while all black areas are narrowed one pixel. Thus, black areas which are 1 or 2 pixels in diameter disappear completely. src
is a pointer to the source RLC, dest
to the destination RLC. The function pointers passed specify the type of operation being performed. fc1
is the function pointer for the horizontal erosion/dilation process, fc2
is the function pointer for the vertical erosion/dilation process. The following macros call this function:
Operation | Call | Basic function fc1() | Basic function fc2() |
---|---|---|---|
Erosion | erode(a, b) | rlc_xero() | rlc_orf() |
Dilation | dilate(a, b) | rlc_xdil() | rlc_andf() |
Of course, you can write your own horizontal and vertical functions. Pass them as function pointers to erxdi().
src | Points to Source RLC. |
dst | Points to Destination RLC. |
fc1 | Points to Function to do the Horizontal Processing. |
fc2 | Points to Function to do the Vertical Processing. |
dx+1
) Bytes of Heap Memory. Address | Pointer past End of Output RLC (Aligned). |
The function erodes/dilates the image by one pixel. It is most similar to the erxdi2() function, but instead of a square as structuring element, it uses a diagonal (diamond-shaped) structuring element. The influence of the structuring element becomes apparent, if the function is called several times on the data of the previos erosion/dilation. A round shaped structuring element can be approximated by alternating the calls of erxdi() and erxdi2(), this procedure will produce an octagonal shaped structuring element which is much closer to a circle. src
is the source RLC, dest
is the destination RLC. The function pointers passed specify the type of operation being performed. fc1
is the function pointer for the horizontal erosion/dilation, fc2
is the function pointer for the vertical erosion/dilation.
The following macros call this function:
Operation | Call | Basic function fc1() | Basic function fc1() |
---|---|---|---|
Erosion | erode2(a, b) | rlc_xero() | rlc_orf() |
Dilation | dilate2(a, b) | rlc_xdil() | rlc_andf() |
Of course, you can write your own horizontal and vertical functions. Pass them as function pointers to erxdi2().
src | Points to Source RLC. |
dst | Points to Destination RLC. |
fc1 | Points to Function to do the Horizontal Processing. |
fc2 | Points to Function to do the Vertical Processing. |
dx+1
) Bytes of Heap Memory. Address | Pointer past End of Output RLC (Aligned). |
The function performs a horizontal median filtering on run length encoded images.
The median filter purges all structures of color col
with length less than lng
. The operation will create less data at address dest
than the original RLC at address src
. Moreover, the operation may be performed in-place, i.e. src
and dest
may be the same. The function is valuable to reduce the amount of useless information in noisy images in an early stage of RLC processing. The function returns a pointer to the next available memory word (U16) to follow the RLC code (integer aligned).
src | Pointer to Source RLC. |
dst | Pointer to Destination RLC. |
col | Color of Median Purge. |
lng | Horizontal Width of Median. |
Address | Pointer Past End of Output RLC (Aligned). |
The function calculates the area of all pixels of a given color (black: color = 0, white: color = 0xFFFF) in the unlabelled RLC. All pixels of a given color (black or white) are included. There is no differentiation according to objects. rlc
is the start address of the run length code in memory. The return value of this function is the area.
Area | Black or White Pixel Count in RLC. |
The function opens a file and reads the RLC of this file to memory at address rlc
. The full path of the file is specified by the string path
. The function returns a pointer to the next available memory word to follow the RLC code (integer aligned).
path | Full File Path to Input File. |
rlc | Allocated Destination RLC. |
Address | Pointer Past End of Output RLC (Aligned). |
NULL | if File Reading Fails. |
The function creates a file and writes the RLC starting at address rlc
to this file. The full path of the file is specified by the string path
. If the function is unable to open the specified file, it returns ERR_OPEN, otherwise ERR_NONE.
path | Full File Path to Output File. |
rlc | Source RLC. |
ERR_NONE | on Success. |
ERR_OPEN | if File Opening Fails. |
This function is the same as rlc_label() but with an extra argument for the end of the rlc. This allows to get a speed up at least at small enough images.
Refer to the documentation of rlc_label().
rlc | Pointer to Unlabelled RLC. |
rlcEnd | Pointer to the memory after the content of the rlc , available as return value of most rlc functions. |
slc | Pointer to SLC (Object Labels) Output. |
mode | Connectivity mode:
|
NULL | on Licence Error. |
NULL | if Memory Allocation Fails. |
Address | Pointer Past End of Output SLC (Aligned). |
NULL | if an Object Overrun occurs. |
One of the most important functions for binary images (RLC) is object labelling. Object labelling or connected component labelling means that all connected areas within an image are being clustered together and assigned a unique identifier, the object number. The function labels the run length code stored starting at the memory address rlc
. The function will output the object labelling information at memory address slc
which must be specified. Enough memory must be available for the memory needs of the SLC (The SLC needs (size_of_rlc - 4) bytes of memory). mode
indicates a certain neighborhood connectedness for the segmentation according to the following table:
mode | Connectedness | Macro | Library |
---|---|---|---|
0 | 4/4 (standard) | sgmt(rlc, slc), label44(rlc, slc) | VCLıb |
1 | 8/8 | label88(rlc, slc) | ExtLıb |
2 | 8/4 | label84(rlc, slc) | ExtLıb |
3 | 4/8 | label48(rlc, slc) | ExtLıb |
A connectedness of 8/4 means that the white pixels must be 8-connected and the black pixels must be 4-connected to form an object.
The slc
pointer is stored in the run length code at address rlc
and rlc+1
. This indicates a labelled RLC. The number of objects found and the object numbers for the individual RLC segments are stored in the SLC. The object numbers begin at 0; a total of 32000 object numbers are allowed. An 'object number overrun' occurs if this number is exceeded.
The return value of this function is the next free memory address (integer aligned). The function returns NULL in case of an error. This might be an object number overrun in which case the number of objects field in the SLC is also set to zero.
rlc | Pointer to Unlabelled RLC. |
slc | Pointer to SLC (Object Labels) Output. |
mode | Connectivity mode:
|
The function copies individual connected pixel areas (objects) out of the labelled RLC. src
is the labelled source RLC, dst
is the unlabelled target RLC. objnum
is the number of the object to be copied. All objects copied out (including black ones) are stored white on a black background in the target RLC regardless of their original color. The return value of this function is the address of the next available memory space immediately after the target RLC. The function is aborted and NULL is returned if src
is unlabelled or if objnum
is larger than the number of objects contained in the RLC.
src | Source RLC. |
dst | Destination RLC. |
objnum | Object Number. |
NULL | if RLC is Unlabelled. |
NULL | if SLC Object Number is Invalid. |
Address | Pointer Past End of Output RLC (Aligned). |
The function calculates the area of all objects in the labelled RLC. rlc
is the start address of the labelled RLC in memory. area
is an array for the object areas, and n
is the maximum number of objects, i.e. usually the dimension of the array. After the function rl_area2()
is called, the object areas for all objects (independent of their colors) are available in the array area
. The function returns the number of objects in the labelled RLC.
rlc | Source RLC. |
area | Computed Areas as Array. |
n | Maximum Number of Array Entries allowed. |
ERR_SLC | if RLC is Unlabelled. |
ERR_RLC_ONOVR | if Object Number overruns. |
Object Count | Number of Objects in SLC. |
The function computes the object inclusion property for all objects. It is calculated, which object is contained by which other object. This topological relationship is stored in the array qin
[].
If an object touches more than one image boundary, this property cannot be computed for this object. In this case, qin
is set to -1 for this object.
rlc | RLC pointer |
QIN | array for QIN values for each object (output) object inclusion relationship -1 indicates that this object touches more than 1 image boundaries. example: QIN[2] = 1 means object 2 is inside object 1 |
n | size of QIN[] |
ERR_SLC | if RLC is Unlabelled. |
ERR_RLC_ONOVR | if an Object Number Overrun occured. |
ERR_SLC_INCON | if SLC object count is inappropriate. |
ERR_RLC_MEM | if Memory Allocation Failed. |
Object Count | on Success. |
The function computes the number of holes for all objects in labelled RLC. Please be aware that even very small objects with a few pixels are counted as holes. It is therefore recommended to clean the image with the function rlc_arf() first.
rlc | RLC Pointer. |
holes | Array for the Number of Holes for Each Object (Output). |
n | Size of holes [] Array. |
ERR_RLC_MEM | if Memory Allocation Fails. |
ERR_SLC | if RLC is Unlabelled. |
ERR_RLC_ONOVR | if an Object Number Overrun occured. |
ERR_SLC_INCON | if SLC object count is inappropriate. |
ERR_RLC_MEM | if Memory Allocation Failed. |
Object Count | on Success. |
The function deletes all objects of the source RLC with an area less than min_area
. This can be used to drastically reduce the amount of RLC entries and to speed up the following routines operating on RLC. The function is intended to eliminate small objects.
Note, that the output RLC is unlabelled. It might therefore be necessary to call sgmt() again for object labelling. The function returns the number of objects on success or the (negative) standard error code on error.
src | Labelled source RLC. |
dst | Destination RLC (unlabelled). |
min_area | Objects smaller than min_area will be deleted. |
ERR_SLC | if RLC is unlabelled. |
ERR_SLC_INCON | if SLC object count is inappropriate. |
ERR_RLC_MEM | if Memory Allocation Fails. |
Object Count | Count of Objects in original source RLC. |
The function deletes all objects of the source RLC with an area less than min_area
and larger than max_area
. With col
it is possible to select the color for the objects to be deleted. With col
!= (0, -1), any color is selected for deletion.
The function calls rlc_delete(). Please mind that any restriction for rlc_delete() also applies to rlc_arf2()
Note, that the output RLC is unlabelled. It might therefore be necessary to call sgmt() again for object labelling. The function returns the number of objects on success or the (negative) standard error code on error.
src | Labelled source RLC. |
dst | Destination RLC (unlabelled). |
col | Color of objects to be deleted, 0 = black, -1 = white, any other value: any color |
min_area | Objects smaller than min_area will be deleted. |
max_area | Objects larger than max_area will be deleted. |
ERR_SLC | if RLC is unlabelled. |
ERR_SLC_INCON | if SLC object count is inappropriate. |
ERR_RLC_MEM | if Memory Allocation Fails. |
ERR_RLC_MEM | if Memory Allocation Fails. |
Object Count | Count of Objects in original source RLC. |
The function is used for the selection of objects in a binary image given by rlc
. A second binary image rlc2
is used as a guide image to specify where objects in the first image are selected. Together with the function rlc_delete(), this functionality is sometimes called 'morphological reconstruction'. The function generates an array selector
, which is 1 for each object selected and 0 otherwise The format of both RLCs (i.e. the size of the image in x and y) must be identical, otherwise the function returns with ERR_RLCFMT.
rlc | Points to Labelled RLC. |
rlc2 | Points to (Unlabelled) "Selector" RLC. |
selector | Output Array with Selection Information for All Objects. |
n | Size of selector [], must be >= Number of Objects in the Input RLC. |
mode | Selection Mode, Reference for the selection is always rlc2 , e.g. in mode=2 all objects in rlc would be selected where the rlc2-(selector) pixels are black, all others are deselected.
|
ERR_SLC | if RLC is Unlabelled. |
ERR_RLC_ONOVR | if Object Count is 0, or overruns n . |
ERR_SLC_INCON | if SLC object count is inappropriate. |
ERR_RLCFMT | if RLC dx/y differs from Selector RLC dx/y. |
Object Number | Number of Objects. |
I32 rlc_select_by_polygon_simple | ( | U16 * | rlc, |
I32 * | xyLst, | ||
U32 | xyCnt, | ||
I32 * | selector, | ||
U32 | maxSelector | ||
) |
The function is used for the selection of objects in a binary image given by rlc
. A interior simple polygon is used as a guide to specify where objects in the image are selected: Everything but the background selects the underlying objects. The function generates an array selector
, which is 1 for each object selected and 0 otherwise.
rlc | Points to Labelled RLC. |
selector | Output Array with Selection Information for All Objects, Size of selector [], must be at least the Number of Objects in the Input RLC. |
maxSelector | Selector array size. |
ERR_SLC | if RLC is Unlabelled. |
ERR_OVERRUN | if Selector array is too small. |
ERR_MEMORY | if allocation fails. |
ERR_PARAM | if polygon generation fails. |
The function deletes objects from an RLC using a selection list. The source RLC must be labelled, whereas the result RLC is unlabelled. Some restrictions apply for the usage: (1) Deleting only one object and keeping all others works fine (2) Deleting strictly objects of one color works fine (3) Deleting objects without holes (internal objects) works fine (4) Deleting smaller objects and keeping larger ones works fine The term "smaller" may be in the sense of "less pixels" or "smaller width" or "smaller height" or any diameter or projection in any direction (5) Deleting ANY objects with ANY color without the above restrictions may lead to inconsistent or unexpected behavior. Unexpected dst
RLCs may be produced. It is at the user's responsibility to make sure that one of the above conditions is met. The function does NOT check for it.
src | aource RLC. |
dst | destination RLC. |
keep | selection Array == 0: delete, != 0 : keep. |
NULL | if RLC is unlabelled. |
NULL | if SLC object count is inappropriate. |
Address | Pointer to the next available RLC. |
The function is used for the selection of objects in a binary image given by rlc
. A coordinate pair (x, y) defines the position where an object in the image should be selected. Together with the function rlc_delete(), this functionality is sometimes called 'morphological reconstruction'. The function returns the (positive) objectnumber of the selected object or a (negative) error code.
rlc | Points to Labelled RLC. |
x,y | Coordinates of Selection Point. |
object | Object Number (output). |
ERR_SLC | if RLC is Unlabelled. |
ERR_RLC_ONOVR | if Object Count is 0. |
ERR_SLC_INCON | if SLC object count is inappropriate. |
ERR_PARAM | if (x, y) not within image. |
Object Number | . |
The function is used for the extraction of objects in a binary image given by rlc
. A coordinate pair (x, y) defines the position where an object in the image should be extracted. This is sometimes called 'morphological reconstruction' of an object. The extracted object is always white on dark background. rlc_keep_object() internally calls function rlc_getobject() first to get the object number of the relevant object. It then extracts the object from the RLC using function rlc_cut(). The function returns the (positive) objectnumber of the selected object or a (negative) error code.
Function can be called in-place i.e. src
and dst
can be pointers to the same address.
src | Pointer to labelled source RLC. |
dst | Pointer to unlabelled destination RLC (output). |
x,y | Coordinates of Selection Point. |
object | Object Number (output). |
function outputs RLC for all objects overlapping the seed RLC
src | source image |
seed | seed RLC, only objects that overlap seed will survive |
rlc | destination RLC |
thresh | threshold for binarization |
size | maximum size of output RLC |
mode | the seed mode (see select()) 0: standard mode: select white objects 1: select white (and all black) objects 2: select black objects 3: select black (and all white) objects |
pointer | to next available RLC address, error: NULL |
function outputs RLC for all objects overlapping the seed RLC select pixels between thr1 = lo, thr2 = 150 = high
src | source image |
seed | seed RLC, only objects that overlap seed will survive |
rlc | destination RLC |
thr1,thr2 | high and low thresholds for binarization |
size | maximum size of output RLC |
mode | the seed mode (see select()) 0: standard mode: select white objects 1: select white (and all black) objects 2: select black objects 3: select black (and all white) objects |
pointer | to next available RLC address, error: NULL |
U16* rlcand_slc | ( | U16 * | rlca, |
U16 * | slca, | ||
U16 * | rlcb, | ||
U16 * | rlcOut, | ||
U16 * | slcOut, | ||
I32 * | newObjNrOrNULL | ||
) |
The function makes it possible to calculate a logical AND operation between two run length codes by preserving the object numbers of the first RLC source rlca
. The second RLC, rlcb
, is used as guide image, where
rlcb
white regions get the underlying rlca
object number, andrlcb
black regions get the maximum object number, which increases then by 1.rlcOut
must be different from rlca
and rlcb
. The RLCs to be linked must have the identical format (dx
, dy
). If this is not the case, then the function returns NULL
. Otherwise, the function returns the next not yet written memory address for the resulting RLC dest
(integer aligned).
rlca | First RLC Source. |
slca | First SLC Source or NULL to use the implicit pointer at rlca . |
rlcb | Second RLC Source (white keep objects, black writes new objNr). |
rlcOut | RLC Output. |
slcOut | SLC Output. |
newObjNrOrNULL | If set to NULL, the output slc has the same object numbers as the input slc, that means, that there may be object numbers not present anymore; if you set it to an array of objNr size, there will be a renumbering reducing the object number; the new count is stored at the slcOut , and the rlcb black region object gets the number (new count-1); the array can be used to look up the new number by using the old object number as index. |
NULL | if rlca and rlcb have different formats. |
Address | Pointer past end of output RLC (aligned). |
The function reads RLC line at memory address src
, enlarges all RLC items horizontally by factor magX
, vertically by magY
lines and outputs the result to dest
. The function can be used in-place, i.e. src
and dst
can be identical;
Negative magX
or will zoom down.
src | Pointer to Source RLC. |
dst | Pointer to Destination RLC. |
magX | Zoom factor x. |
magY | Zoom factor y. |
Address | Pointer Past End of Output RLC (Aligned). |
The function creates an empty test image RLC format using just one color.
rlc | RLC Test Image Output. |
dx | x Size of RLC. |
dy | y Size of RLC. |
color | Fill color. |
Address | Pointer past End of Output RLC (Aligned). |
Address | Pointer past End of Output RLC (Aligned). |
I32 rlc_rect | ( | U16 * | rlc, |
U16 | rlcDx, | ||
U16 | rlcDy, | ||
I32 | rlcMaxBytes, | ||
U16 | x0, | ||
U16 | y0, | ||
U16 | x1, | ||
U16 | y1, | ||
U16 | col | ||
) |
This function generates a RLC image with a rectangle at it.
-1 | x0 , x1 , y0 , y1 , out of range rlcDx , rlcDy . |
-2 | rlcMaxBytes is too low, needs more memory. |
rlc | Pre-Allocated Source RLC Pointer. |
rlcMaxBytes | Allocated Bytes for the RLC Pointer. |
x0,y0,x1,y1 | Diagonal Rectangle Points, both part of the rectangle. |
col | Color of the Rectangle, Background is inverse. |
This function draws a Bresenham line in normalized floatingpoint form into a new RLC image with size (rlcDx
, rlcDy
). The line is defined as: . If the line does not intersect the RLC image, the function outputs an empty RLC.
Memory requirement for RLC: sizeof(U16) * (4 + 4*(max(rlcDx,rlcDy) + 1)) at maximum.
The function returns a pointer to the next valid address behind the RLC.
rlc | Pre-allocated source RLC pointer (see text). |
rlcDx,rlcDy | Dimensions of the RLC generated. |
cx,cy,b | Parameters of the line to be drawn. |
col | Color of the line, background is inverse. |
U16* rlc_drawlinesegment | ( | U16 * | rlc, |
U16 | rlcDx, | ||
U16 | rlcDy, | ||
I32 | x0In, | ||
I32 | y0In, | ||
I32 | x1In, | ||
I32 | y1In, | ||
I32 | col | ||
) |
This function draws a Bresenham line from coordinate (x0In
, y0In
) to (x1In
, y1In
) into a new RLC image with size (rlcDx
, rlcDy
). If the line does not intersect the RLC image, the function outputs an empty RLC.
Memory requirement for RLC: sizeof(U16) * (4 + 4*(max(rlcDx,rlcDy) + 1)) at maximum.
The function returns a pointer to the next valid address behind the RLC.
rlc | Pre-allocated source RLC pointer (see text). |
rlcDx,rlcDy | Dimensions of the RLC generated. |
x0In,y0In,x1In,y1In | End points of the line to be drawn. |
col | Color of the line, background is inverse. |
rlc | pointer to next available RLC address (integer aligned). |
I32 rlc_draw_polygon | ( | U16 * | rlcOut, |
U16 | rlcDx, | ||
U16 | rlcDy, | ||
I32 * | pi32PxLst, | ||
U32 | u32CornerCount, | ||
I32 | col | ||
) |
The function draws a polyline in the image pointed by psImgOut
. The line can be drawn normally, or as XOR in the gray image or using dotted or other styles.
The drawing stops at the boundary of the image variable.
The nature of drawing is specified by passing the pointer (* func
)() to the drawing function itself. The following macros use this function: draw_polylined(), draw_polylinex().
psImgOut | Pointer to Image Variable. |
u32CornerCount | Corner Count of the Polyline. |
pi32PxLst | List of u32CornerCount Point Coordinates as Pixel List [I32 P1x, I32 P1y, I32 P2x, ...]. |
col | Contour Color. |
func | Drawing Function, eg. dashed_U8(). |
ERR_MEMORY | if allocation fails. |
1 | if a corner lies outside of the image. |
I32 rlc_fill_polygons_simple | ( | U16 * | rlc, |
U16 | rlcDx, | ||
U16 | rlcDy, | ||
U32 | rlcMaxBytes, | ||
U32 | lstCnt, | ||
I32 * | xyLst, | ||
U32 * | xyCnt | ||
) |
ERR_MEMORY | if allocation fails. |
ERR_PARAM | if polygon generation fails. |
positive | if polygon exceeds image. |
The function works on labelled RLC and calculates the average grey value for each object using the original grey image. The image variable src
provides the data for the averaging. The function immediately aborts with error code ERR_FORMAT if the image format (dx
, dy
) implicitly contained in the run length code does not agree with a->dx and a->dy of the image variable. It returns with ERR_OVERRUN if there is not enough space to store the result in the array average
. On success the function returns the (positive) number of objects.
nobj | No Error. |
ERR_FORMAT | Format Error. |
ERR_OVERRUN | too many objects for size of output array |
src | Input Image. |
rlc | Pointer to RLC (must be labelled). |
average | result array |
n | number of array elements for average |
The function returns the maximum value of a given channel ch as list over the SLC objects.
lstObjMaxVal | output, points to pre-allocated array with SLC object number entries. |
src | Pointer to Source Image containing the values. |
ch | Channel of Source Image used for obtaining the pixel value. |
rlc | Labelled Run lenght code for object reference. |
slcOrNULL | If set to NULL, the SLC reference at the rlc data is used. |
ERR_TYPE | if src is of unknown type or unsupported |
ERR_PARAM | if ch exceeds image src components. |
ERR_OVERRUN | if src dx/dy is smaller than rlc dx/dy |
ERR_SLC | if rlc is unlabelled. |
ERR_NONE | on success. |
The function creates a test image in RLC format. rlc
is the start address of the RLC, where the test image is written to. dx
and dy
is the horizontal and vertical size of the image. size
is the size of the individual chess-board squares in pixel. dy
must be a multiple of size
, it will be rounded off otherwise. The function returns a pointer to the next available memory word (U16) to follow the RLC code (integer aligned). The function can be used to test functionality and execution timing of RLC functions including object labelling. A test image of size 640×480 with a chess-board square size of 32 pixels needs 10084 words (U16) of RLC, which is a good approximation of the average information amount of a 'real life' image of that format.
rlc | RLC Test Image Output. |
dx | x Size of RLC. |
dy | y Size of RLC. |
size | Size of individual Chessboard Tiles. |
dx+1
) Bytes of Heap Memory. Address | Pointer past End of Output RLC (Aligned). |
Problems usually occur with functions which use run length code if the RLC contains errors. For example, even the function rlcout(), which outputs the RLC on the screen, may crash if called with faulty RLC. The functions in the library have been checked for correctness, so problems are not to be expected. If the user, however, develops an own function for RLC processing, it is recommended to check the RLC during the development process. The function chkrlc() may be used for this purpose. The function should not be used for the final program, since - it was not optimized for speed - it outputs debug information via the serial communication link In particular, this function checks the following:
dx
and dy
are printed.dx
.For labelled RLC, the following is also checked:
In case of error, the function returns -1, otherwise 0.
Debug information is printed during execution.
rlc | Points to RLC. |
-1 | if RLC is not Consistent. |
ERR_NONE | on Success. |
The function parses the (unlabelled) RLC specified by pointer rlc
and returns the next available memory address (integer aligned) right behind the RLC. Be careful: If the RLC is labelled, please make sure to write NULL to the SLC pointer contained in the RLC before writing to the result address of this function.
Address | Pointer Past End of Output RLC (Aligned). |
This function prints out CLC information parallel to its RLC positions for debugging.
rlc | The RLC of the CLC |
clc | The CLC to be used |
indent | Left indentation used for printing. |
This function prints out CLC color per Pixel, so it is only meaningful for debugging small images.
rlc | The RLC of the CLC |
clc | The CLC to be used |
indent | Left indentation used for printing. |
U16* vc_clcmk | ( | image * | src, |
I32 | thr, | ||
U16 * | rlc, | ||
U16 * | clc, | ||
U16 | colCircularMax, | ||
U16 | colBg, | ||
I32 | fastModeIff1, | ||
I32 | rlcMaxBytes | ||
) |
This function generates a so-called color run length code (CLC) from an image. It consists of two outputs:
rlc
which stores the positions where colors change; color interpretation of the RLC value (0xFFFF as white and 0 as black) becomes senseless,clc
containing src->ccmp1
where values of the guide input source src->st equals or exceeds the threshold thr
,thr
, called ´background´.An example usage is the input of a vector image from the gradient_3x3_thresh() function, using the magnitude (st) as guide input and the direction (ccmp1) as color. The threshold selects the strong enough edges, and their direction is stored as color at the CLC clc
. Regions with magnitudes lower than the threshold get the value colBg at the CLC.
src | input image data of type IMAGE_VECTOR (st: threshold check, ccmp1: color) |
rlc | Result Pointer to Unlabelled RLC Output. |
clc | Result Pointer to CLC Output. |
colBg | CLC value for magnitude < thr , for example 0xFFFF. |
fastModeIff1 | In this mode the src input image's ccmp1 channel must already contain the thresholded magnitude information by having assigned colBg at those pixels (set colBg appropriate!), where the magnitude at the st channel is smaller than the threshold thr ; information at st is ignored. |
rlcMaxBytes | Allocated size of rlc and clc . |
NULL | if src is not of IMAGE_VECTOR |
NULL | on ERR_MEMORY wrt. rlcMaxBytes |
rlc | Pointer to Unlabelled RLC. |
rlcEnd | Pointer to first position after Unlabelled RLC (returned by most RLC functions, for example vc_clcmk()). |
clc | Pointer to CLC. |
slc | Pointer to SLC (Object Labels) Output. |
mode | Connectivity mode:
|
NULL | if allocation fails. |
NULL | if there are too much objects. |
NULL | on Licence Error. |
NULL | if Memory Allocation Fails. |
Address | Pointer Past End of Output SLC (Aligned). |
NULL | if an Object Overrun occurs. |
I32 vc_cyclic_colrange | ( | U16 * | colRangeLen, |
U16 * | colRangeSt, | ||
U8 * | wrapsIff1, | ||
U16 | objRef, | ||
U16 * | colOfObj, | ||
I32 | colCircularMax, | ||
I32 | colBg, | ||
U32 * | eqv_tbl, | ||
U16 | objCnt | ||
) |
This function gets the color range from objects where eqv_tbl
[objRef] == eqv_tbl
[obj]. The colors are at the colOfObj
table (not over eqv_tbl
, so for example colOfObj
[objRef]). colCircularMax
is the end value, for example 256 or 128 where the color wraps. colRangeLen
is then the result value of the 'color angle' and colRangeSt
the first color; wrapsIff1
is set to 1 if the circular maximum is overstepped by the range, e.g. 126 127 0 1 2 -> range 4, st 126, wraps
colRangeLen,colRangeSt,wrapsIff1 | Color Range output. |
objRef,eqv_tbl | Reference ObjectNr for testing equality over eqv_tbl with each object: eqv_tbl [objRef] == eqv_tbl [obj] |
colOfObj | Color of each object, referenced over the object number. |
colCircularMax | Maximum color not part of the color cycle anymore. |
colBg | If color of object is this color, it is ignored for the range acquisition: 'background color'. |
objCnt | Number of objects. |
I32 vc_clc_merge_objs_by_colTol | ( | U16 * | rlcOut, |
U16 * | clcOut, | ||
U16 * | slcOut, | ||
U16 * | rlc, | ||
U16 * | clc, | ||
U16 * | slc, | ||
I32 | maxColTol, | ||
I32 | mergedMaxColTol | ||
) |
This function merges objects of the labelled CLC if their color is nearly similar. This similarity test is local, meaning, objects with color 1,2,3 are merged to one object also if the maxColTol
is set to 1. If mergedMaxColTol
> 0, the total area of the objects with colors to be merged is tested against it, and if is out of range, the color of the merged object is set to colBg
.
rlcOut,clcOut,slcOut | Result output. |
rlc,clc,slc | Input RLC/CLC/SLC. |
maxColTol | Maximum local color tolerance to be merged. |
mergedMaxColTol | If greater than zero and area oversteps, the background color of the CLC is assigned to the merged object. |
I32 vc_clc_remove_objs_by_area | ( | U16 * | rlcOut, |
U16 * | clcOut, | ||
U16 * | slcOut, | ||
U16 * | rlc, | ||
U16 * | clc, | ||
U16 * | slc, | ||
I32 | minArea | ||
) |
This function melds all objects smaller than the given area with a random neighbour which must be greater than the area; so if there is not even one neighbour of such kind, the smaller area object is still present afterwards.
rlcOut,clcOut,slcOut | Result output. |
rlc,clc,slc | Input RLC/CLC/SLC. |
minArea | Minimum area to be kept. |
This function writes the CLC image defined by image variable rlc
and clc
to a RGB image. The color represents its clc
value by going from its minimum clc value to its maximum: Red -> Orange -> Yellow -> Green -> Cyan -> Blue -> Violet -> Pink. The pixel is turned black if a background pixel is detected (colBg=*(clc+3)).
imgRgb | The preallocated Destination Image. |
rlc,clc | Source Image Pointer. |
This function writes the CLC image defined by image variable rlc
and clc
as a color bitmap file (BMP) to the file specified by path
. The color represents its clc
value by going from its minimum clc value to its maximum: Red -> Orange -> Yellow -> Green -> Cyan -> Blue -> Violet -> Pink. The pixel is turned black if a background pixel is detected (colBg=*(clc+3)).
The image is stored in 24 Bit true-color mode.
path | The Destination File. |
rlc,clc | Source Image Pointer. |
ERR_MEMORY | on memory allocation failure. |
I32 mask_polygon | ( | image * | psImgIn, |
image * | psImgOut, | ||
U8 | color, | ||
U32 | u32CornerCount, | ||
I32 * | pi32PxLst, | ||
U8 | u8OutputSizeToSelectionIff1 | ||
) |
The function fills all but a polygon shaped image region. The polygon contour, especially the points provided, are not part of the mask being set to the given color color
, the inner of the polygon remains untouched. The function can be used to restrict one of the functions from the group 'Multiple Pixels to Values Mappings' to only a part of the image e.g., histogram of a polygon shaped area.
psImgIn | The Source Image of Type IMAGE_GREY. |
psImgOut | The Destination Image (may be equal to psImgIn ). |
color | The Fill Color. |
u32CornerCount | Count of Corners of the Polygon. |
pi32PxLst | List of u32CornerCount Point Coordinates as Pixel List [I32 p1x, I32 p1y, I32 p2x, ...]. |
u8OutputSizeToSelectionIff1 | recalculates psImgOut->dx, psImgOut->dy to fit the selection, use a psImgIn sized allocation for the psImgOut target! |
ERR_PARAM | if (u32CornerCount < 3) |
ERR_NONE | on Success. |
ERR_RLCFMT | if Internal RLC Generation fails. |
ERR_SLC | if Internal SLC Generation fails. |
ERR_PARAM | if given Polygon is not OK, e.g., Self Overlapping, Crossing Image Border. |
ERR_INCONS | if rlc_mask_image() fails. |
ERR_RLCFMT | if rl_ftr2() fails. |
ERR_BOUNDS | if a Point lies Outside of an Image. |
ERR_SINGULAR | if Singular or Self Intersecting. |
ERR_MEMORY | if Memory Allocation fails. |