83 #include <config_auto.h>
87 #include "allheaders.h"
91 static const l_int32 MinWidth = 100;
92 static const l_int32 MinHeight = 100;
120 l_int32 w, h, htfound, tlfound;
121 PIX *pixr, *pix1, *pix2;
132 if (ppixhm) *ppixhm = NULL;
133 if (ppixtm) *ppixtm = NULL;
134 if (ppixtb) *ppixtb = NULL;
135 if (!pixs || pixGetDepth(pixs) != 1)
136 return ERROR_INT(
"pixs undefined or not 1 bpp", __func__, 1);
138 if (w < MinWidth || h < MinHeight) {
139 L_ERROR(
"pix too small: w = %d, h = %d\n", __func__, w, h);
173 pixOr(pixhm, pixhm, pix1);
224 cmap = pixGetColormap(pix1);
232 BOXA *bahm, *batm, *batb;
245 "/tmp/lept/pageseg/debug.pdf");
246 L_INFO(
"Writing debug pdf to /tmp/lept/pageseg/debug.pdf\n", __func__);
311 PIX *pix1, *pix2, *pixhs, *pixhm, *pixd;
313 if (ppixtext) *ppixtext = NULL;
314 if (phtfound) *phtfound = 0;
315 if (!pixs || pixGetDepth(pixs) != 1)
316 return (
PIX *)ERROR_PTR(
"pixs undefined or not 1 bpp", __func__, NULL);
318 if (w < MinWidth || h < MinHeight) {
319 L_ERROR(
"pix too small: w = %d, h = %d\n", __func__, w, h);
345 if (phtfound && !empty)
351 *ppixtext =
pixCopy(NULL, pixs);
392 PIX *pix1, *pix2, *pixvws, *pixd;
394 if (ptlfound) *ptlfound = 0;
396 return (
PIX *)ERROR_PTR(
"&pixvws not defined", __func__, NULL);
398 if (!pixs || pixGetDepth(pixs) != 1)
399 return (
PIX *)ERROR_PTR(
"pixs undefined or not 1 bpp", __func__, NULL);
401 if (w < MinWidth || h < MinHeight) {
402 L_ERROR(
"pix too small: w = %d, h = %d\n", __func__, w, h);
481 PIX *pix1, *pix2, *pix3, *pixd;
483 if (!pixs || pixGetDepth(pixs) != 1)
484 return (
PIX *)ERROR_PTR(
"pixs undefined or not 1 bpp", __func__, NULL);
486 if (w < MinWidth || h < MinHeight) {
487 L_ERROR(
"pix too small: w = %d, h = %d\n", __func__, w, h);
491 return (
PIX *)ERROR_PTR(
"pixvws not defined", __func__, NULL);
498 L_INFO(
"no fg pixels in textblock mask\n", __func__);
571 l_int32 flag, nbox, intersects;
572 l_int32 w, h, bx, by, bw, bh, left, right, top, bottom;
573 PIX *pixb, *pixb2, *pixseed, *pixsf, *pixm, *pix1, *pixg2;
574 BOX *box, *boxfg, *boxin, *boxd;
578 return (
BOX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
580 if (w < MinWidth || h < MinHeight) {
581 L_ERROR(
"pix too small: w = %d, h = %d\n", __func__, w, h);
590 flag = (showmorph) ? 100 : 0;
595 pixOr(pixseed, pixseed, pix1);
598 pixOr(pixseed, pixseed, pix1);
618 left = (bx > mindist) ? erasedist : 0;
619 right = (w - bx - bw > mindist) ? erasedist : 0;
620 top = (by > mindist) ? erasedist : 0;
621 bottom = (h - by - bh > mindist) ? erasedist : 0;
636 boxin =
boxCreate(0.1 * w, 0, 0.8 * w, h);
699 l_int32 ncomp, i, xoff, yoff;
700 BOXA *boxa1, *boxa2, *boxat1, *boxat2, *boxad;
702 PIX *pix, *pix1, *pix2, *pixdb;
703 PIXA *pixa1, *pixadb;
705 if (pboxa) *pboxa = NULL;
706 if (ppixa) *ppixa = NULL;
707 if (ppixdebug) *ppixdebug = NULL;
708 if (!pixs || pixGetDepth(pixs) != 1)
709 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
727 pixadb = (ppixdebug) ?
pixaCreate(ncomp) : NULL;
728 for (i = 0; i < ncomp; i++) {
796 l_int32 w, h, n2, i, firstmin, xmin, xshift;
797 l_int32 nmin, nleft, nright, nsplit, isplit, ncomp;
798 l_int32 *array1, *array2;
801 NUMA *na1, *na2, *nasplit;
804 if (ppixdebug) *ppixdebug = NULL;
805 if (!pixs || pixGetDepth(pixs) != 1)
806 return (
BOXA *)ERROR_PTR(
"pixa undefined or not 1 bpp", __func__, NULL);
832 firstmin = (array1[array2[0]] > array1[array2[1]]) ? 1 : 2;
834 for (i = firstmin; i < n2 - 1; i+= 2) {
837 if (xmin + 2 >= w)
break;
838 nleft = array1[xmin - 2];
839 nright = array1[xmin + 2];
842 "Splitting: xmin = %d, w = %d; nl = %d, nmin = %d, nr = %d\n",
843 xmin, w, nleft, nmin, nright);
845 if (nleft - nmin >= mindel && nright - nmin >= mindel)
851 if (ppixdebug && nsplit > 0) {
853 gplotSimple1(na1, GPLOT_PNG,
"/tmp/lept/split/split", NULL);
870 for (i = 0, xshift = 0; i < nsplit; i++) {
872 box =
boxCreate(xshift, 0, isplit - xshift, h);
876 box =
boxCreate(xshift, 0, w - xshift, h);
883 for (i = 0; i < ncomp; i++) {
955 l_int32 res, csize, empty;
956 BOXA *boxa1, *boxa2, *boxa3;
957 PIX *pix1, *pix2, *pix3;
958 PIXA *pixa1, *pixa2, *pixa3;
961 return (
PIXA *)ERROR_PTR(
"pixs not defined", __func__, NULL);
964 if (pixGetDepth(pixs) > 1) {
976 L_INFO(
"no fg pixels in input image\n", __func__);
990 if ((res = pixGetXRes(pixs)) == 0) {
991 L_INFO(
"Resolution is not set: setting to 300 ppi\n", __func__);
994 csize = L_MIN(120., 60.0 * res / 300.0);
995 snprintf(buf,
sizeof(buf),
"c%d.1 + o%d.1", csize, csize / 3);
1008 minw = (minw != 0) ? minw : (l_int32)(0.12 * res);
1009 minh = (minh != 0) ? minh : (l_int32)(0.07 * res);
1091 l_int32 res, csize, empty;
1092 BOXA *boxa1, *boxa2, *boxa3;
1094 PIX *pix1, *pix2, *pix3;
1095 PIXA *pixa1, *pixa2;
1098 return (
PIXA *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1101 if ((res = pixGetXRes(pixs)) == 0) {
1102 L_INFO(
"Resolution is not set: setting to 300 ppi\n", __func__);
1105 maxw = (maxw != 0) ? maxw : (l_int32)(0.5 * res);
1106 maxh = (maxh != 0) ? maxh : (l_int32)(0.5 * res);
1109 if (pixGetDepth(pixs) > 1) {
1121 L_INFO(
"no fg pixels in input image\n", __func__);
1134 csize = L_MIN(120., 60.0 * res / 300.0);
1135 snprintf(buf,
sizeof(buf),
"c%d.1", csize);
1210 l_float32 deltafract,
1211 l_float32 peakfract,
1212 l_float32 clipfract,
1216 l_int32 w, h, res, i, n, npeak;
1217 l_float32 scalefact, redfact, minval, maxval, val4, val5, fract;
1219 NUMA *na1, *na2, *na3, *na4, *na5;
1220 PIX *pix1, *pix2, *pix3, *pix4, *pix5;
1223 return ERROR_INT(
"&ncols not defined", __func__, 1);
1225 if (!pixs || pixGetDepth(pixs) != 1)
1226 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
1227 if (deltafract < 0.15 || deltafract > 0.75)
1228 L_WARNING(
"deltafract not in [0.15 ... 0.75]\n", __func__);
1229 if (peakfract < 0.25 || peakfract > 0.9)
1230 L_WARNING(
"peakfract not in [0.25 ... 0.9]\n", __func__);
1231 if (clipfract < 0.0 || clipfract >= 0.5)
1232 return ERROR_INT(
"clipfract not in [0.0 ... 0.5)\n", __func__, 1);
1236 if ((res = pixGetXRes(pixs)) == 0) {
1237 L_WARNING(
"resolution undefined; set to 300\n", __func__);
1242 L_WARNING(
"resolution %d very low\n", __func__, res);
1243 scalefact = 37.5 / res;
1244 pix1 =
pixScale(pixs, scalefact, scalefact);
1246 redfact = (l_float32)res / 37.5;
1249 else if (redfact < 4.0)
1251 else if (redfact < 8.0)
1253 else if (redfact < 16.0)
1262 box =
boxCreate(clipfract * w, clipfract * h,
1263 (1.0 - 2 * clipfract) * w, (1.0 - 2 * clipfract) * h);
1281 pix5 =
pixRead(
"/tmp/lept/plot.png");
1292 fract = (l_float32)(maxval - minval) / h;
1294 L_INFO(
"very little content on page; 0 text columns\n", __func__);
1301 for (i = 0, npeak = 0; i < n; i++) {
1304 if (val4 > 0.3 && val4 < 0.7 && val5 >= peakfract) {
1306 L_INFO(
"Peak(loc,val) = (%5.3f,%5.3f)\n", __func__, val4, val5);
1309 *pncols = npeak + 1;
1360 l_int32 i, empty, maxw, w, h, n1, n2, n3, minlines, big_comp;
1361 l_float32 ratio1, ratio2;
1363 BOXA *boxa1, *boxa2, *boxa3, *boxa4, *boxa5;
1364 PIX *pix1, *pix2, *pix3, *pix4, *pix5, *pix6, *pix7;
1369 return ERROR_INT(
"&istext not defined", __func__, 1);
1372 return ERROR_INT(
"pixs not defined", __func__, 1);
1376 return ERROR_INT(
"pix1 not made", __func__, 1);
1381 L_INFO(
"pix is empty\n", __func__);
1384 w = pixGetWidth(pix1);
1394 for (i = 0; i < 81; i++)
1403 pix3 =
pixHMT(NULL, pix1, sel1);
1405 pix5 =
pixXor(NULL, pix1, pix4);
1474 ratio1 = (l_float32)maxw / (l_float32)w;
1475 ratio2 = (l_float32)n3 / (l_float32)n2;
1476 minlines = L_MAX(2, h / 125);
1477 if (big_comp || ratio1 < 0.6 || ratio2 < 0.8 || n3 < minlines)
1482 if (*pistext == 1) {
1483 L_INFO(
"This is text: \n n1 = %d, n2 = %d, n3 = %d, "
1484 "minlines = %d\n maxw = %d, ratio1 = %4.2f, h = %d, "
1485 "big_comp = %d\n", __func__, n1, n2, n3, minlines,
1486 maxw, ratio1, h, big_comp);
1488 L_INFO(
"This is not text: \n n1 = %d, n2 = %d, n3 = %d, "
1489 "minlines = %d\n maxw = %d, ratio1 = %4.2f, h = %d, "
1490 "big_comp = %d\n", __func__, n1, n2, n3, minlines,
1491 maxw, ratio1, h, big_comp);
1528 if (ptop) *ptop = 0;
1529 if (pbot) *pbot = 0;
1531 return ERROR_INT(
"nothing to determine", __func__, 1);
1532 if (!pixs || pixGetDepth(pixs) != 1)
1533 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
1539 for (i = 0; i < n; i++) {
1540 if (array[i] >= thresh) {
1547 for (i = n - 1; i >= 0; i--) {
1548 if (array[i] >= thresh) {
1613 l_int32 empty, nhb, nvb, nvw, score, htfound;
1614 PIX *pix1, *pix2, *pix3, *pix4, *pix5, *pix6, *pix7, *pix8, *pix9;
1617 return ERROR_INT(
"&score not defined", __func__, 1);
1620 return ERROR_INT(
"pixs not defined", __func__, 1);
1631 L_INFO(
"pix has an image region\n", __func__);
1637 return ERROR_INT(
"pix1 not made", __func__, 1);
1643 L_INFO(
"pix is empty\n", __func__);
1678 pix6 =
pixOr(NULL, pix3, pix5);
1717 if (nhb > 1) score++;
1718 if (nvb > 2) score++;
1719 if (nvw > 3) score++;
1720 if (nvw > 6) score++;
1757 l_float32 cropfract,
1763 PIX *pix1, *pix2, *pix3, *pix4, *pix5;
1766 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1775 box1 =
boxCreate((l_int32)(cropfract * w), (l_int32)(cropfract * h),
1776 (l_int32)((1.0 - 2 * cropfract) * w),
1777 (l_int32)((1.0 - 2 * cropfract) * h));
1783 if (pixGetDepth(pixs) > 1) {
1789 L_INFO(
"pix cleaning failed\n", __func__);
1803 if ((res = pixGetXRes(pixs)) == 0) {
1804 L_WARNING(
"Resolution is not set: using 300 ppi\n", __func__);
1807 if (res != outres) {
1808 factor = (l_float32)outres / (l_float32)res;
1809 pix5 =
pixScale(pix4, factor, factor);
1843 l_int32 w, h, sampling;
1846 PIX *pix1, *pix2, *pixm;
1849 return ERROR_INT(
"&bg not defined", __func__, 1);
1851 if (!pixs || pixGetDepth(pixs) != 8)
1852 return ERROR_INT(
"pixs not defined or not 8 bpp", __func__, 1);
1853 if (darkthresh > 128)
1854 L_WARNING(
"darkthresh unusually large\n", __func__);
1855 if (edgecrop < 0.0 || edgecrop >= 1.0)
1856 return ERROR_INT(
"edgecrop not in [0.0 ... 1.0)", __func__, 1);
1862 if (edgecrop > 0.0) {
1863 box =
boxCreate(0.5 * edgecrop * w, 0.5 * edgecrop * h,
1864 (1.0 - edgecrop) * w, (1.0 - edgecrop) * h);
1872 sampling = L_MAX(1, (l_int32)sqrt((l_float64)(w * h) / 50000. + 0.5));
1876 if (darkthresh > 0) {
1882 *pbg = (l_int32)(fbg + 0.5);
1926 l_int32 i, op, bx, by, bw, bh;
1931 if (ppixdb) *ppixdb = NULL;
1933 return ERROR_INT(
"&boxa not defined", __func__, 1);
1935 if (!pixs || pixGetDepth(pixs) != 1)
1936 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
1937 if (polarity != 0 && polarity != 1)
1938 return ERROR_INT(
"invalid polarity", __func__, 1);
1940 L_WARNING(
"large num rectangles = %d requested; using 1000\n",
1950 for (i = 0; i < nrect; i++) {
1953 L_ERROR(
"failure in pixFindLargestRectangle\n", __func__);
2026 l_int32 i, j, w, h, d, wpls, val;
2027 l_int32 wp, hp, w1, w2, h1, h2, wmin, hmin, area1, area2;
2029 l_int32 maxarea, wmax, hmax, vertdist, horizdist, prevfg;
2031 l_uint32 *datas, *lines;
2032 l_uint32 **linew, **lineh;
2037 if (ppixdb) *ppixdb = NULL;
2039 return ERROR_INT(
"&box not defined", __func__, 1);
2042 return ERROR_INT(
"pixs not defined", __func__, 1);
2045 return ERROR_INT(
"pixs not 1 bpp", __func__, 1);
2046 if (polarity != 0 && polarity != 1)
2047 return ERROR_INT(
"invalid polarity", __func__, 1);
2050 lowestfg = (l_int32 *)LEPT_CALLOC(w,
sizeof(l_int32));
2051 for (i = 0; i < w; i++)
2062 wpls = pixGetWpl(pixs);
2063 maxarea = xmax = ymax = wmax = hmax = 0;
2064 for (i = 0; i < h; i++) {
2065 lines = datas + i * wpls;
2067 for (j = 0; j < w; j++) {
2069 if ((val ^ polarity) == 0) {
2070 if (i == 0 && j == 0) {
2072 }
else if (i == 0) {
2073 wp = linew[i][j - 1] + 1;
2075 }
else if (j == 0) {
2077 hp = lineh[i - 1][j] + 1;
2080 w1 = linew[i - 1][j];
2081 h1 = lineh[i - 1][j];
2082 horizdist = j - prevfg;
2083 wmin = L_MIN(w1, horizdist);
2084 area1 = wmin * (h1 + 1);
2087 w2 = linew[i][j - 1];
2088 h2 = lineh[i][j - 1];
2089 vertdist = i - lowestfg[j];
2090 hmin = L_MIN(h2, vertdist);
2091 area2 = hmin * (w2 + 1);
2093 if (area1 > area2) {
2108 if (wp * hp > maxarea) {
2119 box =
boxCreate(xmax - wmax + 1, ymax - hmax + 1, wmax, hmax);
2129 LEPT_FREE(lowestfg);
2171 pixFindRectangleInCC(
PIX *pixs,
2178 l_int32 x, y, i, w, h, w1, h1, w2, h2, found, res;
2179 l_int32 xfirst, xlast, xstart, yfirst, ylast, length;
2180 BOX *box1, *box2, *box3, *box4, *box5;
2181 PIX *pix1, *pix2, *pixdb1, *pixdb2;
2184 if (!pixs || pixGetDepth(pixs) != 1)
2185 return (
BOX *)ERROR_PTR(
"pixs undefined or not 1 bpp", __func__, NULL);
2186 if (fract <= 0.0 || fract > 1.0)
2187 return (
BOX *)ERROR_PTR(
"invalid fraction", __func__, NULL);
2189 return (
BOX *)ERROR_PTR(
"invalid scan direction", __func__, NULL);
2192 return (
BOX *)ERROR_PTR(
"invalid select", __func__, NULL);
2222 for (i = 0; i < h; i++) {
2224 if (length >= (l_int32)(fract * w + 0.5)) {
2227 xlast = xfirst + length - 1;
2233 L_WARNING(
"no run of sufficient size was found\n", __func__);
2241 w1 = xlast - xfirst + 1;
2244 for (i = yfirst + 1; i < h; i++) {
2246 if (xstart > xfirst || (xstart + length - 1 < xlast) ||
2249 h1 = ylast - yfirst + 1;
2253 box1 =
boxCreate(xfirst, yfirst, w1, h1);
2257 for (i = h - 1; i >= 0; i--) {
2259 if (length >= (l_int32)(fract * w + 0.5)) {
2262 xlast = xfirst + length - 1;
2268 w2 = xlast - xfirst + 1;
2270 for (i = ylast - 1; i >= 0; i--) {
2272 if (xstart > xfirst || (xstart + length - 1 < xlast) ||
2275 h2 = ylast - yfirst + 1;
2279 box2 =
boxCreate(xfirst, yfirst, w2, h2);
2310 box5 = (box4) ?
boxTransform(box4, x, y, 1.0, 1.0) : NULL;
2321 res = pixGetXRes(pixs);
2322 L_INFO(
"Writing debug files to /tmp/lept/rect/\n", __func__);
2324 "/tmp/lept/rect/fitrect.pdf");
2326 pixWrite(
"/tmp/lept/rect/fitrect.png", pix1, IFF_PNG);
2363 l_int32 i, n, empty, x, y, w, h;
2367 PIX *pix1, *pix2, *pix3, *pix4, *pix5;
2369 if (ppixm) *ppixm = NULL;
2371 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
2372 if (thresh == 0) thresh = 128;
2375 return (
PIX *)ERROR_PTR(
"pix1 not made", __func__, NULL);
2404 for (i = 0; i < n; i++) {
2408 if (pixadb)
lept_stderr(
"fg fraction: %5.3f\n", fgfract);
PIX * pixCleanBackgroundToWhite(PIX *pixs, PIX *pixim, PIX *pixg, l_float32 gamma, l_int32 blackval, l_int32 whiteval)
pixCleanBackgroundToWhite()
#define GET_DATA_BIT(pdata, n)
PIX * pixReduceRankBinaryCascade(PIX *pixs, l_int32 level1, l_int32 level2, l_int32 level3, l_int32 level4)
pixReduceRankBinaryCascade()
void bmfDestroy(L_BMF **pbmf)
bmfDestroy()
L_BMF * bmfCreate(const char *dir, l_int32 fontsize)
bmfCreate()
l_ok boxGetGeometry(const BOX *box, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
boxGetGeometry()
void boxDestroy(BOX **pbox)
boxDestroy()
l_ok boxaGetBoxGeometry(BOXA *boxa, l_int32 index, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
boxaGetBoxGeometry()
l_ok boxaWriteDebug(const char *filename, BOXA *boxa)
boxaWriteDebug()
l_ok boxaAddBox(BOXA *boxa, BOX *box, l_int32 copyflag)
boxaAddBox()
void boxaDestroy(BOXA **pboxa)
boxaDestroy()
l_int32 boxaGetCount(const BOXA *boxa)
boxaGetCount()
BOX * boxaGetBox(BOXA *boxa, l_int32 index, l_int32 accessflag)
boxaGetBox()
BOX * boxCopy(BOX *box)
boxCopy()
void boxaaDestroy(BOXAA **pbaa)
boxaaDestroy()
BOX * boxCreate(l_int32 x, l_int32 y, l_int32 w, l_int32 h)
boxCreate()
BOXA * boxaCreate(l_int32 n)
boxaCreate()
l_ok boxaJoin(BOXA *boxad, BOXA *boxas, l_int32 istart, l_int32 iend)
boxaJoin()
l_ok boxIntersects(BOX *box1, BOX *box2, l_int32 *presult)
boxIntersects()
BOX * boxOverlapRegion(BOX *box1, BOX *box2)
boxOverlapRegion()
BOXA * boxaAdjustSides(BOXA *boxas, l_int32 delleft, l_int32 delright, l_int32 deltop, l_int32 delbot)
boxaAdjustSides()
BOX * boxBoundingRegion(BOX *box1, BOX *box2)
boxBoundingRegion()
BOX * boxAdjustSides(BOX *boxd, BOX *boxs, l_int32 delleft, l_int32 delright, l_int32 deltop, l_int32 delbot)
boxAdjustSides()
l_ok boxaaGetExtent(BOXAA *baa, l_int32 *pw, l_int32 *ph, BOX **pbox, BOXA **pboxa)
boxaaGetExtent()
BOX * boxRotateOrth(BOX *box, l_int32 w, l_int32 h, l_int32 rotation)
boxRotateOrth()
BOX * boxTransform(BOX *box, l_int32 shiftx, l_int32 shifty, l_float32 scalex, l_float32 scaley)
boxTransform()
BOXA * boxaTransform(BOXA *boxas, l_int32 shiftx, l_int32 shifty, l_float32 scalex, l_float32 scaley)
boxaTransform()
BOXA * boxaaFlattenToBoxa(BOXAA *baa, NUMA **pnaindex, l_int32 copyflag)
boxaaFlattenToBoxa()
BOXA * boxaSort(BOXA *boxas, l_int32 sorttype, l_int32 sortorder, NUMA **pnaindex)
boxaSort()
BOXAA * boxaSort2d(BOXA *boxas, NUMAA **pnaad, l_int32 delta1, l_int32 delta2, l_int32 minh1)
boxaSort2d()
PIX * pixDrawBoxaRandom(PIX *pixs, BOXA *boxa, l_int32 width)
pixDrawBoxaRandom()
BOXA * boxaSelectBySize(BOXA *boxas, l_int32 width, l_int32 height, l_int32 type, l_int32 relation, l_int32 *pchanged)
boxaSelectBySize()
PTAA * pixGetOuterBordersPtaa(PIX *pixs)
pixGetOuterBordersPtaa()
l_ok pixcmapResetColor(PIXCMAP *cmap, l_int32 index, l_int32 rval, l_int32 gval, l_int32 bval)
pixcmapResetColor()
BOXA * pixConnCompBB(PIX *pixs, l_int32 connectivity)
pixConnCompBB()
BOXA * pixConnComp(PIX *pixs, PIXA **ppixa, l_int32 connectivity)
pixConnComp()
l_ok pixCountConnComp(PIX *pixs, l_int32 connectivity, l_int32 *pcount)
pixCountConnComp()
l_ok gplotSimple1(NUMA *na, l_int32 outformat, const char *outroot, const char *title)
gplotSimple1()
l_ok pixRenderBoxBlend(PIX *pix, BOX *box, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval, l_float32 fract)
pixRenderBoxBlend()
PIX * pixRenderRandomCmapPtaa(PIX *pix, PTAA *ptaa, l_int32 polyflag, l_int32 width, l_int32 closeflag)
pixRenderRandomCmapPtaa()
l_ok pixRenderHashBoxArb(PIX *pix, BOX *box, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline, l_int32 rval, l_int32 gval, l_int32 bval)
pixRenderHashBoxArb()
l_ok pixRenderBoxArb(PIX *pix, BOX *box, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval)
pixRenderBoxArb()
l_ok pixRenderBoxaArb(PIX *pix, BOXA *boxa, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval)
pixRenderBoxaArb()
PIX * pixThresholdToBinary(PIX *pixs, l_int32 thresh)
pixThresholdToBinary()
PIX * pixOpenBrick(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixOpenBrick()
PIX * pixCloseSafeBrick(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixCloseSafeBrick()
PIX * pixHMT(PIX *pixd, PIX *pixs, SEL *sel)
pixHMT()
PIX * pixDilateBrick(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixDilateBrick()
PIX * pixMorphSequenceByComponent(PIX *pixs, const char *sequence, l_int32 connectivity, l_int32 minw, l_int32 minh, BOXA **pboxa)
pixMorphSequenceByComponent()
PIX * pixMorphSequence(PIX *pixs, const char *sequence, l_int32 dispsep)
pixMorphSequence()
PIX * pixMorphCompSequence(PIX *pixs, const char *sequence, l_int32 dispsep)
pixMorphCompSequence()
l_ok numaAddNumber(NUMA *na, l_float32 val)
numaAddNumber()
l_ok numaGetFValue(NUMA *na, l_int32 index, l_float32 *pval)
numaGetFValue()
l_ok numaWriteStderr(NUMA *na)
numaWriteStderr()
NUMA * numaCreate(l_int32 n)
numaCreate()
void numaDestroy(NUMA **pna)
numaDestroy()
l_int32 numaGetCount(NUMA *na)
numaGetCount()
l_ok numaGetIValue(NUMA *na, l_int32 index, l_int32 *pival)
numaGetIValue()
l_int32 * numaGetIArray(NUMA *na)
numaGetIArray()
l_ok numaGetMin(NUMA *na, l_float32 *pminval, l_int32 *piminloc)
numaGetMin()
l_ok numaGetMax(NUMA *na, l_float32 *pmaxval, l_int32 *pimaxloc)
numaGetMax()
NUMA * numaFindExtrema(NUMA *nas, l_float32 delta, NUMA **pnav)
numaFindExtrema()
NUMA * numaTransform(NUMA *nas, l_float32 shift, l_float32 scale)
numaTransform()
l_ok pixFindThreshFgExtent(PIX *pixs, l_int32 thresh, l_int32 *ptop, l_int32 *pbot)
pixFindThreshFgExtent()
PIX * pixAutoPhotoinvert(PIX *pixs, l_int32 thresh, PIX **ppixm, PIXA *pixadb)
pixFindRectangleInCC()
BOX * pixFindPageForeground(PIX *pixs, l_int32 threshold, l_int32 mindist, l_int32 erasedist, l_int32 showmorph, PIXAC *pixac)
pixFindPageForeground()
l_ok pixGetRegionsBinary(PIX *pixs, PIX **ppixhm, PIX **ppixtm, PIX **ppixtb, PIXA *pixadb)
pixGetRegionsBinary()
BOXA * pixSplitComponentWithProfile(PIX *pixs, l_int32 delta, l_int32 mindel, PIX **ppixdebug)
pixSplitComponentWithProfile()
PIXA * pixExtractTextlines(PIX *pixs, l_int32 maxw, l_int32 maxh, l_int32 minw, l_int32 minh, l_int32 adjw, l_int32 adjh, PIXA *pixadb)
pixExtractTextlines()
PIX * pixGenerateHalftoneMask(PIX *pixs, PIX **ppixtext, l_int32 *phtfound, PIXA *pixadb)
pixGenerateHalftoneMask()
l_ok pixEstimateBackground(PIX *pixs, l_int32 darkthresh, l_float32 edgecrop, l_int32 *pbg)
pixEstimateBackground()
l_ok pixFindLargeRectangles(PIX *pixs, l_int32 polarity, l_int32 nrect, BOXA **pboxa, PIX **ppixdb)
pixFindLargeRectangles()
PIX * pixGenHalftoneMask(PIX *pixs, PIX **ppixtext, l_int32 *phtfound, l_int32 debug)
pixGenHalftoneMask()
PIX * pixPrepare1bpp(PIX *pixs, BOX *box, l_float32 cropfract, l_int32 outres)
pixPrepare1bpp()
l_ok pixCountTextColumns(PIX *pixs, l_float32 deltafract, l_float32 peakfract, l_float32 clipfract, l_int32 *pncols, PIXA *pixadb)
pixCountTextColumns()
l_ok pixSplitIntoCharacters(PIX *pixs, l_int32 minw, l_int32 minh, BOXA **pboxa, PIXA **ppixa, PIX **ppixdebug)
pixSplitIntoCharacters()
PIX * pixGenTextlineMask(PIX *pixs, PIX **ppixvws, l_int32 *ptlfound, PIXA *pixadb)
pixGenTextlineMask()
l_ok pixFindLargestRectangle(PIX *pixs, l_int32 polarity, BOX **pbox, PIX **ppixdb)
pixFindLargestRectangle()
PIXA * pixExtractRawTextlines(PIX *pixs, l_int32 maxw, l_int32 maxh, l_int32 adjw, l_int32 adjh, PIXA *pixadb)
pixExtractRawTextlines()
l_ok pixDecideIfTable(PIX *pixs, BOX *box, l_int32 orient, l_int32 *pscore, PIXA *pixadb)
pixDecideIfTable()
l_ok pixDecideIfText(PIX *pixs, BOX *box, l_int32 *pistext, PIXA *pixadb)
pixDecideIfText()
PIX * pixGenTextblockMask(PIX *pixs, PIX *pixvws, PIXA *pixadb)
pixGenTextblockMask()
l_ok pixaConvertToPdf(PIXA *pixa, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, const char *title, const char *fileout)
pixaConvertToPdf()
l_uint32 * pixGetData(PIX *pix)
pixGetData()
l_ok pixSetResolution(PIX *pix, l_int32 xres, l_int32 yres)
pixSetResolution()
void pixDestroy(PIX **ppix)
pixDestroy()
l_ok pixGetDimensions(const PIX *pix, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixGetDimensions()
PIX * pixCopy(PIX *pixd, const PIX *pixs)
pixCopy()
PIX * pixCreateTemplate(const PIX *pixs)
pixCreateTemplate()
PIX * pixCreate(l_int32 width, l_int32 height, l_int32 depth)
pixCreate()
PIX * pixClone(PIX *pixs)
pixClone()
void ** pixGetLinePtrs(PIX *pix, l_int32 *psize)
pixGetLinePtrs()
l_ok pixSetPixel(PIX *pix, l_int32 x, l_int32 y, l_uint32 val)
pixSetPixel()
l_ok pixSetOrClearBorder(PIX *pixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot, l_int32 op)
pixSetOrClearBorder()
NUMA * pixCountByColumn(PIX *pix, BOX *box)
pixCountByColumn()
l_ok pixZero(PIX *pix, l_int32 *pempty)
pixZero()
PIX * pixInvert(PIX *pixd, PIX *pixs)
pixInvert()
PIX * pixOr(PIX *pixd, PIX *pixs1, PIX *pixs2)
pixOr()
NUMA * pixCountPixelsByColumn(PIX *pix)
pixCountPixelsByColumn()
PIX * pixXor(PIX *pixd, PIX *pixs1, PIX *pixs2)
pixXor()
l_ok pixForegroundFraction(PIX *pix, l_float32 *pfract)
pixForegroundFraction()
l_ok pixCombineMasked(PIX *pixd, PIX *pixs, PIX *pixm)
pixCombineMasked()
NUMA * pixCountPixelsByRow(PIX *pix, l_int32 *tab8)
pixCountPixelsByRow()
PIX * pixSubtract(PIX *pixd, PIX *pixs1, PIX *pixs2)
pixSubtract()
l_ok pixGetRankValueMasked(PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor, l_float32 rank, l_float32 *pval, NUMA **pna)
pixGetRankValueMasked()
PIX * pixClipRectangle(PIX *pixs, BOX *box, BOX **pboxc)
pixClipRectangle()
l_ok pixClipToForeground(PIX *pixs, PIX **ppixd, BOX **pbox)
pixClipToForeground()
PIXA * pixClipRectangles(PIX *pixs, BOXA *boxa)
pixClipRectangles()
@ REMOVE_CMAP_TO_GRAYSCALE
@ L_GEOMETRIC_INTERSECTION
l_ok pixaAddPix(PIXA *pixa, PIX *pix, l_int32 copyflag)
pixaAddPix()
void pixaDestroy(PIXA **ppixa)
pixaDestroy()
PIXA * pixaCreate(l_int32 n)
pixaCreate()
l_int32 pixaGetCount(PIXA *pixa)
pixaGetCount()
BOXA * pixaGetBoxa(PIXA *pixa, l_int32 accesstype)
pixaGetBoxa()
l_ok pixaGetBoxGeometry(PIXA *pixa, l_int32 index, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
pixaGetBoxGeometry()
PIX * pixaGetPix(PIXA *pixa, l_int32 index, l_int32 accesstype)
pixaGetPix()
PIX * pixSelectBySize(PIX *pixs, l_int32 width, l_int32 height, l_int32 connectivity, l_int32 type, l_int32 relation, l_int32 *pchanged)
pixSelectBySize()
PIXA * pixaSelectBySize(PIXA *pixas, l_int32 width, l_int32 height, l_int32 type, l_int32 relation, l_int32 *pchanged)
pixaSelectBySize()
PIX * pixaDisplayRandomCmap(PIXA *pixa, l_int32 w, l_int32 h)
pixaDisplayRandomCmap()
PIX * pixaDisplayTiledInRows(PIXA *pixa, l_int32 outdepth, l_int32 maxwidth, l_float32 scalefactor, l_int32 background, l_int32 spacing, l_int32 border)
pixaDisplayTiledInRows()
PIX * pixaDisplayTiledAndScaled(PIXA *pixa, l_int32 outdepth, l_int32 tilewidth, l_int32 ncols, l_int32 background, l_int32 spacing, l_int32 border)
pixaDisplayTiledAndScaled()
l_ok pixAddConstantGray(PIX *pixs, l_int32 val)
pixAddConstantGray()
l_ok pixacompAddPix(PIXAC *pixac, PIX *pix, l_int32 comptype)
pixacompAddPix()
PIX * pixConvert1To4Cmap(PIX *pixs)
pixConvert1To4Cmap()
PIX * pixRemoveColormap(PIX *pixs, l_int32 type)
pixRemoveColormap()
PIX * pixConvertTo1(PIX *pixs, l_int32 threshold)
pixConvertTo1()
PIX * pixConvertTo8(PIX *pixs, l_int32 cmapflag)
pixConvertTo8()
PIX * pixConvertTo32(PIX *pixs)
pixConvertTo32()
l_ok ptaaWriteDebug(const char *filename, PTAA *ptaa, l_int32 type)
ptaaWriteDebug()
void ptaaDestroy(PTAA **pptaa)
ptaaDestroy()
PIX * pixRead(const char *filename)
pixRead()
l_ok pixRasterop(PIX *pixd, l_int32 dx, l_int32 dy, l_int32 dw, l_int32 dh, l_int32 op, PIX *pixs, l_int32 sx, l_int32 sy)
pixRasterop()
PIX * pixRotate90(PIX *pixs, l_int32 direction)
pixRotate90()
l_ok pixFindMaxHorizontalRunOnLine(PIX *pix, l_int32 y, l_int32 *pxstart, l_int32 *psize)
pixFindMaxHorizontalRunOnLine()
PIX * pixScale(PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScale()
PIX * pixExpandReplicate(PIX *pixs, l_int32 factor)
pixExpandReplicate()
PIX * pixFillHolesToBoundingRect(PIX *pixs, l_int32 minsize, l_float32 maxhfract, l_float32 minfgfract)
pixFillHolesToBoundingRect()
PIX * pixSeedfillBinary(PIX *pixd, PIX *pixs, PIX *pixm, l_int32 connectivity)
pixSeedfillBinary()
PIX * pixSeedfillBinaryRestricted(PIX *pixd, PIX *pixs, PIX *pixm, l_int32 connectivity, l_int32 xmax, l_int32 ymax)
pixSeedfillBinaryRestricted()
PIX * pixRemoveBorderConnComps(PIX *pixs, l_int32 connectivity)
pixRemoveBorderConnComps()
SEL * selCreateFromPix(PIX *pix, l_int32 cy, l_int32 cx, const char *name)
selCreateFromPix()
void selDestroy(SEL **psel)
selDestroy()
l_ok selSetElement(SEL *sel, l_int32 row, l_int32 col, l_int32 type)
selSetElement()
PIX * pixDeskewBoth(PIX *pixs, l_int32 redsearch)
pixDeskewBoth()
PIX * pixDeskew(PIX *pixs, l_int32 redsearch)
pixDeskew()
l_ok pixaAddPixWithText(PIXA *pixa, PIX *pixs, l_int32 reduction, L_BMF *bmf, const char *textstr, l_uint32 val, l_int32 location)
pixaAddPixWithText()
void lept_stderr(const char *fmt,...)
lept_stderr()
l_int32 lept_mkdir(const char *subdir)
lept_mkdir()