Leptonica 1.68
C Image Processing Library

pixafunc1.c File Reference

Binary Pixa (array of Pix) filtering, sorting, clipping. See conncomp.c. More...

#include <string.h>
#include "allheaders.h"

Go to the source code of this file.

Functions

PIXpixSelectBySize (PIX *pixs, l_int32 width, l_int32 height, l_int32 connectivity, l_int32 type, l_int32 relation, l_int32 *pchanged)
PIXApixaSelectBySize (PIXA *pixas, l_int32 width, l_int32 height, l_int32 type, l_int32 relation, l_int32 *pchanged)
PIXpixSelectByAreaPerimRatio (PIX *pixs, l_float32 thresh, l_int32 connectivity, l_int32 type, l_int32 *pchanged)
PIXApixaSelectByAreaPerimRatio (PIXA *pixas, l_float32 thresh, l_int32 type, l_int32 *pchanged)
PIXpixSelectByAreaFraction (PIX *pixs, l_float32 thresh, l_int32 connectivity, l_int32 type, l_int32 *pchanged)
PIXApixaSelectByAreaFraction (PIXA *pixas, l_float32 thresh, l_int32 type, l_int32 *pchanged)
PIXpixSelectByWidthHeightRatio (PIX *pixs, l_float32 thresh, l_int32 connectivity, l_int32 type, l_int32 *pchanged)
PIXApixaSelectByWidthHeightRatio (PIXA *pixas, l_float32 thresh, l_int32 type, l_int32 *pchanged)
PIXApixaSelectWithIndicator (PIXA *pixas, NUMA *na, l_int32 *pchanged)
l_int32 pixRemoveWithIndicator (PIX *pixs, PIXA *pixa, NUMA *na)
l_int32 pixAddWithIndicator (PIX *pixs, PIXA *pixa, NUMA *na)
PIXApixaSort (PIXA *pixas, l_int32 sorttype, l_int32 sortorder, NUMA **pnaindex, l_int32 copyflag)
PIXApixaBinSort (PIXA *pixas, l_int32 sorttype, l_int32 sortorder, NUMA **pnaindex, l_int32 copyflag)
PIXApixaSortByIndex (PIXA *pixas, NUMA *naindex, l_int32 copyflag)
PIXAApixaSort2dByIndex (PIXA *pixas, NUMAA *naa, l_int32 copyflag)
PIXApixaAddBorderGeneral (PIXA *pixad, PIXA *pixas, l_int32 left, l_int32 right, l_int32 top, l_int32 bot, l_uint32 val)
PIXApixaaFlattenToPixa (PIXAA *pixaa, NUMA **pnaindex, l_int32 copyflag)
l_int32 pixaSizeRange (PIXA *pixa, l_int32 *pminw, l_int32 *pminh, l_int32 *pmaxw, l_int32 *pmaxh)
PIXApixaClipToPix (PIXA *pixas, PIX *pixs)
l_int32 pixaAnyColormaps (PIXA *pixa, l_int32 *phascmap)
l_int32 pixaGetDepthInfo (PIXA *pixa, l_int32 *pmaxdepth, l_int32 *psame)
l_int32 pixaEqual (PIXA *pixa1, PIXA *pixa2, l_int32 maxdist, NUMA **pnaindex, l_int32 *psame)

Variables

static const l_int32 MIN_COMPS_FOR_BIN_SORT = 500

Detailed Description


Function Documentation

PIX* pixSelectBySize ( PIX pixs,
l_int32  width,
l_int32  height,
l_int32  connectivity,
l_int32  type,
l_int32  relation,
l_int32 pchanged 
)

pixSelectBySize()

Input: pixs (1 bpp) width, height (threshold dimensions) connectivity (4 or 8) type (L_SELECT_WIDTH, L_SELECT_HEIGHT, L_SELECT_IF_EITHER, L_SELECT_IF_BOTH) relation (L_SELECT_IF_LT, L_SELECT_IF_GT, L_SELECT_IF_LTE, L_SELECT_IF_GTE) &changed (<optional return>=""> 1 if changed; 0 otherwise) Return: filtered pixd, or null on error

Notes: (1) The args specify constraints on the size of the components that are kept. (2) If unchanged, returns a copy of pixs. Otherwise, returns a new pix with the filtered components. (3) If the selection type is L_SELECT_WIDTH, the input height is ignored, and v.v. (4) To keep small components, use relation = L_SELECT_IF_LT or L_SELECT_IF_LTE. To keep large components, use relation = L_SELECT_IF_GT or L_SELECT_IF_GTE.

Definition at line 161 of file pixafunc1.c.

References boxaDestroy(), ERROR_PTR, FALSE, L_SELECT_HEIGHT, L_SELECT_IF_BOTH, L_SELECT_IF_EITHER, L_SELECT_IF_GT, L_SELECT_IF_GTE, L_SELECT_IF_LT, L_SELECT_IF_LTE, L_SELECT_WIDTH, NULL, pixaDestroy(), pixaDisplay(), pixaGetCount(), pixaSelectBySize(), pixConnComp(), pixCopy(), pixCopyColormap(), pixCopyInputFormat(), pixCopyResolution(), pixCopyText(), pixCreateTemplate(), pixGetDimensions(), pixZero(), PROCNAME, and TRUE.

Referenced by DoPageSegmentation(), main(), pixGenTextblockMask(), and pixGetRegionsBinary().

PIXA* pixaSelectBySize ( PIXA pixas,
l_int32  width,
l_int32  height,
l_int32  type,
l_int32  relation,
l_int32 pchanged 
)

pixaSelectBySize()

Input: pixas width, height (threshold dimensions) type (L_SELECT_WIDTH, L_SELECT_HEIGHT, L_SELECT_IF_EITHER, L_SELECT_IF_BOTH) relation (L_SELECT_IF_LT, L_SELECT_IF_GT, L_SELECT_IF_LTE, L_SELECT_IF_GTE) &changed (<optional return>=""> 1 if changed; 0 otherwise) Return: pixad, or null on error

Notes: (1) The args specify constraints on the size of the components that are kept. (2) Uses pix and box clones in the new pixa. (3) If the selection type is L_SELECT_WIDTH, the input height is ignored, and v.v. (4) To keep small components, use relation = L_SELECT_IF_LT or L_SELECT_IF_LTE. To keep large components, use relation = L_SELECT_IF_GT or L_SELECT_IF_GTE.

Definition at line 247 of file pixafunc1.c.

References boxaDestroy(), boxaMakeSizeIndicator(), ERROR_PTR, L_CLONE, L_SELECT_HEIGHT, L_SELECT_IF_BOTH, L_SELECT_IF_EITHER, L_SELECT_IF_GT, L_SELECT_IF_GTE, L_SELECT_IF_LT, L_SELECT_IF_LTE, L_SELECT_WIDTH, NULL, numaDestroy(), pixaGetBoxa(), pixaSelectWithIndicator(), and PROCNAME.

Referenced by jbGetComponents(), main(), pixGetTextlineCenters(), and pixSelectBySize().

PIX* pixSelectByAreaPerimRatio ( PIX pixs,
l_float32  thresh,
l_int32  connectivity,
l_int32  type,
l_int32 pchanged 
)

pixSelectByAreaPerimRatio()

Input: pixs (1 bpp) thresh (threshold ratio of interior/boundary pixels) connectivity (4 or 8) type (L_SELECT_IF_LT, L_SELECT_IF_GT, L_SELECT_IF_LTE, L_SELECT_IF_GTE) &changed (<optional return>=""> 1 if changed; 0 if clone returned) Return: pixd, or null on error

Notes: (1) The args specify constraints on the size of the components that are kept. (2) If unchanged, returns a copy of pixs. Otherwise, returns a new pix with the filtered components. (3) This filters "thin" components, where a thin component is defined to have a ratio of interior to boundary pixels that is smaller than a given threshold value. (4) Use L_SELECT_IF_LT or L_SELECT_IF_LTE to save the thin components, and L_SELECT_IF_GT or L_SELECT_IF_GTE to remove them.

Definition at line 305 of file pixafunc1.c.

References boxaDestroy(), ERROR_PTR, FALSE, L_SELECT_IF_GT, L_SELECT_IF_GTE, L_SELECT_IF_LT, L_SELECT_IF_LTE, NULL, pixaDestroy(), pixaDisplay(), pixaGetCount(), pixaSelectByAreaPerimRatio(), pixConnComp(), pixCopy(), pixCopyColormap(), pixCopyInputFormat(), pixCopyResolution(), pixCopyText(), pixCreateTemplate(), pixGetDimensions(), pixZero(), PROCNAME, and TRUE.

Referenced by main().

PIXA* pixaSelectByAreaPerimRatio ( PIXA pixas,
l_float32  thresh,
l_int32  type,
l_int32 pchanged 
)

pixaSelectByAreaPerimRatio()

Input: pixas thresh (threshold ratio of interior/boundary pixels) type (L_SELECT_IF_LT, L_SELECT_IF_GT, L_SELECT_IF_LTE, L_SELECT_IF_GTE) &changed (<optional return>=""> 1 if changed; 0 if clone returned) Return: pixad, or null on error

Notes: (1) Returns a pixa clone if no components are removed. (2) Uses pix and box clones in the new pixa. (3) We define a thin component here to be one with a ratio of interior to boundary pixels that is smaller than a given threshold value. (4) Use L_SELECT_IF_LT or L_SELECT_IF_LTE to save the thin components, and L_SELECT_IF_GT or L_SELECT_IF_GTE to remove them.

Definition at line 382 of file pixafunc1.c.

References ERROR_PTR, L_SELECT_IF_GT, L_SELECT_IF_GTE, L_SELECT_IF_LT, L_SELECT_IF_LTE, NULL, numaDestroy(), numaMakeThresholdIndicator(), pixaFindAreaPerimRatio(), pixaSelectWithIndicator(), and PROCNAME.

Referenced by pixSelectByAreaPerimRatio().

PIX* pixSelectByAreaFraction ( PIX pixs,
l_float32  thresh,
l_int32  connectivity,
l_int32  type,
l_int32 pchanged 
)

pixSelectByAreaFraction()

Input: pixs (1 bpp) thresh (threshold ratio of fg pixels to (w * h)) connectivity (4 or 8) type (L_SELECT_IF_LT, L_SELECT_IF_GT, L_SELECT_IF_LTE, L_SELECT_IF_GTE) &changed (<optional return>=""> 1 if changed; 0 if clone returned) Return: pixd, or null on error

Notes: (1) The args specify constraints on the amount of foreground coverage of the components that are kept. (2) If unchanged, returns a copy of pixs. Otherwise, returns a new pix with the filtered components. (3) This filters components based on the fraction of fg pixels of the component in its bounding box. (4) Use L_SELECT_IF_LT or L_SELECT_IF_LTE to save components with less than the threshold fraction of foreground, and L_SELECT_IF_GT or L_SELECT_IF_GTE to remove them.

Definition at line 436 of file pixafunc1.c.

References boxaDestroy(), ERROR_PTR, FALSE, L_SELECT_IF_GT, L_SELECT_IF_GTE, L_SELECT_IF_LT, L_SELECT_IF_LTE, NULL, pixaDestroy(), pixaDisplay(), pixaGetCount(), pixaSelectByAreaFraction(), pixConnComp(), pixCopy(), pixCopyColormap(), pixCopyInputFormat(), pixCopyResolution(), pixCopyText(), pixCreateTemplate(), pixGetDimensions(), pixZero(), PROCNAME, and TRUE.

Referenced by main().

PIXA* pixaSelectByAreaFraction ( PIXA pixas,
l_float32  thresh,
l_int32  type,
l_int32 pchanged 
)

pixaSelectByAreaFraction()

Input: pixas thresh (threshold ratio of fg pixels to (w * h)) type (L_SELECT_IF_LT, L_SELECT_IF_GT, L_SELECT_IF_LTE, L_SELECT_IF_GTE) &changed (<optional return>=""> 1 if changed; 0 if clone returned) Return: pixad, or null on error

Notes: (1) Returns a pixa clone if no components are removed. (2) Uses pix and box clones in the new pixa. (3) This filters components based on the fraction of fg pixels of the component in its bounding box. (4) Use L_SELECT_IF_LT or L_SELECT_IF_LTE to save components with less than the threshold fraction of foreground, and L_SELECT_IF_GT or L_SELECT_IF_GTE to remove them.

Definition at line 513 of file pixafunc1.c.

References ERROR_PTR, L_SELECT_IF_GT, L_SELECT_IF_GTE, L_SELECT_IF_LT, L_SELECT_IF_LTE, NULL, numaDestroy(), numaMakeThresholdIndicator(), pixaFindAreaFraction(), pixaSelectWithIndicator(), and PROCNAME.

Referenced by pixSelectByAreaFraction().

PIX* pixSelectByWidthHeightRatio ( PIX pixs,
l_float32  thresh,
l_int32  connectivity,
l_int32  type,
l_int32 pchanged 
)

pixSelectByWidthHeightRatio()

Input: pixs (1 bpp) thresh (threshold ratio of width/height) connectivity (4 or 8) type (L_SELECT_IF_LT, L_SELECT_IF_GT, L_SELECT_IF_LTE, L_SELECT_IF_GTE) &changed (<optional return>=""> 1 if changed; 0 if clone returned) Return: pixd, or null on error

Notes: (1) The args specify constraints on the width-to-height ratio for components that are kept. (2) If unchanged, returns a copy of pixs. Otherwise, returns a new pix with the filtered components. (3) This filters components based on the width-to-height ratios. (4) Use L_SELECT_IF_LT or L_SELECT_IF_LTE to save components with less than the threshold ratio, and L_SELECT_IF_GT or L_SELECT_IF_GTE to remove them.

Definition at line 566 of file pixafunc1.c.

References boxaDestroy(), ERROR_PTR, FALSE, L_SELECT_IF_GT, L_SELECT_IF_GTE, L_SELECT_IF_LT, L_SELECT_IF_LTE, NULL, pixaDestroy(), pixaDisplay(), pixaGetCount(), pixaSelectByWidthHeightRatio(), pixConnComp(), pixCopy(), pixCopyColormap(), pixCopyInputFormat(), pixCopyResolution(), pixCopyText(), pixCreateTemplate(), pixGetDimensions(), pixZero(), PROCNAME, and TRUE.

PIXA* pixaSelectByWidthHeightRatio ( PIXA pixas,
l_float32  thresh,
l_int32  type,
l_int32 pchanged 
)

pixaSelectByWidthHeightRatio()

Input: pixas thresh (threshold ratio of width/height) type (L_SELECT_IF_LT, L_SELECT_IF_GT, L_SELECT_IF_LTE, L_SELECT_IF_GTE) &changed (<optional return>=""> 1 if changed; 0 if clone returned) Return: pixad, or null on error

Notes: (1) Returns a pixa clone if no components are removed. (2) Uses pix and box clones in the new pixa. (3) This filters components based on the width-to-height ratio of each pix. (4) Use L_SELECT_IF_LT or L_SELECT_IF_LTE to save components with less than the threshold ratio, and L_SELECT_IF_GT or L_SELECT_IF_GTE to remove them.

Definition at line 643 of file pixafunc1.c.

References ERROR_PTR, L_SELECT_IF_GT, L_SELECT_IF_GTE, L_SELECT_IF_LT, L_SELECT_IF_LTE, NULL, numaDestroy(), numaMakeThresholdIndicator(), pixaFindWidthHeightRatio(), pixaSelectWithIndicator(), and PROCNAME.

Referenced by pixSelectByWidthHeightRatio().

PIXA* pixaSelectWithIndicator ( PIXA pixas,
NUMA na,
l_int32 pchanged 
)

pixaSelectWithIndicator()

Input: pixas na (indicator numa) &changed (<optional return>=""> 1 if changed; 0 if clone returned) Return: pixad, or null on error

Notes: (1) Returns a pixa clone if no components are removed. (2) Uses pix and box clones in the new pixa. (3) The indicator numa has values 0 (ignore) and 1 (accept).

Definition at line 688 of file pixafunc1.c.

References ERROR_PTR, FALSE, L_CLONE, L_INSERT, NULL, numaGetCount(), numaGetIValue(), pixaAddBox(), pixaAddPix(), pixaCopy(), pixaCreate(), pixaGetBox(), pixaGetPix(), PROCNAME, and TRUE.

Referenced by main(), pixaSelectByAreaFraction(), pixaSelectByAreaPerimRatio(), pixaSelectBySize(), and pixaSelectByWidthHeightRatio().

l_int32 pixRemoveWithIndicator ( PIX pixs,
PIXA pixa,
NUMA na 
)

pixRemoveWithIndicator()

Input: pixs (1 bpp pix from which components are removed; in-place) pixa (of connected components in pixs) na (numa indicator: remove components corresponding to 1s) Return: 0 if OK, 1 on error

Notes: (1) This complements pixAddWithIndicator(). Here, the selected components are set subtracted from pixs.

Definition at line 743 of file pixafunc1.c.

References boxDestroy(), boxGetGeometry(), ERROR_INT, L_CLONE, numaGetCount(), numaGetIValue(), PIX_DST, PIX_NOT, PIX_SRC, pixaGetBox(), pixaGetCount(), pixaGetPix(), pixDestroy(), pixRasterop(), and PROCNAME.

Referenced by main().

l_int32 pixAddWithIndicator ( PIX pixs,
PIXA pixa,
NUMA na 
)

pixAddWithIndicator()

Input: pixs (1 bpp pix from which components are added; in-place) pixa (of connected components, some of which will be put into pixs) na (numa indicator: add components corresponding to 1s) Return: 0 if OK, 1 on error

Notes: (1) This complements pixRemoveWithIndicator(). Here, the selected components are added to pixs.

Definition at line 794 of file pixafunc1.c.

References boxDestroy(), boxGetGeometry(), ERROR_INT, L_CLONE, numaGetCount(), numaGetIValue(), PIX_DST, PIX_SRC, pixaGetBox(), pixaGetCount(), pixaGetPix(), pixDestroy(), pixRasterop(), and PROCNAME.

PIXA* pixaSort ( PIXA pixas,
l_int32  sorttype,
l_int32  sortorder,
NUMA **  pnaindex,
l_int32  copyflag 
)

pixaSort()

Input: pixas sorttype (L_SORT_BY_X, L_SORT_BY_Y, L_SORT_BY_WIDTH, L_SORT_BY_HEIGHT, L_SORT_BY_MIN_DIMENSION, L_SORT_BY_MAX_DIMENSION, L_SORT_BY_PERIMETER, L_SORT_BY_AREA, L_SORT_BY_ASPECT_RATIO) sortorder (L_SORT_INCREASING, L_SORT_DECREASING) &naindex (<optional return>=""> index of sorted order into original array) copyflag (L_COPY, L_CLONE) Return: pixad (sorted version of pixas), or null on error

Notes: (1) This sorts based on the data in the boxa. If the boxa count is not the same as the pixa count, this returns an error. (2) The copyflag refers to the pix and box copies that are inserted into the sorted pixa. These are either L_COPY or L_CLONE.

Definition at line 855 of file pixafunc1.c.

References Pixa::boxa, boxaGetBoxGeometry(), boxaGetCount(), ERROR_PTR, L_CLONE, L_COPY, L_MAX, L_MIN, L_SORT_BY_AREA, L_SORT_BY_ASPECT_RATIO, L_SORT_BY_HEIGHT, L_SORT_BY_MAX_DIMENSION, L_SORT_BY_MIN_DIMENSION, L_SORT_BY_PERIMETER, L_SORT_BY_WIDTH, L_SORT_BY_X, L_SORT_BY_Y, L_SORT_DECREASING, L_SORT_INCREASING, L_WARNING, MIN_COMPS_FOR_BIN_SORT, NULL, numaAddNumber(), numaCreate(), numaDestroy(), numaGetSortIndex(), pixaBinSort(), pixaGetCount(), pixaSortByIndex(), and PROCNAME.

Referenced by main(), and PixaSortTest().

PIXA* pixaBinSort ( PIXA pixas,
l_int32  sorttype,
l_int32  sortorder,
NUMA **  pnaindex,
l_int32  copyflag 
)

pixaBinSort()

Input: pixas sorttype (L_SORT_BY_X, L_SORT_BY_Y, L_SORT_BY_WIDTH, L_SORT_BY_HEIGHT, L_SORT_BY_PERIMETER) sortorder (L_SORT_INCREASING, L_SORT_DECREASING) &naindex (<optional return>=""> index of sorted order into original array) copyflag (L_COPY, L_CLONE) Return: pixad (sorted version of pixas), or null on error

Notes: (1) This sorts based on the data in the boxa. If the boxa count is not the same as the pixa count, this returns an error. (2) The copyflag refers to the pix and box copies that are inserted into the sorted pixa. These are either L_COPY or L_CLONE. (3) For a large number of boxes (say, greater than 1000), this O(n) binsort is much faster than the O(nlogn) shellsort. For 5000 components, this is over 20x faster than boxaSort(). (4) Consequently, pixaSort() calls this function if it will likely go much faster.

Definition at line 978 of file pixafunc1.c.

References Pixa::boxa, boxaGetBoxGeometry(), boxaGetCount(), ERROR_PTR, L_CLONE, L_COPY, L_SORT_BY_HEIGHT, L_SORT_BY_PERIMETER, L_SORT_BY_WIDTH, L_SORT_BY_X, L_SORT_BY_Y, L_SORT_DECREASING, L_SORT_INCREASING, L_WARNING, NULL, numaAddNumber(), numaCreate(), numaDestroy(), numaGetBinSortIndex(), pixaGetCount(), pixaSortByIndex(), and PROCNAME.

Referenced by pixaSort(), and PixaSortTest().

PIXA* pixaSortByIndex ( PIXA pixas,
NUMA naindex,
l_int32  copyflag 
)

pixaSortByIndex()

Input: pixas naindex (na that maps from the new pixa to the input pixa) copyflag (L_COPY, L_CLONE) Return: pixad (sorted), or null on error

Definition at line 1063 of file pixafunc1.c.

References ERROR_PTR, L_CLONE, L_COPY, L_INSERT, NULL, numaGetIValue(), pixaAddBox(), pixaAddPix(), pixaCreate(), pixaGetBox(), pixaGetCount(), pixaGetPix(), and PROCNAME.

Referenced by pixaBinSort(), and pixaSort().

PIXAA* pixaSort2dByIndex ( PIXA pixas,
NUMAA naa,
l_int32  copyflag 
)

pixaSort2dByIndex()

Input: pixas naa (numaa that maps from the new pixaa to the input pixas) copyflag (L_CLONE or L_COPY) Return: pixaa (sorted), or null on error

Definition at line 1104 of file pixafunc1.c.

References ERROR_PTR, L_CLONE, L_INSERT, NULL, numaaGetCount(), numaaGetNuma(), numaaGetNumberCount(), numaDestroy(), numaGetCount(), numaGetIValue(), pixaaAddPixa(), pixaaCreate(), pixaAddBox(), pixaAddPix(), pixaCreate(), pixaGetBox(), pixaGetCount(), pixaGetPix(), and PROCNAME.

Referenced by pixGetWordsInTextlines().

PIXA* pixaAddBorderGeneral ( PIXA pixad,
PIXA pixas,
l_int32  left,
l_int32  right,
l_int32  top,
l_int32  bot,
l_uint32  val 
)

pixaAddBorderGeneral()

Input: pixad (can be null or equal to pixas) pixas (containing pix of all depths; colormap ok) left, right, top, bot (number of pixels added) val (value of added border pixels) Return: pixad (with border added to each pix), including on error

Notes: (1) For binary images: white: val = 0 black: val = 1 For grayscale images: white: val = 2 ** d - 1 black: val = 0 For rgb color images: white: val = 0xffffff00 black: val = 0 For colormapped images, use 'index' found this way: white: pixcmapGetRankIntensity(cmap, 1.0, &index); black: pixcmapGetRankIntensity(cmap, 0.0, &index); (2) For in-place replacement of each pix with a bordered version, use = . To make a new pixa, use = NULL. (3) In both cases, the boxa has sides adjusted as if it were expanded by the border.

Definition at line 1181 of file pixafunc1.c.

References boxaAddBox(), boxaDestroy(), boxAdjustSides(), boxaReplaceBox(), ERROR_PTR, L_CLONE, L_COPY, L_INSERT, L_WARNING_INT, NULL, pixaAddPix(), pixaCreate(), pixAddBorderGeneral(), pixaGetBox(), pixaGetBoxa(), pixaGetBoxaCount(), pixaGetCount(), pixaGetPix(), pixaReplacePix(), pixDestroy(), and PROCNAME.

PIXA* pixaaFlattenToPixa ( PIXAA pixaa,
NUMA **  pnaindex,
l_int32  copyflag 
)

pixaaFlattenToPixa()

Input: pixaa &naindex (<optional return>=""> the pixa index in the pixaa) copyflag (L_COPY or L_CLONE) Return: pixa, or null on error

Notes: (1) This 'flattens' the pixaa to a pixa, taking the pix in order in the first pixa, then the second, etc. (2) If &naindex is defined, we generate a Numa that gives, for each pix in the pixaa, the index of the pixa to which it belongs.

Definition at line 1250 of file pixafunc1.c.

References ERROR_PTR, L_CLONE, L_COPY, L_INSERT, NULL, numaAddNumber(), numaCreate(), pixaAddBox(), pixaAddPix(), pixaaGetCount(), pixaaGetPixa(), pixaCreate(), pixaDestroy(), pixaGetBox(), pixaGetCount(), pixaGetPix(), and PROCNAME.

Referenced by pixGetWordsInTextlines().

l_int32 pixaSizeRange ( PIXA pixa,
l_int32 pminw,
l_int32 pminh,
l_int32 pmaxw,
l_int32 pmaxh 
)

pixaSizeRange()

Input: pixa &minw, &minh, &maxw, &maxh (<optional return>=""> range of dimensions of pix in the array) Return: 0 if OK, 1 on error

Definition at line 1302 of file pixafunc1.c.

References ERROR_INT, L_CLONE, pixaGetCount(), pixaGetPix(), pixDestroy(), pixGetHeight(), pixGetWidth(), and PROCNAME.

Referenced by jbAccumulateComposites(), and jbDataSave().

PIXA* pixaClipToPix ( PIXA pixas,
PIX pixs 
)

pixaClipToPix()

Input: pixas pixs Return: pixad, or null on error

Notes: (1) This is intended for use in situations where pixas was originally generated from the input pixs. (2) Returns a pixad where each pix in pixas is ANDed with its associated region of the input pixs. This region is specified by the the box that is associated with the pix. (3) In a typical application of this function, pixas has a set of region masks, so this generates a pixa of the parts of pixs that correspond to each region mask component, along with the bounding box for the region.

Definition at line 1366 of file pixafunc1.c.

References ERROR_PTR, L_CLONE, L_COPY, L_INSERT, NULL, pixaAddBox(), pixaAddPix(), pixaCreate(), pixaGetBox(), pixaGetCount(), pixaGetPix(), pixAnd(), pixClipRectangle(), pixDestroy(), and PROCNAME.

Referenced by jbGetComponents(), and pixGetWordsInTextlines().

l_int32 pixaAnyColormaps ( PIXA pixa,
l_int32 phascmap 
)

pixaAnyColormaps()

Input: pixa &hascmap (<return> 1 if any pix has a colormap; 0 otherwise) Return: 0 if OK; 1 on error

Definition at line 1407 of file pixafunc1.c.

References ERROR_INT, L_CLONE, pixaGetCount(), pixaGetPix(), pixDestroy(), pixGetColormap(), and PROCNAME.

Referenced by pixaDisplayOnColor(), pixaDisplayOnLattice(), and pixaDisplayTiled().

l_int32 pixaGetDepthInfo ( PIXA pixa,
l_int32 pmaxdepth,
l_int32 psame 
)

pixaGetDepthInfo()

Input: pixa &maxdepth (<optional return>=""> max pixel depth of pix in pixa) &same (<optional return>=""> true if all depths are equal) Return: 0 if OK; 1 on error

Definition at line 1446 of file pixafunc1.c.

References ERROR_INT, FALSE, NULL, pixaGetCount(), pixaGetPixDimensions(), PROCNAME, and TRUE.

Referenced by pixaDisplayOnColor().

l_int32 pixaEqual ( PIXA pixa1,
PIXA pixa2,
l_int32  maxdist,
NUMA **  pnaindex,
l_int32 psame 
)

pixaEqual()

Input: pixa1 pixa2 maxdist &naindex (<optional return>=""> index array of correspondences &same (<return> 1 if equal; 0 otherwise) Return 0 if OK, 1 on error

Notes: (1) The two pixa are the "same" if they contain the same boxa and the same ordered set of pix. However, if they have boxa, the pix in each pixa can differ in ordering by an amount given by the parameter . If they don't have a boxa, the parameter is ignored, and the ordering must be identical. (2) This applies only to boxa geometry, pixels and ordering; other fields in the pix are ignored. (3) naindex[i] gives the position of the box in pixa2 that corresponds to box i in pixa1. It is only returned if the pixa have boxa and the boxa are equal. (4) In situations where the ordering is very different, so that a large is required for "equality", this should be implemented with a hash function for efficiency.

Definition at line 1507 of file pixafunc1.c.

References boxaDestroy(), boxaEqual(), ERROR_INT, L_CLONE, NULL, numaDestroy(), numaGetIValue(), pixaGetBoxa(), pixaGetCount(), pixaGetPix(), pixDestroy(), pixEqual(), and PROCNAME.

Referenced by PixaSortTest().


Variable Documentation

const l_int32 MIN_COMPS_FOR_BIN_SORT = 500 [static]

Definition at line 54 of file pixafunc1.c.

Referenced by pixaSort().

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines