Leptonica
1.54
|
#define L_BUF_SIZE 256 |
l_int32** create2dIntArray | ( | l_int32 | sy, |
l_int32 | sx | ||
) |
Input: sy (rows == height) sx (columns == width) Return: doubly indexed array (i.e., an array of sy row pointers, each of which points to an array of sx ints)
Notes: (1) The array[sy][sx] is indexed in standard "matrix notation", with the row index first.
l_int32 getCompositeParameters | ( | l_int32 | size, |
l_int32 * | psize1, | ||
l_int32 * | psize2, | ||
char ** | pnameh1, | ||
char ** | pnameh2, | ||
char ** | pnamev1, | ||
char ** | pnamev2 | ||
) |
Input: size &size1 (<optional return>=""> brick factor size) &size2 (<optional return>=""> comb factor size) &nameh1 (<optional return>=""> name of horiz brick) &nameh2 (<optional return>=""> name of horiz comb) &namev1 (<optional return>=""> name of vert brick) &namev2 (<optional return>=""> name of vert comb) Return: 0 if OK, 1 on error
Notes: (1) This uses the big lookup table at the top of this file. (2) All returned strings are copies that must be freed.
l_int32 selaAddSel | ( | SELA * | sela, |
SEL * | sel, | ||
const char * | selname, | ||
l_int32 | copyflag | ||
) |
Input: sela sel to be added selname (ignored if already defined in sel; req'd in sel when added to a sela) copyflag (for sel: 0 inserts, 1 copies) Return: 0 if OK; 1 on error
Notes: (1) This adds a sel, either inserting or making a copy. (2) Because every sel in a sela must have a name, it copies the input name if necessary. You can input NULL for selname if the sel already has a name.
SELA* selaCreate | ( | l_int32 | n | ) |
Input: n (initial number of sel ptrs; use 0 for default) Return: sela, or null on error
SELA* selaCreateFromFile | ( | const char * | filename | ) |
Input: filename Return: sela, or null on error
Notes: (1) The file contains a sequence of Sel descriptions. (2) Each Sel is formatted as follows:
void selaDestroy | ( | SELA ** | psela | ) |
Input: &sela (<to be="" nulled>="">) Return: void
Input: sela size (of grid interiors; odd; minimum size of 13 is enforced) gthick (grid thickness; minimum size of 2 is enforced) spacing (between sels, both horizontally and vertically) ncols (number of sels per "line") Return: pix (display of all sels in sela), or null on error
Notes: (1) This gives a visual representation of all the sels in a sela. (2) See notes in selDisplayInPix() for display params of each sel. (3) This gives the nicest results when all sels in the sela are the same size.
l_int32 selaExtendArray | ( | SELA * | sela | ) |
Input: sela Return: 0 if OK; 1 on error
l_int32 selaFindSelByName | ( | SELA * | sela, |
const char * | name, | ||
l_int32 * | pindex, | ||
SEL ** | psel | ||
) |
Input: sela sel name &index (<optional, return>) &sel (<optional, return> sel (not a copy)) Return: 0 if OK; 1 on error
char* selaGetBrickName | ( | SELA * | sela, |
l_int32 | hsize, | ||
l_int32 | vsize | ||
) |
Input: sela hsize, vsize (of brick sel) Return: sel name (new string), or null if no name or on error
char* selaGetCombName | ( | SELA * | sela, |
l_int32 | size, | ||
l_int32 | direction | ||
) |
Input: sela size (the product of sizes of the brick and comb parts) direction (L_HORIZ, L_VERT) Return: sel name (new string), or null if name not found or on error
Notes: (1) Combs are by definition 1-dimensional, either horiz or vert. (2) Use this with comb Sels; e.g., from selaAddDwaCombs().
l_int32 selaGetCount | ( | SELA * | sela | ) |
Input: sela Return: count, or 0 on error
SEL* selaGetSel | ( | SELA * | sela, |
l_int32 | i | ||
) |
Input: sela index of sel to be retrieved (not copied) Return: sel, or null on error
Notes: (1) This returns a ptr to the sel, not a copy, so the caller must not destroy it!
SARRAY* selaGetSelnames | ( | SELA * | sela | ) |
Input: sela Return: sa (of all sel names), or null on error
Input: filename Return: sela, or null on error
SELA* selaReadStream | ( | FILE * | fp | ) |
Input: stream Return: sela, or null on error
Input: filename sela Return: 0 if OK, 1 on error
l_int32 selaWriteStream | ( | FILE * | fp, |
SELA * | sela | ||
) |
Input: stream sela Return: 0 if OK, 1 on error
Input: height, width name (<optional> sel name; can be null) Return: sel, or null on error
Notes: (1) selCreate() initializes all values to 0. (2) After this call, (cy,cx) and nonzero data values must be assigned. If a text name is not assigned here, it will be needed later when the sel is put into a sela.
Input: height, width cy, cx (origin, relative to UL corner at 0,0) type (SEL_HIT, SEL_MISS, or SEL_DONT_CARE) Return: sel, or null on error
Notes: (1) This is a rectangular sel of all hits, misses or don't cares.
SEL* selCreateComb | ( | l_int32 | factor1, |
l_int32 | factor2, | ||
l_int32 | direction | ||
) |
Input: factor1 (contiguous space between comb tines) factor2 (number of comb tines) direction (L_HORIZ, L_VERT) Return: sel, or null on error
Notes: (1) This generates a comb Sel of hits with the origin as near the center as possible.
SEL* selCreateFromColorPix | ( | PIX * | pixs, |
char * | selname | ||
) |
Input: pixs (cmapped or rgb) selname (<optional> sel name; can be null) Return: sel if OK, null on error
Notes: (1) The sel size is given by the size of pixs. (2) In pixs, hits are represented by green pixels, misses by red pixels, and don't-cares by white pixels. (3) In pixs, there may be no misses, but there must be at least 1 hit. (4) At most there can be only one origin pixel, which is optionally specified by using a lower-intensity pixel: if a hit: dark green if a miss: dark red if a don't care: gray If there is no such pixel, the origin defaults to the approximate center of the sel.
SEL* selCreateFromPix | ( | PIX * | pix, |
l_int32 | cy, | ||
l_int32 | cx, | ||
const char * | name | ||
) |
Input: pix cy, cx (origin of sel) name (<optional> sel name; can be null) Return: sel, or null on error
Notes: (1) The origin must be positive.
SEL* selCreateFromPta | ( | PTA * | pta, |
l_int32 | cy, | ||
l_int32 | cx, | ||
const char * | name | ||
) |
Input: pta cy, cx (origin of sel) name (<optional> sel name; can be null) Return: sel (of minimum required size), or null on error
Notes: (1) The origin and all points in the pta must be positive.
static SEL * selCreateFromSArray | ( | SARRAY * | sa, |
l_int32 | first, | ||
l_int32 | last | ||
) | [static] |
Input: sa first (line of sarray where Sel begins) last (line of sarray where Sel ends) Return: sela, or null on error
Notes: (1) The Sel contains the following lines:
SEL* selCreateFromString | ( | const char * | text, |
l_int32 | h, | ||
l_int32 | w, | ||
const char * | name | ||
) |
Input: text height, width name (<optional> sel name; can be null) Return: sel of the given size, or null on error
Notes: (1) The text is an array of chars (in row-major order) where each char can be one of the following: 'x': hit 'o': miss ' ': don't-care (2) Use an upper case char to indicate the origin of the Sel. When the origin falls on a don't-care, use 'C' as the uppecase for ' '. (3) The text can be input in a format that shows the 2D layout; e.g., static const char *seltext = "x " "x Oo " "x " "xxxxx";
void selDestroy | ( | SEL ** | psel | ) |
Input: &sel (<to be="" nulled>="">) Return: void
PIX* selDisplayInPix | ( | SEL * | sel, |
l_int32 | size, | ||
l_int32 | gthick | ||
) |
Input: sel size (of grid interiors; odd; minimum size of 13 is enforced) gthick (grid thickness; minimum size of 2 is enforced) Return: pix (display of sel), or null on error
Notes: (1) This gives a visual representation of a general (hit-miss) sel. (2) The empty sel is represented by a grid of intersecting lines. (3) Three different patterns are generated for the sel elements:
l_int32 selFindMaxTranslations | ( | SEL * | sel, |
l_int32 * | pxp, | ||
l_int32 * | pyp, | ||
l_int32 * | pxn, | ||
l_int32 * | pyn | ||
) |
Input: sel &xp, &yp, &xn, &yn (<return> max shifts) Return: 0 if OK; 1 on error
Note: these are the maximum shifts for the erosion operation. For example, when j < cx, the shift of the image is +x to the cx. This is a positive xp shift.
Input: sel row col &type (<return> SEL_HIT, SEL_MISS, SEL_DONT_CARE) Return: 0 if OK; 1 on error
char* selGetName | ( | SEL * | sel | ) |
Input: sel Return: sel name (not copied), or null if no name or on error
Input: sel &sy, &sx, &cy, &cx (<optional return>="">; each can be null) Return: 0 if OK, 1 on error
l_int32 selGetTypeAtOrigin | ( | SEL * | sel, |
l_int32 * | ptype | ||
) |
Input: sel &type (<return> SEL_HIT, SEL_MISS, SEL_DONT_CARE) Return: 0 if OK; 1 on error or if origin is not found
char* selPrintToString | ( | SEL * | sel | ) |
Input: sel Return: str (string; caller must free)
Notes: (1) This is an inverse function of selCreateFromString. It prints a textual representation of the SEL to a malloc'd string. The format is the same as selCreateFromString except that newlines are inserted into the output between rows. (2) This is useful for debugging. However, if you want to save some Sels in a file, put them in a Sela and write them out with selaWrite(). They can then be read in with selaRead().
SEL* selReadFromColorImage | ( | const char * | pathname | ) |
Input: pathname Return: sel if OK; null on error
Notes: (1) Loads an image from a file and creates a (hit-miss) sel. (2) The sel name is taken from the pathname without the directory and extension.
SEL* selReadStream | ( | FILE * | fp | ) |
Input: stream Return: sel, or null on error
SEL* selRotateOrth | ( | SEL * | sel, |
l_int32 | quads | ||
) |
Input: sel quads (0 - 4; number of 90 degree cw rotations) Return: seld, or null on error
Input: sel row col type (SEL_HIT, SEL_MISS, SEL_DONT_CARE) Return: 0 if OK; 1 on error
Notes: (1) Because we use row and column to index into an array, they are always non-negative. The location of the origin (and the type of operation) determine the actual direction of the rasterop.
l_int32 selSetName | ( | SEL * | sel, |
const char * | name | ||
) |
Input: sel name (<optional>; can be null) Return: 0 if OK, 1 on error
Notes: (1) Always frees the existing sel name, if defined. (2) If name is not defined, just clears any existing sel name.
l_int32 selSetOrigin | ( | SEL * | sel, |
l_int32 | cy, | ||
l_int32 | cx | ||
) |
Input: sel cy, cx Return: 0 if OK; 1 on error
Input: filename sel Return: 0 if OK, 1 on error
l_int32 selWriteStream | ( | FILE * | fp, |
SEL * | sel | ||
) |
Input: stream sel Return: 0 if OK, 1 on error
struct CompParameterMap comp_parameter_map[] [static] |
const l_int32 INITIAL_PTR_ARRAYSIZE = 50 [static] |