Leptonica 1.68
C Image Processing Library
|
Implements Pixa (array of Pix) and Pixaa (2d array of Pix) class. More...
Go to the source code of this file.
Implements Pixa (array of Pix) and Pixaa (2d array of Pix) class.
Pixa creation, destruction, copying PIXA *pixaCreate() PIXA *pixaCreateFromPix() PIXA *pixaCreateFromBoxa() PIXA *pixaSplitPix() void pixaDestroy() PIXA *pixaCopy() Pixa addition l_int32 pixaAddPix() l_int32 pixaExtendArray() l_int32 pixaExtendArrayToSize() l_int32 pixaAddBox() Pixa accessors l_int32 pixaGetCount() l_int32 pixaChangeRefcount() PIX *pixaGetPix() l_int32 pixaGetPixDimensions() PIX *pixaGetBoxa() l_int32 pixaGetBoxaCount() BOX *pixaGetBox() l_int32 pixaGetBoxGeometry() PIX **pixaGetPixArray() Pixa array modifiers l_int32 pixaReplacePix() l_int32 pixaInsertPix() l_int32 pixaRemovePix() l_int32 pixaInitFull() l_int32 pixaClear() Pixa combination PIXA *pixaJoin() Pixaa creation, destruction PIXAA *pixaaCreate() PIXAA *pixaaCreateFromPixa() void pixaaDestroy() Pixaa addition l_int32 pixaaAddPixa() l_int32 pixaaExtendArray() l_int32 pixaaAddBox() Pixaa accessors l_int32 pixaaGetCount() PIXA *pixaaGetPixa() BOXA *pixaaGetBoxa() Pixa serialized I/O (requires png support) PIXA *pixaRead() PIXA *pixaReadStream() l_int32 pixaWrite() l_int32 pixaWriteStream() Pixaa serialized I/O (requires png support) PIXAA *pixaaRead() PIXAA *pixaaReadStream() l_int32 pixaaWrite() l_int32 pixaaWriteStream() 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.
Input: n (initial number of ptrs) Return: pixa, or null on error
Definition at line 106 of file pixabasic.c.
References Pixa::boxa, boxaCreate(), CALLOC, ERROR_PTR, INITIAL_PTR_ARRAYSIZE, Pixa::n, Pixa::nalloc, NULL, Pixa::pix, PROCNAME, and Pixa::refcount.
Referenced by AddTransformsRGB(), AddTransformsYUV(), CopyStoreClean(), fpixaDisplayQuadtree(), GeneratePattern(), GenerateSetOfMargePix(), GetImageMask(), jbAccumulateComposites(), jbClasserCreate(), jbClassifyCorrelation(), jbClassifyRankHaus(), jbDataRender(), jbGetComponents(), jbTemplatesFromComposites(), main(), pixaaCreateFromPixa(), pixaAddBorderGeneral(), pixaaDisplayTiledAndScaled(), pixaaFlattenToPixa(), pixaClipToPix(), pixacompDisplayTiledAndScaled(), pixaCopy(), pixaCreateFromBoxa(), pixaCreateFromPix(), pixaCreateFromPixacomp(), pixaDisplayOnColor(), pixaDisplayOnLattice(), pixaDisplayTiled(), pixaDisplayTiledAndScaled(), pixaDisplayTiledInRows(), pixaGenerateFont(), pixaMorphSequenceByComponent(), pixaMorphSequenceByRegion(), pixaReadFilesSA(), pixaReadMultipageTiff(), pixaReadStream(), pixaSelectWithIndicator(), pixaSort2dByIndex(), pixaSortByIndex(), pixaSplitPix(), pixConnCompPixa(), pixDisplayColorArray(), pixExtractBarcodes(), pixFindHistoPeaksHSV(), pixItalicWords(), PixSavePlots1(), PixSavePlots2(), pixSetUnderTransparency(), PixTest1(), PixTest2(), pixThinGeneral(), pixWordMaskByDilation(), ReconstructPixa1(), ReconstructPixa2(), RotateTest(), selaAddCrossJunctions(), selaAddTJunctions(), selaDisplayInPix(), shearTest(), TestHardlight(), TestImage(), TestProjection(), and wshedApply().
Input: pixs (with individual components on a lattice) n (number of components) cellw (width of each cell) cellh (height of each cell) Return: pixa, or null on error
Note: for bpp = 1, we truncate each retrieved pix to the ON pixels, which we assume for now start at (0,0)
Definition at line 143 of file pixabasic.c.
References ERROR_PTR, L_COPY, L_INSERT, NULL, PIX_SRC, pixaAddPix(), pixaCreate(), pixClipToForeground(), pixCreate(), pixDestroy(), pixGetDimensions(), pixRasterop(), and PROCNAME.
Referenced by jbDataRender().
Input: pixs boxa &cropwarn (<optional return>=""> TRUE if the boxa extent is larger than pixs. Return: pixad, or null on error
Notes: (1) This simply extracts from pixs the region corresponding to each box in the boxa. (2) The 3rd 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 202 of file pixabasic.c.
References boxaGetBox(), boxaGetCount(), boxaGetExtent(), boxDestroy(), ERROR_PTR, FALSE, L_COPY, L_INSERT, NULL, pixaAddBox(), pixaAddPix(), pixaCreate(), pixClipRectangle(), pixGetDimensions(), PROCNAME, and TRUE.
Referenced by pixGetWordsInTextlines().
PIXA* pixaSplitPix | ( | PIX * | pixs, |
l_int32 | nx, | ||
l_int32 | ny, | ||
l_int32 | borderwidth, | ||
l_uint32 | bordercolor | ||
) |
Input: pixs (with individual components on a lattice) nx (number of mosaic cells horizontally) ny (number of mosaic cells vertically) borderwidth (of added border on all sides) bordercolor (in our RGBA format: 0xrrggbbaa) Return: pixa, or null on error
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 274 of file pixabasic.c.
References ERROR_PTR, L_INSERT, L_MAX, NULL, nx, ny, PIX_SRC, pixaAddPix(), pixaCreate(), pixClearAll(), pixCopyColormap(), pixCreate(), pixGetDimensions(), pixRasterop(), pixSetAll(), pixSetAllArbitrary(), and PROCNAME.
Referenced by main().
void pixaDestroy | ( | PIXA ** | ppixa | ) |
Input: &pixa (<can be="" nulled>="">) Return: void
Notes: (1) Decrements the ref count and, if 0, destroys the pixa. (2) Always nulls the input ptr.
Definition at line 333 of file pixabasic.c.
References Pixa::boxa, boxaDestroy(), FREE, L_WARNING, Pixa::n, NULL, Pixa::pix, pixaChangeRefcount(), pixDestroy(), PROCNAME, and Pixa::refcount.
Referenced by AddTransformsRGB(), AddTransformsYUV(), bmfDestroy(), DisplayPix(), DisplayResult(), DoPageSegmentation(), fpixaDisplayQuadtree(), GeneratePattern(), GetImageMask(), jbAccumulateComposites(), jbAddPage(), jbClasserDestroy(), jbClassifyCorrelation(), jbClassifyRankHaus(), jbCorrelation(), jbDataRender(), jbGetComponents(), jbRankHaus(), jbWordsInTextlines(), main(), pixaaDestroy(), pixaaDisplay(), pixaaDisplayByPixa(), pixaaDisplayTiledAndScaled(), pixaaFlattenToPixa(), pixaaWriteStream(), pixacompDisplayTiledAndScaled(), pixaDisplayOnColor(), pixaDisplayOnLattice(), pixaDisplayTiled(), pixaDisplayTiledAndScaled(), pixaDisplayTiledInRows(), pixaReadStream(), PixaSaveDisplay(), pixaSaveFont(), PixaSortTest(), pixDisplayColorArray(), pixDisplayMatchedPattern(), pixFillHolesToBoundingRect(), pixFindRectangleComps(), pixGetAllCCBorders(), pixGetCCBorders(), pixGetOuterBordersPtaa(), pixGetRegionsBinary(), pixGetTextlineCenters(), pixGetWordsInTextlines(), pixItalicWords(), pixMorphSequenceByComponent(), pixMorphSequenceByRegion(), pixPaintSelfThroughMask(), pixProcessBarcodes(), pixQualifyLocalMinima(), pixRemoveMatchedPattern(), pixSelectByAreaFraction(), pixSelectByAreaPerimRatio(), pixSelectBySize(), pixSelectByWidthHeightRatio(), pixSelectiveConnCompFill(), pixSelectMinInConnComp(), pixSetUnderTransparency(), pixSmoothConnectedRegions(), pixSplitIntoBoxa(), PixTest1(), PixTest2(), pixThinGeneral(), pixWordMaskByDilation(), ptaaGetBoundaryPixels(), RotateTest(), selaAddCrossJunctions(), selaAddTJunctions(), selaDisplayInPix(), shearTest(), TestImage(), TestProjection(), wshedDestroy(), wshedRenderColors(), and wshedRenderFill().
Input: pixas copyflag: 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 Return: new pixa, or null on error
Note: see pix.h for description of the copy types.
Definition at line 377 of file pixabasic.c.
References ERROR_PTR, L_CLONE, L_COPY, L_COPY_CLONE, L_INSERT, Pixa::n, NULL, pixaAddBox(), pixaAddPix(), pixaChangeRefcount(), pixaCreate(), pixaGetBox(), pixaGetPix(), and PROCNAME.
Referenced by main(), pixaaAddPixa(), pixaaGetPixa(), pixaDisplayOnColor(), pixaDisplayOnLattice(), pixaDisplayTiled(), pixaSelectWithIndicator(), and wshedBasins().
Input: pixa pix (to be added) copyflag (L_INSERT, L_COPY, L_CLONE) Return: 0 if OK; 1 on error
Definition at line 430 of file pixabasic.c.
References ERROR_INT, L_CLONE, L_COPY, L_INSERT, Pixa::n, Pixa::nalloc, NULL, Pixa::pix, pixaExtendArray(), pixaGetCount(), pixClone(), pixCopy(), and PROCNAME.
Referenced by AddTransformsRGB(), AddTransformsYUV(), CopyStoreClean(), fpixaDisplayQuadtree(), GeneratePattern(), GenerateSetOfMargePix(), GetImageMask(), jbAccumulateComposites(), jbClassifyCorrelation(), jbClassifyRankHaus(), jbDataRender(), jbTemplatesFromComposites(), main(), pixaaCreateFromPixa(), pixaAddBorderGeneral(), pixaaDisplayTiledAndScaled(), pixaaFlattenToPixa(), pixaClipToPix(), pixacompDisplayTiledAndScaled(), pixaCopy(), pixaCreateFromBoxa(), pixaCreateFromPix(), pixaCreateFromPixacomp(), PixAddEdgeData(), pixaDisplayOnColor(), pixaDisplayOnLattice(), pixaDisplayTiled(), pixaDisplayTiledAndScaled(), pixaDisplayTiledInRows(), pixaGenerateFont(), pixaJoin(), pixaMorphSequenceByComponent(), pixaMorphSequenceByRegion(), pixaReadFilesSA(), pixaReadMultipageTiff(), pixaReadStream(), pixaSelectWithIndicator(), pixaSort2dByIndex(), pixaSortByIndex(), pixaSplitPix(), pixConnCompPixa(), pixExtractBarcodes(), pixFindHistoPeaksHSV(), pixSaveTiledOutline(), pixThinGeneral(), pixWordMaskByDilation(), ReconstructPixa1(), ReconstructPixa2(), selaAddCrossJunctions(), selaAddTJunctions(), selaDisplayInPix(), TranslateAndSave2(), and wshedSaveBasin().
Input: pixa Return: 0 if OK; 1 on error
Notes: (1) Doubles the size of the pixa and boxa ptr arrays.
Definition at line 475 of file pixabasic.c.
References ERROR_INT, Pixa::nalloc, pixaExtendArrayToSize(), and PROCNAME.
Referenced by pixaAddPix(), and pixaInsertPix().
Input: pixa Return: 0 if OK; 1 on error
Notes: (1) If necessary, reallocs new pixa and boxa ptrs arrays to . The pixa and boxa ptr arrays must always be equal in size.
Definition at line 497 of file pixabasic.c.
References Pixa::boxa, boxaExtendArrayToSize(), ERROR_INT, Pixa::nalloc, NULL, Pixa::pix, PROCNAME, reallocNew(), and size.
Referenced by main(), and pixaExtendArray().
Input: pixa box copyflag (L_INSERT, L_COPY, L_CLONE) Return: 0 if OK, 1 on error
Definition at line 525 of file pixabasic.c.
References Pixa::boxa, boxaAddBox(), ERROR_INT, L_CLONE, L_COPY, L_INSERT, and PROCNAME.
Referenced by jbClassifyCorrelation(), jbClassifyRankHaus(), pixaaFlattenToPixa(), pixaClipToPix(), pixaCopy(), pixaCreateFromBoxa(), pixaMorphSequenceByComponent(), pixaMorphSequenceByRegion(), pixaSelectWithIndicator(), pixaSort2dByIndex(), pixaSortByIndex(), pixExtractBarcodes(), pixSaveTiledOutline(), ReconstructPixa1(), ReconstructPixa2(), and wshedSaveBasin().
Input: pixa Return: count, or 0 if no pixa
Definition at line 554 of file pixabasic.c.
References ERROR_INT, Pixa::n, and PROCNAME.
Referenced by AddTextAndSave(), jbAccumulateComposites(), jbClassifyCorrelation(), jbClassifyRankHaus(), jbCorrelation(), jbRankHaus(), jbTemplatesFromComposites(), main(), MakePtrasFromPixa(), pixaaCreateFromPixa(), pixaAddBorderGeneral(), pixaAddPix(), pixaaDisplay(), pixaaDisplayByPixa(), pixaaFlattenToPixa(), pixaAnyColormaps(), pixaBinSort(), pixaCentroids(), pixaClear(), pixaClipToPix(), pixacompCreateFromPixa(), pixacompDisplayTiledAndScaled(), pixaCountPixels(), pixAddWithIndicator(), pixaDisplay(), pixaDisplayOnColor(), pixaDisplayOnLattice(), pixaDisplayRandomCmap(), pixaDisplayTiled(), pixaDisplayTiledAndScaled(), pixaDisplayTiledInRows(), pixaDisplayUnsplit(), pixaEqual(), pixaExtractColumnFromEachPix(), pixaFindAreaFraction(), pixaFindAreaPerimRatio(), pixaFindDimensions(), pixaFindPerimSizeRatio(), pixaFindWidthHeightProduct(), pixaFindWidthHeightRatio(), pixaGenerateFont(), pixaGetAlignedStats(), pixaGetDepthInfo(), pixaInsertPix(), pixaJoin(), pixaMorphSequenceByComponent(), pixaMorphSequenceByRegion(), pixaRemovePix(), pixaSaveFont(), pixaSizeRange(), pixaSort(), pixaSort2dByIndex(), pixaSortByIndex(), pixaWriteCompressedToPS(), pixaWriteFiles(), pixaWriteStream(), pixFindRectangleComps(), pixGetTextlineCenters(), pixMorphSequenceByComponent(), pixMorphSequenceByRegion(), pixPaintSelfThroughMask(), pixQualifyLocalMinima(), pixReadBarcodes(), pixRemoveWithIndicator(), pixSaveTiledOutline(), pixSelectByAreaFraction(), pixSelectByAreaPerimRatio(), pixSelectBySize(), pixSelectByWidthHeightRatio(), and wshedRenderFill().
Input: pixa Return: 0 if OK, 1 on error
Definition at line 572 of file pixabasic.c.
References ERROR_INT, PROCNAME, and Pixa::refcount.
Referenced by pixaCopy(), and pixaDestroy().
Input: pixa index (to the index-th pix) accesstype (L_COPY or L_CLONE) Return: pix, or null on error
Definition at line 594 of file pixabasic.c.
References ERROR_PTR, L_CLONE, L_COPY, Pixa::n, NULL, Pixa::pix, pixClone(), pixCopy(), and PROCNAME.
Referenced by bmfGetPix(), bmfGetWidth(), CopyStoreClean(), findSimilarSizedTemplatesNext(), jbAccumulateComposites(), jbClassifyCorrelation(), jbClassifyRankHaus(), jbCorrelation(), jbDataRender(), jbGetLLCorners(), jbGetULCorners(), jbRankHaus(), jbTemplatesFromComposites(), main(), MakePtrasFromPixa(), pixaaCreateFromPixa(), pixaAddBorderGeneral(), pixaaDisplay(), pixaaDisplayByPixa(), pixaaFlattenToPixa(), pixaAnyColormaps(), pixaCentroids(), pixaClipToPix(), pixacompCreateFromPixa(), pixacompDisplayTiledAndScaled(), pixaCopy(), pixaCountPixels(), pixAddWithIndicator(), pixaDisplay(), pixaDisplayOnColor(), pixaDisplayOnLattice(), pixaDisplayRandomCmap(), pixaDisplayTiled(), pixaDisplayTiledAndScaled(), pixaDisplayTiledInRows(), pixaDisplayUnsplit(), pixaEqual(), pixaExtractColumnFromEachPix(), pixaFindAreaFraction(), pixaFindAreaPerimRatio(), pixaFindDimensions(), pixaFindPerimSizeRatio(), pixaFindWidthHeightProduct(), pixaFindWidthHeightRatio(), pixaGenerateFont(), pixaGetPixDimensions(), pixaJoin(), pixaMorphSequenceByComponent(), pixaMorphSequenceByRegion(), pixaSelectWithIndicator(), pixaSizeRange(), pixaSort2dByIndex(), pixaSortByIndex(), pixaWriteCompressedToPS(), pixaWriteFiles(), pixaWriteStream(), pixFillHolesToBoundingRect(), pixFindRectangleComps(), pixGetAllCCBorders(), pixGetCCBorders(), pixGetOuterBordersPtaa(), pixGetTextlineCenters(), pixMorphSequenceByComponent(), pixMorphSequenceByRegion(), pixPaintSelfThroughMask(), pixQualifyLocalMinima(), pixReadBarcodes(), pixRemoveWithIndicator(), pixSaveTiledOutline(), pixSelectiveConnCompFill(), pixSelectMinInConnComp(), pixSmoothConnectedRegions(), pixSplitIntoBoxa(), pixWordMaskByDilation(), ptaaGetBoundaryPixels(), selaDisplayInPix(), and wshedRenderFill().
l_int32 pixaGetPixDimensions | ( | PIXA * | pixa, |
l_int32 | index, | ||
l_int32 * | pw, | ||
l_int32 * | ph, | ||
l_int32 * | pd | ||
) |
Input: pixa index (to the index-th box) &w, &h, &d (<optional return>="">; each can be null) Return: 0 if OK, 1 on error
Definition at line 623 of file pixabasic.c.
References ERROR_INT, L_CLONE, Pixa::n, NULL, pixaGetPix(), pixDestroy(), pixGetDimensions(), and PROCNAME.
Referenced by pixaDisplayOnLattice(), pixaDisplayTiledInRows(), pixaDisplayUnsplit(), pixaGetAlignedStats(), pixaGetDepthInfo(), pixaMorphSequenceByComponent(), pixaMorphSequenceByRegion(), selaAddCrossJunctions(), and selaAddTJunctions().
Input: pixa accesstype (L_COPY, L_CLONE, L_COPY_CLONE) Return: boxa, or null on error
Definition at line 654 of file pixabasic.c.
References Pixa::boxa, boxaCopy(), ERROR_PTR, L_CLONE, L_COPY, L_COPY_CLONE, NULL, and PROCNAME.
Referenced by pixaAddBorderGeneral(), pixaaDisplay(), pixacompCreateFromPixa(), pixaDisplay(), pixaDisplayOnColor(), pixaDisplayRandomCmap(), pixaEqual(), pixaJoin(), pixaSelectBySize(), PixaSortTest(), pixGetWordsInTextlines(), pixMorphSequenceByComponent(), and pixMorphSequenceByRegion().
Input: pixa Return: count, or 0 on error
Definition at line 678 of file pixabasic.c.
References Pixa::boxa, boxaGetCount(), ERROR_INT, and PROCNAME.
Referenced by pixaAddBorderGeneral(), pixaMorphSequenceByComponent(), and pixaMorphSequenceByRegion().
Input: pixa index (to the index-th pix) accesstype (L_COPY or L_CLONE) Return: box (if null, not automatically an error), or null on error
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 708 of file pixabasic.c.
References Boxa::box, Pixa::boxa, boxClone(), boxCopy(), ERROR_PTR, L_CLONE, L_COPY, Boxa::n, NULL, and PROCNAME.
Referenced by main(), MakePtrasFromPixa(), pixaAddBorderGeneral(), pixaaFlattenToPixa(), pixaClipToPix(), pixaCopy(), pixAddWithIndicator(), pixaGetBoxGeometry(), pixaMorphSequenceByComponent(), pixaMorphSequenceByRegion(), pixaSelectWithIndicator(), pixaSort2dByIndex(), pixaSortByIndex(), pixGetAllCCBorders(), pixPaintSelfThroughMask(), and pixRemoveWithIndicator().
l_int32 pixaGetBoxGeometry | ( | PIXA * | pixa, |
l_int32 | index, | ||
l_int32 * | px, | ||
l_int32 * | py, | ||
l_int32 * | pw, | ||
l_int32 * | ph | ||
) |
Input: pixa index (to the index-th box) &x, &y, &w, &h (<optional return>="">; each can be null) Return: 0 if OK, 1 on error
Definition at line 746 of file pixabasic.c.
References boxDestroy(), boxGetGeometry(), ERROR_INT, L_CLONE, Pixa::n, NULL, pixaGetBox(), and PROCNAME.
Referenced by pixaaDisplay(), pixaDisplay(), pixaDisplayOnColor(), pixaDisplayRandomCmap(), pixGetTextlineCenters(), pixMorphSequenceByComponent(), pixMorphSequenceByRegion(), pixSaveTiledOutline(), and wshedRenderFill().
Input: pixa Return: pix array, or null on error
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 783 of file pixabasic.c.
References ERROR_PTR, NULL, Pixa::pix, and PROCNAME.
Referenced by pixThinGeneral().
Input: pixa index (to the index-th pix) pix (insert to replace existing one) box (<optional> insert to replace existing) Return: 0 if OK, 1 on error
Notes: (1) In-place replacement of one pix. (2) The previous pix at that location is destroyed.
Definition at line 812 of file pixabasic.c.
References Pixa::boxa, boxaReplaceBox(), ERROR_INT, Boxa::n, Pixa::n, Pixa::pix, pixDestroy(), and PROCNAME.
Referenced by main(), pixaAddBorderGeneral(), pixaGenerateFont(), and pixaInitFull().
Input: pixa index (at which pix is to be inserted) pixs (new pix to be inserted) box (<optional> new box to be inserted) Return: 0 if OK, 1 on error
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 860 of file pixabasic.c.
References Pixa::boxa, boxaExtendArray(), boxaInsertBox(), ERROR_INT, Pixa::n, Pixa::nalloc, Pixa::pix, pixaExtendArray(), pixaGetCount(), and PROCNAME.
Referenced by main().
Input: pixa index (of pix to be removed) Return: 0 if OK, 1 on error
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 908 of file pixabasic.c.
References Pixa::boxa, boxaGetCount(), boxaRemoveBox(), ERROR_INT, Pixa::n, NULL, Pixa::pix, pixaGetCount(), pixDestroy(), and PROCNAME.
Referenced by main().
Input: pixa (typically empty) pix (to be replicated into the entire pixa ptr array) box (<optional> to be replicated into the entire boxa ptr array) Return: 0 if OK, 1 on error
Notes: (1) This initializes a pixa by filling up the entire pix ptr array with copies of . Any existing pix are destroyed. It also fills the boxa with copies of . After this oepration, the numbers of pix and 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) 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, up to some index "max": Pixa *pixa = pixaCreate(max); Pix *pix = pixCreate(1, 1, 1); // little memory Box *box = boxCreate(...); pixaInitFull(pixa, pix, box); An existing pixa with a smaller ptr array can also be reused: pixaExtendArrayToSize(pixa, max); Pix *pix = pixCreate(...); Box *box = boxCreate(...); pixaInitFull(pixa, pix, box); For these situations, the pix should be small and disposable. The initialization allows the pixa to always be properly filled, even if all pix (and boxes) are not later replaced.
Definition at line 975 of file pixabasic.c.
References Pixa::boxa, boxaInitFull(), ERROR_INT, Pixa::n, Pixa::nalloc, NULL, pixaReplacePix(), pixCopy(), and PROCNAME.
Referenced by main().
Input: pixa Return: 0 if OK, 1 on error
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 1014 of file pixabasic.c.
References Pixa::boxa, boxaClear(), ERROR_INT, Pixa::n, Pixa::pix, pixaGetCount(), pixDestroy(), and PROCNAME.
Input: pixad (dest pixa; add to this one) pixas (source pixa; add from this one) istart (starting index in nas) iend (ending index in nas; use 0 to cat all) Return: 0 if OK, 1 on error
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'
Definition at line 1049 of file pixabasic.c.
References boxaDestroy(), boxaJoin(), ERROR_INT, L_CLONE, L_INFO, L_INSERT, pixaAddPix(), pixaGetBoxa(), pixaGetCount(), pixaGetPix(), and PROCNAME.
Input: n (initial number of pixa ptrs) Return: pixaa, or null on error
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 1117 of file pixabasic.c.
References Pixaa::boxa, boxaCreate(), CALLOC, ERROR_PTR, INITIAL_PTR_ARRAYSIZE, Pixaa::n, Pixaa::nalloc, NULL, Pixaa::pixa, and PROCNAME.
Referenced by CopyStoreClean(), jbClasserCreate(), main(), pixaaCreateFromPixa(), pixaaReadStream(), and pixaSort2dByIndex().
Input: pixa n (number specifying subdivision of pixa) type (L_CHOOSE_CONSECUTIVE, L_CHOOSE_SKIP_BY) copyflag (L_CLONE, L_COPY) Return: pixaa, or null on error
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 1158 of file pixabasic.c.
References ERROR_PTR, L_CHOOSE_CONSECUTIVE, L_CHOOSE_SKIP_BY, L_CLONE, L_COPY, L_INSERT, L_MIN, NULL, pixaaAddPixa(), pixaaCreate(), pixaAddPix(), pixaCreate(), pixaGetCount(), pixaGetPix(), and PROCNAME.
Referenced by main().
void pixaaDestroy | ( | PIXAA ** | ppixaa | ) |
Input: &pixaa <to be="" nulled>=""> Return: void
Definition at line 1221 of file pixabasic.c.
References Pixaa::boxa, boxaDestroy(), FREE, L_WARNING, Pixaa::n, NULL, Pixaa::pixa, pixaDestroy(), and PROCNAME.
Referenced by CopyStoreClean(), jbClasserDestroy(), main(), and pixGetWordsInTextlines().
Input: pixaa pixa (to be added) 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 Return: 0 if OK; 1 on error
Definition at line 1265 of file pixabasic.c.
References ERROR_INT, L_CLONE, L_COPY, L_COPY_CLONE, L_INSERT, Pixaa::n, Pixaa::nalloc, NULL, Pixaa::pixa, pixaaExtendArray(), pixaaGetCount(), pixaCopy(), and PROCNAME.
Referenced by CopyStoreClean(), jbClassifyCorrelation(), jbClassifyRankHaus(), main(), pixaaCreateFromPixa(), pixaaReadStream(), and pixaSort2dByIndex().
Input: pixaa Return: 0 if OK; 1 on error
Definition at line 1306 of file pixabasic.c.
References ERROR_INT, Pixaa::nalloc, NULL, Pixaa::pixa, PROCNAME, and reallocNew().
Referenced by pixaaAddPixa().
Input: pixaa box copyflag (L_INSERT, L_COPY, L_CLONE) Return: 0 if OK, 1 on error
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 1336 of file pixabasic.c.
References Pixaa::boxa, boxaAddBox(), ERROR_INT, L_CLONE, L_COPY, L_INSERT, and PROCNAME.
Referenced by main().
Input: pixaa Return: count, or 0 if no pixaa
Definition at line 1365 of file pixabasic.c.
References ERROR_INT, Pixaa::n, and PROCNAME.
Referenced by jbAccumulateComposites(), pixaaAddPixa(), pixaaDisplay(), pixaaDisplayByPixa(), pixaaDisplayTiledAndScaled(), pixaaFlattenToPixa(), and pixaaWriteStream().
Input: pixaa index (to the index-th pixa) accesstype (L_COPY, L_CLONE, L_COPY_CLONE) Return: pixa, or null on error
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 1395 of file pixabasic.c.
References ERROR_PTR, L_CLONE, L_COPY, L_COPY_CLONE, Pixaa::n, NULL, Pixaa::pixa, pixaCopy(), and PROCNAME.
Referenced by jbAccumulateComposites(), jbClassifyCorrelation(), jbClassifyRankHaus(), pixaaDisplay(), pixaaDisplayByPixa(), pixaaDisplayTiledAndScaled(), pixaaFlattenToPixa(), and pixaaWriteStream().
Input: pixaa accesstype (L_COPY, L_CLONE) Return: boxa, or null on error
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 1429 of file pixabasic.c.
References Pixaa::boxa, boxaCopy(), ERROR_PTR, L_CLONE, L_COPY, NULL, and PROCNAME.
Referenced by pixaaDisplay().
PIXA* pixaRead | ( | const char * | filename | ) |
Input: filename Return: pixa, or null on error
Notes: (1) The pix are stored in the file as png. If the png library is not linked, this will fail.
Definition at line 1461 of file pixabasic.c.
References ERROR_PTR, fopenReadStream(), NULL, pixaReadStream(), and PROCNAME.
Referenced by main(), and pixaGetFont().
PIXA* pixaReadStream | ( | FILE * | fp | ) |
Input: stream Return: pixa, or null on error
Notes: (1) The pix are stored in the file as png. If the png library is not linked, this will fail.
Definition at line 1498 of file pixabasic.c.
References Pixa::boxa, boxaDestroy(), boxaReadStream(), ERROR_PTR, L_INSERT, NULL, PIXA_VERSION_NUMBER, pixaAddPix(), pixaCreate(), pixaDestroy(), pixReadStreamPng(), pixSetXRes(), pixSetYRes(), PROCNAME, and version.
Referenced by pixaaReadStream(), and pixaRead().
Input: filename pixa Return: 0 if OK, 1 on error
Notes: (1) The pix are stored in the file as png. If the png library is not linked, this will fail.
Definition at line 1557 of file pixabasic.c.
References ERROR_INT, NULL, pixaWriteStream(), and PROCNAME.
Referenced by main(), pixaSaveFont(), and PixaSortTest().
Input: stream (opened for "wb") pixa Return: 0 if OK, 1 on error
Notes: (1) The pix are stored in the file as png. If the png library is not linked, this will fail.
Definition at line 1594 of file pixabasic.c.
References Pixa::boxa, boxaWriteStream(), ERROR_INT, L_CLONE, NULL, PIXA_VERSION_NUMBER, pixaGetCount(), pixaGetPix(), pixDestroy(), pixWriteStreamPng(), PROCNAME, Pix::xres, and Pix::yres.
Referenced by pixaaWriteStream(), and pixaWrite().
PIXAA* pixaaRead | ( | const char * | filename | ) |
Input: filename Return: pixaa, or null on error
Notes: (1) The pix are stored in the file as png. If the png library is not linked, this will fail.
Definition at line 1641 of file pixabasic.c.
References ERROR_PTR, fopenReadStream(), NULL, pixaaReadStream(), and PROCNAME.
Referenced by main().
PIXAA* pixaaReadStream | ( | FILE * | fp | ) |
Input: stream Return: pixaa, or null on error
Notes: (1) The pix are stored in the file as png. If the png library is not linked, this will fail.
Definition at line 1678 of file pixabasic.c.
References Pixaa::boxa, boxaDestroy(), boxaReadStream(), ERROR_PTR, L_INSERT, NULL, PIXAA_VERSION_NUMBER, pixaaAddPixa(), pixaaCreate(), pixaReadStream(), PROCNAME, and version.
Referenced by pixaaRead().
Input: filename pixaa Return: 0 if OK, 1 on error
Notes: (1) The pix are stored in the file as png. If the png library is not linked, this will fail.
Definition at line 1735 of file pixabasic.c.
References ERROR_INT, NULL, pixaaWriteStream(), and PROCNAME.
Referenced by main().
Input: stream (opened for "wb") pixaa Return: 0 if OK, 1 on error
Notes: (1) The pix are stored in the file as png. If the png library is not linked, this will fail.
Definition at line 1773 of file pixabasic.c.
References Pixaa::boxa, boxaWriteStream(), ERROR_INT, L_CLONE, NULL, PIXAA_VERSION_NUMBER, pixaaGetCount(), pixaaGetPixa(), pixaDestroy(), pixaWriteStream(), and PROCNAME.
Referenced by pixaaWrite().
const l_int32 INITIAL_PTR_ARRAYSIZE = 20 [static] |
Definition at line 93 of file pixabasic.c.
Referenced by pixaaCreate(), and pixaCreate().