Leptonica  1.82.0
Image processing and image analysis suite
pixafunc1.c File Reference
#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)
 
NUMApixaMakeSizeIndicator (PIXA *pixa, l_int32 width, l_int32 height, l_int32 type, l_int32 relation)
 
PIXpixSelectByPerimToAreaRatio (PIX *pixs, l_float32 thresh, l_int32 connectivity, l_int32 type, l_int32 *pchanged)
 
PIXApixaSelectByPerimToAreaRatio (PIXA *pixas, l_float32 thresh, l_int32 type, l_int32 *pchanged)
 
PIXpixSelectByPerimSizeRatio (PIX *pixs, l_float32 thresh, l_int32 connectivity, l_int32 type, l_int32 *pchanged)
 
PIXApixaSelectByPerimSizeRatio (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)
 
PIXpixSelectByArea (PIX *pixs, l_float32 thresh, l_int32 connectivity, l_int32 type, l_int32 *pchanged)
 
PIXApixaSelectByArea (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)
 
PIXApixaSelectByNumConnComp (PIXA *pixas, l_int32 nmin, l_int32 nmax, l_int32 connectivity, l_int32 *pchanged)
 
PIXApixaSelectWithIndicator (PIXA *pixas, NUMA *na, l_int32 *pchanged)
 
l_ok pixRemoveWithIndicator (PIX *pixs, PIXA *pixa, NUMA *na)
 
l_ok pixAddWithIndicator (PIX *pixs, PIXA *pixa, NUMA *na)
 
PIXApixaSelectWithString (PIXA *pixas, const char *str, l_int32 *perror)
 
PIXpixaRenderComponent (PIX *pixs, PIXA *pixa, l_int32 index)
 
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)
 
PIXApixaSelectRange (PIXA *pixas, l_int32 first, l_int32 last, l_int32 copyflag)
 
PIXAApixaaSelectRange (PIXAA *paas, l_int32 first, l_int32 last, l_int32 copyflag)
 
PIXAApixaaScaleToSize (PIXAA *paas, l_int32 wd, l_int32 hd)
 
PIXAApixaaScaleToSizeVar (PIXAA *paas, NUMA *nawd, NUMA *nahd)
 
PIXApixaScaleToSize (PIXA *pixas, l_int32 wd, l_int32 hd)
 
PIXApixaScaleToSizeRel (PIXA *pixas, l_int32 delw, l_int32 delh)
 
PIXApixaScale (PIXA *pixas, l_float32 scalex, l_float32 scaley)
 
PIXApixaScaleBySampling (PIXA *pixas, l_float32 scalex, l_float32 scaley)
 
PIXApixaRotate (PIXA *pixas, l_float32 angle, l_int32 type, l_int32 incolor, l_int32 width, l_int32 height)
 
PIXApixaRotateOrth (PIXA *pixas, l_int32 rotation)
 
PIXApixaTranslate (PIXA *pixas, l_int32 hshift, l_int32 vshift, l_int32 incolor)
 
PIXApixaAddBorderGeneral (PIXA *pixad, PIXA *pixas, l_int32 left, l_int32 right, l_int32 top, l_int32 bot, l_uint32 val)
 
PIXApixaaFlattenToPixa (PIXAA *paa, NUMA **pnaindex, l_int32 copyflag)
 
l_ok pixaaSizeRange (PIXAA *paa, l_int32 *pminw, l_int32 *pminh, l_int32 *pmaxw, l_int32 *pmaxh)
 
l_ok pixaSizeRange (PIXA *pixa, l_int32 *pminw, l_int32 *pminh, l_int32 *pmaxw, l_int32 *pmaxh)
 
PIXApixaClipToPix (PIXA *pixas, PIX *pixs)
 
l_ok pixaClipToForeground (PIXA *pixas, PIXA **ppixad, BOXA **pboxa)
 
l_ok pixaGetRenderingDepth (PIXA *pixa, l_int32 *pdepth)
 
l_ok pixaHasColor (PIXA *pixa, l_int32 *phascolor)
 
l_ok pixaAnyColormaps (PIXA *pixa, l_int32 *phascmap)
 
l_ok pixaGetDepthInfo (PIXA *pixa, l_int32 *pmaxdepth, l_int32 *psame)
 
PIXApixaConvertToSameDepth (PIXA *pixas)
 
PIXApixaConvertToGivenDepth (PIXA *pixas, l_int32 depth)
 
l_ok pixaEqual (PIXA *pixa1, PIXA *pixa2, l_int32 maxdist, NUMA **pnaindex, l_int32 *psame)
 
l_ok pixaSetFullSizeBoxa (PIXA *pixa)
 

Variables

static const l_int32 MinCompsForBinSort = 200
 
static const l_float32 MinAngleToRotate = 0.001
 

Detailed Description

     Filters
          PIX      *pixSelectBySize()
          PIXA     *pixaSelectBySize()
          NUMA     *pixaMakeSizeIndicator()
          PIX      *pixSelectByPerimToAreaRatio()
          PIXA     *pixaSelectByPerimToAreaRatio()
          PIX      *pixSelectByPerimSizeRatio()
          PIXA     *pixaSelectByPerimSizeRatio()
          PIX      *pixSelectByAreaFraction()
          PIXA     *pixaSelectByAreaFraction()
          PIX      *pixSelectByArea()
          PIXA     *pixaSelectByArea()
          PIX      *pixSelectByWidthHeightRatio()
          PIXA     *pixaSelectByWidthHeightRatio()
          PIXA     *pixaSelectByNumConnComp()
          PIXA     *pixaSelectWithIndicator()
          l_int32   pixRemoveWithIndicator()
          l_int32   pixAddWithIndicator()
          PIXA     *pixaSelectWithString()
          PIX      *pixaRenderComponent()
     Sort functions
          PIXA     *pixaSort()
          PIXA     *pixaBinSort()
          PIXA     *pixaSortByIndex()
          PIXAA    *pixaSort2dByIndex()
     Pixa and Pixaa range selection
          PIXA     *pixaSelectRange()
          PIXAA    *pixaaSelectRange()
     Pixa and Pixaa scaling
          PIXAA    *pixaaScaleToSize()
          PIXAA    *pixaaScaleToSizeVar()
          PIXA     *pixaScaleToSize()
          PIXA     *pixaScaleToSizeRel()
          PIXA     *pixaScale()
          PIXA     *pixaScaleBySampling()
     Pixa rotation and translation
          PIXA     *pixaRotate()
          PIXA     *pixaRotateOrth()
          PIXA     *pixaTranslate()
     Miscellaneous
          PIXA     *pixaAddBorderGeneral()
          PIXA     *pixaaFlattenToPixa()
          l_int32   pixaaSizeRange()
          l_int32   pixaSizeRange()
          PIXA     *pixaClipToPix()
          PIXA     *pixaClipToForeground()
          l_int32   pixaGetRenderingDepth()
          l_int32   pixaHasColor()
          l_int32   pixaAnyColormaps()
          l_int32   pixaGetDepthInfo()
          PIXA     *pixaConvertToSameDepth()
          PIXA     *pixaConvertToGivenDepth()
          l_int32   pixaEqual()
          l_int32   pixaSetFullSizeBoxa()

Definition in file pixafunc1.c.

Function Documentation

◆ pixaAddBorderGeneral()

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

pixaAddBorderGeneral()

Parameters
[in]pixadcan be null or equal to pixas
[in]pixascontaining pix of all depths; colormap ok
[in]left,right,top,botnumber of pixels added
[in]valvalue of added border pixels
Returns
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 pixad = pixas.  To make a new pixa, use pixad = NULL.
     (3) In both cases, the boxa has sides adjusted as if it were
         expanded by the border.

Definition at line 2411 of file pixafunc1.c.

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

◆ pixaaFlattenToPixa()

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

pixaaFlattenToPixa()

Parameters
[in]paa
[out]pnaindex[optional] the pixa index in the pixaa
[in]copyflagL_COPY or L_CLONE
Returns
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 2482 of file pixafunc1.c.

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

Referenced by pixGetWordsInTextlines(), recogDebugAverages(), and recogExtractPixa().

◆ pixaAnyColormaps()

l_ok pixaAnyColormaps ( PIXA pixa,
l_int32 *  phascmap 
)

pixaAnyColormaps()

Parameters
[in]pixa
[out]phascmap1 if any pix has a colormap; 0 otherwise
Returns
0 if OK; 1 on error

Definition at line 2845 of file pixafunc1.c.

References L_CLONE, pixaGetCount(), and pixaGetPix().

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

◆ pixaaScaleToSize()

PIXAA* pixaaScaleToSize ( PIXAA paas,
l_int32  wd,
l_int32  hd 
)

pixaaScaleToSize()

Parameters
[in]paas
[in]wdtarget width; use 0 if using height as target
[in]hdtarget height; use 0 if using width as target
Returns
paad, or NULL on error
Notes:
     (1) This guarantees that each output scaled image has the
         dimension(s) you specify.
          ~ To specify the width with isotropic scaling, set hd = 0.
          ~ To specify the height with isotropic scaling, set wd = 0.
          ~ If both wd and hd are specified, the image is scaled
            (in general, anisotropically) to that size.
          ~ It is an error to set both wd and hd to 0.

Definition at line 1925 of file pixafunc1.c.

References L_CLONE, L_INSERT, pixaaAddPixa(), pixaaCreate(), pixaaGetCount(), pixaaGetPixa(), pixaDestroy(), and pixaScaleToSize().

◆ pixaaScaleToSizeVar()

PIXAA* pixaaScaleToSizeVar ( PIXAA paas,
NUMA nawd,
NUMA nahd 
)

pixaaScaleToSizeVar()

Parameters
[in]paas
[in]nawd[optional] target widths; use NULL if using height
[in]nahd[optional] target height; use NULL if using width
Returns
paad, or NULL on error
Notes:
     (1) This guarantees that the scaled images in each pixa have the
         dimension(s) you specify in the numas.
          ~ To specify the width with isotropic scaling, set nahd = NULL.
          ~ To specify the height with isotropic scaling, set nawd = NULL.
          ~ If both nawd and nahd are specified, the image is scaled
            (in general, anisotropically) to that size.
          ~ It is an error to set both nawd and nahd to NULL.
     (2) If either nawd and/or nahd is defined, it must have the same
         count as the number of pixa in paas.

Definition at line 1974 of file pixafunc1.c.

References L_CLONE, L_INSERT, numaGetCount(), numaGetIValue(), pixaaAddPixa(), pixaaCreate(), pixaaGetCount(), pixaaGetPixa(), pixaDestroy(), and pixaScaleToSize().

◆ pixaaSelectRange()

PIXAA* pixaaSelectRange ( PIXAA paas,
l_int32  first,
l_int32  last,
l_int32  copyflag 
)

pixaaSelectRange()

Parameters
[in]paas
[in]firstuse 0 to select from the beginning
[in]lastuse -1 to select to the end
[in]copyflagL_COPY, L_CLONE
Returns
paad, or NULL on error
Notes:
     (1) The copyflag specifies what we do with each pixa from paas.
         Specifically, L_CLONE inserts a clone into paad of each
         selected pixa from paas.

Definition at line 1864 of file pixafunc1.c.

References L_CLONE, L_COPY, L_INSERT, pixaaAddPixa(), pixaaCreate(), pixaaGetCount(), and pixaaGetPixa().

◆ pixaaSizeRange()

l_ok pixaaSizeRange ( PIXAA paa,
l_int32 *  pminw,
l_int32 *  pminh,
l_int32 *  pmaxw,
l_int32 *  pmaxh 
)

pixaaSizeRange()

Parameters
[in]paa
[out]pminw,pminh,pmaxw,pmaxh[optional] range of dimensions of all boxes
Returns
0 if OK, 1 on error

Definition at line 2537 of file pixafunc1.c.

References L_CLONE, pixaaGetCount(), pixaaGetPixa(), pixaDestroy(), and pixaSizeRange().

◆ pixaBinSort()

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

pixaBinSort()

Parameters
[in]pixas
[in]sorttypeL_SORT_BY_X, L_SORT_BY_Y, L_SORT_BY_WIDTH, L_SORT_BY_HEIGHT, L_SORT_BY_PERIMETER
[in]sortorderL_SORT_INCREASING, L_SORT_DECREASING
[out]pnaindex[optional] index of sorted order into original array
[in]copyflagL_COPY, L_CLONE
Returns
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 1615 of file pixafunc1.c.

References Pixa::boxa, boxaGetBoxGeometry(), boxaGetCount(), 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, numaAddNumber(), numaCreate(), numaDestroy(), numaGetBinSortIndex(), pixaGetCount(), and pixaSortByIndex().

◆ pixaClipToForeground()

l_ok pixaClipToForeground ( PIXA pixas,
PIXA **  ppixad,
BOXA **  pboxa 
)

pixaClipToForeground()

Parameters
[in]pixas
[out]ppixad[optional] pixa of clipped pix returned
[out]pboxa[optional] clipping boxes returned
Returns
0 if OK, 1 on error
Notes:
     (1) At least one of [&pixd, &boxa] must be specified.
     (2) Any pix with no fg pixels is skipped.
     (3) See pixClipToForeground().

Definition at line 2710 of file pixafunc1.c.

References boxaAddBox(), boxaCreate(), boxDestroy(), L_CLONE, L_INSERT, pixaAddPix(), pixaCreate(), pixaGetCount(), pixaGetPix(), pixClipToForeground(), and pixDestroy().

◆ pixaClipToPix()

PIXA* pixaClipToPix ( PIXA pixas,
PIX pixs 
)

pixaClipToPix()

Parameters
[in]pixas
[in]pixs
Returns
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 2661 of file pixafunc1.c.

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

◆ pixaConvertToGivenDepth()

PIXA* pixaConvertToGivenDepth ( PIXA pixas,
l_int32  depth 
)

pixaConvertToGivenDepth()

Parameters
[in]pixas
[in]depthspecify either 8 or 32 bpp
Returns
pixad, or NULL on error
Notes:
     (1) Use this to remove any colormaps and convert all pix to either
         8 or 32 bpp.
     (2) To convert losslessly, get depth from pixaGetRenderingDepth().
     (3) Clone pix may be in the returned pixa if conversion is to 32 bpp.

Definition at line 3009 of file pixafunc1.c.

References L_CLONE, pixaCreate(), pixaGetCount(), pixaGetPix(), and pixaGetRenderingDepth().

◆ pixaConvertToSameDepth()

PIXA* pixaConvertToSameDepth ( PIXA pixas)

pixaConvertToSameDepth()

Parameters
[in]pixas
Returns
pixad, or NULL on error
Notes:
     (1) Any pix with 16 bpp will be converted to 8 bpp.
         If all pix have bpp = 1, the output depth will be 1.
         If any pix has color (either rgb or a colormap with color),
         the output depth will be 32.
         Otherwise, the output depth is the maximum of 8 and the
         the max depth of all the pix.
     (2) This can be used to allow lossless rendering onto
         a single pix. (Except: 16 bpp gets converted to 8.)

Definition at line 2937 of file pixafunc1.c.

References L_CLONE, L_COPY, L_INSERT, pixaAddPix(), pixaAnyColormaps(), pixaCopy(), pixaCreate(), pixaDestroy(), pixaGetBoxa(), pixaGetCount(), pixaGetDepthInfo(), pixaGetPix(), pixaGetRenderingDepth(), pixaSetBoxa(), pixConvertTo32(), pixConvertTo8(), and pixDestroy().

Referenced by pixaDisplayTiledInColumns().

◆ pixAddWithIndicator()

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

pixAddWithIndicator()

Parameters
[in]pixs1 bpp pix from which components are added; in-place
[in]pixaof connected components, some of which will be put into pixs
[in]nanuma indicator: add components corresponding to 1s
Returns
0 if OK, 1 on error
Notes:
     (1) This complements pixRemoveWithIndicator().   Here, the selected
         components are added to pixs.

Definition at line 1281 of file pixafunc1.c.

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

◆ pixaEqual()

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

pixaEqual()

Parameters
[in]pixa1
[in]pixa2
[in]maxdist
[out]pnaindex[optional] index array of correspondences
[out]psame1 if equal; 0 otherwise
Returns
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 maxdist.  If they
         don't have a boxa, the maxdist parameter is ignored,
         and the ordering of the pix 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 maxdist is required for "equality", this should be
         implemented with a hash function for efficiency.

Definition at line 3082 of file pixafunc1.c.

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

◆ pixaGetDepthInfo()

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

pixaGetDepthInfo()

Parameters
[in]pixa
[out]pmaxdepth[optional] max pixel depth of pix in pixa
[out]psame[optional] true if all depths are equal
Returns
0 if OK; 1 on error

Definition at line 2884 of file pixafunc1.c.

References pixaGetCount(), and pixaGetPixDimensions().

Referenced by pixaConvertToSameDepth(), pixaDisplayTiled(), pixaDisplayTiledInColumns(), and pixaGetRenderingDepth().

◆ pixaGetRenderingDepth()

l_ok pixaGetRenderingDepth ( PIXA pixa,
l_int32 *  pdepth 
)

pixaGetRenderingDepth()

Parameters
[in]pixa
[out]pdepthdepth required to render if all colormaps are removed
Returns
0 if OK; 1 on error
Notes:
     (1) Any pix with 16 bpp will be considered as having 8 bpp.
         If all pix have bpp = 1, this returns 1.
         If any pix has color (either rgb or a colormap with color),
         this return 32.
         Otherwise, this returns the maximum of 8 and the max depth
         of all the pix.
     (2) This can be used to allow lossless rendering onto a single pix.

Definition at line 2767 of file pixafunc1.c.

References pixaGetDepthInfo(), and pixaHasColor().

Referenced by convertToNUpFiles(), pixaConvertToGivenDepth(), pixaConvertToNUpPixa(), pixaConvertToSameDepth(), and pixaDisplayPairTiledInColumns().

◆ pixaHasColor()

l_ok pixaHasColor ( PIXA pixa,
l_int32 *  phascolor 
)

pixaHasColor()

Parameters
[in]pixa
[out]phascolor1 if any pix is rgb or has a colormap with color; 0 otherwise
Returns
0 if OK; 1 on error

Definition at line 2804 of file pixafunc1.c.

References L_CLONE, pixaGetCount(), and pixaGetPix().

Referenced by pixaGetRenderingDepth().

◆ pixaMakeSizeIndicator()

NUMA* pixaMakeSizeIndicator ( PIXA pixa,
l_int32  width,
l_int32  height,
l_int32  type,
l_int32  relation 
)

pixaMakeSizeIndicator()

Parameters
[in]pixa
[in]width,heightthreshold dimensions
[in]typeL_SELECT_WIDTH, L_SELECT_HEIGHT, L_SELECT_IF_EITHER, L_SELECT_IF_BOTH
[in]relationL_SELECT_IF_LT, L_SELECT_IF_GT, L_SELECT_IF_LTE, L_SELECT_IF_GTE
Returns
na indicator array, or NULL on error
Notes:
     (1) The args specify constraints on the size of the
         components that are kept.
     (2) If the selection type is L_SELECT_WIDTH, the input
         height is ignored, and v.v.
     (3) 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 362 of file pixafunc1.c.

References 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, numaAddNumber(), numaCreate(), pixaGetCount(), and pixaGetPixDimensions().

Referenced by pixaSelectBySize().

◆ pixaRenderComponent()

PIX* pixaRenderComponent ( PIX pixs,
PIXA pixa,
l_int32  index 
)

pixaRenderComponent()

Parameters
[in]pixs[optional] 1 bpp pix
[in]pixaof 1 bpp connected components, one of which will be rendered in pixs, with its origin determined by the associated box.
[in]indexof component to be rendered
Returns
pixd, or NULL on error
Notes:
     (1) If pixs is null, this generates an empty pix of a size determined
         by union of the component bounding boxes, and including the origin.
     (2) The selected component is blitted into pixs.

Definition at line 1405 of file pixafunc1.c.

References pixaGetCount().

◆ pixaRotate()

PIXA* pixaRotate ( PIXA pixas,
l_float32  angle,
l_int32  type,
l_int32  incolor,
l_int32  width,
l_int32  height 
)

pixaRotate()

Parameters
[in]pixas1, 2, 4, 8, 32 bpp rgb
[in]anglerotation angle in radians; clockwise is positive
[in]typeL_ROTATE_AREA_MAP, L_ROTATE_SHEAR, L_ROTATE_SAMPLING
[in]incolorL_BRING_IN_WHITE, L_BRING_IN_BLACK
[in]widthoriginal width; use 0 to avoid embedding
[in]heightoriginal height; use 0 to avoid embedding
Returns
pixad, or NULL on error
Notes:
     (1) Each pix is rotated about its center.  See pixRotate() for details.
     (2) The boxa array is copied.  Why is it not rotated?
         If a boxa exists, the array of boxes is in 1-to-1
         correspondence with the array of pix, and each box typically
         represents the location of the pix relative to an image from
         which it has been extracted.  Like the pix, we could rotate
         each box around its center, and then generate a box that
         contains all four corners, as is done in boxaRotate(), but
         this seems unnecessary.

Definition at line 2227 of file pixafunc1.c.

References L_BRING_IN_BLACK, L_BRING_IN_WHITE, L_ROTATE_AREA_MAP, L_ROTATE_SAMPLING, and L_ROTATE_SHEAR.

◆ pixaRotateOrth()

PIXA* pixaRotateOrth ( PIXA pixas,
l_int32  rotation 
)

pixaRotateOrth()

Parameters
[in]pixas
[in]rotation0 = noop, 1 = 90 deg, 2 = 180 deg, 3 = 270 deg; all rotations are clockwise
Returns
pixad, or NULL on error
Notes:
     (1) Rotates each pix in the pixa.  Rotates and saves the boxes in
         the boxa if the boxa is full.

Definition at line 2285 of file pixafunc1.c.

References boxDestroy(), boxRotateOrth(), L_CLONE, L_COPY, L_INSERT, pixaAddBox(), pixaAddPix(), pixaCopy(), pixaCreate(), pixaDestroy(), pixaGetBox(), pixaGetBoxaCount(), pixaGetCount(), pixaGetPix(), pixDestroy(), pixGetDimensions(), and pixRotateOrth().

◆ pixaScale()

PIXA* pixaScale ( PIXA pixas,
l_float32  scalex,
l_float32  scaley 
)

pixaScale()

Parameters
[in]pixas
[in]scalex
[in]scaley
Returns
pixad, or NULL on error
Notes:
     (1) If pixas has a full boxes, it is scaled as well.

Definition at line 2111 of file pixafunc1.c.

References L_CLONE, pixaCreate(), pixaGetCount(), pixaGetPix(), and pixScale().

◆ pixaScaleBySampling()

PIXA* pixaScaleBySampling ( PIXA pixas,
l_float32  scalex,
l_float32  scaley 
)

pixaScaleBySampling()

Parameters
[in]pixas
[in]scalex
[in]scaley
Returns
pixad, or NULL on error
Notes:
     (1) If pixas has a full boxes, it is scaled as well.

Definition at line 2162 of file pixafunc1.c.

References L_CLONE, pixaCreate(), pixaGetCount(), pixaGetPix(), and pixScaleBySampling().

◆ pixaScaleToSize()

PIXA* pixaScaleToSize ( PIXA pixas,
l_int32  wd,
l_int32  hd 
)

pixaScaleToSize()

Parameters
[in]pixas
[in]wdtarget width; use 0 if using height as target
[in]hdtarget height; use 0 if using width as target
Returns
pixad, or NULL on error
Notes:
     (1) See pixaaScaleToSize()

Definition at line 2022 of file pixafunc1.c.

References L_CLONE, pixaCopy(), pixaCreate(), pixaGetCount(), pixaGetPix(), and pixScaleToSize().

Referenced by pixaaScaleToSize(), and pixaaScaleToSizeVar().

◆ pixaScaleToSizeRel()

PIXA* pixaScaleToSizeRel ( PIXA pixas,
l_int32  delw,
l_int32  delh 
)

pixaScaleToSizeRel()

Parameters
[in]pixas
[in]delwchange in width, in pixels; 0 means no change
[in]delhchange in height, in pixels; 0 means no change return pixad, or NULL on error
Notes:
     (1) If a requested change in a pix is not possible because
         either the requested width or height is <= 0, issue a
         warning and return a copy.

Definition at line 2067 of file pixafunc1.c.

References L_CLONE, L_COPY, L_INSERT, pixaAddPix(), pixaCreate(), pixaGetCount(), pixaGetPix(), pixDestroy(), and pixScaleToSizeRel().

◆ pixaSelectByArea()

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

pixaSelectByArea()

Parameters
[in]pixas
[in]threshthreshold number of fg pixels
[in]typeL_SELECT_IF_LT, L_SELECT_IF_GT, L_SELECT_IF_LTE, L_SELECT_IF_GTE
[out]pchanged[optional] 1 if changed; 0 if clone returned
Returns
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 number of fg pixels
         in the component.
     (4) Use L_SELECT_IF_LT or L_SELECT_IF_LTE to save components
         with less than the threshold number of fg pixels, and
         L_SELECT_IF_GT or L_SELECT_IF_GTE to remove them.

Definition at line 926 of file pixafunc1.c.

References L_SELECT_IF_GT, L_SELECT_IF_GTE, L_SELECT_IF_LT, L_SELECT_IF_LTE, numaDestroy(), numaMakeThresholdIndicator(), pixaCountPixels(), and pixaSelectWithIndicator().

Referenced by pixSelectByArea().

◆ pixaSelectByAreaFraction()

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

pixaSelectByAreaFraction()

Parameters
[in]pixas
[in]threshthreshold ratio of fg pixels to (w * h)
[in]typeL_SELECT_IF_LT, L_SELECT_IF_GT, L_SELECT_IF_LTE, L_SELECT_IF_GTE
[out]pchanged[optional] 1 if changed; 0 if clone returned
Returns
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 792 of file pixafunc1.c.

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

Referenced by pixSelectByAreaFraction().

◆ pixaSelectByNumConnComp()

PIXA* pixaSelectByNumConnComp ( PIXA pixas,
l_int32  nmin,
l_int32  nmax,
l_int32  connectivity,
l_int32 *  pchanged 
)

pixaSelectByNumConnComp()

Parameters
[in]pixas
[in]nminminimum number of components
[in]nmaxmaximum number of components
[in]connectivity4 or 8
[out]pchanged[optional] 1 if changed; 0 if clone returned
Returns
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 by the number of connected components in
         a given range.

Definition at line 1109 of file pixafunc1.c.

References L_CLONE, numaAddNumber(), numaCreate(), numaDestroy(), pixaGetCount(), pixaGetPix(), pixaSelectWithIndicator(), pixCountConnComp(), and pixDestroy().

◆ pixaSelectByPerimSizeRatio()

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

pixaSelectByPerimSizeRatio()

Parameters
[in]pixas
[in]threshthreshold ratio of fg boundary to b.b. circumference
[in]typeL_SELECT_IF_LT, L_SELECT_IF_GT, L_SELECT_IF_LTE, L_SELECT_IF_GTE
[out]pchanged[optional] 1 if changed; 0 if clone returned
Returns
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) See pixSelectByPerimSizeRatio().

Definition at line 658 of file pixafunc1.c.

References L_SELECT_IF_GT, L_SELECT_IF_GTE, L_SELECT_IF_LT, L_SELECT_IF_LTE, numaDestroy(), numaMakeThresholdIndicator(), pixaFindPerimSizeRatio(), and pixaSelectWithIndicator().

Referenced by pixSelectByPerimSizeRatio().

◆ pixaSelectByPerimToAreaRatio()

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

pixaSelectByPerimToAreaRatio()

Parameters
[in]pixas
[in]threshthreshold ratio of fg boundary to fg pixels
[in]typeL_SELECT_IF_LT, L_SELECT_IF_GT, L_SELECT_IF_LTE, L_SELECT_IF_GTE
[out]pchanged[optional] 1 if changed; 0 if clone returned
Returns
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) See pixSelectByPerimToAreaRatio().

Definition at line 527 of file pixafunc1.c.

References L_SELECT_IF_GT, L_SELECT_IF_GTE, L_SELECT_IF_LT, L_SELECT_IF_LTE, numaDestroy(), numaMakeThresholdIndicator(), pixaFindPerimToAreaRatio(), and pixaSelectWithIndicator().

Referenced by pixSelectByPerimToAreaRatio().

◆ pixaSelectBySize()

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

pixaSelectBySize()

Parameters
[in]pixas
[in]width,heightthreshold dimensions
[in]typeL_SELECT_WIDTH, L_SELECT_HEIGHT, L_SELECT_IF_EITHER, L_SELECT_IF_BOTH
[in]relationL_SELECT_IF_LT, L_SELECT_IF_GT, L_SELECT_IF_LTE, L_SELECT_IF_GTE
[out]pchanged[optional] 1 if changed; 0 otherwise
Returns
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 306 of file pixafunc1.c.

References 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, numaDestroy(), pixaMakeSizeIndicator(), and pixaSelectWithIndicator().

Referenced by pixaDisplayMultiTiled(), and pixSelectBySize().

◆ pixaSelectByWidthHeightRatio()

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

pixaSelectByWidthHeightRatio()

Parameters
[in]pixas
[in]threshthreshold ratio of width/height
[in]typeL_SELECT_IF_LT, L_SELECT_IF_GT, L_SELECT_IF_LTE, L_SELECT_IF_GTE
[out]pchanged[optional] 1 if changed; 0 if clone returned
Returns
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 1059 of file pixafunc1.c.

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

Referenced by pixSelectByWidthHeightRatio().

◆ pixaSelectRange()

PIXA* pixaSelectRange ( PIXA pixas,
l_int32  first,
l_int32  last,
l_int32  copyflag 
)

pixaSelectRange()

Parameters
[in]pixas
[in]firstuse 0 to select from the beginning
[in]lastuse -1 to select to the end
[in]copyflagL_COPY, L_CLONE
Returns
pixad, or NULL on error
Notes:
     (1) The copyflag specifies what we do with each pix from pixas.
         Specifically, L_CLONE inserts a clone into pixad of each
         selected pix from pixas.

Definition at line 1809 of file pixafunc1.c.

References L_CLONE, L_COPY, L_INSERT, pixaAddPix(), pixaCreate(), pixaGetCount(), and pixaGetPix().

Referenced by pixaSelectToPdf(), and recogFilterPixaBySize().

◆ pixaSelectWithIndicator()

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

pixaSelectWithIndicator()

Parameters
[in]pixas
[in]naindicator numa
[out]pchanged[optional] 1 if changed; 0 if clone returned
Returns
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).
     (4) If the source boxa is not fully populated, it is left
         empty in the dest pixa.

Definition at line 1168 of file pixafunc1.c.

References L_CLONE, L_INSERT, numaGetCount(), numaGetIValue(), pixaAddBox(), pixaAddPix(), pixaCopy(), pixaCreate(), pixaGetBox(), pixaGetBoxaCount(), and pixaGetPix().

Referenced by pixaSelectByArea(), pixaSelectByAreaFraction(), pixaSelectByNumConnComp(), pixaSelectByPerimSizeRatio(), pixaSelectByPerimToAreaRatio(), pixaSelectBySize(), and pixaSelectByWidthHeightRatio().

◆ pixaSelectWithString()

PIXA* pixaSelectWithString ( PIXA pixas,
const char *  str,
l_int32 *  perror 
)

pixaSelectWithString()

Parameters
[in]pixas
[in]strstring of indices into pixa, giving the pix to be selected
[out]perror[optional] 1 if any indices are invalid; 0 if all indices are valid
Returns
pixad, or NULL on error
Notes:
     (1) Returns a pixa with copies of selected pix.
     (2) Associated boxes are also copied, if fully populated.

Definition at line 1334 of file pixafunc1.c.

References L_COPY, L_INSERT, numaCreateFromString(), numaDestroy(), numaGetCount(), numaGetIValue(), numaGetMax(), pixaAddBox(), pixaAddPix(), pixaCreate(), pixaGetBox(), pixaGetBoxaCount(), pixaGetCount(), and pixaGetPix().

◆ pixaSetFullSizeBoxa()

l_ok pixaSetFullSizeBoxa ( PIXA pixa)

pixaSetFullSizeBoxa()

Parameters
[in]pixa
Returns
0 if OK, 1 on error
Notes:
     (1) Replaces the existing boxa.  Each box gives the dimensions
         of the corresponding pix.  This is needed for functions
         like pixaSort() that sort based on the boxes.

Definition at line 3166 of file pixafunc1.c.

References boxaAddBox(), boxaCreate(), boxCreate(), L_CLONE, L_INSERT, pixaGetCount(), pixaGetPix(), pixaSetBoxa(), pixDestroy(), and pixGetDimensions().

Referenced by pixaSort().

◆ pixaSizeRange()

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

pixaSizeRange()

Parameters
[in]pixa
[out]pminw,pminh,pmaxw,pmaxh[optional] range of dimensions of pix in the array
Returns
0 if OK, 1 on error

Definition at line 2591 of file pixafunc1.c.

References L_CLONE, pixaGetCount(), and pixaGetPix().

Referenced by pixaAccumulateSamples(), pixaaSizeRange(), pixaDisplayTiled(), pixaDisplayTiledWithText(), and recogAverageSamples().

◆ pixaSort()

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

pixaSort()

Parameters
[in]pixas
[in]sorttypeL_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
[in]sortorderL_SORT_INCREASING, L_SORT_DECREASING
[out]pnaindex[optional] index of sorted order into original array
[in]copyflagL_COPY, L_CLONE
Returns
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) If the boxa is empty, it makes one corresponding to the
         dimensions of each pix, which allows meaningful sorting on
         all types except x and y.
     (3) 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 1475 of file pixafunc1.c.

References Pixa::boxa, boxaGetCount(), L_CLONE, L_COPY, 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, pixaCopy(), pixaGetCount(), and pixaSetFullSizeBoxa().

Referenced by recogFilterPixaBySize().

◆ pixaSort2dByIndex()

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

pixaSort2dByIndex()

Parameters
[in]pixas
[in]naanumaa that maps from the new pixaa to the input pixas
[in]copyflagL_CLONE or L_COPY
Returns
paa sorted, or NULL on error

Definition at line 1744 of file pixafunc1.c.

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

Referenced by pixGetWordsInTextlines().

◆ pixaSortByIndex()

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

pixaSortByIndex()

Parameters
[in]pixas
[in]naindexna that maps from the new pixa to the input pixa
[in]copyflagL_COPY, L_CLONE
Returns
pixad sorted, or NULL on error

Definition at line 1703 of file pixafunc1.c.

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

Referenced by pixaBinSort().

◆ pixaTranslate()

PIXA* pixaTranslate ( PIXA pixas,
l_int32  hshift,
l_int32  vshift,
l_int32  incolor 
)

pixaTranslate()

Parameters
[in]pixas
[in]hshifthorizontal shift; hshift > 0 is to right
[in]vshiftvertical shift; vshift > 0 is down
[in]incolorL_BRING_IN_WHITE, L_BRING_IN_BLACK
Returns
pixad, or NULL on error.

Definition at line 2337 of file pixafunc1.c.

References boxaDestroy(), boxaTransform(), L_CLONE, L_COPY, L_INSERT, pixaAddPix(), pixaCopy(), pixaCreate(), pixaDestroy(), pixaGetBoxa(), pixaGetBoxaCount(), pixaGetCount(), pixaGetPix(), pixaSetBoxa(), pixDestroy(), and pixTranslate().

◆ pixRemoveWithIndicator()

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

pixRemoveWithIndicator()

Parameters
[in]pixs1 bpp pix from which components are removed; in-place
[in]pixaof connected components in pixs
[in]nanuma indicator: remove components corresponding to 1s
Returns
0 if OK, 1 on error
Notes:
     (1) This complements pixAddWithIndicator().   Here, the selected
         components are set subtracted from pixs.

Definition at line 1228 of file pixafunc1.c.

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

◆ pixSelectByArea()

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

pixSelectByArea()

Parameters
[in]pixs1 bpp
[in]threshthreshold number of FG pixels
[in]connectivity4 or 8
[in]typeL_SELECT_IF_LT, L_SELECT_IF_GT, L_SELECT_IF_LTE, L_SELECT_IF_GTE
[out]pchanged[optional] 1 if changed; 0 if clone returned
Returns
pixd, or NULL on error
Notes:
     (1) The args specify constraints on the number of foreground
         pixels in 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 number of fg pixels
         in each component.
     (4) Use L_SELECT_IF_LT or L_SELECT_IF_LTE to save components
         with less than the threshold number of fg pixels, and
         L_SELECT_IF_GT or L_SELECT_IF_GTE to remove them.

Definition at line 848 of file pixafunc1.c.

References boxaDestroy(), L_SELECT_IF_GT, L_SELECT_IF_GTE, L_SELECT_IF_LT, L_SELECT_IF_LTE, pixaDestroy(), pixaDisplay(), pixaGetCount(), pixaSelectByArea(), pixConnComp(), pixCopy(), pixCreateTemplate(), pixGetDimensions(), and pixZero().

◆ pixSelectByAreaFraction()

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

pixSelectByAreaFraction()

Parameters
[in]pixs1 bpp
[in]threshthreshold ratio of fg pixels to (w * h)
[in]connectivity4 or 8
[in]typeL_SELECT_IF_LT, L_SELECT_IF_GT, L_SELECT_IF_LTE, L_SELECT_IF_GTE
[out]pchanged[optional] 1 if changed; 0 if clone returned
Returns
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 714 of file pixafunc1.c.

References boxaDestroy(), L_SELECT_IF_GT, L_SELECT_IF_GTE, L_SELECT_IF_LT, L_SELECT_IF_LTE, pixaDestroy(), pixaDisplay(), pixaGetCount(), pixaSelectByAreaFraction(), pixConnComp(), pixCopy(), pixCreateTemplate(), pixGetDimensions(), and pixZero().

◆ pixSelectByPerimSizeRatio()

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

pixSelectByPerimSizeRatio()

Parameters
[in]pixs1 bpp
[in]threshthreshold ratio of fg boundary to fg pixels
[in]connectivity4 or 8
[in]typeL_SELECT_IF_LT, L_SELECT_IF_GT, L_SELECT_IF_LTE, L_SELECT_IF_GTE
[out]pchanged[optional] 1 if changed; 0 if clone returned
Returns
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 components with smooth vs. dendritic shape, using
         the ratio of the fg boundary pixels to the circumference of
         the bounding box, and comparing it to a threshold value.
     (4) Use L_SELECT_IF_LT or L_SELECT_IF_LTE to save the smooth
         boundary components, and L_SELECT_IF_GT or L_SELECT_IF_GTE
         to remove them.

Definition at line 584 of file pixafunc1.c.

References boxaDestroy(), L_SELECT_IF_GT, L_SELECT_IF_GTE, L_SELECT_IF_LT, L_SELECT_IF_LTE, pixaDestroy(), pixaDisplay(), pixaGetCount(), pixaSelectByPerimSizeRatio(), pixConnComp(), pixCopy(), pixCreateTemplate(), pixGetDimensions(), and pixZero().

◆ pixSelectByPerimToAreaRatio()

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

pixSelectByPerimToAreaRatio()

Parameters
[in]pixs1 bpp
[in]threshthreshold ratio of fg boundary to fg pixels
[in]connectivity4 or 8
[in]typeL_SELECT_IF_LT, L_SELECT_IF_GT, L_SELECT_IF_LTE, L_SELECT_IF_GTE
[out]pchanged[optional] 1 if changed; 0 if clone returned
Returns
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 "thick" components, where a thick component
         is defined to have a ratio of boundary to interior pixels
         that is smaller than a given threshold value.
     (4) Use L_SELECT_IF_LT or L_SELECT_IF_LTE to save the thicker
         components, and L_SELECT_IF_GT or L_SELECT_IF_GTE to remove them.

Definition at line 453 of file pixafunc1.c.

References boxaDestroy(), L_SELECT_IF_GT, L_SELECT_IF_GTE, L_SELECT_IF_LT, L_SELECT_IF_LTE, pixaDestroy(), pixaDisplay(), pixaGetCount(), pixaSelectByPerimToAreaRatio(), pixConnComp(), pixCopy(), pixCreateTemplate(), pixGetDimensions(), and pixZero().

◆ pixSelectBySize()

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

pixSelectBySize()

Parameters
[in]pixs1 bpp
[in]width,heightthreshold dimensions
[in]connectivity4 or 8
[in]typeL_SELECT_WIDTH, L_SELECT_HEIGHT, L_SELECT_IF_EITHER, L_SELECT_IF_BOTH
[in]relationL_SELECT_IF_LT, L_SELECT_IF_GT, L_SELECT_IF_LTE, L_SELECT_IF_GTE
[out]pchanged[optional] 1 if changed; 0 otherwise
Returns
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 219 of file pixafunc1.c.

References boxaDestroy(), 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, pixaDestroy(), pixaDisplay(), pixaGetCount(), pixaSelectBySize(), pixConnComp(), pixCopy(), pixCreateTemplate(), pixGetDimensions(), and pixZero().

Referenced by pixDecideIfTable().

◆ pixSelectByWidthHeightRatio()

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

pixSelectByWidthHeightRatio()

Parameters
[in]pixs1 bpp
[in]threshthreshold ratio of width/height
[in]connectivity4 or 8
[in]typeL_SELECT_IF_LT, L_SELECT_IF_GT, L_SELECT_IF_LTE, L_SELECT_IF_GTE
[out]pchanged[optional] 1 if changed; 0 if clone returned
Returns
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 981 of file pixafunc1.c.

References boxaDestroy(), L_SELECT_IF_GT, L_SELECT_IF_GTE, L_SELECT_IF_LT, L_SELECT_IF_LTE, pixaDestroy(), pixaDisplay(), pixaGetCount(), pixaSelectByWidthHeightRatio(), pixConnComp(), pixCopy(), pixCreateTemplate(), pixGetDimensions(), and pixZero().