![]() |
Leptonica
1.82.0
Image processing and image analysis suite
|
#include <string.h>
#include "allheaders.h"
Go to the source code of this file.
Functions | |
static l_int32 | pixaExtendArray (PIXA *pixa) |
static l_int32 | pixaaExtendArray (PIXAA *paa) |
PIXA * | pixaCreate (l_int32 n) |
PIXA * | pixaCreateFromPix (PIX *pixs, l_int32 n, l_int32 cellw, l_int32 cellh) |
PIXA * | pixaCreateFromBoxa (PIX *pixs, BOXA *boxa, l_int32 start, l_int32 num, l_int32 *pcropwarn) |
PIXA * | pixaSplitPix (PIX *pixs, l_int32 nx, l_int32 ny, l_int32 borderwidth, l_uint32 bordercolor) |
void | pixaDestroy (PIXA **ppixa) |
PIXA * | pixaCopy (PIXA *pixa, l_int32 copyflag) |
l_ok | pixaAddPix (PIXA *pixa, PIX *pix, l_int32 copyflag) |
l_ok | pixaAddBox (PIXA *pixa, BOX *box, l_int32 copyflag) |
l_ok | pixaExtendArrayToSize (PIXA *pixa, size_t size) |
l_int32 | pixaGetCount (PIXA *pixa) |
l_ok | pixaChangeRefcount (PIXA *pixa, l_int32 delta) |
PIX * | pixaGetPix (PIXA *pixa, l_int32 index, l_int32 accesstype) |
l_ok | pixaGetPixDimensions (PIXA *pixa, l_int32 index, l_int32 *pw, l_int32 *ph, l_int32 *pd) |
BOXA * | pixaGetBoxa (PIXA *pixa, l_int32 accesstype) |
l_int32 | pixaGetBoxaCount (PIXA *pixa) |
BOX * | pixaGetBox (PIXA *pixa, l_int32 index, l_int32 accesstype) |
l_ok | pixaGetBoxGeometry (PIXA *pixa, l_int32 index, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph) |
l_ok | pixaSetBoxa (PIXA *pixa, BOXA *boxa, l_int32 accesstype) |
PIX ** | pixaGetPixArray (PIXA *pixa) |
l_ok | pixaVerifyDepth (PIXA *pixa, l_int32 *psame, l_int32 *pmaxd) |
l_ok | pixaVerifyDimensions (PIXA *pixa, l_int32 *psame, l_int32 *pmaxw, l_int32 *pmaxh) |
l_ok | pixaIsFull (PIXA *pixa, l_int32 *pfullpa, l_int32 *pfullba) |
l_ok | pixaCountText (PIXA *pixa, l_int32 *pntext) |
l_ok | pixaSetText (PIXA *pixa, const char *text, SARRAY *sa) |
void *** | pixaGetLinePtrs (PIXA *pixa, l_int32 *psize) |
l_ok | pixaWriteStreamInfo (FILE *fp, PIXA *pixa) |
l_ok | pixaReplacePix (PIXA *pixa, l_int32 index, PIX *pix, BOX *box) |
l_ok | pixaInsertPix (PIXA *pixa, l_int32 index, PIX *pixs, BOX *box) |
l_ok | pixaRemovePix (PIXA *pixa, l_int32 index) |
l_ok | pixaRemovePixAndSave (PIXA *pixa, l_int32 index, PIX **ppix, BOX **pbox) |
l_ok | pixaRemoveSelected (PIXA *pixa, NUMA *naindex) |
l_ok | pixaInitFull (PIXA *pixa, PIX *pix, BOX *box) |
l_ok | pixaClear (PIXA *pixa) |
l_ok | pixaJoin (PIXA *pixad, PIXA *pixas, l_int32 istart, l_int32 iend) |
PIXA * | pixaInterleave (PIXA *pixa1, PIXA *pixa2, l_int32 copyflag) |
l_ok | pixaaJoin (PIXAA *paad, PIXAA *paas, l_int32 istart, l_int32 iend) |
PIXAA * | pixaaCreate (l_int32 n) |
PIXAA * | pixaaCreateFromPixa (PIXA *pixa, l_int32 n, l_int32 type, l_int32 copyflag) |
void | pixaaDestroy (PIXAA **ppaa) |
l_ok | pixaaAddPixa (PIXAA *paa, PIXA *pixa, l_int32 copyflag) |
l_ok | pixaaAddPix (PIXAA *paa, l_int32 index, PIX *pix, BOX *box, l_int32 copyflag) |
l_ok | pixaaAddBox (PIXAA *paa, BOX *box, l_int32 copyflag) |
l_int32 | pixaaGetCount (PIXAA *paa, NUMA **pna) |
PIXA * | pixaaGetPixa (PIXAA *paa, l_int32 index, l_int32 accesstype) |
BOXA * | pixaaGetBoxa (PIXAA *paa, l_int32 accesstype) |
PIX * | pixaaGetPix (PIXAA *paa, l_int32 index, l_int32 ipix, l_int32 accessflag) |
l_ok | pixaaVerifyDepth (PIXAA *paa, l_int32 *psame, l_int32 *pmaxd) |
l_ok | pixaaVerifyDimensions (PIXAA *paa, l_int32 *psame, l_int32 *pmaxw, l_int32 *pmaxh) |
l_int32 | pixaaIsFull (PIXAA *paa, l_int32 *pfull) |
l_ok | pixaaInitFull (PIXAA *paa, PIXA *pixa) |
l_ok | pixaaReplacePixa (PIXAA *paa, l_int32 index, PIXA *pixa) |
l_ok | pixaaClear (PIXAA *paa) |
l_ok | pixaaTruncate (PIXAA *paa) |
PIXA * | pixaRead (const char *filename) |
PIXA * | pixaReadStream (FILE *fp) |
PIXA * | pixaReadMem (const l_uint8 *data, size_t size) |
l_ok | pixaWriteDebug (const char *fname, PIXA *pixa) |
l_ok | pixaWrite (const char *filename, PIXA *pixa) |
l_ok | pixaWriteStream (FILE *fp, PIXA *pixa) |
l_ok | pixaWriteMem (l_uint8 **pdata, size_t *psize, PIXA *pixa) |
PIXA * | pixaReadBoth (const char *filename) |
PIXAA * | pixaaReadFromFiles (const char *dirname, const char *substr, l_int32 first, l_int32 nfiles) |
PIXAA * | pixaaRead (const char *filename) |
PIXAA * | pixaaReadStream (FILE *fp) |
PIXAA * | pixaaReadMem (const l_uint8 *data, size_t size) |
l_ok | pixaaWrite (const char *filename, PIXAA *paa) |
l_ok | pixaaWriteStream (FILE *fp, PIXAA *paa) |
l_ok | pixaaWriteMem (l_uint8 **pdata, size_t *psize, PIXAA *paa) |
Variables | |
static const size_t | MaxInitPtrArraySize = 100000 |
static const size_t | MaxPixaPtrArraySize = 5000000 |
static const size_t | MaxPixaaPtrArraySize = 1000000 |
static const size_t | InitialPtrArraySize = 20 |
Pixa creation, destruction, copying PIXA *pixaCreate() PIXA *pixaCreateFromPix() PIXA *pixaCreateFromBoxa() PIXA *pixaSplitPix() void pixaDestroy() PIXA *pixaCopy() Pixa addition l_int32 pixaAddPix() l_int32 pixaAddBox() static l_int32 pixaExtendArray() l_int32 pixaExtendArrayToSize() Pixa accessors l_int32 pixaGetCount() l_int32 pixaChangeRefcount() PIX *pixaGetPix() l_int32 pixaGetPixDimensions() BOXA *pixaGetBoxa() l_int32 pixaGetBoxaCount() BOX *pixaGetBox() l_int32 pixaGetBoxGeometry() l_int32 pixaSetBoxa() PIX **pixaGetPixArray() l_int32 pixaVerifyDepth() l_int32 pixaVerifyDimensions() l_int32 pixaIsFull() l_int32 pixaCountText() l_int32 pixaSetText() void ***pixaGetLinePtrs() Pixa output info l_int32 pixaWriteStreamInfo() Pixa array modifiers l_int32 pixaReplacePix() l_int32 pixaInsertPix() l_int32 pixaRemovePix() l_int32 pixaRemovePixAndSave() l_int32 pixaRemoveSelected() l_int32 pixaInitFull() l_int32 pixaClear() Pixa and Pixaa combination l_int32 pixaJoin() PIXA *pixaInterleave() l_int32 pixaaJoin() Pixaa creation, destruction PIXAA *pixaaCreate() PIXAA *pixaaCreateFromPixa() void pixaaDestroy() Pixaa addition l_int32 pixaaAddPixa() static l_int32 pixaaExtendArray() l_int32 pixaaAddPix() l_int32 pixaaAddBox() Pixaa accessors l_int32 pixaaGetCount() PIXA *pixaaGetPixa() BOXA *pixaaGetBoxa() PIX *pixaaGetPix() l_int32 pixaaVerifyDepth() l_int32 pixaaVerifyDimensions() l_int32 pixaaIsFull() Pixaa array modifiers l_int32 pixaaInitFull() l_int32 pixaaReplacePixa() l_int32 pixaaClear() l_int32 pixaaTruncate() Pixa serialized I/O (requires png support) PIXA *pixaRead() PIXA *pixaReadStream() PIXA *pixaReadMem() l_int32 pixaWriteDebug() l_int32 pixaWrite() l_int32 pixaWriteStream() l_int32 pixaWriteMem() PIXA *pixaReadBoth() Pixaa serialized I/O (requires png support) PIXAA *pixaaReadFromFiles() PIXAA *pixaaRead() PIXAA *pixaaReadStream() PIXAA *pixaaReadMem() l_int32 pixaaWrite() l_int32 pixaaWriteStream() l_int32 pixaaWriteMem() Important note on reference counting: Reference counting for the Pixa is analogous to that for the Boxa. See pix.h for details. pixaCopy() provides three possible modes of copy. The basic rule is that however a Pixa is obtained (e.g., from pixaCreate*(), pixaCopy(), or a Pixaa accessor), it is necessary to call pixaDestroy() on it.
Definition in file pixabasic.c.
[in] | paa | |
[in] | box | |
[in] | copyflag | L_INSERT, L_COPY, L_CLONE |
Notes: (1) The box can be used, for example, to hold the support region of a pixa that is being added to the pixaa.
Definition at line 2122 of file pixabasic.c.
References Pixaa::boxa, boxaAddBox(), L_CLONE, L_COPY, and L_INSERT.
[in] | paa | input paa |
[in] | index | index of pixa in paa |
[in] | pix | to be added |
[in] | box | [optional] to be added |
[in] | copyflag | L_INSERT, L_COPY, L_CLONE |
Definition at line 2083 of file pixabasic.c.
References L_CLONE, pixaAddBox(), pixaAddPix(), pixaaGetPixa(), and pixaDestroy().
Referenced by recogAddAllSamples(), and recogTrainingFinished().
[in] | paa | |
[in] | pixa | to be added |
[in] | copyflag | L_INSERT inserts the pixa directly; L_COPY makes a new pixa and copies each pix and each box; L_CLONE gives a new handle to the input pixa; L_COPY_CLONE makes a new pixa and inserts clones of all pix and boxes |
Definition at line 1998 of file pixabasic.c.
References L_CLONE, L_COPY, L_COPY_CLONE, L_INSERT, Pixaa::n, Pixaa::nalloc, Pixaa::pixa, pixaaExtendArray(), pixaaGetCount(), pixaCopy(), and pixaDestroy().
Referenced by pixaaCreateFromPixa(), pixaaJoin(), pixaaReadFromFiles(), pixaaScaleToSize(), pixaaScaleToSizeVar(), pixaaSelectRange(), pixaSort2dByIndex(), recogAddAllSamples(), and recogDebugAverages().
l_ok pixaaClear | ( | PIXAA * | paa | ) |
[in] | paa |
Notes: (1) This destroys all pixa in the pixaa, and nulls the ptrs in the pixa ptr array.
Definition at line 2532 of file pixabasic.c.
References Pixaa::n, Pixaa::pixa, pixaaGetCount(), and pixaDestroy().
PIXAA* pixaaCreate | ( | l_int32 | n | ) |
[in] | n | initial number of pixa ptrs |
Notes: (1) A pixaa provides a 2-level hierarchy of images. A common use is for segmentation masks, which are inexpensive to store in png format. (2) For example, suppose you want a mask for each textline in a two-column page. The textline masks for each column can be represented by a pixa, of which there are 2 in the pixaa. The boxes for the textline mask components within a column can have their origin referred to the column rather than the page. Then the boxa field can be used to represent the two box (regions) for the columns, and the (x,y) components of each box can be used to get the absolute position of the textlines on the page.
Definition at line 1852 of file pixabasic.c.
Referenced by pixaaCreateFromPixa(), pixaaReadFromFiles(), pixaaScaleToSize(), pixaaScaleToSizeVar(), pixaaSelectRange(), pixaSort2dByIndex(), recogDebugAverages(), and recogTrainingFinished().
[in] | pixa | |
[in] | n | number specifying subdivision of pixa |
[in] | type | L_CHOOSE_CONSECUTIVE, L_CHOOSE_SKIP_BY |
[in] | copyflag | L_CLONE, L_COPY |
Notes: (1) This subdivides a pixa into a set of smaller pixa that are accumulated into a pixaa. (2) If type == L_CHOOSE_CONSECUTIVE, the first 'n' pix are put in a pixa and added to pixaa, then the next 'n', etc. If type == L_CHOOSE_SKIP_BY, the first pixa is made by aggregating pix[0], pix[n], pix[2*n], etc. (3) The copyflag specifies if each new pix is a copy or a clone.
Definition at line 1895 of file pixabasic.c.
References L_CHOOSE_CONSECUTIVE, L_CHOOSE_SKIP_BY, L_CLONE, L_COPY, L_INSERT, pixaaAddPixa(), pixaaCreate(), pixaAddPix(), pixaCreate(), pixaGetCount(), and pixaGetPix().
[in] | pixa | |
[in] | box | |
[in] | copyflag | L_INSERT, L_COPY, L_CLONE |
Definition at line 555 of file pixabasic.c.
References Pixa::boxa, boxaAddBox(), L_CLONE, L_COPY, and L_INSERT.
Referenced by pixaaAddPix(), pixaaFlattenToPixa(), pixaClipToPix(), pixaCopy(), pixaCreateFromBoxa(), pixaDisplayTiledByIndex(), pixaInterleave(), pixaMorphSequenceByComponent(), pixaRotateOrth(), pixaSelectWithIndicator(), pixaSelectWithString(), pixaSort2dByIndex(), pixaSortByIndex(), pixClipRectangles(), and wshedSaveBasin().
[in] | pixa | |
[in] | pix | to be added |
[in] | copyflag | L_INSERT, L_COPY, L_CLONE |
Definition at line 506 of file pixabasic.c.
References L_CLONE, L_COPY, L_INSERT, Pixa::n, Pixa::nalloc, Pixa::pix, pixaExtendArray(), pixaGetCount(), pixClone(), pixCopy(), and pixDestroy().
Referenced by boxaCombineOverlaps(), boxaCombineOverlapsInPair(), boxaCompareRegions(), boxaDisplayTiled(), dewarpaShowArrays(), evalColorfillData(), fpixaDisplayQuadtree(), makeColorfillTestData(), pixaaAddPix(), pixaaCreateFromPixa(), pixaAddBorderGeneral(), pixaAddPixWithText(), pixaAddTextlines(), pixaAddTextNumber(), pixaaDisplayByPixa(), pixaaDisplayTiledAndScaled(), pixaaFlattenToPixa(), pixaClipToForeground(), pixaClipToPix(), pixaConstrainedSelect(), pixaConvertTo1(), pixaConvertTo32(), pixaConvertTo8(), pixaConvertTo8Colormap(), pixaConvertToNUpPixa(), pixaConvertToSameDepth(), pixaCopy(), pixaCreateFromBoxa(), pixaCreateFromPix(), pixaCreateFromPixacomp(), pixaDisplayBoxaa(), pixaDisplayMultiTiled(), pixaDisplayOnLattice(), pixaDisplayTiled(), pixaDisplayTiledAndScaled(), pixaDisplayTiledByIndex(), pixaDisplayTiledInRows(), pixaDisplayTiledWithText(), pixaInterleave(), pixaJoin(), pixaModifyStrokeWidth(), pixaMorphSequenceByComponent(), pixaReadFilesSA(), pixaReadMemMultipageTiff(), pixaReadMultipageTiff(), pixaRotateOrth(), pixaScaleToSizeRel(), pixaSelectRange(), pixaSelectWithIndicator(), pixaSelectWithString(), pixaSetStrokeWidth(), pixaSort2dByIndex(), pixaSortByIndex(), pixaSplitIntoFiles(), pixaSplitPix(), pixaThinConnected(), pixaTranslate(), pixAutoPhotoinvert(), pixClipRectangles(), pixCompareGrayByHisto(), pixCompareWithTranslation(), pixDecideIfTable(), pixDisplayColorArray(), pixDisplayOutliers(), pixMakeGamutRGB(), recogAddDigitPadTemplates(), recogAverageSamples(), recogDebugAverages(), recogDisplayOutlier(), recogFilterPixaBySize(), recogShowAverageTemplates(), recogShowMatch(), recogShowMatchesInRange(), recogTrainFromBoot(), selaAddCrossJunctions(), selaAddTJunctions(), selaDisplayInPix(), showExtractNumbers(), and wshedSaveBasin().
void pixaaDestroy | ( | PIXAA ** | ppaa | ) |
[in,out] | ppaa | use ptr address so it will be nulled |
Definition at line 1957 of file pixabasic.c.
References Pixaa::boxa, boxaDestroy(), Pixaa::n, Pixaa::pixa, and pixaDestroy().
Referenced by pixGetWordsInTextlines(), recogDestroy(), recogFilterPixaBySize(), and recogTrainingFinished().
|
static |
[in] | paa |
Notes: (1) The max number of pixa ptrs is 1M.
Definition at line 2048 of file pixabasic.c.
References Pixaa::nalloc.
Referenced by pixaaAddPixa().
[in] | paa | |
[in] | accesstype | L_COPY, L_CLONE |
Notes: (1) L_COPY returns a copy; L_CLONE returns a new reference to the boxa. (2) In both cases, invoke boxaDestroy() on the returned boxa.
Definition at line 2244 of file pixabasic.c.
References Pixaa::boxa, boxaCopy(), L_CLONE, and L_COPY.
Referenced by pixaaDisplay().
[in] | paa | |
[out] | pna | [optional] number of pix in each pixa |
Notes: (1) If paa is empty, a returned na will also be empty.
Definition at line 2157 of file pixabasic.c.
References L_CLONE, Pixaa::n, numaAddNumber(), numaCreate(), pixaaGetPixa(), pixaDestroy(), and pixaGetCount().
Referenced by pixaaAddPixa(), pixaaClear(), pixaaDisplay(), pixaaDisplayByPixa(), pixaaDisplayTiledAndScaled(), pixaaFlattenToPixa(), pixaaIsFull(), pixaaJoin(), pixaaScaleToSize(), pixaaScaleToSizeVar(), pixaaSelectRange(), pixaaSizeRange(), pixaaTruncate(), pixaaVerifyDepth(), pixaaVerifyDimensions(), pixaaWriteStream(), recogAddAllSamples(), recogAddCharstrLabels(), recogAddMissingClassStrings(), recogDebugAverages(), recogFilterPixaBySize(), recogIsPaddingNeeded(), and recogShowContent().
[in] | paa | |
[in] | index | index into the pixa array in the pixaa |
[in] | ipix | index into the pix array in the pixa |
[in] | accessflag | L_COPY or L_CLONE |
Definition at line 2268 of file pixabasic.c.
References L_CLONE, pixaaGetPixa(), pixaDestroy(), and pixaGetPix().
Referenced by recogDebugAverages(), recogDisplayOutlier(), and recogShowPath().
[in] | paa | |
[in] | index | to the index-th pixa |
[in] | accesstype | L_COPY, L_CLONE, L_COPY_CLONE |
Notes: (1) L_COPY makes a new pixa with a copy of every pix (2) L_CLONE just makes a new reference to the pixa, and bumps the counter. You would use this, for example, when you need to extract some data from a pix within a pixa within a pixaa. (3) L_COPY_CLONE makes a new pixa with a clone of every pix and box (4) In all cases, you must invoke pixaDestroy() on the returned pixa
Definition at line 2206 of file pixabasic.c.
References L_CLONE, L_COPY, L_COPY_CLONE, Pixaa::n, Pixaa::pixa, and pixaCopy().
Referenced by pixaaAddPix(), pixaaDisplay(), pixaaDisplayByPixa(), pixaaDisplayTiledAndScaled(), pixaaFlattenToPixa(), pixaaGetCount(), pixaaGetPix(), pixaaIsFull(), pixaaJoin(), pixaaScaleToSize(), pixaaScaleToSizeVar(), pixaaSelectRange(), pixaaSizeRange(), pixaaTruncate(), pixaaVerifyDepth(), pixaaVerifyDimensions(), pixaaWriteStream(), recogAddAllSamples(), recogAddCharstrLabels(), recogAverageSamples(), recogDebugAverages(), recogFilterPixaBySize(), and recogTrainingFinished().
[in] | paa | typically empty |
[in] | pixa | to be replicated into the entire pixa ptr array |
Notes: (1) This initializes a pixaa by filling up the entire pixa ptr array with copies of pixa. Any existing pixa are destroyed. (2) Example usage. This function is useful to prepare for a random insertion (or replacement) of pixa into a pixaa. To randomly insert pixa into a pixaa, up to some index "max": Pixaa *paa = pixaaCreate(max); Pixa *pixa = pixaCreate(1); // if you want little memory pixaaInitFull(paa, pixa); // copy it to entire array pixaDestroy(&pixa); // no longer needed The initialization allows the pixaa to always be properly filled.
Definition at line 2457 of file pixabasic.c.
References L_COPY, Pixaa::n, Pixaa::nalloc, pixaaReplacePixa(), and pixaCopy().
Referenced by recogTrainingFinished().
l_int32 pixaaIsFull | ( | PIXAA * | paa, |
l_int32 * | pfull | ||
) |
[in] | paa | |
[out] | pfull | 1 if all pixa in the paa have full pix arrays |
Notes: (1) Does not require boxa associated with each pixa to be full.
Definition at line 2405 of file pixabasic.c.
References L_CLONE, pixaaGetCount(), pixaaGetPixa(), pixaDestroy(), and pixaIsFull().
[in] | paad | dest pixaa; add to this one |
[in] | paas | [optional] source pixaa; add from this one |
[in] | istart | starting index in pixaas |
[in] | iend | ending index in pixaas; use -1 to cat all |
Notes: (1) This appends a clone of each indicated pixa in paas to pixaad (2) istart < 0 is taken to mean 'read from the start' (istart = 0) (3) iend < 0 means 'read to the end'
Definition at line 1794 of file pixabasic.c.
References L_CLONE, L_INSERT, pixaaAddPixa(), pixaaGetCount(), and pixaaGetPixa().
PIXAA* pixaaRead | ( | const char * | filename | ) |
[in] | filename |
Notes: (1) The pix are stored in the file as png. If the png library is not linked, this will fail.
Definition at line 3028 of file pixabasic.c.
References fopenReadStream(), and pixaaReadStream().
PIXAA* pixaaReadFromFiles | ( | const char * | dirname, |
const char * | substr, | ||
l_int32 | first, | ||
l_int32 | nfiles | ||
) |
[in] | dirname | directory |
[in] | substr | [optional] substring filter on filenames; can be NULL |
[in] | first | 0-based |
[in] | nfiles | use 0 for everything from first to the end |
Notes: (1) The files must be serialized pixa files (e.g., *.pa) If some files cannot be read, warnings are issued. (2) Use substr to filter filenames in the directory. If substr == NULL, this takes all files. (3) After filtering, use first and nfiles to select a contiguous set of files, that have been lexically sorted in increasing order.
Definition at line 2978 of file pixabasic.c.
References getSortedPathnamesInDirectory(), L_INSERT, L_NOCOPY, pixaaAddPixa(), pixaaCreate(), pixaRead(), sarrayDestroy(), sarrayGetCount(), and sarrayGetString().
PIXAA* pixaaReadMem | ( | const l_uint8 * | data, |
size_t | size | ||
) |
[in] | data | of serialized pixaa |
[in] | size | of data in bytes |
Definition at line 3129 of file pixabasic.c.
References fopenReadFromMemory(), and pixaaReadStream().
PIXAA* pixaaReadStream | ( | FILE * | fp | ) |
[in] | fp | file stream |
Notes: (1) The pix are stored in the file as png. If the png library is not linked, this will fail. (2) It is OK for the pixaa to be empty.
Definition at line 3066 of file pixabasic.c.
References PIXAA_VERSION_NUMBER.
Referenced by pixaaRead(), and pixaaReadMem().
[in] | paa | |
[in] | index | to the index-th pixa |
[in] | pixa | insert to replace existing one |
Notes: (1) This allows random insertion of a pixa into a pixaa, with destruction of any existing pixa at that location. The input pixa is now owned by the pixaa. (2) No other pixa in the array are affected. (3) The index must be within the allowed set.
Definition at line 2499 of file pixabasic.c.
References Pixaa::n, Pixaa::pixa, and pixaDestroy().
Referenced by pixaaInitFull().
l_ok pixaaTruncate | ( | PIXAA * | paa | ) |
[in] | paa |
Notes: (1) This identifies the largest index containing a pixa that has any pix within it, destroys all pixa above that index, and resets the count.
Definition at line 2563 of file pixabasic.c.
References L_CLONE, Pixaa::n, Pixaa::pixa, pixaaGetCount(), pixaaGetPixa(), pixaDestroy(), and pixaGetCount().
Referenced by recogTrainingFinished().
l_ok pixaaVerifyDepth | ( | PIXAA * | paa, |
l_int32 * | psame, | ||
l_int32 * | pmaxd | ||
) |
[in] | paa | |
[out] | psame | 1 if all pix have the same depth; 0 otherwise |
[out] | pmaxd | [optional] max depth of all pix in pixaa |
Notes: (1) It is considered to be an error if any pixa have no pix.
Definition at line 2301 of file pixabasic.c.
References L_CLONE, pixaaGetCount(), pixaaGetPixa(), pixaDestroy(), and pixaVerifyDepth().
l_ok pixaaVerifyDimensions | ( | PIXAA * | paa, |
l_int32 * | psame, | ||
l_int32 * | pmaxw, | ||
l_int32 * | pmaxh | ||
) |
[in] | paa | |
[out] | psame | 1 if all pix have the same depth; 0 otherwise |
[out] | pmaxw | [optional] max width of all pix in pixaa |
[out] | pmaxh | [optional] max height of all pix in pixaa |
Notes: (1) It is considered to be an error if any pixa have no pix.
Definition at line 2351 of file pixabasic.c.
References L_CLONE, pixaaGetCount(), pixaaGetPixa(), pixaDestroy(), and pixaVerifyDimensions().
l_ok pixaaWrite | ( | const char * | filename, |
PIXAA * | paa | ||
) |
[in] | filename | |
[in] | paa |
Notes: (1) The pix are stored in the file as png. If the png library is not linked, this will fail.
Definition at line 3163 of file pixabasic.c.
References fopenWriteStream(), and pixaaWriteStream().
l_ok pixaaWriteMem | ( | l_uint8 ** | pdata, |
size_t * | psize, | ||
PIXAA * | paa | ||
) |
[out] | pdata | data of serialized pixaa |
[out] | psize | size of returned data |
[in] | paa |
Notes: (1) Serializes a pixaa in memory and puts the result in a buffer.
Definition at line 3250 of file pixabasic.c.
References fopenWriteWinTempfile(), l_binaryReadStream(), and pixaaWriteStream().
l_ok pixaaWriteStream | ( | FILE * | fp, |
PIXAA * | paa | ||
) |
[in] | fp | file stream opened for "wb" |
[in] | paa |
Notes: (1) The pix are stored in the file as png. If the png library is not linked, this will fail.
Definition at line 3204 of file pixabasic.c.
References Pixaa::boxa, boxaWriteStream(), L_CLONE, PIXAA_VERSION_NUMBER, pixaaGetCount(), pixaaGetPixa(), pixaDestroy(), and pixaWriteStream().
Referenced by pixaaWrite(), and pixaaWriteMem().
l_ok pixaChangeRefcount | ( | PIXA * | pixa, |
l_int32 | delta | ||
) |
[in] | pixa | |
[in] | delta |
Definition at line 669 of file pixabasic.c.
References Pixa::refcount.
Referenced by pixaCopy(), and pixaDestroy().
l_ok pixaClear | ( | PIXA * | pixa | ) |
[in] | pixa |
Notes: (1) This destroys all pix in the pixa, as well as all boxes in the boxa. The ptrs in the pix ptr array are all null'd. The number of allocated pix, n, is set to 0.
Definition at line 1635 of file pixabasic.c.
References Pixa::boxa, boxaClear(), Pixa::n, Pixa::pix, pixaGetCount(), and pixDestroy().
[in] | pixa | |
[in] | copyflag | see pix.h for details: L_COPY makes a new pixa and copies each pix and each box; L_CLONE gives a new ref-counted handle to the input pixa; L_COPY_CLONE makes a new pixa and inserts clones of all pix and boxes |
Definition at line 453 of file pixabasic.c.
References L_CLONE, L_COPY, L_COPY_CLONE, L_INSERT, Pixa::n, pixaAddBox(), pixaAddPix(), pixaChangeRefcount(), pixaCreate(), pixaGetBox(), pixaGetBoxaCount(), and pixaGetPix().
Referenced by pixaaAddPixa(), pixaaGetPixa(), pixaaInitFull(), pixaConvertToSameDepth(), pixaDisplayMultiTiled(), pixaDisplayOnLattice(), pixaDisplayTiled(), pixaExtendByMorph(), pixaRotateOrth(), pixaScaleToSize(), pixaSelectToPdf(), pixaSelectWithIndicator(), pixaSort(), pixaTranslate(), recogFilterPixaBySize(), recogTrainFromBoot(), and wshedBasins().
l_ok pixaCountText | ( | PIXA * | pixa, |
l_int32 * | pntext | ||
) |
[in] | pixa | |
[out] | pntext | number of pix with non-empty text strings |
Notes: (1) All pix have non-empty text strings if the returned value ntext equals the pixa count.
Definition at line 1107 of file pixabasic.c.
References L_CLONE, pixaGetCount(), pixaGetPix(), pixDestroy(), and pixGetText().
Referenced by recogCreateFromPixaNoFinish().
PIXA* pixaCreate | ( | l_int32 | n | ) |
[in] | n | initial number of ptrs |
Notes: (1) This creates an empty boxa.
Definition at line 167 of file pixabasic.c.
Referenced by bilateralCreate(), boxaCompareRegions(), boxaDisplayTiled(), dewarpaShowArrays(), fpixaDisplayQuadtree(), makeColorfillTestData(), partifyFiles(), pixaaCreateFromPixa(), pixaAddBorderGeneral(), pixaAddTextlines(), pixaAddTextNumber(), pixaaDisplayByPixa(), pixaaDisplayTiledAndScaled(), pixaaFlattenToPixa(), pixaClipToForeground(), pixaClipToPix(), pixaConstrainedSelect(), pixaConvertTo1(), pixaConvertTo32(), pixaConvertTo8(), pixaConvertTo8Colormap(), pixaConvertToGivenDepth(), pixaConvertToNUpPixa(), pixaConvertToSameDepth(), pixaCopy(), pixaCreateFromBoxa(), pixaCreateFromPix(), pixaCreateFromPixacomp(), pixaDisplayBoxaa(), pixaDisplayMultiTiled(), pixaDisplayOnLattice(), pixaDisplayPairTiledInColumns(), pixaDisplayTiled(), pixaDisplayTiledAndScaled(), pixaDisplayTiledByIndex(), pixaDisplayTiledInColumns(), pixaDisplayTiledInRows(), pixaDisplayTiledWithText(), pixaInterleave(), pixaMakeFromTiledPix(), pixaMakeFromTiledPixa(), pixaModifyStrokeWidth(), pixaMorphSequenceByComponent(), pixaReadFilesSA(), pixaReadMemMultipageTiff(), pixaReadMultipageTiff(), pixaRotateOrth(), pixaScale(), pixaScaleBySampling(), pixaScaleToSize(), pixaScaleToSizeRel(), pixaSelectRange(), pixaSelectWithIndicator(), pixaSelectWithString(), pixaSetStrokeWidth(), pixaSort2dByIndex(), pixaSortByIndex(), pixaSplitIntoFiles(), pixaSplitPix(), pixaThinConnected(), pixaTranslate(), pixClipRectangles(), pixCompareGrayByHisto(), pixComparePhotoRegionsByHisto(), pixCompareWithTranslation(), pixDisplayColorArray(), pixDisplayOutliers(), pixMakeGamutRGB(), recogAddAllSamples(), recogAverageSamples(), recogDebugAverages(), recogDisplayOutlier(), recogFilterPixaBySize(), recogIdentifyPixa(), recogShowAverageTemplates(), recogShowMatch(), recogShowMatchesInRange(), recogTrainFromBoot(), recogTrainingFinished(), selaAddCrossJunctions(), selaAddTJunctions(), selaDisplayInPix(), and showExtractNumbers().
PIXA* pixaCreateFromBoxa | ( | PIX * | pixs, |
BOXA * | boxa, | ||
l_int32 | start, | ||
l_int32 | num, | ||
l_int32 * | pcropwarn | ||
) |
[in] | pixs | |
[in] | boxa | |
[in] | start | first box to use |
[in] | num | number of boxes; use 0 to go to the end |
[out] | pcropwarn | [optional] TRUE if the boxa extent is larger than pixs. |
Notes: (1) This simply extracts from pixs the region corresponding to each box in the boxa. To extract all the regions, set both start and num to 0. (2) The 5th arg is optional. If the extent of the boxa exceeds the size of the pixa, so that some boxes are either clipped or entirely outside the pix, a warning is returned as TRUE. (3) pixad will have only the properly clipped elements, and the internal boxa will be correct.
Definition at line 272 of file pixabasic.c.
References boxaGetBox(), boxaGetCount(), boxaGetExtent(), boxDestroy(), L_COPY, L_INSERT, pixaAddBox(), pixaAddPix(), pixaCreate(), pixClipRectangle(), and pixGetDimensions().
Referenced by pixaMakeFromTiledPix(), and pixGetWordsInTextlines().
[in] | pixs | with individual components on a lattice |
[in] | n | number of components |
[in] | cellw | width of each cell |
[in] | cellh | height of each cell |
Notes: (1) For bpp = 1, we truncate each retrieved pix to the ON pixels, which we assume for now start at (0,0)
Definition at line 206 of file pixabasic.c.
References L_COPY, L_INSERT, PIX_SRC, pixaAddPix(), pixaCreate(), pixaDestroy(), pixClipToForeground(), pixCreate(), pixDestroy(), pixGetDimensions(), and pixRasterop().
void pixaDestroy | ( | PIXA ** | ppixa | ) |
[in,out] | ppixa | use ptr address so it will be nulled |
Notes: (1) Decrements the ref count and, if 0, destroys the pixa. (2) Always nulls the input ptr.
Definition at line 412 of file pixabasic.c.
References Pixa::boxa, boxaDestroy(), Pixa::n, Pixa::pix, pixaChangeRefcount(), pixDestroy(), and Pixa::refcount.
Referenced by bilateralDestroy(), bmfDestroy(), boxaCompareRegions(), boxaDisplayTiled(), convertTiffMultipageToPdf(), convertToNUpPixa(), evalColorfillData(), l_colorfillDestroy(), pixaaAddPix(), pixaaAddPixa(), pixaaClear(), pixaaDestroy(), pixaaDisplay(), pixaaDisplayByPixa(), pixaaDisplayTiledAndScaled(), pixaaFlattenToPixa(), pixaaGetCount(), pixaaGetPix(), pixaaIsFull(), pixaaReplacePixa(), pixaaScaleToSize(), pixaaScaleToSizeVar(), pixaaSizeRange(), pixaaTruncate(), pixaaVerifyDepth(), pixaaVerifyDimensions(), pixaaWriteStream(), pixaCompareInPdf(), pixacompDisplayTiledAndScaled(), pixaConvertToNUpPixa(), pixaConvertToSameDepth(), pixaCreateFromPix(), pixaDisplayMultiTiled(), pixaDisplayTiled(), pixaDisplayTiledAndScaled(), pixaDisplayTiledByIndex(), pixaDisplayTiledInRows(), pixaDisplayTiledWithText(), pixaMakeFromTiledPixa(), pixaMorphSequenceByComponent(), pixaRotateOrth(), pixaSelectToPdf(), pixaSplitPix(), pixaTranslate(), pixCompareGrayByHisto(), pixComparePhotoRegionsByHisto(), pixCompareWithTranslation(), pixDisplayColorArray(), pixDisplayOutliers(), pixGetGrayHistogramTiled(), pixGetWordsInTextlines(), pixMakeGamutRGB(), pixMorphSequenceByComponent(), pixSelectByArea(), pixSelectByAreaFraction(), pixSelectByPerimSizeRatio(), pixSelectByPerimToAreaRatio(), pixSelectBySize(), pixSelectByWidthHeightRatio(), recogAddAllSamples(), recogAddCharstrLabels(), recogAddDigitPadTemplates(), recogAverageSamples(), recogCreateFromRecog(), recogDebugAverages(), recogDestroy(), recogDisplayOutlier(), recogFilterPixaBySize(), recogMakeBootDigitRecog(), recogMakeBootDigitTemplates(), recogPadDigitTrainingSet(), recogRemoveOutliers1(), recogRemoveOutliers2(), recogShowAverageTemplates(), recogShowMatch(), recogTrainFromBoot(), recogTrainingFinished(), selaDisplayInPix(), wshedDestroy(), wshedRenderColors(), and wshedRenderFill().
|
static |
[in] | pixa |
Notes: (1) Doubles the size of the pixa and boxa ptr arrays. (2) The max number of pix in the array is 5 million.
Definition at line 586 of file pixabasic.c.
References Pixa::nalloc, and pixaExtendArrayToSize().
Referenced by pixaAddPix(), and pixaInsertPix().
l_ok pixaExtendArrayToSize | ( | PIXA * | pixa, |
size_t | size | ||
) |
[in] | pixa | |
[in] | size | number of pix ptrs in new array |
Notes: (1) If necessary, reallocs new pixa and boxa ptrs arrays to size. The pixa and boxa ptr arrays must always be equal in size. (2) The max number of pix ptrs is 5M.
Definition at line 612 of file pixabasic.c.
References Pixa::nalloc.
Referenced by pixaExtendArray().
[in] | pixa | |
[in] | index | to the index-th pix |
[in] | accesstype | L_COPY or L_CLONE |
Notes: (1) There is always a boxa with a pixa, and it is initialized so that each box ptr is NULL. (2) In general, we expect that there is either a box associated with each pix, or no boxes at all in the boxa. (3) Having no boxes is thus not an automatic error. Whether it is an actual error is determined by the calling program. If the caller expects to get a box, it is an error; see, e.g., pixaGetBoxGeometry().
Definition at line 816 of file pixabasic.c.
References Boxa::box, Pixa::boxa, boxClone(), boxCopy(), L_CLONE, L_COPY, and Boxa::n.
Referenced by evalColorfillData(), pixaAddBorderGeneral(), pixaaFlattenToPixa(), pixaClipToPix(), pixaCopy(), pixAddWithIndicator(), pixaGetBoxGeometry(), pixaInterleave(), pixaMorphSequenceByComponent(), pixaRotateOrth(), pixaSelectWithIndicator(), pixaSelectWithString(), pixaSort2dByIndex(), pixaSortByIndex(), and pixRemoveWithIndicator().
[in] | pixa | |
[in] | accesstype | L_COPY, L_CLONE, L_COPY_CLONE |
Definition at line 760 of file pixabasic.c.
References Pixa::boxa, boxaCopy(), L_CLONE, L_COPY, and L_COPY_CLONE.
Referenced by pixaAddBorderGeneral(), pixaaDisplay(), pixaConvertTo1(), pixaConvertTo32(), pixaConvertTo8(), pixaConvertTo8Colormap(), pixaConvertToSameDepth(), pixaDisplay(), pixaDisplayRandomCmap(), pixaEqual(), pixaIsFull(), pixaJoin(), pixaTranslate(), pixGetWordsInTextlines(), and pixMorphSequenceByComponent().
l_int32 pixaGetBoxaCount | ( | PIXA * | pixa | ) |
[in] | pixa |
Definition at line 784 of file pixabasic.c.
References Pixa::boxa, and boxaGetCount().
Referenced by pixaAddBorderGeneral(), pixaaFlattenToPixa(), pixaCopy(), pixaInterleave(), pixaJoin(), pixaMorphSequenceByComponent(), pixaRotateOrth(), pixaSelectWithIndicator(), pixaSelectWithString(), and pixaTranslate().
l_ok pixaGetBoxGeometry | ( | PIXA * | pixa, |
l_int32 | index, | ||
l_int32 * | px, | ||
l_int32 * | py, | ||
l_int32 * | pw, | ||
l_int32 * | ph | ||
) |
[in] | pixa | |
[in] | index | to the index-th box |
[out] | px,py,pw,ph | [optional] each can be null |
Definition at line 854 of file pixabasic.c.
References boxDestroy(), boxGetGeometry(), L_CLONE, Pixa::n, and pixaGetBox().
Referenced by pixaDisplayRandomCmap(), pixMorphSequenceByComponent(), and wshedRenderFill().
l_int32 pixaGetCount | ( | PIXA * | pixa | ) |
[in] | pixa |
Definition at line 650 of file pixabasic.c.
References Pixa::n.
Referenced by bilateralApply(), boxaDisplayTiled(), boxaReconcileSidesByMedian(), evalColorfillData(), pixaAccumulateSamples(), pixaaCreateFromPixa(), pixaAddBorderGeneral(), pixaAddPix(), pixaAddTextlines(), pixaAddTextNumber(), pixaaFlattenToPixa(), pixaaGetCount(), pixaAnyColormaps(), pixaaTruncate(), pixaBinSort(), pixaCentroids(), pixaClear(), pixaClipToForeground(), pixaClipToPix(), pixaCompareInPdf(), pixaComparePhotoRegionsByHisto(), pixaConstrainedSelect(), pixaConvertTo1(), pixaConvertTo32(), pixaConvertTo8(), pixaConvertTo8Colormap(), pixaConvertToGivenDepth(), pixaConvertToNUpPixa(), pixaConvertToPdfData(), pixaConvertToSameDepth(), pixaCountPixels(), pixaCountText(), pixAddWithIndicator(), pixaDisplay(), pixaDisplayBoxaa(), pixaDisplayMultiTiled(), pixaDisplayOnLattice(), pixaDisplayPairTiledInColumns(), pixaDisplayRandomCmap(), pixaDisplayTiled(), pixaDisplayTiledAndScaled(), pixaDisplayTiledByIndex(), pixaDisplayTiledInColumns(), pixaDisplayTiledInRows(), pixaDisplayTiledWithText(), pixaDisplayUnsplit(), pixaEqual(), pixaFindAreaFraction(), pixaFindDimensions(), pixaFindPerimSizeRatio(), pixaFindPerimToAreaRatio(), pixaFindStrokeWidth(), pixaFindWidthHeightProduct(), pixaFindWidthHeightRatio(), pixaGetAlignedStats(), pixaGetDepthInfo(), pixaGetLinePtrs(), pixaHasColor(), pixaInsertPix(), pixaInterleave(), pixaIsFull(), pixaJoin(), pixaMakeSizeIndicator(), pixaModifyStrokeWidth(), pixaMorphSequenceByComponent(), pixaRemovePix(), pixaRemovePixAndSave(), pixaRenderComponent(), pixaRotateOrth(), pixaScale(), pixaScaleBySampling(), pixaScaleToSize(), pixaScaleToSizeRel(), pixaSelectByNumConnComp(), pixaSelectRange(), pixaSelectToPdf(), pixaSelectWithString(), pixaSetFullSizeBoxa(), pixaSetStrokeWidth(), pixaSetText(), pixaSizeRange(), pixaSort(), pixaSort2dByIndex(), pixaSortByIndex(), pixaSplitIntoFiles(), pixaThinConnected(), pixaTranslate(), pixaVerifyDepth(), pixaVerifyDimensions(), pixaWriteMemMultipageTiff(), pixaWriteMultipageTiff(), pixaWriteStream(), pixaWriteStreamInfo(), pixDisplayOutliers(), pixMorphSequenceByComponent(), pixReadBarcodes(), pixRemoveWithIndicator(), pixSelectByArea(), pixSelectByAreaFraction(), pixSelectByPerimSizeRatio(), pixSelectByPerimToAreaRatio(), pixSelectBySize(), pixSelectByWidthHeightRatio(), recogAddAllSamples(), recogAddCharstrLabels(), recogAddDigitPadTemplates(), recogAverageSamples(), recogCreateFromPixaNoFinish(), recogDebugAverages(), recogFilterPixaBySize(), recogIdentifyPixa(), recogShowMatchesInRange(), recogTrainFromBoot(), recogTrainingFinished(), selaCreateFromColorPixa(), and wshedRenderFill().
void*** pixaGetLinePtrs | ( | PIXA * | pixa, |
l_int32 * | psize | ||
) |
[in] | pixa | of pix that all have the same depth |
[out] | psize | [optional] number of pix in the pixa |
Notes: (1) See pixGetLinePtrs() for details. (2) It is best if all pix in the pixa are the same size. The size of each line ptr array is equal to the height of the pix that it refers to. (3) This is an array of arrays. To destroy it: for (i = 0; i < size; i++) LEPT_FREE(lineset[i]); LEPT_FREE(lineset);
Definition at line 1214 of file pixabasic.c.
References L_CLONE, pixaGetCount(), pixaGetPix(), pixaVerifyDepth(), pixDestroy(), and pixGetLinePtrs().
[in] | pixa | |
[in] | index | to the index-th pix |
[in] | accesstype | L_COPY or L_CLONE |
Definition at line 691 of file pixabasic.c.
References L_CLONE, L_COPY, Pixa::n, Pixa::pix, pixClone(), and pixCopy().
Referenced by bmfGetPix(), boxaDisplayTiled(), evalColorfillData(), pixaAccumulateSamples(), pixaaCreateFromPixa(), pixaAddBorderGeneral(), pixaAddTextlines(), pixaAddTextNumber(), pixaaDisplay(), pixaaFlattenToPixa(), pixaaGetPix(), pixaAnyColormaps(), pixaCentroids(), pixaClipToForeground(), pixaClipToPix(), pixaComparePhotoRegionsByHisto(), pixaConstrainedSelect(), pixaConvertTo1(), pixaConvertTo32(), pixaConvertTo8(), pixaConvertTo8Colormap(), pixaConvertToGivenDepth(), pixaConvertToNUpPixa(), pixaConvertToPdfData(), pixaConvertToSameDepth(), pixaCopy(), pixaCountPixels(), pixaCountText(), pixAddWithIndicator(), pixaDisplay(), pixaDisplayBoxaa(), pixaDisplayMultiTiled(), pixaDisplayOnLattice(), pixaDisplayPairTiledInColumns(), pixaDisplayRandomCmap(), pixaDisplayTiled(), pixaDisplayTiledAndScaled(), pixaDisplayTiledByIndex(), pixaDisplayTiledInColumns(), pixaDisplayTiledInRows(), pixaDisplayTiledWithText(), pixaDisplayUnsplit(), pixaEqual(), pixaFindAreaFraction(), pixaFindDimensions(), pixaFindPerimSizeRatio(), pixaFindPerimToAreaRatio(), pixaFindStrokeWidth(), pixaFindWidthHeightProduct(), pixaFindWidthHeightRatio(), pixaGetLinePtrs(), pixaGetPixDimensions(), pixaHasColor(), pixaInterleave(), pixaIsFull(), pixaJoin(), pixaMakeFromTiledPixa(), pixaModifyStrokeWidth(), pixaMorphSequenceByComponent(), pixaRemovePixAndSave(), pixaRotateOrth(), pixaScale(), pixaScaleBySampling(), pixaScaleToSize(), pixaScaleToSizeRel(), pixaSelectByNumConnComp(), pixaSelectRange(), pixaSelectWithIndicator(), pixaSelectWithString(), pixaSetFullSizeBoxa(), pixaSetStrokeWidth(), pixaSetText(), pixaSizeRange(), pixaSort2dByIndex(), pixaSortByIndex(), pixaSplitIntoFiles(), pixaThinConnected(), pixaTranslate(), pixaWriteMemMultipageTiff(), pixaWriteMultipageTiff(), pixaWriteStream(), pixaWriteStreamInfo(), pixCompareTilesByHisto(), pixCompareWithTranslation(), pixDisplayOutliers(), pixGetGrayHistogramTiled(), pixMorphSequenceByComponent(), pixReadBarcodes(), pixRemoveWithIndicator(), recogAddAllSamples(), recogAddCharstrLabels(), recogAddDigitPadTemplates(), recogCreateFromPixaNoFinish(), recogDisplayOutlier(), recogFilterPixaBySize(), recogGetWindowedArea(), recogIdentifyPixa(), recogMakeDecodingArray(), recogShowAverageTemplates(), recogShowMatchesInRange(), recogShowPath(), recogTrainFromBoot(), recogTrainingFinished(), selaCreateFromColorPixa(), selaDisplayInPix(), and wshedRenderFill().
[in] | pixa |
Notes: (1) This returns a ptr to the actual array. The array is owned by the pixa, so it must not be destroyed. (2) The caller should always check if the return value is NULL before accessing any of the pix ptrs in this array!
Definition at line 935 of file pixabasic.c.
References Pixa::pix.
l_ok pixaGetPixDimensions | ( | PIXA * | pixa, |
l_int32 | index, | ||
l_int32 * | pw, | ||
l_int32 * | ph, | ||
l_int32 * | pd | ||
) |
[in] | pixa | |
[in] | index | to the index-th box |
[out] | pw,ph,pd | [optional] each can be null |
Definition at line 726 of file pixabasic.c.
References L_CLONE, Pixa::n, pixaGetPix(), pixDestroy(), and pixGetDimensions().
Referenced by bmfGetWidth(), pixaDisplayTiledInRows(), pixaDisplayUnsplit(), pixaGetAlignedStats(), pixaGetDepthInfo(), pixaMakeSizeIndicator(), pixaMorphSequenceByComponent(), pixaVerifyDepth(), pixaVerifyDimensions(), recogFilterPixaBySize(), selaAddCrossJunctions(), and selaAddTJunctions().
[in] | pixa | typically empty |
[in] | pix | [optional] to be replicated to the entire pixa ptr array |
[in] | box | [optional] to be replicated to the entire boxa ptr array |
Notes: (1) This initializes a pixa by filling up the entire pix ptr array with copies of pix. If pix == NULL, we use a tiny placeholder pix (w = h = d = 1). Any existing pix are destroyed. It also optionally fills the boxa with copies of box. After this operation, the numbers of pix and (optionally) boxes are equal to the number of allocated ptrs. (2) Note that we use pixaReplacePix() instead of pixaInsertPix(). They both have the same effect when inserting into a NULL ptr in the pixa ptr array: (3) If the boxa is not initialized (i.e., filled with boxes), later insertion of boxes will cause an error, because the 'n' field is 0. (4) Example usage. This function is useful to prepare for a random insertion (or replacement) of pix into a pixa. To randomly insert pix into a pixa, without boxes, up to some index "max": Pixa *pixa = pixaCreate(max); pixaInitFull(pixa, NULL, NULL); An existing pixa with a smaller ptr array can also be reused: pixaExtendArrayToSize(pixa, max); pixaInitFull(pixa, NULL, NULL); The initialization allows the pixa to always be properly filled, even if all pix (and boxes) are not later replaced.
Definition at line 1593 of file pixabasic.c.
References Pixa::boxa, boxaInitFull(), Pixa::n, Pixa::nalloc, pixaReplacePix(), pixCopy(), and pixCreate().
[in] | pixa | |
[in] | index | at which pix is to be inserted |
[in] | pixs | new pix to be inserted |
[in] | box | [optional] new box to be inserted |
Notes: (1) This shifts pixa[i] --> pixa[i + 1] for all i >= index, and then inserts at pixa[index]. (2) To insert at the beginning of the array, set index = 0. (3) It should not be used repeatedly on large arrays, because the function is O(n). (4) To append a pix to a pixa, it's easier to use pixaAddPix().
Definition at line 1370 of file pixabasic.c.
References Pixa::boxa, boxaExtendArray(), boxaInsertBox(), Pixa::n, Pixa::nalloc, Pixa::pix, pixaExtendArray(), and pixaGetCount().
[in] | pixa1 | first src pixa |
[in] | pixa2 | second src pixa |
[in] | copyflag | L_CLONE, L_COPY |
Notes: (1) copyflag determines if the pix are copied or cloned. The boxes, if they exist, are copied. (2) If the two pixa have different sizes, a warning is issued, and the number of pairs returned is the minimum size.
Definition at line 1729 of file pixabasic.c.
References L_CLONE, L_COPY, L_INSERT, pixaAddBox(), pixaAddPix(), pixaCreate(), pixaGetBox(), pixaGetBoxaCount(), pixaGetCount(), and pixaGetPix().
Referenced by pixaCompareInPdf().
l_ok pixaIsFull | ( | PIXA * | pixa, |
l_int32 * | pfullpa, | ||
l_int32 * | pfullba | ||
) |
[in] | pixa | |
[out] | pfullpa | [optional] 1 if pixa is full |
[out] | pfullba | [optional] 1 if boxa is full |
Notes: (1) A pixa is "full" if the array of pix is fully occupied from index 0 to index (pixa->n - 1).
Definition at line 1057 of file pixabasic.c.
References boxaDestroy(), boxaIsFull(), L_CLONE, pixaGetBoxa(), pixaGetCount(), pixaGetPix(), and pixDestroy().
Referenced by pixaaIsFull(), and recogCreateFromPixaNoFinish().
[in] | pixad | dest pixa; add to this one |
[in] | pixas | [optional] source pixa; add from this one |
[in] | istart | starting index in pixas |
[in] | iend | ending index in pixas; use -1 to cat all |
Notes: (1) This appends a clone of each indicated pix in pixas to pixad (2) istart < 0 is taken to mean 'read from the start' (istart = 0) (3) iend < 0 means 'read to the end' (4) If pixas is NULL or contains no pix, this is a no-op.
Definition at line 1673 of file pixabasic.c.
References boxaDestroy(), boxaJoin(), L_CLONE, L_INSERT, pixaAddPix(), pixaGetBoxa(), pixaGetBoxaCount(), pixaGetCount(), and pixaGetPix().
Referenced by pixaMakeFromTiledPixa(), recogFilterPixaBySize(), and recogMakeBootDigitTemplates().
PIXA* pixaRead | ( | const char * | filename | ) |
[in] | filename |
Notes: (1) The pix are stored in the file as png. If the png library is not linked, this will fail.
Definition at line 2610 of file pixabasic.c.
References fopenReadStream(), and pixaReadStream().
Referenced by pixaaReadFromFiles(), and pixaReadBoth().
PIXA* pixaReadBoth | ( | const char * | filename | ) |
[in] | filename |
Notes: (1) This reads serialized files of either a pixa or a pixacomp, and returns a pixa in memory. It requires png and jpeg libraries.
Definition at line 2921 of file pixabasic.c.
References L_COPY, l_getStructStrFromFile(), L_STR_NAME, pixacompDestroy(), pixacompRead(), pixaCreateFromPixacomp(), and pixaRead().
PIXA* pixaReadMem | ( | const l_uint8 * | data, |
size_t | size | ||
) |
[in] | data | of serialized pixa |
[in] | size | of data in bytes |
Definition at line 2712 of file pixabasic.c.
References fopenReadFromMemory(), and pixaReadStream().
PIXA* pixaReadStream | ( | FILE * | fp | ) |
[in] | fp | file stream |
Notes: (1) The pix are stored in the file as png. If the png library is not linked, this will fail. (2) It is OK for the pixa to be empty.
Definition at line 2648 of file pixabasic.c.
References PIXA_VERSION_NUMBER.
Referenced by pixaRead(), and pixaReadMem().
l_ok pixaRemovePix | ( | PIXA * | pixa, |
l_int32 | index | ||
) |
[in] | pixa | |
[in] | index | of pix to be removed |
Notes: (1) This shifts pixa[i] --> pixa[i - 1] for all i > index. (2) It should not be used repeatedly on large arrays, because the function is O(n). (3) The corresponding box is removed as well, if it exists.
Definition at line 1423 of file pixabasic.c.
References Pixa::boxa, boxaGetCount(), boxaRemoveBox(), Pixa::n, Pixa::pix, pixaGetCount(), and pixDestroy().
Referenced by pixaRemoveSelected().
[in] | pixa | |
[in] | index | of pix to be removed |
[out] | ppix | [optional] removed pix |
[out] | pbox | [optional] removed box |
Notes: (1) This shifts pixa[i] --> pixa[i - 1] for all i > index. (2) It should not be used repeatedly on large arrays, because the function is O(n). (3) The corresponding box is removed as well, if it exists. (4) The removed pix and box can either be retained or destroyed.
Definition at line 1477 of file pixabasic.c.
References Pixa::boxa, boxaGetCount(), boxaRemoveBoxAndSave(), L_CLONE, Pixa::n, Pixa::pix, pixaGetCount(), pixaGetPix(), and pixDestroy().
[in] | pixa | |
[in] | naindex | numa of indices of pix to be removed |
Notes: (1) This gives error messages for invalid indices
Definition at line 1531 of file pixabasic.c.
References L_SORT_DECREASING, numaDestroy(), numaGetCount(), numaGetIValue(), numaSort(), and pixaRemovePix().
[in] | pixa | |
[in] | index | to the index-th pix |
[in] | pix | insert to replace existing one |
[in] | box | [optional] insert to replace existing |
Notes: (1) In-place replacement of one pix. (2) The previous pix at that location is destroyed.
Definition at line 1320 of file pixabasic.c.
References Pixa::boxa, boxaReplaceBox(), Pixa::n, Boxa::n, Pixa::pix, and pixDestroy().
Referenced by pixaAddBorderGeneral(), and pixaInitFull().
[in] | pixa | |
[in] | boxa | |
[in] | accesstype | L_INSERT, L_COPY, L_CLONE |
Notes: (1) This destroys the existing boxa in the pixa.
Definition at line 896 of file pixabasic.c.
References Pixa::boxa, boxaCopy(), boxaDestroy(), L_CLONE, L_COPY, and L_INSERT.
Referenced by pixaConvertTo1(), pixaConvertTo32(), pixaConvertTo8(), pixaConvertTo8Colormap(), pixaConvertToSameDepth(), pixaSetFullSizeBoxa(), and pixaTranslate().
[in] | pixa | |
[in] | text | [optional] single text string, to insert in each pix |
[in] | sa | [optional] array of text strings, to insert in each pix |
Notes: (1) To clear all the text fields, use sa == NULL and text == NULL. (2) Otherwise, this replaces all text fields with a copy of a string, either the same string or a string from sa. (3) To set all the text fields to the same value text, use sa = NULL. (4) If sa is defined, ignore text and use the strings in sa. sa must have the same count as pixa.
Definition at line 1155 of file pixabasic.c.
References L_CLONE, L_NOCOPY, pixaGetCount(), pixaGetPix(), pixDestroy(), pixSetText(), sarrayGetCount(), and sarrayGetString().
Referenced by pixaMakeFromTiledPixa().
PIXA* pixaSplitPix | ( | PIX * | pixs, |
l_int32 | nx, | ||
l_int32 | ny, | ||
l_int32 | borderwidth, | ||
l_uint32 | bordercolor | ||
) |
[in] | pixs | with individual components on a lattice |
[in] | nx | number of mosaic cells horizontally |
[in] | ny | number of mosaic cells vertically |
[in] | borderwidth | of added border on all sides |
[in] | bordercolor | in our RGBA format: 0xrrggbbaa |
Notes: (1) This is a variant on pixaCreateFromPix(), where we simply divide the image up into (approximately) equal subunits. If you want the subimages to have essentially the same aspect ratio as the input pix, use nx = ny. (2) If borderwidth is 0, we ignore the input bordercolor and redefine it to white. (3) The bordercolor is always used to initialize each tiled pix, so that if the src is clipped, the unblitted part will be this color. This avoids 1 pixel wide black stripes at the left and lower edges.
Definition at line 350 of file pixabasic.c.
References L_INSERT, PIX_SRC, pixaAddPix(), pixaCreate(), pixaDestroy(), pixClearAll(), pixCopyColormap(), pixCreate(), pixGetDimensions(), pixRasterop(), pixSetAll(), and pixSetAllArbitrary().
Referenced by pixCompareTilesByHisto(), and pixGetGrayHistogramTiled().
l_ok pixaVerifyDepth | ( | PIXA * | pixa, |
l_int32 * | psame, | ||
l_int32 * | pmaxd | ||
) |
[in] | pixa | |
[out] | psame | 1 if depth is the same for all pix; 0 otherwise |
[out] | pmaxd | [optional] max depth of all pix |
Notes: (1) It is considered to be an error if there are no pix.
Definition at line 960 of file pixabasic.c.
References pixaGetCount(), and pixaGetPixDimensions().
Referenced by pixaaVerifyDepth(), pixaDisplayOnLattice(), pixaDisplayRandomCmap(), pixaFindStrokeWidth(), pixaGetLinePtrs(), pixaModifyStrokeWidth(), pixaSetStrokeWidth(), pixaThinConnected(), recogCreateFromPixaNoFinish(), and recogTrainFromBoot().
l_ok pixaVerifyDimensions | ( | PIXA * | pixa, |
l_int32 * | psame, | ||
l_int32 * | pmaxw, | ||
l_int32 * | pmaxh | ||
) |
[in] | pixa | |
[out] | psame | 1 if dimensions are the same for all pix; 0 otherwise |
[out] | pmaxw | [optional] max width of all pix |
[out] | pmaxh | [optional] max height of all pix |
Notes: (1) It is considered to be an error if there are no pix.
Definition at line 1006 of file pixabasic.c.
References pixaGetCount(), and pixaGetPixDimensions().
Referenced by pixaaVerifyDimensions().
l_ok pixaWrite | ( | const char * | filename, |
PIXA * | pixa | ||
) |
[in] | filename | |
[in] | pixa |
Notes: (1) The pix are stored in the file as png. If the png library is not linked, this will fail.
Definition at line 2777 of file pixabasic.c.
References fopenWriteStream(), and pixaWriteStream().
Referenced by pixaWriteDebug().
l_ok pixaWriteDebug | ( | const char * | fname, |
PIXA * | pixa | ||
) |
[in] | fname | |
[in] | pixa |
Notes: (1) Debug version, intended for use in the library when writing to files in a temp directory with names that are compiled in. This is used instead of pixaWrite() for all such library calls. (2) The global variable LeptDebugOK defaults to 0, and can be set or cleared by the function setLeptDebugOK().
Definition at line 2749 of file pixabasic.c.
References pixaWrite().
Referenced by pixaSplitIntoFiles().
l_ok pixaWriteMem | ( | l_uint8 ** | pdata, |
size_t * | psize, | ||
PIXA * | pixa | ||
) |
[out] | pdata | data of serialized pixa |
[out] | psize | size of returned data |
[in] | pixa |
Notes: (1) Serializes a pixa in memory and puts the result in a buffer.
Definition at line 2865 of file pixabasic.c.
References fopenWriteWinTempfile(), l_binaryReadStream(), and pixaWriteStream().
l_ok pixaWriteStream | ( | FILE * | fp, |
PIXA * | pixa | ||
) |
[in] | fp | file stream opened for "wb" |
[in] | pixa |
Notes: (1) The pix are stored in the file as png. If the png library is not linked, this will fail.
Definition at line 2818 of file pixabasic.c.
References Pixa::boxa, boxaWriteStream(), L_CLONE, PIXA_VERSION_NUMBER, pixaGetCount(), pixaGetPix(), pixDestroy(), pixWriteStreamPng(), Pix::xres, and Pix::yres.
Referenced by pixaaWriteStream(), pixaWrite(), and pixaWriteMem().
l_ok pixaWriteStreamInfo | ( | FILE * | fp, |
PIXA * | pixa | ||
) |
[in] | fp | file stream |
[in] | pixa |
Notes: (1) For each pix in the pixa, write out the pix dimensions, spp, text string (if it exists), and cmap info.
Definition at line 1262 of file pixabasic.c.
References L_CLONE, pixaGetCount(), pixaGetPix(), and pixGetDimensions().
|
static |
n'importe quoi
Definition at line 146 of file pixabasic.c.