106#include <config_auto.h>
111#include "allheaders.h"
113static const l_uint32 rmask32[] = {0x0,
114 0x00000001, 0x00000003, 0x00000007, 0x0000000f,
115 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff,
116 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff,
117 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff,
118 0x0001ffff, 0x0003ffff, 0x0007ffff, 0x000fffff,
119 0x001fffff, 0x003fffff, 0x007fffff, 0x00ffffff,
120 0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff,
121 0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff};
147 if (pnaw) *pnaw = NULL;
148 if (pnah) *pnah = NULL;
150 return ERROR_INT(
"no output requested", __func__, 1);
152 return ERROR_INT(
"pixa not defined", __func__, 1);
154 n = pixaGetCount(pixa);
155 if (pnaw) *pnaw = numaCreate(n);
156 if (pnah) *pnah = numaCreate(n);
157 for (i = 0; i < n; i++) {
158 pixt = pixaGetPix(pixa, i,
L_CLONE);
159 pixGetDimensions(pixt, &w, &h, NULL);
161 numaAddNumber(*pnaw, w);
163 numaAddNumber(*pnah, h);
197 return ERROR_INT(
"&fract not defined", __func__, 1);
199 if (!pixs || pixGetDepth(pixs) != 1)
200 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
203 tab8 = makePixelSumTab8();
207 pixt = pixErodeBrick(NULL, pixs, 3, 3);
208 pixCountPixels(pixt, &nfg, tab8);
211 if (!tab) LEPT_FREE(tab8);
214 pixXor(pixt, pixt, pixs);
215 pixCountPixels(pixt, &nbound, tab8);
216 *pfract = (l_float32)nfg / (l_float32)nbound;
219 if (!tab) LEPT_FREE(tab8);
246 return (
NUMA *)ERROR_PTR(
"pixa not defined", __func__, NULL);
248 n = pixaGetCount(pixa);
250 tab = makePixelSumTab8();
251 for (i = 0; i < n; i++) {
252 pixt = pixaGetPix(pixa, i,
L_CLONE);
254 numaAddNumber(na, fract);
294 return ERROR_INT(
"&fract not defined", __func__, 1);
296 if (!pixs || pixGetDepth(pixs) != 1)
297 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
300 tab8 = makePixelSumTab8();
304 pixCountPixels(pixs, &nfg, tab8);
306 if (!tab) LEPT_FREE(tab8);
309 pixt = pixErodeBrick(NULL, pixs, 3, 3);
310 pixXor(pixt, pixt, pixs);
311 pixCountPixels(pixt, &nbound, tab8);
312 *pfract = (l_float32)nbound / (l_float32)nfg;
315 if (!tab) LEPT_FREE(tab8);
346 return (
NUMA *)ERROR_PTR(
"pixa not defined", __func__, NULL);
348 n = pixaGetCount(pixa);
350 tab = makePixelSumTab8();
351 for (i = 0; i < n; i++) {
352 pixt = pixaGetPix(pixa, i,
L_CLONE);
354 numaAddNumber(na, ratio);
394 return ERROR_INT(
"&ratio not defined", __func__, 1);
396 if (!pixs || pixGetDepth(pixs) != 1)
397 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
400 tab8 = makePixelSumTab8();
404 pixt = pixErodeBrick(NULL, pixs, 3, 3);
405 pixXor(pixt, pixt, pixs);
406 pixCountPixels(pixt, &nbound, tab8);
407 pixGetDimensions(pixs, &w, &h, NULL);
408 *pratio = (0.5f * nbound) / (l_float32)(w + h);
411 if (!tab) LEPT_FREE(tab8);
438 return (
NUMA *)ERROR_PTR(
"pixa not defined", __func__, NULL);
440 n = pixaGetCount(pixa);
442 tab = makePixelSumTab8();
443 for (i = 0; i < n; i++) {
444 pixt = pixaGetPix(pixa, i,
L_CLONE);
446 numaAddNumber(na, fract);
478 return ERROR_INT(
"&fract not defined", __func__, 1);
480 if (!pixs || pixGetDepth(pixs) != 1)
481 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
484 tab8 = makePixelSumTab8();
487 pixGetDimensions(pixs, &w, &h, NULL);
488 pixCountPixels(pixs, &sum, tab8);
489 *pfract = (l_float32)sum / (l_float32)(w * h);
491 if (!tab) LEPT_FREE(tab8);
528 return (
NUMA *)ERROR_PTR(
"pixa not defined", __func__, NULL);
529 if (!pixm || pixGetDepth(pixm) != 1)
530 return (
NUMA *)ERROR_PTR(
"pixm undefined or not 1 bpp", __func__, NULL);
532 n = pixaGetCount(pixa);
534 tab = makePixelSumTab8();
535 pixaIsFull(pixa, NULL, &full);
537 for (i = 0; i < n; i++) {
538 pix = pixaGetPix(pixa, i,
L_CLONE);
540 box = pixaGetBox(pixa, i,
L_CLONE);
542 numaAddNumber(na, fract);
551 pixGetDimensions(pixm, &w, &h, NULL);
552 pix1 = pixaDisplay(pixa, w, h);
553 pix2 = pixCreate(w, h, 8);
554 pixSetColormap(pix2, pixcmapCreate(8));
556 pixSetMaskedCmap(pix2, pix1, 0, 0, 255, 0, 0);
557 pixRasterop(pix1, 0, 0, w, h,
PIX_MASK, pixm, 0, 0);
558 pixSetMaskedCmap(pix2, pix1, 0, 0, 0, 255, 0);
559 pixDisplay(pix2, 100, 100);
599l_int32 x, y, w, h, sum, masksum;
604 return ERROR_INT(
"&fract not defined", __func__, 1);
606 if (!pixs || pixGetDepth(pixs) != 1)
607 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
608 if (!pixm || pixGetDepth(pixm) != 1)
609 return ERROR_INT(
"pixm not defined or not 1 bpp", __func__, 1);
612 tab8 = makePixelSumTab8();
617 boxGetGeometry(box, &x, &y, NULL, NULL);
618 pixGetDimensions(pixs, &w, &h, NULL);
620 pix1 = pixCopy(NULL, pixs);
621 pixRasterop(pix1, 0, 0, w, h,
PIX_MASK, pixm, x, y);
622 pixCountPixels(pixs, &sum, tab8);
625 if (!tab) LEPT_FREE(tab8);
628 pixCountPixels(pix1, &masksum, tab8);
629 *pfract = (l_float32)masksum / (l_float32)sum;
631 if (!tab) LEPT_FREE(tab8);
657 return (
NUMA *)ERROR_PTR(
"pixa not defined", __func__, NULL);
659 n = pixaGetCount(pixa);
661 for (i = 0; i < n; i++) {
662 pixt = pixaGetPix(pixa, i,
L_CLONE);
663 pixGetDimensions(pixt, &w, &h, NULL);
664 numaAddNumber(na, (l_float32)w / (l_float32)h);
691 return (
NUMA *)ERROR_PTR(
"pixa not defined", __func__, NULL);
693 n = pixaGetCount(pixa);
695 for (i = 0; i < n; i++) {
696 pixt = pixaGetPix(pixa, i,
L_CLONE);
697 pixGetDimensions(pixt, &w, &h, NULL);
698 numaAddNumber(na, w * h);
731l_int32 w, h, nintersect, nunion;
734 if (pnoverlap) *pnoverlap = 0;
736 return ERROR_INT(
"&ratio not defined", __func__, 1);
738 if (!pixs1 || pixGetDepth(pixs1) != 1)
739 return ERROR_INT(
"pixs1 not defined or not 1 bpp", __func__, 1);
740 if (!pixs2 || pixGetDepth(pixs2) != 1)
741 return ERROR_INT(
"pixs2 not defined or not 1 bpp", __func__, 1);
744 tab8 = makePixelSumTab8();
748 pixGetDimensions(pixs2, &w, &h, NULL);
749 pixt = pixCopy(NULL, pixs1);
750 pixRasterop(pixt, x2, y2, w, h,
PIX_MASK, pixs2, 0, 0);
751 pixCountPixels(pixt, &nintersect, tab8);
753 *pnoverlap = nintersect;
754 pixCopy(pixt, pixs1);
755 pixRasterop(pixt, x2, y2, w, h,
PIX_PAINT, pixs2, 0, 0);
756 pixCountPixels(pixt, &nunion, tab8);
757 if (!tab) LEPT_FREE(tab8);
761 *pratio = (l_float32)nintersect / (l_float32)nunion;
792l_int32 w, h, i, n, conforms;
798 if (!pixs || pixGetDepth(pixs) != 1)
799 return (
BOXA *)ERROR_PTR(
"pixs undefined or not 1 bpp", __func__, NULL);
801 return (
BOXA *)ERROR_PTR(
"dist must be >= 0", __func__, NULL);
802 if (minw <= 2 * dist && minh <= 2 * dist)
803 return (
BOXA *)ERROR_PTR(
"invalid parameters", __func__, NULL);
805 boxa = pixConnComp(pixs, &pixa, 8);
806 boxad = boxaCreate(0);
807 n = pixaGetCount(pixa);
808 for (i = 0; i < n; i++) {
809 pix = pixaGetPix(pixa, i,
L_CLONE);
810 pixGetDimensions(pix, &w, &h, NULL);
811 if (w < minw || h < minh) {
817 box = boxaGetBox(boxa, i,
L_COPY);
874 return ERROR_INT(
"&conforms not defined", __func__, 1);
876 if (!pixs || pixGetDepth(pixs) != 1)
877 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
879 return ERROR_INT(
"dist must be >= 0", __func__, 1);
880 pixGetDimensions(pixs, &w, &h, NULL);
881 if (w <= 2 * dist || h <= 2 * dist) {
882 L_WARNING(
"automatic conformation: distance too large\n", __func__);
891 pix1 = pixCopy(NULL, pixs);
896 pixInvert(pix1, pix1);
897 pix2 = pixExtractBorderConnComps(pix1, 4);
904 pixSetOrClearBorder(pix2, dist, dist, dist, dist,
PIX_CLR);
905 pixZero(pix2, &empty);
908 *pconforms = (empty) ? 1 : 0;
939 return (
PIXA *)ERROR_PTR(
"pixs not defined", __func__, NULL);
941 return (
PIXA *)ERROR_PTR(
"boxa not defined", __func__, NULL);
943 n = boxaGetCount(boxa);
944 pixa = pixaCreate(n);
945 for (i = 0; i < n; i++) {
946 box = boxaGetBox(boxa, i,
L_CLONE);
998l_int32 w, h, d, bx, by, bw, bh;
1002 if (pboxc) *pboxc = NULL;
1004 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1006 return (
PIX *)ERROR_PTR(
"box not defined", __func__, NULL);
1009 pixGetDimensions(pixs, &w, &h, &d);
1010 if ((boxc = boxClipToRectangle(box, w, h)) == NULL) {
1011 L_WARNING(
"box doesn't overlap pix\n", __func__);
1014 boxGetGeometry(boxc, &bx, &by, &bw, &bh);
1017 if ((pixd = pixCreate(bw, bh, d)) == NULL) {
1019 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
1021 pixCopyResolution(pixd, pixs);
1022 pixCopyColormap(pixd, pixs);
1023 pixCopyText(pixd, pixs);
1024 pixRasterop(pixd, 0, 0, bw, bh,
PIX_SRC, pixs, bx, by);
1060l_int32 w, h, bx, by, bw, bh, bord;
1065 return (
PIX *)ERROR_PTR(
"&boxn not defined", __func__, NULL);
1068 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1070 return (
PIX *)ERROR_PTR(
"box not defined", __func__, NULL);
1073 pixGetDimensions(pixs, &w, &h, NULL);
1074 boxGetGeometry(box, &bx, &by, &bw, &bh);
1075 bord = L_MIN(bx, by);
1076 bord = L_MIN(bord, w - bx - bw);
1077 bord = L_MIN(bord, h - by - bh);
1078 bord = L_MIN(bord, maxbord);
1082 pixGetDimensions(pix1, &w, &h, NULL);
1083 *pboxn = boxCreate(0, 0, w, h);
1088 box1 = boxAdjustSides(NULL, box, -bord, bord, -bord, bord);
1091 *pboxn = boxCreate(bord, bord, bw, bh);
1132l_int32 wm, hm, index, rval, gval, bval;
1139 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1140 if (!pixm || pixGetDepth(pixm) != 1)
1141 return (
PIX *)ERROR_PTR(
"pixm undefined or not 1 bpp", __func__, NULL);
1144 pixGetDimensions(pixm, &wm, &hm, NULL);
1145 box = boxCreate(x, y, wm, hm);
1150 cmap = pixGetColormap(pixd);
1151 pixmi = pixInvert(NULL, pixm);
1153 extractRGBValues(outval, &rval, &gval, &bval);
1154 pixcmapGetNearestIndex(cmap, rval, gval, bval, &index);
1155 pixcmapGetColor(cmap, index, &rval, &gval, &bval);
1156 composeRGBPixel(rval, gval, bval, &pixel);
1157 pixPaintThroughMask(pixd, pixmi, 0, 0, pixel);
1159 pixPaintThroughMask(pixd, pixmi, 0, 0, outval);
1191l_int32 w1, h1, w2, h2, w, h;
1193 if (!ppixd1 || !ppixd2)
1194 return ERROR_INT(
"&pixd1 and &pixd2 not both defined", __func__, 1);
1195 *ppixd1 = *ppixd2 = NULL;
1196 if (!pixs1 || !pixs2)
1197 return ERROR_INT(
"pixs1 and pixs2 not defined", __func__, 1);
1199 pixGetDimensions(pixs1, &w1, &h1, NULL);
1200 pixGetDimensions(pixs2, &w2, &h2, NULL);
1206 if (*ppixd1 == NULL || *ppixd2 == NULL)
1207 return ERROR_INT(
"cropped image failure", __func__, 1);
1231l_int32 ws, hs, wd, hd, d;
1235 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1237 pixGetDimensions(pixs, &ws, &hs, &d);
1238 if (ws <= w && hs <= h)
1239 return pixClone(pixs);
1243 if ((pixd = pixCreate(wd, hd, d)) == NULL)
1244 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
1245 pixCopyResolution(pixd, pixs);
1246 pixCopyColormap(pixd, pixs);
1247 pixCopyText(pixd, pixs);
1248 pixCopyInputFormat(pixd, pixs);
1249 pixRasterop(pixd, 0, 0, wd, hd,
PIX_SRC, pixs, 0, 0);
1284l_int32 i, j, ws, hs, d;
1288 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1289 if (!pixt && (w <= 0 || h <= 0))
1290 return (
PIX *)ERROR_PTR(
"both w and h not > 0", __func__, NULL);
1293 pixGetDimensions(pixt, &w, &h, NULL);
1294 pixGetDimensions(pixs, &ws, &hs, &d);
1295 if (ws == w && hs == h)
1296 return pixCopy(NULL, pixs);
1298 if ((pixd = pixCreate(w, h, d)) == NULL)
1299 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
1300 pixCopyResolution(pixd, pixs);
1301 pixCopyColormap(pixd, pixs);
1302 pixCopyText(pixd, pixs);
1303 pixCopyInputFormat(pixd, pixs);
1304 pixRasterop(pixd, 0, 0, ws, hs,
PIX_SRC, pixs, 0, 0);
1305 if (ws >= w && hs >= h)
1310 for (j = ws; j < w; j++)
1311 pixRasterop(pixd, j, 0, 1, h,
PIX_SRC, pixd, ws - 1, 0);
1314 for (i = hs; i < h; i++)
1315 pixRasterop(pixd, 0, i, w, 1,
PIX_SRC, pixd, 0, hs - 1);
1346pixSelectComponentBySize(
PIX *pixs,
1349 l_int32 connectivity,
1352l_int32 n, empty, sorttype, index;
1358 if (pbox) *pbox = NULL;
1359 if (!pixs || pixGetDepth(pixs) != 1)
1360 return (
PIX *)ERROR_PTR(
"pixs undefined or not 1 bpp", __func__, NULL);
1372 return (
PIX *)ERROR_PTR(
"invalid selection type", __func__, NULL);
1373 if (connectivity != 4 && connectivity != 8)
1374 return (
PIX *)ERROR_PTR(
"connectivity not 4 or 8", __func__, NULL);
1375 pixZero(pixs, &empty);
1377 return (
PIX *)ERROR_PTR(
"no foreground pixels", __func__, NULL);
1379 boxa1 = pixConnComp(pixs, &pixa1, connectivity);
1380 n = boxaGetCount(boxa1);
1381 if (rankorder < 0 || rankorder >= n)
1384 pixd = pixaGetPix(pixa2, rankorder,
L_COPY);
1386 numaGetIValue(naindex, rankorder, &index);
1387 *pbox = boxaGetBox(boxa1, index,
L_COPY);
1390 numaDestroy(&naindex);
1391 boxaDestroy(&boxa1);
1392 pixaDestroy(&pixa1);
1393 pixaDestroy(&pixa2);
1417pixFilterComponentBySize(
PIX *pixs,
1420 l_int32 connectivity,
1427 if (!pixs || pixGetDepth(pixs) != 1)
1428 return (
PIX *)ERROR_PTR(
"pixs undefined or not 1 bpp", __func__, NULL);
1430 pix1 = pixSelectComponentBySize(pixs, rankorder, type, connectivity, &box);
1433 return (
PIX *)ERROR_PTR(
"pix1 not made", __func__, NULL);
1438 boxGetGeometry(box, &x, &y, &w, &h);
1439 pix2 = pixCreateTemplate(pixs);
1440 pixRasterop(pix2, x, y, w, h,
PIX_SRC, pix1, 0, 0);
1490 if (w <= 0 || h <= 0)
1491 return (
PIX *)ERROR_PTR(
"mask size 0", __func__, NULL);
1492 if (hf < 0.0 || hf > 1.0)
1493 return (
PIX *)ERROR_PTR(
"invalid horiz fractions", __func__, NULL);
1494 if (vf < 0.0 || vf > 1.0)
1495 return (
PIX *)ERROR_PTR(
"invalid vert fractions", __func__, NULL);
1502 return (
PIX *)ERROR_PTR(
"invalid type", __func__, NULL);
1546l_int32 h1, h2, v1, v2;
1549 if (w <= 0 || h <= 0)
1550 return (
PIX *)ERROR_PTR(
"mask size 0", __func__, NULL);
1551 if (hf1 < 0.0 || hf1 > 1.0 || hf2 < 0.0 || hf2 > 1.0)
1552 return (
PIX *)ERROR_PTR(
"invalid horiz fractions", __func__, NULL);
1553 if (vf1 < 0.0 || vf1 > 1.0 || vf2 < 0.0 || vf2 > 1.0)
1554 return (
PIX *)ERROR_PTR(
"invalid vert fractions", __func__, NULL);
1555 if (hf1 > hf2 || vf1 > vf2)
1556 return (
PIX *)ERROR_PTR(
"invalid relative sizes", __func__, NULL);
1558 pixd = pixCreate(w, h, 1);
1561 if (hf1 == 0.0 && vf1 == 0.0 && hf2 == 1.0 && vf2 == 1.0) {
1565 if (hf1 == hf2 && vf1 == vf2) {
1570 h1 = 0.5f * hf1 * w;
1571 h2 = 0.5f * hf2 * w;
1572 v1 = 0.5f * vf1 * h;
1573 v2 = 0.5f * vf2 * h;
1574 pixRasterop(pixd, h1, v1, w - 2 * h1, h - 2 * v1,
PIX_SET, NULL, 0, 0);
1575 if (hf2 < 1.0 && vf2 < 1.0)
1576 pixRasterop(pixd, h2, v2, w - 2 * h2, h - 2 * v2,
PIX_CLR, NULL, 0, 0);
1606l_int32 empty, same, niters;
1610 if (!pixs || pixGetDepth(pixs) != 1)
1611 return (
PIX *)ERROR_PTR(
"pixs undefined or not 1 bpp", __func__, NULL);
1613 return (
PIX *)ERROR_PTR(
"maxiters must be >= 0", __func__, NULL);
1614 if (maxiters == 0) maxiters = 50;
1616 pixZero(pixs, &empty);
1617 pix1 = pixCreateTemplate(pixs);
1618 if (empty)
return pix1;
1621 boxa = pixConnCompBB(pixs, 8);
1624 if (maxiters == 1)
return pix1;
1627 while (niters < maxiters) {
1629 boxa = pixConnCompBB(pix1, 8);
1630 pix2 = pixCopy(NULL, pix1);
1633 pixEqual(pix1, pix2, &same);
1636 L_INFO(
"%d iterations\n", __func__, niters - 1);
1640 L_INFO(
"maxiters = %d reached\n", __func__, niters);
1678l_int32 w1, h1, w2, h2, empty, count1, count3;
1682 return ERROR_INT(
"&fract not defined", __func__, 1);
1684 if (!pix1 || pixGetDepth(pix1) != 1)
1685 return ERROR_INT(
"pix1 not defined or not 1 bpp", __func__, 1);
1686 if (!pix2 || pixGetDepth(pix2) != 1)
1687 return ERROR_INT(
"pix2 not defined or not 1 bpp", __func__, 1);
1689 pixGetDimensions(pix1, &w1, &h1, NULL);
1690 pixGetDimensions(pix2, &w2, &h2, NULL);
1691 if (w1 != w2 || h1 != h2) {
1692 L_INFO(
"sizes unequal: (w1,w2) = (%d,%d), (h1,h2) = (%d,%d)\n",
1693 __func__, w1, w2, h1, h2);
1695 pixZero(pix1, &empty);
1696 if (empty)
return 0;
1697 pixZero(pix2, &empty);
1698 if (empty)
return 0;
1700 pix3 = pixCopy(NULL, pix1);
1701 pixAnd(pix3, pix3, pix2);
1702 pixCountPixels(pix1, &count1, NULL);
1703 pixCountPixels(pix3, &count3, NULL);
1704 *pfract = (l_float32)count3 / (l_float32)count1;
1732l_int32 w, h, wpl, nfullwords, extra, i, j;
1733l_int32 minx, miny, maxx, maxy;
1734l_uint32 result, mask;
1735l_uint32 *data, *line;
1738 if (ppixd) *ppixd = NULL;
1739 if (pbox) *pbox = NULL;
1740 if (!ppixd && !pbox)
1741 return ERROR_INT(
"no output requested", __func__, 1);
1742 if (!pixs || (pixGetDepth(pixs) != 1))
1743 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
1745 pixGetDimensions(pixs, &w, &h, NULL);
1746 nfullwords = w / 32;
1748 mask = ~rmask32[32 - extra];
1749 wpl = pixGetWpl(pixs);
1750 data = pixGetData(pixs);
1753 for (i = 0, miny = 0; i < h; i++, miny++) {
1754 line = data + i * wpl;
1755 for (j = 0; j < nfullwords; j++)
1758 result |= (line[j] & mask);
1766 for (i = h - 1, maxy = h - 1; i >= 0; i--, maxy--) {
1767 line = data + i * wpl;
1768 for (j = 0; j < nfullwords; j++)
1771 result |= (line[j] & mask);
1777 for (j = 0, minx = 0; j < w; j++, minx++) {
1778 for (i = 0; i < h; i++) {
1779 line = data + i * wpl;
1786 for (j = w - 1, maxx = w - 1; j >= 0; j--, maxx--) {
1787 for (i = 0; i < h; i++) {
1788 line = data + i * wpl;
1795 box = boxCreate(minx, miny, maxx - minx + 1, maxy - miny + 1);
1829l_int32 i, j, w, h, wpl, found;
1830l_uint32 *data, *line;
1833 return ERROR_INT(
"&canclip not defined", __func__, 1);
1835 if (!pixs || (pixGetDepth(pixs) != 1))
1836 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
1839 pixGetDimensions(pixs, &w, &h, NULL);
1840 data = pixGetData(pixs);
1841 wpl = pixGetWpl(pixs);
1843 for (j = 0; found == FALSE && j < w; j++)
1850 line = data + (h - 1) * wpl;
1852 for (j = 0; found == FALSE && j < w; j++)
1861 for (i = 0, line = data; found == FALSE && i < h; line += wpl, i++)
1869 for (i = 0, line = data; found == FALSE && i < h; line += wpl, i++)
1901l_int32 w, h, bx, by, bw, bh, cbw, cbh, left, right, top, bottom;
1904 if (ppixd) *ppixd = NULL;
1905 if (pboxd) *pboxd = NULL;
1906 if (!ppixd && !pboxd)
1907 return ERROR_INT(
"no output requested", __func__, 1);
1908 if (!pixs || (pixGetDepth(pixs) != 1))
1909 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
1914 pixGetDimensions(pixs, &w, &h, NULL);
1915 boxGetGeometry(boxs, &bx, &by, &bw, &bh);
1916 cbw = L_MIN(bw, w - bx);
1917 cbh = L_MIN(bh, h - by);
1918 if (cbw < 0 || cbh < 0)
1919 return ERROR_INT(
"box not within image", __func__, 1);
1920 boxt = boxCreate(bx, by, cbw, cbh);
1930 boxd = boxCreate(left, top, right - left + 1, bottom - top + 1);
1965l_int32 bx, by, bw, bh, x, xstart, xend, y, ystart, yend, wpl;
1966l_uint32 *data, *line;
1970 return ERROR_INT(
"&loc not defined", __func__, 1);
1972 if (!pixs || (pixGetDepth(pixs) != 1))
1973 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
1976 pixGetDimensions(pixs, &bw, &bh, NULL);
1978 if ((boxt = boxClipToRectangle(box, bw, bh)) == NULL)
1979 return ERROR_INT(
"invalid box", __func__, 1);
1980 boxGetGeometry(boxt, &bx, &by, &bw, &bh);
1990 data = pixGetData(pixs);
1991 wpl = pixGetWpl(pixs);
1993 for (x = xstart; x <= xend; x++) {
1994 for (y = ystart; y <= yend; y++) {
1995 line = data + y * wpl;
2003 for (x = xend; x >= xstart; x--) {
2004 for (y = ystart; y <= yend; y++) {
2005 line = data + y * wpl;
2013 for (y = ystart; y <= yend; y++) {
2014 line = data + y * wpl;
2015 for (x = xstart; x <= xend; x++) {
2023 for (y = yend; y >= ystart; y--) {
2024 line = data + y * wpl;
2025 for (x = xstart; x <= xend; x++) {
2033 return ERROR_INT(
"invalid scanflag", __func__, 1);
2083l_int32 w, h, bx, by, bw, bh, cbw, cbh, left, right, top, bottom;
2084l_int32 lfound, rfound, tfound, bfound, change;
2087 if (ppixd) *ppixd = NULL;
2088 if (pboxd) *pboxd = NULL;
2089 if (!ppixd && !pboxd)
2090 return ERROR_INT(
"no output requested", __func__, 1);
2091 if (!pixs || (pixGetDepth(pixs) != 1))
2092 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
2093 if (lowthresh < 1 || highthresh < 1 ||
2094 lowthresh > highthresh || maxwidth < 1)
2095 return ERROR_INT(
"invalid thresholds", __func__, 1);
2096 factor = L_MIN(1, factor);
2098 if (lowthresh == 1 && highthresh == 1)
2101 pixGetDimensions(pixs, &w, &h, NULL);
2103 boxGetGeometry(boxs, &bx, &by, &bw, &bh);
2104 cbw = L_MIN(bw, w - bx);
2105 cbh = L_MIN(bh, h - by);
2106 if (cbw < 0 || cbh < 0)
2107 return ERROR_INT(
"box not within image", __func__, 1);
2108 boxt = boxCreate(bx, by, cbw, cbh);
2110 boxt = boxCreate(0, 0, w, h);
2113 lfound = rfound = tfound = bfound = 0;
2114 while (!lfound || !rfound || !tfound || !bfound) {
2121 boxRelocateOneSide(boxt, boxt, left,
L_FROM_LEFT);
2137 boxRelocateOneSide(boxt, boxt, top,
L_FROM_TOP);
2145 boxRelocateOneSide(boxt, boxt, bottom,
L_FROM_BOT);
2150 lept_stderr(
"iter: %d %d %d %d\n", lfound, rfound, tfound, bfound);
2153 if (change == 0)
break;
2158 return ERROR_INT(
"not all edges found", __func__, 1);
2160 boxd = boxCreate(left, top, right - left + 1, bottom - top + 1);
2211l_int32 bx, by, bw, bh, foundmin, loc, sum, wpl;
2212l_int32 x, xstart, xend, y, ystart, yend;
2213l_uint32 *data, *line;
2217 return ERROR_INT(
"&ploc not defined", __func__, 1);
2219 if (!pixs || (pixGetDepth(pixs) != 1))
2220 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
2221 if (lowthresh < 1 || highthresh < 1 ||
2222 lowthresh > highthresh || maxwidth < 1)
2223 return ERROR_INT(
"invalid thresholds", __func__, 1);
2224 factor = L_MIN(1, factor);
2227 pixGetDimensions(pixs, &bw, &bh, NULL);
2229 if ((boxt = boxClipToRectangle(box, bw, bh)) == NULL)
2230 return ERROR_INT(
"invalid box", __func__, 1);
2231 boxGetGeometry(boxt, &bx, &by, &bw, &bh);
2241 data = pixGetData(pixs);
2242 wpl = pixGetWpl(pixs);
2245 for (x = xstart; x <= xend; x++) {
2247 for (y = ystart; y <= yend; y += factor) {
2248 line = data + y * wpl;
2252 if (!foundmin && sum < lowthresh)
2258 if (sum >= highthresh) {
2260 lept_stderr(
"Left: x = %d, loc = %d\n", x, loc);
2262 if (x - loc < maxwidth) {
2271 for (x = xend; x >= xstart; x--) {
2273 for (y = ystart; y <= yend; y += factor) {
2274 line = data + y * wpl;
2278 if (!foundmin && sum < lowthresh)
2284 if (sum >= highthresh) {
2286 lept_stderr(
"Right: x = %d, loc = %d\n", x, loc);
2288 if (loc - x < maxwidth) {
2297 for (y = ystart; y <= yend; y++) {
2299 line = data + y * wpl;
2300 for (x = xstart; x <= xend; x += factor) {
2304 if (!foundmin && sum < lowthresh)
2310 if (sum >= highthresh) {
2312 lept_stderr(
"Top: y = %d, loc = %d\n", y, loc);
2314 if (y - loc < maxwidth) {
2323 for (y = yend; y >= ystart; y--) {
2325 line = data + y * wpl;
2326 for (x = xstart; x <= xend; x += factor) {
2330 if (!foundmin && sum < lowthresh)
2336 if (sum >= highthresh) {
2338 lept_stderr(
"Bottom: y = %d, loc = %d\n", y, loc);
2340 if (loc - y < maxwidth) {
2349 return ERROR_INT(
"invalid scanflag", __func__, 1);
2388l_int32 i, w, h, d, xmin, ymin, xmax, ymax, npts, direction;
2396 return (
NUMA *)ERROR_PTR(
"pixs not defined", __func__, NULL);
2397 pixGetDimensions(pixs, &w, &h, &d);
2398 if (d != 1 && d != 8)
2399 return (
NUMA *)ERROR_PTR(
"d not 1 or 8 bpp", __func__, NULL);
2400 if (pixGetColormap(pixs))
2401 return (
NUMA *)ERROR_PTR(
"pixs has a colormap", __func__, NULL);
2403 L_WARNING(
"factor must be >= 1; setting to 1\n", __func__);
2408 x1 = L_MAX(0, L_MIN(x1, w - 1));
2409 x2 = L_MAX(0, L_MIN(x2, w - 1));
2410 y1 = L_MAX(0, L_MIN(y1, h - 1));
2411 y2 = L_MAX(0, L_MIN(y2, h - 1));
2413 if (x1 == x2 && y1 == y2) {
2414 pixGetPixel(pixs, x1, y1, &val);
2416 numaAddNumber(na, val);
2429 xmin = L_MIN(x1, x2);
2430 xmax = L_MAX(x1, x2);
2431 numaSetParameters(na, xmin, factor);
2432 for (i = xmin; i <= xmax; i += factor) {
2433 pixGetPixel(pixs, i, y1, &val);
2434 numaAddNumber(na, val);
2437 ymin = L_MIN(y1, y2);
2438 ymax = L_MAX(y1, y2);
2439 numaSetParameters(na, ymin, factor);
2440 for (i = ymin; i <= ymax; i += factor) {
2441 pixGetPixel(pixs, x1, i, &val);
2442 numaAddNumber(na, val);
2445 slope = (l_float64)((y2 - y1) / (x2 - x1));
2446 if (L_ABS(slope) < 1.0) {
2447 xmin = L_MIN(x1, x2);
2448 xmax = L_MAX(x1, x2);
2449 ymin = (xmin == x1) ? y1 : y2;
2450 ymax = (ymin == y1) ? y2 : y1;
2451 pta = generatePtaLine(xmin, ymin, xmax, ymax);
2452 numaSetParameters(na, xmin, (l_float32)factor);
2454 ymin = L_MIN(y1, y2);
2455 ymax = L_MAX(y1, y2);
2456 xmin = (ymin == y1) ? x1 : x2;
2457 xmax = (xmin == x1) ? x2 : x1;
2458 pta = generatePtaLine(xmin, ymin, xmax, ymax);
2459 numaSetParameters(na, ymin, (l_float32)factor);
2461 npts = ptaGetCount(pta);
2462 for (i = 0; i < npts; i += factor) {
2463 ptaGetPt(pta, i, &x, &y);
2464 pixGetPixel(pixs, (l_int32)x, (l_int32)y, &val);
2465 numaAddNumber(na, val);
2469 pixPlotAlongPta(pixs, pta, GPLOT_PNG, NULL);
2506l_int32 i, j, w, h, d, direction, count, wpl;
2507l_uint32 *data, *line;
2511 return ERROR_INT(
"pixs not defined", __func__, 1);
2512 pixGetDimensions(pixs, &w, &h, &d);
2513 if (d != 1 && d != 8)
2514 return ERROR_INT(
"d not 1 or 8 bpp", __func__, 1);
2515 if (pixGetColormap(pixs))
2516 return ERROR_INT(
"pixs has a colormap", __func__, 1);
2517 if (x1 > x2 || y1 > y2)
2518 return ERROR_INT(
"x1 > x2 or y1 > y2", __func__, 1);
2522 x2 = L_MIN(w - 1, x2);
2523 y1 = L_MAX(0, L_MIN(y1, h - 1));
2525 }
else if (x1 == x2) {
2527 y2 = L_MIN(h - 1, y2);
2528 x1 = L_MAX(0, L_MIN(x1, w - 1));
2531 return ERROR_INT(
"line neither horiz nor vert", __func__, 1);
2535 L_WARNING(
"factor must be >= 1; setting to 1\n", __func__);
2539 data = pixGetData(pixs);
2540 wpl = pixGetWpl(pixs);
2544 line = data + y1 * wpl;
2545 for (j = x1, count = 0; j <= x2; count++, j += factor) {
2552 for (i = y1, count = 0; i <= y2; count++, i += factor) {
2553 line = data + i * wpl;
2561 return sum / (l_float32)count;
2604l_int32 i, j, w, h, d, start, end;
2610 return (
NUMA *)ERROR_PTR(
"pixs not defined", __func__, NULL);
2611 if (fract < 0.0 || fract > 1.0)
2612 return (
NUMA *)ERROR_PTR(
"fract < 0.0 or > 1.0", __func__, NULL);
2614 return (
NUMA *)ERROR_PTR(
"invalid direction", __func__, NULL);
2615 if (first < 0) first = 0;
2617 return (
NUMA *)ERROR_PTR(
"last must be >= first", __func__, NULL);
2619 L_WARNING(
"factor1 must be >= 1; setting to 1\n", __func__);
2623 L_WARNING(
"factor2 must be >= 1; setting to 1\n", __func__);
2628 if (pixGetColormap(pixs))
2631 pixr = pixClone(pixs);
2632 pixGetDimensions(pixr, &w, &h, &d);
2634 pixg = pixClone(pixr);
2636 pixg = pixConvertTo8(pixr, 0);
2638 nad = numaCreate(0);
2639 numaSetParameters(nad, 0, factor2);
2641 start = (l_int32)(0.5 * (1.0 - fract) * (l_float32)w);
2644 L_WARNING(
"last > h - 1; clipping\n", __func__);
2647 for (i = first; i <= last; i += factor2) {
2649 numaAddNumber(nad, ave);
2652 start = (l_int32)(0.5 * (1.0 - fract) * (l_float32)h);
2655 L_WARNING(
"last > w - 1; clipping\n", __func__);
2658 for (j = first; j <= last; j += factor2) {
2660 numaAddNumber(nad, ave);
2714 l_int32 minreversal,
2718l_int32 i, j, w, h, d, start, end, nr;
2723 return (
NUMA *)ERROR_PTR(
"pixs not defined", __func__, NULL);
2724 if (fract < 0.0 || fract > 1.0)
2725 return (
NUMA *)ERROR_PTR(
"fract < 0.0 or > 1.0", __func__, NULL);
2727 return (
NUMA *)ERROR_PTR(
"invalid direction", __func__, NULL);
2728 if (first < 0) first = 0;
2730 return (
NUMA *)ERROR_PTR(
"last must be >= first", __func__, NULL);
2732 L_WARNING(
"factor1 must be >= 1; setting to 1\n", __func__);
2736 L_WARNING(
"factor2 must be >= 1; setting to 1\n", __func__);
2741 if (pixGetColormap(pixs))
2744 pixr = pixClone(pixs);
2745 pixGetDimensions(pixr, &w, &h, &d);
2747 pixg = pixClone(pixr);
2750 pixg = pixConvertTo8(pixr, 0);
2753 nad = numaCreate(0);
2754 numaSetParameters(nad, 0, factor2);
2756 start = (l_int32)(0.5 * (1.0 - fract) * (l_float32)w);
2759 L_WARNING(
"last > h - 1; clipping\n", __func__);
2762 for (i = first; i <= last; i += factor2) {
2764 numaCountReversals(naline, minreversal, &nr, NULL);
2765 numaAddNumber(nad, nr);
2766 numaDestroy(&naline);
2769 start = (l_int32)(0.5 * (1.0 - fract) * (l_float32)h);
2772 L_WARNING(
"last > w - 1; clipping\n", __func__);
2775 for (j = first; j <= last; j += factor2) {
2777 numaCountReversals(naline, minreversal, &nr, NULL);
2778 numaAddNumber(nad, nr);
2779 numaDestroy(&naline);
2824l_int32 i, j, w, h, cmin, cmax, maxloc, n, x, y;
2826l_float32 norm, rootvar;
2828l_float64 sum1, sum2, ave, var;
2833 return ERROR_INT(
"&nad not defined", __func__, 1);
2835 if (!pixs || pixGetDepth(pixs) != 8)
2836 return ERROR_INT(
"pixs not defined or not 8bpp", __func__, 1);
2838 return ERROR_INT(
"window size must be > 1", __func__, 1);
2840 return ERROR_INT(
"invalid direction", __func__, 1);
2841 pixGetDimensions(pixs, &w, &h, NULL);
2843 if (loc < 0 || loc > maxloc)
2844 return ERROR_INT(
"invalid line position", __func__, 1);
2847 cmin = L_MIN(c1, c2);
2848 cmax = L_MAX(c1, c2);
2850 cmin = L_MAX(0, L_MIN(cmin, maxloc));
2851 cmax = L_MAX(0, L_MIN(cmax, maxloc));
2852 n = cmax - cmin + 1;
2857 for (i = cmin; i <= cmax; i++)
2858 ptaAddPt(pta, i, loc);
2860 for (i = cmin; i <= cmax; i++)
2861 ptaAddPt(pta, loc, i);
2865 na1 = numaCreate(n);
2866 numaSetParameters(na1, cmin, 1);
2867 for (i = 0; i < n; i++) {
2868 ptaGetIPt(pta, i, &x, &y);
2869 pixGetPixel(pixs, x, y, &val);
2870 numaAddNumber(na1, val);
2872 array = numaGetFArray(na1,
L_NOCOPY);
2876 nad = numaCreate(n);
2878 numaSetParameters(nad, cmin + size / 2, 1);
2879 norm = 1.0f / (l_float32)size;
2880 for (i = 0; i < n - size; i++) {
2882 for (j = 0; j < size; j++) {
2885 sum2 += (l_float64)(val) * val;
2888 var = norm * sum2 - ave * ave;
2891 rootvar = (l_float32)sqrt(var);
2892 numaAddNumber(nad, rootvar);
2946l_int32 i, j, w, h, d, x, y, n, dir, found, minval, maxval, negloc, posloc;
2952 if (pnamin) *pnamin = NULL;
2953 if (pnamax) *pnamax = NULL;
2954 if (pminave) *pminave = UNDEF;
2955 if (pmaxave) *pmaxave = UNDEF;
2956 if (!pnamin && !pnamax && !pminave && !pmaxave)
2957 return ERROR_INT(
"no output requested", __func__, 1);
2959 return ERROR_INT(
"pixs not defined", __func__, 1);
2960 pixGetDimensions(pixs, &w, &h, &d);
2961 if (d != 8 || pixGetColormap(pixs))
2962 return ERROR_INT(
"pixs not 8 bpp or has colormap", __func__, 1);
2966 return ERROR_INT(
"invalid direction", __func__, 1);
2968 pta = generatePtaLine(x1, y1, x2, y2);
2969 n = ptaGetCount(pta);
2970 dir = (L_ABS(x1 - x2) == n - 1) ? L_HORIZ : L_VERT;
2971 namin = numaCreate(n);
2972 namax = numaCreate(n);
2979 for (i = 0; i < n; i++) {
2980 ptaGetIPt(pta, i, &x, &y);
2984 if (dir == L_HORIZ) {
2985 if (x < 0 || x >= w)
continue;
2986 for (j = negloc; j <= posloc; j++) {
2987 if (y + j < 0 || y + j >= h)
continue;
2988 pixGetPixel(pixs, x, y + j, &val);
2990 if (val < minval) minval = val;
2991 if (val > maxval) maxval = val;
2994 if (y < 0 || y >= h)
continue;
2995 for (j = negloc; j <= posloc; j++) {
2996 if (x + j < 0 || x + j >= w)
continue;
2997 pixGetPixel(pixs, x + j, y, &val);
2999 if (val < minval) minval = val;
3000 if (val > maxval) maxval = val;
3004 numaAddNumber(namin, minval);
3005 numaAddNumber(namax, maxval);
3009 n = numaGetCount(namin);
3011 numaDestroy(&namin);
3012 numaDestroy(&namax);
3014 return ERROR_INT(
"no output from this line", __func__, 1);
3018 numaGetSum(namin, &sum);
3022 numaGetSum(namax, &sum);
3028 numaDestroy(&namin);
3032 numaDestroy(&namax);
3057l_int32 i, j, k, m, w, h, wpl, val;
3059l_uint32 *datas, *datad, *lines, *lined;
3063 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
3064 if (pixGetDepth(pixs) != 8)
3065 return (
PIX *)ERROR_PTR(
"pixs not 8 bpp", __func__, NULL);
3066 if (pixGetColormap(pixs))
3067 return (
PIX *)ERROR_PTR(
"pixs has a colormap", __func__, NULL);
3069 pixGetDimensions(pixs, &w, &h, NULL);
3070 pixd = pixCreateTemplate(pixs);
3071 datas = pixGetData(pixs);
3072 datad = pixGetData(pixd);
3073 wpl = pixGetWpl(pixs);
3074 for (i = 0; i < h; i++) {
3075 memset(histo, 0, 1024);
3076 lines = datas + i * wpl;
3077 lined = datad + i * wpl;
3078 for (j = 0; j < w; j++) {
3082 for (m = 0, j = 0; m < 256; m++) {
3083 for (k = 0; k < histo[m]; k++, j++)
3108l_int32 i, j, k, m, w, h, val;
3110void **lines8, **lined8;
3114 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
3115 if (pixGetDepth(pixs) != 8)
3116 return (
PIX *)ERROR_PTR(
"pixs not 8 bpp", __func__, NULL);
3117 if (pixGetColormap(pixs))
3118 return (
PIX *)ERROR_PTR(
"pixs has a colormap", __func__, NULL);
3120 pixGetDimensions(pixs, &w, &h, NULL);
3121 pixd = pixCreateTemplate(pixs);
3122 lines8 = pixGetLinePtrs(pixs, NULL);
3123 lined8 = pixGetLinePtrs(pixd, NULL);
3124 for (j = 0; j < w; j++) {
3125 memset(histo, 0, 1024);
3126 for (i = 0; i < h; i++) {
3130 for (m = 0, i = 0; m < 256; m++) {
3131 for (k = 0; k < histo[m]; k++, i++)
#define GET_DATA_BYTE(pdata, n)
#define SET_DATA_BYTE(pdata, n, val)
#define GET_DATA_BIT(pdata, n)
l_ok pixWindowedVarianceOnLine(PIX *pixs, l_int32 dir, l_int32 loc, l_int32 c1, l_int32 c2, l_int32 size, NUMA **pnad)
pixWindowedVarianceOnLine()
PIX * pixClipRectangleWithBorder(PIX *pixs, BOX *box, l_int32 maxbord, BOX **pboxn)
pixClipRectangleWithBorder()
l_ok pixFractionFgInMask(PIX *pix1, PIX *pix2, l_float32 *pfract)
pixFractionFgInMask()
l_ok pixFindAreaPerimRatio(PIX *pixs, l_int32 *tab, l_float32 *pfract)
pixFindAreaPerimRatio()
l_ok pixFindPerimToAreaRatio(PIX *pixs, l_int32 *tab, l_float32 *pfract)
pixFindPerimToAreaRatio()
NUMA * pixaFindWidthHeightRatio(PIXA *pixa)
pixaFindWidthHeightRatio()
PIX * pixClipRectangle(PIX *pixs, BOX *box, BOX **pboxc)
pixClipRectangle()
PIX * pixClipMasked(PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_uint32 outval)
pixClipMasked()
NUMA * pixaFindPerimToAreaRatio(PIXA *pixa)
pixaFindPerimToAreaRatio()
PIX * pixRankColumnTransform(PIX *pixs)
pixRankColumnTransform()
l_ok pixFindPerimSizeRatio(PIX *pixs, l_int32 *tab, l_float32 *pratio)
pixFindPerimSizeRatio()
PIX * pixMakeFrameMask(l_int32 w, l_int32 h, l_float32 hf1, l_float32 hf2, l_float32 vf1, l_float32 vf2)
pixMakeFrameMask()
NUMA * pixExtractOnLine(PIX *pixs, l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2, l_int32 factor)
pixExtractOnLine()
l_ok pixFindAreaFraction(PIX *pixs, l_int32 *tab, l_float32 *pfract)
pixFindAreaFraction()
l_ok pixScanForForeground(PIX *pixs, BOX *box, l_int32 scanflag, l_int32 *ploc)
pixScanForForeground()
NUMA * pixaFindAreaFraction(PIXA *pixa)
pixaFindAreaFraction()
PIXA * pixClipRectangles(PIX *pixs, BOXA *boxa)
pixClipRectangles()
l_ok pixClipBoxToEdges(PIX *pixs, BOX *boxs, l_int32 lowthresh, l_int32 highthresh, l_int32 maxwidth, l_int32 factor, PIX **ppixd, BOX **pboxd)
pixClipBoxToEdges()
PIX * pixResizeToMatch(PIX *pixs, PIX *pixt, l_int32 w, l_int32 h)
pixResizeToMatch()
l_float32 pixAverageOnLine(PIX *pixs, l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2, l_int32 factor)
pixAverageOnLine()
l_ok pixTestClipToForeground(PIX *pixs, l_int32 *pcanclip)
pixTestClipToForeground()
l_ok pixClipBoxToForeground(PIX *pixs, BOX *boxs, PIX **ppixd, BOX **pboxd)
pixClipBoxToForeground()
l_ok pixFindAreaFractionMasked(PIX *pixs, BOX *box, PIX *pixm, l_int32 *tab, l_float32 *pfract)
pixFindAreaFractionMasked()
PIX * pixMakeCoveringOfRectangles(PIX *pixs, l_int32 maxiters)
pixMakeCoveringOfRectangles()
l_ok pixScanForEdge(PIX *pixs, BOX *box, l_int32 lowthresh, l_int32 highthresh, l_int32 maxwidth, l_int32 factor, l_int32 scanflag, l_int32 *ploc)
pixScanForEdge()
NUMA * pixAverageIntensityProfile(PIX *pixs, l_float32 fract, l_int32 dir, l_int32 first, l_int32 last, l_int32 factor1, l_int32 factor2)
pixAverageIntensityProfile()
l_ok pixMinMaxNearLine(PIX *pixs, l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2, l_int32 dist, l_int32 direction, NUMA **pnamin, NUMA **pnamax, l_float32 *pminave, l_float32 *pmaxave)
pixMinMaxNearLine()
BOXA * pixFindRectangleComps(PIX *pixs, l_int32 dist, l_int32 minw, l_int32 minh)
pixFindRectangleComps()
PIX * pixCropToSize(PIX *pixs, l_int32 w, l_int32 h)
pixCropToSize()
l_ok pixClipToForeground(PIX *pixs, PIX **ppixd, BOX **pbox)
pixClipToForeground()
l_ok pixaFindDimensions(PIXA *pixa, NUMA **pnaw, NUMA **pnah)
pixaFindDimensions()
NUMA * pixaFindAreaFractionMasked(PIXA *pixa, PIX *pixm, l_int32 debug)
pixaFindAreaFractionMasked()
PIX * pixRankRowTransform(PIX *pixs)
pixRankRowTransform()
l_ok pixConformsToRectangle(PIX *pixs, BOX *box, l_int32 dist, l_int32 *pconforms)
pixConformsToRectangle()
l_ok pixFindOverlapFraction(PIX *pixs1, PIX *pixs2, l_int32 x2, l_int32 y2, l_int32 *tab, l_float32 *pratio, l_int32 *pnoverlap)
pixFindOverlapFraction()
l_ok pixCropToMatch(PIX *pixs1, PIX *pixs2, PIX **ppixd1, PIX **ppixd2)
pixCropToMatch()
PIX * pixMakeSymmetricMask(l_int32 w, l_int32 h, l_float32 hf, l_float32 vf, l_int32 type)
pixSelectComponentBySize()
NUMA * pixaFindPerimSizeRatio(PIXA *pixa)
pixaFindPerimSizeRatio()
NUMA * pixaFindWidthHeightProduct(PIXA *pixa)
pixaFindWidthHeightProduct()
NUMA * pixReversalProfile(PIX *pixs, l_float32 fract, l_int32 dir, l_int32 first, l_int32 last, l_int32 minreversal, l_int32 factor1, l_int32 factor2)
pixReversalProfile()
@ L_SORT_BY_MAX_DIMENSION
@ REMOVE_CMAP_TO_GRAYSCALE
@ L_SELECT_BY_MAX_DIMENSION