Leptonica 1.68
C Image Processing Library

pageseg.c File Reference

Top-level page segmentation, halftone region extraction, textline extraction. More...

#include <stdio.h>
#include <stdlib.h>
#include "allheaders.h"

Go to the source code of this file.

Functions

l_int32 pixGetRegionsBinary (PIX *pixs, PIX **ppixhm, PIX **ppixtm, PIX **ppixtb, l_int32 debug)
PIXpixGenHalftoneMask (PIX *pixs, PIX **ppixtext, l_int32 *phtfound, l_int32 debug)
PIXpixGenTextlineMask (PIX *pixs, PIX **ppixvws, l_int32 *ptlfound, l_int32 debug)
PIXpixGenTextblockMask (PIX *pixs, PIX *pixvws, l_int32 debug)

Detailed Description

Top-level page segmentation, halftone region extraction, textline extraction.

    Top level page segmentation
        l_int32   pixGetRegionsBinary()

    Halftone region extraction
        PIX      *pixGenHalftoneMask()

    Textline extraction
        PIX      *pixGenTextlineMask()

    Textblock extraction
        PIX      *pixGenTextblockMask()

Definition in file pageseg.c.


Function Documentation

l_int32 pixGetRegionsBinary ( PIX pixs,
PIX **  ppixhm,
PIX **  ppixtm,
PIX **  ppixtb,
l_int32  debug 
)

pixGetRegionsBinary()

Input: pixs (1 bpp, assumed to be 300 to 400 ppi) &pixhm (<optional return>=""> halftone mask) &pixtm (<optional return>=""> textline mask) &pixtb (<optional return>=""> textblock mask) debug (flag: set to 1 for debug output) Return: 0 if OK, 1 on error

Notes: (1) It is best to deskew the image before segmenting. (2) The debug flag enables a number of outputs. These are included to show how to generate and save/display these results.

Definition at line 57 of file pageseg.c.

References boxaDestroy(), boxaWrite(), ERROR_INT, FREE, genTempFilename(), IFF_PNG, L_SELECT_IF_EITHER, L_SELECT_IF_GTE, NULL, pixaDestroy(), pixaDisplayRandomCmap(), pixcmapResetColor(), pixConnComp(), pixDestroy(), pixDilateBrick(), pixDisplay(), pixDisplayWrite(), pixDisplayWriteFormat(), pixExpandReplicate(), pixGenHalftoneMask(), pixGenTextblockMask(), pixGenTextlineMask(), pixGetColormap(), pixGetDepth(), pixGetDimensions(), pixGetOuterBordersPtaa(), pixOr(), pixReduceRankBinaryCascade(), pixRenderRandomCmapPtaa(), pixSeedfillBinary(), pixSelectBySize(), pixSubtract(), PROCNAME, ptaaDestroy(), and ptaaWrite().

Referenced by main().

PIX* pixGenHalftoneMask ( PIX pixs,
PIX **  ppixtext,
l_int32 phtfound,
l_int32  debug 
)

pixGenHalftoneMask()

Input: pixs (1 bpp, assumed to be 150 to 200 ppi) &pixtext (<optional return>=""> text part of pixs) &htfound (<optional return>=""> 1 if the mask is not empty) debug (flag: 1 for debug output) Return: pixd (halftone mask), or null on error

Definition at line 223 of file pageseg.c.

References ERROR_PTR, IFF_PNG, NULL, pixCloseSafeBrick(), pixCopy(), pixDestroy(), pixDisplayWrite(), pixDisplayWriteFormat(), pixExpandReplicate(), pixGetDepth(), pixOpenBrick(), pixReduceRankBinaryCascade(), pixSeedfillBinary(), pixSubtract(), pixZero(), and PROCNAME.

Referenced by GetImageMask(), main(), and pixGetRegionsBinary().

PIX* pixGenTextlineMask ( PIX pixs,
PIX **  ppixvws,
l_int32 ptlfound,
l_int32  debug 
)

pixGenTextlineMask()

Input: pixs (1 bpp, assumed to be 150 to 200 ppi) &pixvws (<return> vertical whitespace mask) &tlfound (<optional return>=""> 1 if the mask is not empty) debug (flag: 1 for debug output) Return: pixd (textline mask), or null on error

Notes: (1) The input pixs should be deskewed. (2) pixs should have no halftone pixels. (3) Both the input image and the returned textline mask are at the same resolution.

Definition at line 302 of file pageseg.c.

References ERROR_PTR, IFF_PNG, NULL, pixCloseSafeBrick(), pixDestroy(), pixDisplayWrite(), pixDisplayWriteFormat(), pixGetDepth(), pixInvert(), pixMorphCompSequence(), pixOpenBrick(), pixSubtract(), pixZero(), and PROCNAME.

Referenced by main(), and pixGetRegionsBinary().

PIX* pixGenTextblockMask ( PIX pixs,
PIX pixvws,
l_int32  debug 
)

pixGenTextblockMask()

Input: pixs (1 bpp, textline mask, assumed to be 150 to 200 ppi) pixvws (vertical white space mask) debug (flag: 1 for debug output) Return: pixd (textblock mask), or null on error

Notes: (1) Both the input masks (textline and vertical white space) and the returned textblock mask are at the same resolution. (2) The result is somewhat noisy, in that small "blocks" of text may be included. These can be removed by post-processing, using, e.g., pixSelectBySize(pix, 60, 60, 4, L_SELECT_IF_EITHER, L_SELECT_IF_GTE, NULL);

Definition at line 386 of file pageseg.c.

References ERROR_PTR, IFF_PNG, L_SELECT_IF_BOTH, L_SELECT_IF_GTE, NULL, pixCloseSafeBrick(), pixDestroy(), pixDisplayWriteFormat(), pixGetDepth(), pixMorphSequence(), pixMorphSequenceByComponent(), pixSelectBySize(), pixSubtract(), and PROCNAME.

Referenced by pixGetRegionsBinary().

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines