107#include <config_auto.h>
112#include "allheaders.h"
114static const l_uint32 rmask32[] = {0x0,
115 0x00000001, 0x00000003, 0x00000007, 0x0000000f,
116 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff,
117 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff,
118 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff,
119 0x0001ffff, 0x0003ffff, 0x0007ffff, 0x000fffff,
120 0x001fffff, 0x003fffff, 0x007fffff, 0x00ffffff,
121 0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff,
122 0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff};
148 if (pnaw) *pnaw = NULL;
149 if (pnah) *pnah = NULL;
151 return ERROR_INT(
"no output requested", __func__, 1);
153 return ERROR_INT(
"pixa not defined", __func__, 1);
155 n = pixaGetCount(pixa);
156 if (pnaw) *pnaw = numaCreate(n);
157 if (pnah) *pnah = numaCreate(n);
158 for (i = 0; i < n; i++) {
159 pixt = pixaGetPix(pixa, i,
L_CLONE);
160 pixGetDimensions(pixt, &w, &h, NULL);
162 numaAddNumber(*pnaw, w);
164 numaAddNumber(*pnah, h);
198 return ERROR_INT(
"&fract not defined", __func__, 1);
200 if (!pixs || pixGetDepth(pixs) != 1)
201 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
204 tab8 = makePixelSumTab8();
208 pixt = pixErodeBrick(NULL, pixs, 3, 3);
209 pixCountPixels(pixt, &nfg, tab8);
212 if (!tab) LEPT_FREE(tab8);
215 pixXor(pixt, pixt, pixs);
216 pixCountPixels(pixt, &nbound, tab8);
217 *pfract = (l_float32)nfg / (l_float32)nbound;
220 if (!tab) LEPT_FREE(tab8);
247 return (
NUMA *)ERROR_PTR(
"pixa not defined", __func__, NULL);
249 n = pixaGetCount(pixa);
251 tab = makePixelSumTab8();
252 for (i = 0; i < n; i++) {
253 pixt = pixaGetPix(pixa, i,
L_CLONE);
255 numaAddNumber(na, fract);
295 return ERROR_INT(
"&fract not defined", __func__, 1);
297 if (!pixs || pixGetDepth(pixs) != 1)
298 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
301 tab8 = makePixelSumTab8();
305 pixCountPixels(pixs, &nfg, tab8);
307 if (!tab) LEPT_FREE(tab8);
310 pixt = pixErodeBrick(NULL, pixs, 3, 3);
311 pixXor(pixt, pixt, pixs);
312 pixCountPixels(pixt, &nbound, tab8);
313 *pfract = (l_float32)nbound / (l_float32)nfg;
316 if (!tab) LEPT_FREE(tab8);
347 return (
NUMA *)ERROR_PTR(
"pixa not defined", __func__, NULL);
349 n = pixaGetCount(pixa);
351 tab = makePixelSumTab8();
352 for (i = 0; i < n; i++) {
353 pixt = pixaGetPix(pixa, i,
L_CLONE);
355 numaAddNumber(na, ratio);
395 return ERROR_INT(
"&ratio not defined", __func__, 1);
397 if (!pixs || pixGetDepth(pixs) != 1)
398 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
401 tab8 = makePixelSumTab8();
405 pixt = pixErodeBrick(NULL, pixs, 3, 3);
406 pixXor(pixt, pixt, pixs);
407 pixCountPixels(pixt, &nbound, tab8);
408 pixGetDimensions(pixs, &w, &h, NULL);
409 *pratio = (0.5f * nbound) / (l_float32)(w + h);
412 if (!tab) LEPT_FREE(tab8);
439 return (
NUMA *)ERROR_PTR(
"pixa not defined", __func__, NULL);
441 n = pixaGetCount(pixa);
443 tab = makePixelSumTab8();
444 for (i = 0; i < n; i++) {
445 pixt = pixaGetPix(pixa, i,
L_CLONE);
447 numaAddNumber(na, fract);
479 return ERROR_INT(
"&fract not defined", __func__, 1);
481 if (!pixs || pixGetDepth(pixs) != 1)
482 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
485 tab8 = makePixelSumTab8();
488 pixGetDimensions(pixs, &w, &h, NULL);
489 pixCountPixels(pixs, &sum, tab8);
490 *pfract = (l_float32)sum / (l_float32)(w * h);
492 if (!tab) LEPT_FREE(tab8);
529 return (
NUMA *)ERROR_PTR(
"pixa not defined", __func__, NULL);
530 if (!pixm || pixGetDepth(pixm) != 1)
531 return (
NUMA *)ERROR_PTR(
"pixm undefined or not 1 bpp", __func__, NULL);
533 n = pixaGetCount(pixa);
535 tab = makePixelSumTab8();
536 pixaIsFull(pixa, NULL, &full);
538 for (i = 0; i < n; i++) {
539 pix = pixaGetPix(pixa, i,
L_CLONE);
541 box = pixaGetBox(pixa, i,
L_CLONE);
543 numaAddNumber(na, fract);
552 pixGetDimensions(pixm, &w, &h, NULL);
553 pix1 = pixaDisplay(pixa, w, h);
554 pix2 = pixCreate(w, h, 8);
555 pixSetColormap(pix2, pixcmapCreate(8));
557 pixSetMaskedCmap(pix2, pix1, 0, 0, 255, 0, 0);
558 pixRasterop(pix1, 0, 0, w, h,
PIX_MASK, pixm, 0, 0);
559 pixSetMaskedCmap(pix2, pix1, 0, 0, 0, 255, 0);
560 pixDisplay(pix2, 100, 100);
600l_int32 x, y, w, h, sum, masksum;
605 return ERROR_INT(
"&fract not defined", __func__, 1);
607 if (!pixs || pixGetDepth(pixs) != 1)
608 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
609 if (!pixm || pixGetDepth(pixm) != 1)
610 return ERROR_INT(
"pixm not defined or not 1 bpp", __func__, 1);
613 tab8 = makePixelSumTab8();
618 boxGetGeometry(box, &x, &y, NULL, NULL);
619 pixGetDimensions(pixs, &w, &h, NULL);
621 pix1 = pixCopy(NULL, pixs);
622 pixRasterop(pix1, 0, 0, w, h,
PIX_MASK, pixm, x, y);
623 pixCountPixels(pixs, &sum, tab8);
626 if (!tab) LEPT_FREE(tab8);
629 pixCountPixels(pix1, &masksum, tab8);
630 *pfract = (l_float32)masksum / (l_float32)sum;
632 if (!tab) LEPT_FREE(tab8);
658 return (
NUMA *)ERROR_PTR(
"pixa not defined", __func__, NULL);
660 n = pixaGetCount(pixa);
662 for (i = 0; i < n; i++) {
663 pixt = pixaGetPix(pixa, i,
L_CLONE);
664 pixGetDimensions(pixt, &w, &h, NULL);
665 numaAddNumber(na, (l_float32)w / (l_float32)h);
692 return (
NUMA *)ERROR_PTR(
"pixa not defined", __func__, NULL);
694 n = pixaGetCount(pixa);
696 for (i = 0; i < n; i++) {
697 pixt = pixaGetPix(pixa, i,
L_CLONE);
698 pixGetDimensions(pixt, &w, &h, NULL);
699 numaAddNumber(na, w * h);
732l_int32 w, h, nintersect, nunion;
735 if (pnoverlap) *pnoverlap = 0;
737 return ERROR_INT(
"&ratio not defined", __func__, 1);
739 if (!pixs1 || pixGetDepth(pixs1) != 1)
740 return ERROR_INT(
"pixs1 not defined or not 1 bpp", __func__, 1);
741 if (!pixs2 || pixGetDepth(pixs2) != 1)
742 return ERROR_INT(
"pixs2 not defined or not 1 bpp", __func__, 1);
745 tab8 = makePixelSumTab8();
749 pixGetDimensions(pixs2, &w, &h, NULL);
750 pixt = pixCopy(NULL, pixs1);
751 pixRasterop(pixt, x2, y2, w, h,
PIX_MASK, pixs2, 0, 0);
752 pixCountPixels(pixt, &nintersect, tab8);
754 *pnoverlap = nintersect;
755 pixCopy(pixt, pixs1);
756 pixRasterop(pixt, x2, y2, w, h,
PIX_PAINT, pixs2, 0, 0);
757 pixCountPixels(pixt, &nunion, tab8);
758 if (!tab) LEPT_FREE(tab8);
762 *pratio = (l_float32)nintersect / (l_float32)nunion;
793l_int32 w, h, i, n, conforms;
799 if (!pixs || pixGetDepth(pixs) != 1)
800 return (
BOXA *)ERROR_PTR(
"pixs undefined or not 1 bpp", __func__, NULL);
802 return (
BOXA *)ERROR_PTR(
"dist must be >= 0", __func__, NULL);
803 if (minw <= 2 * dist && minh <= 2 * dist)
804 return (
BOXA *)ERROR_PTR(
"invalid parameters", __func__, NULL);
806 boxa = pixConnComp(pixs, &pixa, 8);
807 boxad = boxaCreate(0);
808 n = pixaGetCount(pixa);
809 for (i = 0; i < n; i++) {
810 pix = pixaGetPix(pixa, i,
L_CLONE);
811 pixGetDimensions(pix, &w, &h, NULL);
812 if (w < minw || h < minh) {
818 box = boxaGetBox(boxa, i,
L_COPY);
875 return ERROR_INT(
"&conforms not defined", __func__, 1);
877 if (!pixs || pixGetDepth(pixs) != 1)
878 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
880 return ERROR_INT(
"dist must be >= 0", __func__, 1);
881 pixGetDimensions(pixs, &w, &h, NULL);
882 if (w <= 2 * dist || h <= 2 * dist) {
883 L_WARNING(
"automatic conformation: distance too large\n", __func__);
892 pix1 = pixCopy(NULL, pixs);
897 pixInvert(pix1, pix1);
898 pix2 = pixExtractBorderConnComps(pix1, 4);
905 pixSetOrClearBorder(pix2, dist, dist, dist, dist,
PIX_CLR);
906 pixZero(pix2, &empty);
909 *pconforms = (empty) ? 1 : 0;
944 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
946 return (
PIX *)ERROR_PTR(
"boxa not defined", __func__, NULL);
949 return (
PIX *)ERROR_PTR(
"pixa1 not made", __func__, NULL);
950 pixGetDimensions(pixs, &w, &h, NULL);
951 pix1 = pixaDisplay(pixa1, w, h);
980 return (
PIXA *)ERROR_PTR(
"pixs not defined", __func__, NULL);
982 return (
PIXA *)ERROR_PTR(
"boxa not defined", __func__, NULL);
984 n = boxaGetCount(boxa);
985 pixa = pixaCreate(n);
986 for (i = 0; i < n; i++) {
987 box = boxaGetBox(boxa, i,
L_CLONE);
1039l_int32 w, h, d, bx, by, bw, bh;
1043 if (pboxc) *pboxc = NULL;
1045 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1047 return (
PIX *)ERROR_PTR(
"box not defined", __func__, NULL);
1050 pixGetDimensions(pixs, &w, &h, &d);
1051 if ((boxc = boxClipToRectangle(box, w, h)) == NULL) {
1052 L_WARNING(
"box doesn't overlap pix\n", __func__);
1055 boxGetGeometry(boxc, &bx, &by, &bw, &bh);
1058 if ((pixd = pixCreate(bw, bh, d)) == NULL) {
1060 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
1062 pixCopyResolution(pixd, pixs);
1063 pixCopyColormap(pixd, pixs);
1064 pixCopyText(pixd, pixs);
1065 pixRasterop(pixd, 0, 0, bw, bh,
PIX_SRC, pixs, bx, by);
1101l_int32 w, h, bx, by, bw, bh, bord;
1106 return (
PIX *)ERROR_PTR(
"&boxn not defined", __func__, NULL);
1109 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1111 return (
PIX *)ERROR_PTR(
"box not defined", __func__, NULL);
1114 pixGetDimensions(pixs, &w, &h, NULL);
1115 boxGetGeometry(box, &bx, &by, &bw, &bh);
1116 bord = L_MIN(bx, by);
1117 bord = L_MIN(bord, w - bx - bw);
1118 bord = L_MIN(bord, h - by - bh);
1119 bord = L_MIN(bord, maxbord);
1123 pixGetDimensions(pix1, &w, &h, NULL);
1124 *pboxn = boxCreate(0, 0, w, h);
1129 box1 = boxAdjustSides(NULL, box, -bord, bord, -bord, bord);
1132 *pboxn = boxCreate(bord, bord, bw, bh);
1173l_int32 wm, hm, index, rval, gval, bval;
1180 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1181 if (!pixm || pixGetDepth(pixm) != 1)
1182 return (
PIX *)ERROR_PTR(
"pixm undefined or not 1 bpp", __func__, NULL);
1185 pixGetDimensions(pixm, &wm, &hm, NULL);
1186 box = boxCreate(x, y, wm, hm);
1191 cmap = pixGetColormap(pixd);
1192 pixmi = pixInvert(NULL, pixm);
1194 extractRGBValues(outval, &rval, &gval, &bval);
1195 pixcmapGetNearestIndex(cmap, rval, gval, bval, &index);
1196 pixcmapGetColor(cmap, index, &rval, &gval, &bval);
1197 composeRGBPixel(rval, gval, bval, &pixel);
1198 pixPaintThroughMask(pixd, pixmi, 0, 0, pixel);
1200 pixPaintThroughMask(pixd, pixmi, 0, 0, outval);
1232l_int32 w1, h1, w2, h2, w, h;
1234 if (!ppixd1 || !ppixd2)
1235 return ERROR_INT(
"&pixd1 and &pixd2 not both defined", __func__, 1);
1236 *ppixd1 = *ppixd2 = NULL;
1237 if (!pixs1 || !pixs2)
1238 return ERROR_INT(
"pixs1 and pixs2 not defined", __func__, 1);
1240 pixGetDimensions(pixs1, &w1, &h1, NULL);
1241 pixGetDimensions(pixs2, &w2, &h2, NULL);
1247 if (*ppixd1 == NULL || *ppixd2 == NULL)
1248 return ERROR_INT(
"cropped image failure", __func__, 1);
1272l_int32 ws, hs, wd, hd, d;
1276 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1278 pixGetDimensions(pixs, &ws, &hs, &d);
1279 if (ws <= w && hs <= h)
1280 return pixClone(pixs);
1284 if ((pixd = pixCreate(wd, hd, d)) == NULL)
1285 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
1286 pixCopyResolution(pixd, pixs);
1287 pixCopyColormap(pixd, pixs);
1288 pixCopyText(pixd, pixs);
1289 pixCopyInputFormat(pixd, pixs);
1290 pixRasterop(pixd, 0, 0, wd, hd,
PIX_SRC, pixs, 0, 0);
1325l_int32 i, j, ws, hs, d;
1329 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1330 if (!pixt && (w <= 0 || h <= 0))
1331 return (
PIX *)ERROR_PTR(
"both w and h not > 0", __func__, NULL);
1334 pixGetDimensions(pixt, &w, &h, NULL);
1335 pixGetDimensions(pixs, &ws, &hs, &d);
1336 if (ws == w && hs == h)
1337 return pixCopy(NULL, pixs);
1339 if ((pixd = pixCreate(w, h, d)) == NULL)
1340 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
1341 pixCopyResolution(pixd, pixs);
1342 pixCopyColormap(pixd, pixs);
1343 pixCopyText(pixd, pixs);
1344 pixCopyInputFormat(pixd, pixs);
1345 pixRasterop(pixd, 0, 0, ws, hs,
PIX_SRC, pixs, 0, 0);
1346 if (ws >= w && hs >= h)
1351 for (j = ws; j < w; j++)
1352 pixRasterop(pixd, j, 0, 1, h,
PIX_SRC, pixd, ws - 1, 0);
1355 for (i = hs; i < h; i++)
1356 pixRasterop(pixd, 0, i, w, 1,
PIX_SRC, pixd, 0, hs - 1);
1387pixSelectComponentBySize(
PIX *pixs,
1390 l_int32 connectivity,
1393l_int32 n, empty, sorttype, index;
1399 if (pbox) *pbox = NULL;
1400 if (!pixs || pixGetDepth(pixs) != 1)
1401 return (
PIX *)ERROR_PTR(
"pixs undefined or not 1 bpp", __func__, NULL);
1413 return (
PIX *)ERROR_PTR(
"invalid selection type", __func__, NULL);
1414 if (connectivity != 4 && connectivity != 8)
1415 return (
PIX *)ERROR_PTR(
"connectivity not 4 or 8", __func__, NULL);
1416 pixZero(pixs, &empty);
1418 return (
PIX *)ERROR_PTR(
"no foreground pixels", __func__, NULL);
1420 boxa1 = pixConnComp(pixs, &pixa1, connectivity);
1421 n = boxaGetCount(boxa1);
1422 if (rankorder < 0 || rankorder >= n)
1425 pixd = pixaGetPix(pixa2, rankorder,
L_COPY);
1427 numaGetIValue(naindex, rankorder, &index);
1428 *pbox = boxaGetBox(boxa1, index,
L_COPY);
1431 numaDestroy(&naindex);
1432 boxaDestroy(&boxa1);
1433 pixaDestroy(&pixa1);
1434 pixaDestroy(&pixa2);
1458pixFilterComponentBySize(
PIX *pixs,
1461 l_int32 connectivity,
1468 if (!pixs || pixGetDepth(pixs) != 1)
1469 return (
PIX *)ERROR_PTR(
"pixs undefined or not 1 bpp", __func__, NULL);
1471 pix1 = pixSelectComponentBySize(pixs, rankorder, type, connectivity, &box);
1474 return (
PIX *)ERROR_PTR(
"pix1 not made", __func__, NULL);
1479 boxGetGeometry(box, &x, &y, &w, &h);
1480 pix2 = pixCreateTemplate(pixs);
1481 pixRasterop(pix2, x, y, w, h,
PIX_SRC, pix1, 0, 0);
1531 if (w <= 0 || h <= 0)
1532 return (
PIX *)ERROR_PTR(
"mask size 0", __func__, NULL);
1533 if (hf < 0.0 || hf > 1.0)
1534 return (
PIX *)ERROR_PTR(
"invalid horiz fractions", __func__, NULL);
1535 if (vf < 0.0 || vf > 1.0)
1536 return (
PIX *)ERROR_PTR(
"invalid vert fractions", __func__, NULL);
1543 return (
PIX *)ERROR_PTR(
"invalid type", __func__, NULL);
1587l_int32 h1, h2, v1, v2;
1590 if (w <= 0 || h <= 0)
1591 return (
PIX *)ERROR_PTR(
"mask size 0", __func__, NULL);
1592 if (hf1 < 0.0 || hf1 > 1.0 || hf2 < 0.0 || hf2 > 1.0)
1593 return (
PIX *)ERROR_PTR(
"invalid horiz fractions", __func__, NULL);
1594 if (vf1 < 0.0 || vf1 > 1.0 || vf2 < 0.0 || vf2 > 1.0)
1595 return (
PIX *)ERROR_PTR(
"invalid vert fractions", __func__, NULL);
1596 if (hf1 > hf2 || vf1 > vf2)
1597 return (
PIX *)ERROR_PTR(
"invalid relative sizes", __func__, NULL);
1599 pixd = pixCreate(w, h, 1);
1602 if (hf1 == 0.0 && vf1 == 0.0 && hf2 == 1.0 && vf2 == 1.0) {
1606 if (hf1 == hf2 && vf1 == vf2) {
1611 h1 = 0.5f * hf1 * w;
1612 h2 = 0.5f * hf2 * w;
1613 v1 = 0.5f * vf1 * h;
1614 v2 = 0.5f * vf2 * h;
1615 pixRasterop(pixd, h1, v1, w - 2 * h1, h - 2 * v1,
PIX_SET, NULL, 0, 0);
1616 if (hf2 < 1.0 && vf2 < 1.0)
1617 pixRasterop(pixd, h2, v2, w - 2 * h2, h - 2 * v2,
PIX_CLR, NULL, 0, 0);
1647l_int32 empty, same, niters;
1651 if (!pixs || pixGetDepth(pixs) != 1)
1652 return (
PIX *)ERROR_PTR(
"pixs undefined or not 1 bpp", __func__, NULL);
1654 return (
PIX *)ERROR_PTR(
"maxiters must be >= 0", __func__, NULL);
1655 if (maxiters == 0) maxiters = 50;
1657 pixZero(pixs, &empty);
1658 pix1 = pixCreateTemplate(pixs);
1659 if (empty)
return pix1;
1662 boxa = pixConnCompBB(pixs, 8);
1665 if (maxiters == 1)
return pix1;
1668 while (niters < maxiters) {
1670 boxa = pixConnCompBB(pix1, 8);
1671 pix2 = pixCopy(NULL, pix1);
1674 pixEqual(pix1, pix2, &same);
1677 L_INFO(
"%d iterations\n", __func__, niters - 1);
1681 L_INFO(
"maxiters = %d reached\n", __func__, niters);
1719l_int32 w1, h1, w2, h2, empty, count1, count3;
1723 return ERROR_INT(
"&fract not defined", __func__, 1);
1725 if (!pix1 || pixGetDepth(pix1) != 1)
1726 return ERROR_INT(
"pix1 not defined or not 1 bpp", __func__, 1);
1727 if (!pix2 || pixGetDepth(pix2) != 1)
1728 return ERROR_INT(
"pix2 not defined or not 1 bpp", __func__, 1);
1730 pixGetDimensions(pix1, &w1, &h1, NULL);
1731 pixGetDimensions(pix2, &w2, &h2, NULL);
1732 if (w1 != w2 || h1 != h2) {
1733 L_INFO(
"sizes unequal: (w1,w2) = (%d,%d), (h1,h2) = (%d,%d)\n",
1734 __func__, w1, w2, h1, h2);
1736 pixZero(pix1, &empty);
1737 if (empty)
return 0;
1738 pixZero(pix2, &empty);
1739 if (empty)
return 0;
1741 pix3 = pixCopy(NULL, pix1);
1742 pixAnd(pix3, pix3, pix2);
1743 pixCountPixels(pix1, &count1, NULL);
1744 pixCountPixels(pix3, &count3, NULL);
1745 *pfract = (l_float32)count3 / (l_float32)count1;
1773l_int32 w, h, wpl, nfullwords, extra, i, j;
1774l_int32 minx, miny, maxx, maxy;
1775l_uint32 result, mask;
1776l_uint32 *data, *line;
1779 if (ppixd) *ppixd = NULL;
1780 if (pbox) *pbox = NULL;
1781 if (!ppixd && !pbox)
1782 return ERROR_INT(
"no output requested", __func__, 1);
1783 if (!pixs || (pixGetDepth(pixs) != 1))
1784 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
1786 pixGetDimensions(pixs, &w, &h, NULL);
1787 nfullwords = w / 32;
1789 mask = ~rmask32[32 - extra];
1790 wpl = pixGetWpl(pixs);
1791 data = pixGetData(pixs);
1794 for (i = 0, miny = 0; i < h; i++, miny++) {
1795 line = data + i * wpl;
1796 for (j = 0; j < nfullwords; j++)
1799 result |= (line[j] & mask);
1807 for (i = h - 1, maxy = h - 1; i >= 0; i--, maxy--) {
1808 line = data + i * wpl;
1809 for (j = 0; j < nfullwords; j++)
1812 result |= (line[j] & mask);
1818 for (j = 0, minx = 0; j < w; j++, minx++) {
1819 for (i = 0; i < h; i++) {
1820 line = data + i * wpl;
1827 for (j = w - 1, maxx = w - 1; j >= 0; j--, maxx--) {
1828 for (i = 0; i < h; i++) {
1829 line = data + i * wpl;
1836 box = boxCreate(minx, miny, maxx - minx + 1, maxy - miny + 1);
1870l_int32 i, j, w, h, wpl, found;
1871l_uint32 *data, *line;
1874 return ERROR_INT(
"&canclip not defined", __func__, 1);
1876 if (!pixs || (pixGetDepth(pixs) != 1))
1877 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
1880 pixGetDimensions(pixs, &w, &h, NULL);
1881 data = pixGetData(pixs);
1882 wpl = pixGetWpl(pixs);
1884 for (j = 0; found == FALSE && j < w; j++)
1891 line = data + (h - 1) * wpl;
1893 for (j = 0; found == FALSE && j < w; j++)
1902 for (i = 0, line = data; found == FALSE && i < h; line += wpl, i++)
1910 for (i = 0, line = data; found == FALSE && i < h; line += wpl, i++)
1942l_int32 w, h, bx, by, bw, bh, cbw, cbh, left, right, top, bottom;
1945 if (ppixd) *ppixd = NULL;
1946 if (pboxd) *pboxd = NULL;
1947 if (!ppixd && !pboxd)
1948 return ERROR_INT(
"no output requested", __func__, 1);
1949 if (!pixs || (pixGetDepth(pixs) != 1))
1950 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
1955 pixGetDimensions(pixs, &w, &h, NULL);
1956 boxGetGeometry(boxs, &bx, &by, &bw, &bh);
1957 cbw = L_MIN(bw, w - bx);
1958 cbh = L_MIN(bh, h - by);
1959 if (cbw < 0 || cbh < 0)
1960 return ERROR_INT(
"box not within image", __func__, 1);
1961 boxt = boxCreate(bx, by, cbw, cbh);
1971 boxd = boxCreate(left, top, right - left + 1, bottom - top + 1);
2006l_int32 bx, by, bw, bh, x, xstart, xend, y, ystart, yend, wpl;
2007l_uint32 *data, *line;
2011 return ERROR_INT(
"&loc not defined", __func__, 1);
2013 if (!pixs || (pixGetDepth(pixs) != 1))
2014 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
2017 pixGetDimensions(pixs, &bw, &bh, NULL);
2019 if ((boxt = boxClipToRectangle(box, bw, bh)) == NULL)
2020 return ERROR_INT(
"invalid box", __func__, 1);
2021 boxGetGeometry(boxt, &bx, &by, &bw, &bh);
2031 data = pixGetData(pixs);
2032 wpl = pixGetWpl(pixs);
2034 for (x = xstart; x <= xend; x++) {
2035 for (y = ystart; y <= yend; y++) {
2036 line = data + y * wpl;
2044 for (x = xend; x >= xstart; x--) {
2045 for (y = ystart; y <= yend; y++) {
2046 line = data + y * wpl;
2054 for (y = ystart; y <= yend; y++) {
2055 line = data + y * wpl;
2056 for (x = xstart; x <= xend; x++) {
2064 for (y = yend; y >= ystart; y--) {
2065 line = data + y * wpl;
2066 for (x = xstart; x <= xend; x++) {
2074 return ERROR_INT(
"invalid scanflag", __func__, 1);
2124l_int32 w, h, bx, by, bw, bh, cbw, cbh, left, right, top, bottom;
2125l_int32 lfound, rfound, tfound, bfound, change;
2128 if (ppixd) *ppixd = NULL;
2129 if (pboxd) *pboxd = NULL;
2130 if (!ppixd && !pboxd)
2131 return ERROR_INT(
"no output requested", __func__, 1);
2132 if (!pixs || (pixGetDepth(pixs) != 1))
2133 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
2134 if (lowthresh < 1 || highthresh < 1 ||
2135 lowthresh > highthresh || maxwidth < 1)
2136 return ERROR_INT(
"invalid thresholds", __func__, 1);
2137 factor = L_MIN(1, factor);
2139 if (lowthresh == 1 && highthresh == 1)
2142 pixGetDimensions(pixs, &w, &h, NULL);
2144 boxGetGeometry(boxs, &bx, &by, &bw, &bh);
2145 cbw = L_MIN(bw, w - bx);
2146 cbh = L_MIN(bh, h - by);
2147 if (cbw < 0 || cbh < 0)
2148 return ERROR_INT(
"box not within image", __func__, 1);
2149 boxt = boxCreate(bx, by, cbw, cbh);
2151 boxt = boxCreate(0, 0, w, h);
2154 lfound = rfound = tfound = bfound = 0;
2155 while (!lfound || !rfound || !tfound || !bfound) {
2162 boxRelocateOneSide(boxt, boxt, left,
L_FROM_LEFT);
2178 boxRelocateOneSide(boxt, boxt, top,
L_FROM_TOP);
2186 boxRelocateOneSide(boxt, boxt, bottom,
L_FROM_BOT);
2191 lept_stderr(
"iter: %d %d %d %d\n", lfound, rfound, tfound, bfound);
2194 if (change == 0)
break;
2199 return ERROR_INT(
"not all edges found", __func__, 1);
2201 boxd = boxCreate(left, top, right - left + 1, bottom - top + 1);
2252l_int32 bx, by, bw, bh, foundmin, loc, sum, wpl;
2253l_int32 x, xstart, xend, y, ystart, yend;
2254l_uint32 *data, *line;
2258 return ERROR_INT(
"&ploc not defined", __func__, 1);
2260 if (!pixs || (pixGetDepth(pixs) != 1))
2261 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
2262 if (lowthresh < 1 || highthresh < 1 ||
2263 lowthresh > highthresh || maxwidth < 1)
2264 return ERROR_INT(
"invalid thresholds", __func__, 1);
2265 factor = L_MIN(1, factor);
2268 pixGetDimensions(pixs, &bw, &bh, NULL);
2270 if ((boxt = boxClipToRectangle(box, bw, bh)) == NULL)
2271 return ERROR_INT(
"invalid box", __func__, 1);
2272 boxGetGeometry(boxt, &bx, &by, &bw, &bh);
2282 data = pixGetData(pixs);
2283 wpl = pixGetWpl(pixs);
2286 for (x = xstart; x <= xend; x++) {
2288 for (y = ystart; y <= yend; y += factor) {
2289 line = data + y * wpl;
2293 if (!foundmin && sum < lowthresh)
2299 if (sum >= highthresh) {
2301 lept_stderr(
"Left: x = %d, loc = %d\n", x, loc);
2303 if (x - loc < maxwidth) {
2312 for (x = xend; x >= xstart; x--) {
2314 for (y = ystart; y <= yend; y += factor) {
2315 line = data + y * wpl;
2319 if (!foundmin && sum < lowthresh)
2325 if (sum >= highthresh) {
2327 lept_stderr(
"Right: x = %d, loc = %d\n", x, loc);
2329 if (loc - x < maxwidth) {
2338 for (y = ystart; y <= yend; y++) {
2340 line = data + y * wpl;
2341 for (x = xstart; x <= xend; x += factor) {
2345 if (!foundmin && sum < lowthresh)
2351 if (sum >= highthresh) {
2353 lept_stderr(
"Top: y = %d, loc = %d\n", y, loc);
2355 if (y - loc < maxwidth) {
2364 for (y = yend; y >= ystart; y--) {
2366 line = data + y * wpl;
2367 for (x = xstart; x <= xend; x += factor) {
2371 if (!foundmin && sum < lowthresh)
2377 if (sum >= highthresh) {
2379 lept_stderr(
"Bottom: y = %d, loc = %d\n", y, loc);
2381 if (loc - y < maxwidth) {
2390 return ERROR_INT(
"invalid scanflag", __func__, 1);
2429l_int32 i, w, h, d, xmin, ymin, xmax, ymax, npts, direction;
2437 return (
NUMA *)ERROR_PTR(
"pixs not defined", __func__, NULL);
2438 pixGetDimensions(pixs, &w, &h, &d);
2439 if (d != 1 && d != 8)
2440 return (
NUMA *)ERROR_PTR(
"d not 1 or 8 bpp", __func__, NULL);
2441 if (pixGetColormap(pixs))
2442 return (
NUMA *)ERROR_PTR(
"pixs has a colormap", __func__, NULL);
2444 L_WARNING(
"factor must be >= 1; setting to 1\n", __func__);
2449 x1 = L_MAX(0, L_MIN(x1, w - 1));
2450 x2 = L_MAX(0, L_MIN(x2, w - 1));
2451 y1 = L_MAX(0, L_MIN(y1, h - 1));
2452 y2 = L_MAX(0, L_MIN(y2, h - 1));
2454 if (x1 == x2 && y1 == y2) {
2455 pixGetPixel(pixs, x1, y1, &val);
2457 numaAddNumber(na, val);
2470 xmin = L_MIN(x1, x2);
2471 xmax = L_MAX(x1, x2);
2472 numaSetParameters(na, xmin, factor);
2473 for (i = xmin; i <= xmax; i += factor) {
2474 pixGetPixel(pixs, i, y1, &val);
2475 numaAddNumber(na, val);
2478 ymin = L_MIN(y1, y2);
2479 ymax = L_MAX(y1, y2);
2480 numaSetParameters(na, ymin, factor);
2481 for (i = ymin; i <= ymax; i += factor) {
2482 pixGetPixel(pixs, x1, i, &val);
2483 numaAddNumber(na, val);
2486 slope = (l_float64)((y2 - y1) / (x2 - x1));
2487 if (L_ABS(slope) < 1.0) {
2488 xmin = L_MIN(x1, x2);
2489 xmax = L_MAX(x1, x2);
2490 ymin = (xmin == x1) ? y1 : y2;
2491 ymax = (ymin == y1) ? y2 : y1;
2492 pta = generatePtaLine(xmin, ymin, xmax, ymax);
2493 numaSetParameters(na, xmin, (l_float32)factor);
2495 ymin = L_MIN(y1, y2);
2496 ymax = L_MAX(y1, y2);
2497 xmin = (ymin == y1) ? x1 : x2;
2498 xmax = (xmin == x1) ? x2 : x1;
2499 pta = generatePtaLine(xmin, ymin, xmax, ymax);
2500 numaSetParameters(na, ymin, (l_float32)factor);
2502 npts = ptaGetCount(pta);
2503 for (i = 0; i < npts; i += factor) {
2504 ptaGetPt(pta, i, &x, &y);
2505 pixGetPixel(pixs, (l_int32)x, (l_int32)y, &val);
2506 numaAddNumber(na, val);
2510 pixPlotAlongPta(pixs, pta, GPLOT_PNG, NULL);
2547l_int32 i, j, w, h, d, direction, count, wpl;
2548l_uint32 *data, *line;
2552 return ERROR_INT(
"pixs not defined", __func__, 1);
2553 pixGetDimensions(pixs, &w, &h, &d);
2554 if (d != 1 && d != 8)
2555 return ERROR_INT(
"d not 1 or 8 bpp", __func__, 1);
2556 if (pixGetColormap(pixs))
2557 return ERROR_INT(
"pixs has a colormap", __func__, 1);
2558 if (x1 > x2 || y1 > y2)
2559 return ERROR_INT(
"x1 > x2 or y1 > y2", __func__, 1);
2563 x2 = L_MIN(w - 1, x2);
2564 y1 = L_MAX(0, L_MIN(y1, h - 1));
2566 }
else if (x1 == x2) {
2568 y2 = L_MIN(h - 1, y2);
2569 x1 = L_MAX(0, L_MIN(x1, w - 1));
2572 return ERROR_INT(
"line neither horiz nor vert", __func__, 1);
2576 L_WARNING(
"factor must be >= 1; setting to 1\n", __func__);
2580 data = pixGetData(pixs);
2581 wpl = pixGetWpl(pixs);
2585 line = data + y1 * wpl;
2586 for (j = x1, count = 0; j <= x2; count++, j += factor) {
2593 for (i = y1, count = 0; i <= y2; count++, i += factor) {
2594 line = data + i * wpl;
2602 return sum / (l_float32)count;
2645l_int32 i, j, w, h, d, start, end;
2651 return (
NUMA *)ERROR_PTR(
"pixs not defined", __func__, NULL);
2652 if (fract < 0.0 || fract > 1.0)
2653 return (
NUMA *)ERROR_PTR(
"fract < 0.0 or > 1.0", __func__, NULL);
2655 return (
NUMA *)ERROR_PTR(
"invalid direction", __func__, NULL);
2656 if (first < 0) first = 0;
2658 return (
NUMA *)ERROR_PTR(
"last must be >= first", __func__, NULL);
2660 L_WARNING(
"factor1 must be >= 1; setting to 1\n", __func__);
2664 L_WARNING(
"factor2 must be >= 1; setting to 1\n", __func__);
2669 if (pixGetColormap(pixs))
2672 pixr = pixClone(pixs);
2673 pixGetDimensions(pixr, &w, &h, &d);
2675 pixg = pixClone(pixr);
2677 pixg = pixConvertTo8(pixr, 0);
2679 nad = numaCreate(0);
2680 numaSetParameters(nad, 0, factor2);
2682 start = (l_int32)(0.5 * (1.0 - fract) * (l_float32)w);
2685 L_WARNING(
"last > h - 1; clipping\n", __func__);
2688 for (i = first; i <= last; i += factor2) {
2690 numaAddNumber(nad, ave);
2693 start = (l_int32)(0.5 * (1.0 - fract) * (l_float32)h);
2696 L_WARNING(
"last > w - 1; clipping\n", __func__);
2699 for (j = first; j <= last; j += factor2) {
2701 numaAddNumber(nad, ave);
2755 l_int32 minreversal,
2759l_int32 i, j, w, h, d, start, end, nr;
2764 return (
NUMA *)ERROR_PTR(
"pixs not defined", __func__, NULL);
2765 if (fract < 0.0 || fract > 1.0)
2766 return (
NUMA *)ERROR_PTR(
"fract < 0.0 or > 1.0", __func__, NULL);
2768 return (
NUMA *)ERROR_PTR(
"invalid direction", __func__, NULL);
2769 if (first < 0) first = 0;
2771 return (
NUMA *)ERROR_PTR(
"last must be >= first", __func__, NULL);
2773 L_WARNING(
"factor1 must be >= 1; setting to 1\n", __func__);
2777 L_WARNING(
"factor2 must be >= 1; setting to 1\n", __func__);
2782 if (pixGetColormap(pixs))
2785 pixr = pixClone(pixs);
2786 pixGetDimensions(pixr, &w, &h, &d);
2788 pixg = pixClone(pixr);
2791 pixg = pixConvertTo8(pixr, 0);
2794 nad = numaCreate(0);
2795 numaSetParameters(nad, 0, factor2);
2797 start = (l_int32)(0.5 * (1.0 - fract) * (l_float32)w);
2800 L_WARNING(
"last > h - 1; clipping\n", __func__);
2803 for (i = first; i <= last; i += factor2) {
2805 numaCountReversals(naline, minreversal, &nr, NULL);
2806 numaAddNumber(nad, nr);
2807 numaDestroy(&naline);
2810 start = (l_int32)(0.5 * (1.0 - fract) * (l_float32)h);
2813 L_WARNING(
"last > w - 1; clipping\n", __func__);
2816 for (j = first; j <= last; j += factor2) {
2818 numaCountReversals(naline, minreversal, &nr, NULL);
2819 numaAddNumber(nad, nr);
2820 numaDestroy(&naline);
2865l_int32 i, j, w, h, cmin, cmax, maxloc, n, x, y;
2867l_float32 norm, rootvar;
2869l_float64 sum1, sum2, ave, var;
2874 return ERROR_INT(
"&nad not defined", __func__, 1);
2876 if (!pixs || pixGetDepth(pixs) != 8)
2877 return ERROR_INT(
"pixs not defined or not 8bpp", __func__, 1);
2879 return ERROR_INT(
"window size must be > 1", __func__, 1);
2881 return ERROR_INT(
"invalid direction", __func__, 1);
2882 pixGetDimensions(pixs, &w, &h, NULL);
2884 if (loc < 0 || loc > maxloc)
2885 return ERROR_INT(
"invalid line position", __func__, 1);
2888 cmin = L_MIN(c1, c2);
2889 cmax = L_MAX(c1, c2);
2891 cmin = L_MAX(0, L_MIN(cmin, maxloc));
2892 cmax = L_MAX(0, L_MIN(cmax, maxloc));
2893 n = cmax - cmin + 1;
2898 for (i = cmin; i <= cmax; i++)
2899 ptaAddPt(pta, i, loc);
2901 for (i = cmin; i <= cmax; i++)
2902 ptaAddPt(pta, loc, i);
2906 na1 = numaCreate(n);
2907 numaSetParameters(na1, cmin, 1);
2908 for (i = 0; i < n; i++) {
2909 ptaGetIPt(pta, i, &x, &y);
2910 pixGetPixel(pixs, x, y, &val);
2911 numaAddNumber(na1, val);
2913 array = numaGetFArray(na1,
L_NOCOPY);
2917 nad = numaCreate(n);
2919 numaSetParameters(nad, cmin + size / 2, 1);
2920 norm = 1.0f / (l_float32)size;
2921 for (i = 0; i < n - size; i++) {
2923 for (j = 0; j < size; j++) {
2926 sum2 += (l_float64)(val) * val;
2929 var = norm * sum2 - ave * ave;
2932 rootvar = (l_float32)sqrt(var);
2933 numaAddNumber(nad, rootvar);
2987l_int32 i, j, w, h, d, x, y, n, dir, found, minval, maxval, negloc, posloc;
2993 if (pnamin) *pnamin = NULL;
2994 if (pnamax) *pnamax = NULL;
2995 if (pminave) *pminave = UNDEF;
2996 if (pmaxave) *pmaxave = UNDEF;
2997 if (!pnamin && !pnamax && !pminave && !pmaxave)
2998 return ERROR_INT(
"no output requested", __func__, 1);
3000 return ERROR_INT(
"pixs not defined", __func__, 1);
3001 pixGetDimensions(pixs, &w, &h, &d);
3002 if (d != 8 || pixGetColormap(pixs))
3003 return ERROR_INT(
"pixs not 8 bpp or has colormap", __func__, 1);
3007 return ERROR_INT(
"invalid direction", __func__, 1);
3009 pta = generatePtaLine(x1, y1, x2, y2);
3010 n = ptaGetCount(pta);
3011 dir = (L_ABS(x1 - x2) == n - 1) ? L_HORIZ : L_VERT;
3012 namin = numaCreate(n);
3013 namax = numaCreate(n);
3020 for (i = 0; i < n; i++) {
3021 ptaGetIPt(pta, i, &x, &y);
3025 if (dir == L_HORIZ) {
3026 if (x < 0 || x >= w)
continue;
3027 for (j = negloc; j <= posloc; j++) {
3028 if (y + j < 0 || y + j >= h)
continue;
3029 pixGetPixel(pixs, x, y + j, &val);
3031 if (val < minval) minval = val;
3032 if (val > maxval) maxval = val;
3035 if (y < 0 || y >= h)
continue;
3036 for (j = negloc; j <= posloc; j++) {
3037 if (x + j < 0 || x + j >= w)
continue;
3038 pixGetPixel(pixs, x + j, y, &val);
3040 if (val < minval) minval = val;
3041 if (val > maxval) maxval = val;
3045 numaAddNumber(namin, minval);
3046 numaAddNumber(namax, maxval);
3050 n = numaGetCount(namin);
3052 numaDestroy(&namin);
3053 numaDestroy(&namax);
3055 return ERROR_INT(
"no output from this line", __func__, 1);
3059 numaGetSum(namin, &sum);
3063 numaGetSum(namax, &sum);
3069 numaDestroy(&namin);
3073 numaDestroy(&namax);
3098l_int32 i, j, k, m, w, h, wpl, val;
3100l_uint32 *datas, *datad, *lines, *lined;
3104 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
3105 if (pixGetDepth(pixs) != 8)
3106 return (
PIX *)ERROR_PTR(
"pixs not 8 bpp", __func__, NULL);
3107 if (pixGetColormap(pixs))
3108 return (
PIX *)ERROR_PTR(
"pixs has a colormap", __func__, NULL);
3110 pixGetDimensions(pixs, &w, &h, NULL);
3111 pixd = pixCreateTemplate(pixs);
3112 datas = pixGetData(pixs);
3113 datad = pixGetData(pixd);
3114 wpl = pixGetWpl(pixs);
3115 for (i = 0; i < h; i++) {
3116 memset(histo, 0, 1024);
3117 lines = datas + i * wpl;
3118 lined = datad + i * wpl;
3119 for (j = 0; j < w; j++) {
3123 for (m = 0, j = 0; m < 256; m++) {
3124 for (k = 0; k < histo[m]; k++, j++)
3149l_int32 i, j, k, m, w, h, val;
3151void **lines8, **lined8;
3155 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
3156 if (pixGetDepth(pixs) != 8)
3157 return (
PIX *)ERROR_PTR(
"pixs not 8 bpp", __func__, NULL);
3158 if (pixGetColormap(pixs))
3159 return (
PIX *)ERROR_PTR(
"pixs has a colormap", __func__, NULL);
3161 pixGetDimensions(pixs, &w, &h, NULL);
3162 pixd = pixCreateTemplate(pixs);
3163 lines8 = pixGetLinePtrs(pixs, NULL);
3164 lined8 = pixGetLinePtrs(pixd, NULL);
3165 for (j = 0; j < w; j++) {
3166 memset(histo, 0, 1024);
3167 for (i = 0; i < h; i++) {
3171 for (m = 0, i = 0; m < 256; m++) {
3172 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()
PIX * pixExtractRectangularRegions(PIX *pixs, BOXA *boxa)
pixExtractRectangularRegions()
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