Binary Image Library
|
#include <stdlib.h>
#include <string.h>
Macros | |
#define | CNT_TOPLEFT 0x80 |
#define | CNT_TOPRIGHT 0x40 |
#define | CNT_BOTTOMRIGHT 0x20 |
#define | CNT_BOTTOMLEFT 0x10 |
#define | CNT_RIGHT 1 |
#define | CNT_DOWN 2 |
#define | CNT_LEFT 3 |
#define | CNT_UP 4 |
Functions | |
int | morphclose (unsigned char *binary, int width, int height, unsigned char *sel, int swidth, int sheight) |
int | morphopen (unsigned char *binary, int width, int height, unsigned char *sel, int swidth, int sheight) |
int | dilate (unsigned char *binary, int width, int height, unsigned char *sel, int swidth, int sheight) |
int | erode (unsigned char *binary, int width, int height, unsigned char *sel, int swidth, int sheight) |
int * | labelconnected (unsigned char *binary, int width, int height, int connex, int *Nout) |
int | eulernumber (unsigned char *binary, int width, int height) |
int | getbiggestobject (unsigned char *binary, int width, int height, int connex) |
int | branchpoints (unsigned char *binary, int width, int height, int **xout, int **yout) |
int | ends (unsigned char *binary, int width, int height, int **xout, int **yout) |
unsigned char * | perimeter (unsigned char *binary, int width, int height) |
void | invertbinary (unsigned char *binary, int width, int height) |
unsigned char * | copybinary (unsigned char *binary, int width, int height) |
unsigned char * | subbinary (unsigned char *binary, int width, int height, int x, int y, int swidth, int sheight) |
void | boundingbox (unsigned char *binary, int width, int height, int *x, int *y, int *bbwidth, int *bbheight) |
int | simplearea (unsigned char *binary, int width, int height) |
double | complexarea (unsigned char *binary, int width, int height) |
void * | compressbinary (unsigned char *binary, int width, int height, int *clen) |
unsigned char * | decompressbinary (unsigned char *comp, int *width, int *height) |
int | getcontours (unsigned char *binary, int width, int height, double ***x, double ***y, int **Nret) |
int | lineends (unsigned char *binary, int width, int height, int **xout, int **yout) |
unsigned char * | binary_addborder (unsigned char *binary, int width, int height, int border, unsigned char fill) |
unsigned char * | binary_addborderwrapped (unsigned char *binary, int width, int height, int border) |
unsigned char * | binary_removeborder (unsigned char *binary, int width, int height, int border) |
Source for the binary image processing library simple utlities.
Put anything that is simple and stands alone more or less here.
Very much a first, provisional version.
By Malcolm McLean.
unsigned char* binary_addborder | ( | unsigned char * | binary, |
int | width, | ||
int | height, | ||
int | border, | ||
unsigned char | fill | ||
) |
Add a border to binary image (useful for removed edge conditions)
[in] | binary | - the binary image |
width | - image width | |
height | - image height |
unsigned char* binary_addborderwrapped | ( | unsigned char * | binary, |
int | width, | ||
int | height, | ||
int | border | ||
) |
Add border with wrapping (useful for some types of filters).
[in] | binary | - the binary image |
width | - image width | |
height | - image height | |
border | - number of border pixels to add |
unsigned char* binary_removeborder | ( | unsigned char * | binary, |
int | width, | ||
int | height, | ||
int | border | ||
) |
Remove a border from a binary image.
[in] | binary | - the binary image |
width | - image width | |
height | - image height | |
border | - number of border pixels to remove |
void boundingbox | ( | unsigned char * | binary, |
int | width, | ||
int | height, | ||
int * | x, | ||
int * | y, | ||
int * | bbwidth, | ||
int * | bbheight | ||
) |
Get the bounding box of the set pixels in binary image.
[in] | binary | - the binary image |
width | - image width | |
height | - image height | |
[out] | x | return for bounding box top left x co-ordinate |
[out] | y | return for bounding box top left y co-ordinate |
[out] | bbwidth | - return for bounding box width |
[out] | bbheight | - return for bounding box height |
int branchpoints | ( | unsigned char * | binary, |
int | width, | ||
int | height, | ||
int ** | xout, | ||
int ** | yout | ||
) |
Get branch points
[in] | binary | - the binary image |
width | - image width | |
height | - image height | |
[out] | xout | - return for branch point x-coordiantes (malloced) |
[out] | yout | - return for branch point y-coordinates ( malloced) |
double complexarea | ( | unsigned char * | binary, |
int | width, | ||
int | height | ||
) |
Get the area of binary image, weighting pixels by pattern.
[in] | binary | - the binary image |
width | - image width | |
height | - image height |
void * compressbinary | ( | unsigned char * | binary, |
int | width, | ||
int | height, | ||
int * | clen | ||
) |
Quick run-length compression of a binary image.
[in] | binary | - the binary image |
width | - image width | |
height | - image height | |
[out] | clen | - return pointer for length of compressed data |
unsigned char * copybinary | ( | unsigned char * | binary, |
int | width, | ||
int | height | ||
) |
Copy a binary image.
[in] | binary | - the binary image |
width | - iamge width | |
height | - image height |
unsigned char * decompressbinary | ( | unsigned char * | comp, |
int * | width, | ||
int * | height | ||
) |
Decompression of run-length compressed binary image.
[in] | comp | - pointer to the compressed data |
[out] | width | - return pointer for image width |
[out] | height | - return pointer for image height |
static int dilate | ( | unsigned char * | binary, |
int | width, | ||
int | height, | ||
unsigned char * | sel, | ||
int | swidth, | ||
int | sheight | ||
) |
Dilate operation.
[in,out] | bianry | - the binary image |
width | - image width | |
height | - image height | |
sel[in] | - the selection element | |
swidth | - selection element width | |
sheight | - selection element height |
int ends | ( | unsigned char * | binary, |
int | width, | ||
int | height, | ||
int ** | xout, | ||
int ** | yout | ||
) |
Get ends
[in] | binary | - the binary image |
width | - image width | |
height | - image height | |
[out] | xout | - return for end x-coordiantes (malloced) |
[out] | yout | - return for end y-coordinates ( malloced) |
int erode | ( | unsigned char * | binary, |
int | width, | ||
int | height, | ||
unsigned char * | sel, | ||
int | swidth, | ||
int | sheight | ||
) |
Erode operation.
[in,out] | bianry | - the binary image |
width | - image width | |
height | - image height | |
sel[in] | - the selection element | |
swidth | - selection element width | |
sheight | - selection element height |
int eulernumber | ( | unsigned char * | binary, |
int | width, | ||
int | height | ||
) |
Calculate the Euler number for a binary image.
[in] binary - the binary image
width | - image width |
height | - image height |
int getbiggestobject | ( | unsigned char * | binary, |
int | width, | ||
int | height, | ||
int | connex | ||
) |
Erase everything except biggest object in bianry image.
[in.out] | binary - the binary image |
width | - image width |
height | - image height |
connex | - 4 or 8 connectivity |
int getcontours | ( | unsigned char * | binary, |
int | width, | ||
int | height, | ||
double *** | x, | ||
double *** | y, | ||
int ** | Nret | ||
) |
Go round a binary image, extracting the contours of the set pixels.
[in] | binary | - the image |
width | - image width | |
height | - image height | |
[out] | x | - return for x co-ordinates of contours (malloced) |
[out] | y | - return for y co-ordinates of contours (malloced) |
[out] | Nret | - return for contour lengths (malloced) |
void invertbinary | ( | unsigned char * | binary, |
int | width, | ||
int | height | ||
) |
Invert a binary image.
[in,out] | binary | - the binary image |
width | - image width | |
height | - image height |
int * labelconnected | ( | unsigned char * | binary, |
int | width, | ||
int | height, | ||
int | connex, | ||
int * | Nout | ||
) |
Label connected components in binary image.
[in] | binary | - the binary image |
width | - image width | |
height | - image height | |
connex | - 4 or 8 connectivity | |
[out] | Nout | - number of components found returns Width * height array of labels for connected components. |
int lineends | ( | unsigned char * | binary, |
int | width, | ||
int | height, | ||
int ** | xout, | ||
int ** | yout | ||
) |
Get line end points
[in] | binary | - the binary image |
width | - image width | |
height | - image height | |
[out] | xout | - return for branch point x-coordiantes (malloced) |
[out] | yout | - return for branch point y-coordinates ( malloced) |
int morphclose | ( | unsigned char * | binary, |
int | width, | ||
int | height, | ||
unsigned char * | sel, | ||
int | swidth, | ||
int | sheight | ||
) |
Morphological close operation.
[in,out] | bianry | - the binary image |
width | - image width | |
height | - image height | |
sel[in] | - the selection element | |
swidth | - selection element width | |
sheight | - selection element height |
int morphopen | ( | unsigned char * | binary, |
int | width, | ||
int | height, | ||
unsigned char * | sel, | ||
int | swidth, | ||
int | sheight | ||
) |
Morphological open operation.
[in,out] | bianry | - the binary image |
width | - image width | |
height | - image height | |
sel[in] | - the selection element | |
swidth | - selection element width | |
sheight | - selection element height |
unsigned char * perimeter | ( | unsigned char * | binary, |
int | width, | ||
int | height | ||
) |
get perimeter pixels.
[in] | binary | - the bianry image |
width | - image width | |
height | - image height |
int simplearea | ( | unsigned char * | binary, |
int | width, | ||
int | height | ||
) |
Get the area (number of set pixels) in a binary image.
[in] | binary | - the binary image |
width | - image width | |
height | - image height |
unsigned char * subbinary | ( | unsigned char * | binary, |
int | width, | ||
int | height, | ||
int | x, | ||
int | y, | ||
int | swidth, | ||
int | sheight | ||
) |
Take a sub-image of a binary image.
[in] | binary | - the binary image |
width | - image width | |
height | - image height | |
x | - top left x co-ordinate of sub-image | |
y | - top left y co-ordinate of sub-image | |
swidth | - sub image width | |
sheight | - sub image height |