113 #include <config_auto.h>
118 #include "allheaders.h"
121 l_int32 searchdir, l_int32 mindist,
122 l_int32 tsize, l_int32 ntiles);
124 #ifndef NO_CONSOLE_IO
125 #define EQUAL_SIZE_WARNING 0
167 l_int32 wd, hd, wm, hm, w, h, d, wpld, wplm;
168 l_int32 i, j, rval, gval, bval;
169 l_uint32 *datad, *datam, *lined, *linem;
172 return ERROR_INT(
"pixd not defined", __func__, 1);
174 L_WARNING(
"no mask; nothing to do\n", __func__);
177 if (pixGetColormap(pixd)) {
182 if (pixGetDepth(pixm) != 1)
183 return ERROR_INT(
"pixm not 1 bpp", __func__, 1);
184 d = pixGetDepth(pixd);
196 return ERROR_INT(
"pixd not 1, 2, 4, 8, 16 or 32 bpp", __func__, 1);
212 if (d < 32 && val == 0) {
220 if (d < 32 && val == ((1 << d) - 1)) {
230 if (L_ABS(wd - wm) > 7 || L_ABS(hd - hm) > 7)
231 L_WARNING(
"pixd and pixm sizes differ\n", __func__);
235 wpld = pixGetWpl(pixd);
236 wplm = pixGetWpl(pixm);
237 for (i = 0; i < h; i++) {
238 lined = datad + i * wpld;
239 linem = datam + i * wplm;
240 for (j = 0; j < w; j++) {
260 return ERROR_INT(
"shouldn't get here", __func__, 1);
310 return ERROR_INT(
"pixd not defined", __func__, 1);
314 d = pixGetDepth(pixd);
315 if (d != 8 && d != 16 && d != 32)
316 return ERROR_INT(
"pixd not 8, 16 or 32 bpp", __func__, 1);
317 if (pixGetDepth(pixm) != 1)
318 return ERROR_INT(
"pixm not 1 bpp", __func__, 1);
322 return ERROR_INT(
"pixmu not made", __func__, 1);
331 return ERROR_INT(
"pixc not made", __func__, 1);
337 pixAnd(pixmu, pixmu, pixc);
382 l_int32 w, h, d, ws, hs, ds, wm, hm, dm, wmin, hmin;
383 l_int32 wpl, wpls, wplm, i, j, val;
384 l_uint32 *data, *datas, *datam, *line, *lines, *linem;
390 return ERROR_INT(
"pixd not defined", __func__, 1);
392 return ERROR_INT(
"pixs not defined", __func__, 1);
397 return ERROR_INT(
"pixs and pixd depths differ", __func__, 1);
399 return ERROR_INT(
"pixm not 1 bpp", __func__, 1);
400 if (d != 1 && d != 8 && d != 32)
401 return ERROR_INT(
"pixd not 1, 8 or 32 bpp", __func__, 1);
402 if (pixGetColormap(pixd) || pixGetColormap(pixs))
403 return ERROR_INT(
"pixs and/or pixd is cmapped", __func__, 1);
409 wmin = L_MIN(w, L_MIN(ws, wm));
410 hmin = L_MIN(h, L_MIN(hs, hm));
412 pixt =
pixAnd(NULL, pixs, pixm);
423 wpl = pixGetWpl(pixd);
424 wpls = pixGetWpl(pixs);
425 wplm = pixGetWpl(pixm);
427 for (i = 0; i < hmin; i++) {
428 line = data + i * wpl;
429 lines = datas + i * wpls;
430 linem = datam + i * wplm;
431 for (j = 0; j < wmin; j++) {
439 for (i = 0; i < hmin; i++) {
440 line = data + i * wpl;
441 lines = datas + i * wpls;
442 linem = datam + i * wplm;
443 for (j = 0; j < wmin; j++) {
501 l_int32 d, w, h, ws, hs, ds, wm, hm, dm, wmin, hmin;
502 l_int32 wpl, wpls, wplm, i, j, val;
503 l_uint32 *data, *datas, *datam, *line, *lines, *linem;
509 return ERROR_INT(
"pixd not defined", __func__, 1);
511 return ERROR_INT(
"pixs not defined", __func__, 1);
516 return ERROR_INT(
"pixs and pixd depths differ", __func__, 1);
518 return ERROR_INT(
"pixm not 1 bpp", __func__, 1);
519 if (d != 1 && d != 8 && d != 32)
520 return ERROR_INT(
"pixd not 1, 8 or 32 bpp", __func__, 1);
521 if (pixGetColormap(pixd) || pixGetColormap(pixs))
522 return ERROR_INT(
"pixs and/or pixd is cmapped", __func__, 1);
528 wmin = L_MIN(ws, wm);
529 hmin = L_MIN(hs, hm);
531 pixt =
pixAnd(NULL, pixs, pixm);
539 wpl = pixGetWpl(pixd);
541 wpls = pixGetWpl(pixs);
543 wplm = pixGetWpl(pixm);
546 for (i = 0; i < hmin; i++) {
547 if (y + i < 0 || y + i >= h)
continue;
548 line = data + (y + i) * wpl;
549 lines = datas + i * wpls;
550 linem = datam + i * wplm;
551 for (j = 0; j < wmin; j++) {
552 if (x + j < 0 || x + j >= w)
continue;
561 *(line + x + j) = *(lines + j);
564 return ERROR_INT(
"shouldn't get here", __func__, 1);
624 l_int32 d, w, h, wm, hm, wpl, wplm, i, j, rval, gval, bval;
625 l_uint32 *data, *datam, *line, *linem;
630 return ERROR_INT(
"pixd not defined", __func__, 1);
631 if (pixGetColormap(pixd)) {
636 if (pixGetDepth(pixm) != 1)
637 return ERROR_INT(
"pixm not 1 bpp", __func__, 1);
638 d = pixGetDepth(pixd);
650 return ERROR_INT(
"pixd not 1, 2, 4, 8, 16 or 32 bpp", __func__, 1);
666 if (d < 32 && val == 0) {
674 if (d < 32 && val == ((1 << d) - 1)) {
683 wpl = pixGetWpl(pixd);
685 wplm = pixGetWpl(pixm);
687 for (i = 0; i < hm; i++) {
688 if (y + i < 0 || y + i >= h)
continue;
689 line = data + (y + i) * wpl;
690 linem = datam + i * wplm;
691 for (j = 0; j < wm; j++) {
692 if (x + j < 0 || x + j >= w)
continue;
709 *(line + x + j) = val;
712 return ERROR_INT(
"shouldn't get here", __func__, 1);
753 l_int32 i, n, x, y, w, h;
757 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
759 return (
PIX *)ERROR_PTR(
"boxa not defined", __func__, NULL);
761 return (
PIX *)ERROR_PTR(
"invalid background", __func__, NULL);
766 for (i = 0; i < n; i++) {
846 l_int32 w, h, d, wm, hm, dm, i, n, bx, by, bw, bh, edgeblend, retval, minside;
848 BOX *box, *boxv, *boxh;
850 PIX *pixf, *pixv, *pixh, *pix1, *pix2, *pix3, *pix4, *pix5;
856 return ERROR_INT(
"pixd not defined", __func__, 1);
857 if (pixGetColormap(pixd) != NULL)
858 return ERROR_INT(
"pixd has colormap", __func__, 1);
860 if (d != 8 && d != 32)
861 return ERROR_INT(
"pixd not 8 or 32 bpp", __func__, 1);
864 return ERROR_INT(
"pixm not 1 bpp", __func__, 1);
866 return ERROR_INT(
"x and y must be non-negative", __func__, 1);
867 if (searchdir != L_HORIZ && searchdir != L_VERT &&
868 searchdir != L_BOTH_DIRECTIONS)
869 return ERROR_INT(
"invalid searchdir", __func__, 1);
871 return ERROR_INT(
"tilesize must be >= 2", __func__, 1);
873 return ERROR_INT(
"distblend must be >= 0", __func__, 1);
876 if (wm < w || hm < h) {
886 L_WARNING(
"no fg in mask\n", __func__);
899 edgeblend = (n == 1 && distblend > 0) ? 1 : 0;
900 if (distblend > 0 && n > 1)
901 L_WARNING(
"%d components; can not blend at edges\n", __func__, n);
903 for (i = 0; i < n; i++) {
911 minside = L_MIN(bw, bh);
914 if (searchdir == L_HORIZ || searchdir == L_BOTH_DIRECTIONS) {
916 L_MIN(minside, tilesize), ntiles, &boxh, 0);
918 if (searchdir == L_VERT || searchdir == L_BOTH_DIRECTIONS) {
920 L_MIN(minside, tilesize), ntiles, &boxv, 0);
922 if (!boxh && !boxv) {
923 L_WARNING(
"tile region not selected; paint color near boundary\n",
940 pix2 =
pixBlend(pixh, pixv, 0, 0, 0.5);
994 l_int32 w, h, d, i, j, sval, wpls, wpld;
995 l_uint32 *datas, *datad, *lines, *lined;
999 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1001 if (d != 2 && d != 4 && d != 8)
1002 return (
PIX *)ERROR_PTR(
"pix not 2, 4 or 8 bpp", __func__, NULL);
1005 pixCopyResolution(pixd, pixs);
1006 pixCopyInputFormat(pixd, pixs);
1009 wpls = pixGetWpl(pixs);
1010 wpld = pixGetWpl(pixd);
1011 for (i = 0; i < h; i++) {
1012 lines = datas + i * wpls;
1013 lined = datad + i * wpld;
1014 for (j = 0; j < w; j++) {
1049 l_int32 w, h, d, i, j, val, wpls, wpld;
1050 l_uint32 *datas, *datad, *lines, *lined;
1054 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1056 return (
PIX *)ERROR_PTR(
"tab not defined", __func__, NULL);
1058 if (d != 2 && d != 4 && d != 8)
1059 return (
PIX *)ERROR_PTR(
"pix not 2, 4 or 8 bpp", __func__, NULL);
1062 pixCopyResolution(pixd, pixs);
1063 pixCopyInputFormat(pixd, pixs);
1066 wpls = pixGetWpl(pixs);
1067 wpld = pixGetWpl(pixd);
1068 for (i = 0; i < h; i++) {
1069 lines = datas + i * wpls;
1070 lined = datad + i * wpld;
1071 for (j = 0; j < w; j++) {
1121 if (!pixs || pixGetDepth(pixs) != 32)
1122 return (
PIX *)ERROR_PTR(
"pixs undefined or not 32 bpp", __func__, NULL);
1123 if (thresh >= 255.0) thresh = 254.0;
1126 return (
PIX *)ERROR_PTR(
"pix1 not made", __func__, NULL);
1192 PIX *pixg, *pixm, *pixt, *pixd;
1194 if (!pixs || pixGetDepth(pixs) != 32)
1195 return (
PIX *)ERROR_PTR(
"pixs not defined or not 32 bpp",
1198 if (pixGetSpp(pixs) != 4) {
1199 L_WARNING(
"no alpha channel; returning a copy\n", __func__);
1218 pixDisplay(pixt, 0, 0);
1270 if (pbox) *pbox = NULL;
1271 if (!pixs || pixGetDepth(pixs) != 1)
1272 return (
PIX *)ERROR_PTR(
"pixs undefined or not 1 bpp", __func__, NULL);
1274 return (
PIX *)ERROR_PTR(
"dist must be >= 0", __func__, NULL);
1280 L_WARNING(
"no ON pixels in mask\n", __func__);
1337 l_int32 empty, bx, by;
1338 l_float32 rval, gval, bval;
1340 PIX *pix1, *pix2, *pix3;
1343 return ERROR_INT(
"&pval not defined", __func__, 1);
1345 if (!pixs || pixGetDepth(pixs) != 32)
1346 return ERROR_INT(
"pixs undefined or not 32 bpp", __func__, 1);
1347 if (!pixm || pixGetDepth(pixm) != 1)
1348 return ERROR_INT(
"pixm undefined or not 1 bpp", __func__, 1);
1350 return ERROR_INT(
"box not defined", __func__, 1);
1352 return ERROR_INT(
"dist must be >= 0", __func__, 1);
1357 box1 =
boxAdjustSides(NULL, box, -dist - 5, dist + 5, -dist - 5, dist + 5);
1364 snprintf(op,
sizeof(op),
"d%d.%d", 2 * dist, 2 * dist);
1372 pixXor(pix3, pix3, pix2);
1378 &rval, &gval, &bval);
1380 (l_int32)(bval + 0.5), pval);
1382 L_WARNING(
"no pixels found\n", __func__);
1388 pixWriteDebug(
"/tmp/masknear/input.png", pix1, IFF_PNG);
1389 pixWriteDebug(
"/tmp/masknear/adjusted.png", pix2, IFF_PNG);
1390 pixWriteDebug(
"/tmp/masknear/outerfive.png", pix3, IFF_PNG);
1391 lept_stderr(
"Input box; with adjusted sides; clipped\n");
1435 if (!pixm || pixGetDepth(pixm) != 1)
1436 return (
PIX *)ERROR_PTR(
"pixm undefined or not 1 bpp", __func__, NULL);
1485 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1488 if ((pixd =
pixCopy(pixd, pixs)) == NULL)
1489 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
1491 pixRasterop(pixd, 0, 0, pixGetWidth(pixd), pixGetHeight(pixd),
1535 return (
PIX *)ERROR_PTR(
"pixs1 not defined", __func__, pixd);
1537 return (
PIX *)ERROR_PTR(
"pixs2 not defined", __func__, pixd);
1539 return (
PIX *)ERROR_PTR(
"cannot have pixs2 == pixd", __func__, pixd);
1540 if (pixGetDepth(pixs1) != pixGetDepth(pixs2))
1541 return (
PIX *)ERROR_PTR(
"depths of pixs* unequal", __func__, pixd);
1543 #if EQUAL_SIZE_WARNING
1545 L_WARNING(
"pixs1 and pixs2 not equal sizes\n", __func__);
1549 if ((pixd =
pixCopy(pixd, pixs1)) == NULL)
1550 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, pixd);
1553 pixRasterop(pixd, 0, 0, pixGetWidth(pixd), pixGetHeight(pixd),
1597 return (
PIX *)ERROR_PTR(
"pixs1 not defined", __func__, pixd);
1599 return (
PIX *)ERROR_PTR(
"pixs2 not defined", __func__, pixd);
1601 return (
PIX *)ERROR_PTR(
"cannot have pixs2 == pixd", __func__, pixd);
1602 if (pixGetDepth(pixs1) != pixGetDepth(pixs2))
1603 return (
PIX *)ERROR_PTR(
"depths of pixs* unequal", __func__, pixd);
1605 #if EQUAL_SIZE_WARNING
1607 L_WARNING(
"pixs1 and pixs2 not equal sizes\n", __func__);
1611 if ((pixd =
pixCopy(pixd, pixs1)) == NULL)
1612 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, pixd);
1615 pixRasterop(pixd, 0, 0, pixGetWidth(pixd), pixGetHeight(pixd),
1659 return (
PIX *)ERROR_PTR(
"pixs1 not defined", __func__, pixd);
1661 return (
PIX *)ERROR_PTR(
"pixs2 not defined", __func__, pixd);
1663 return (
PIX *)ERROR_PTR(
"cannot have pixs2 == pixd", __func__, pixd);
1664 if (pixGetDepth(pixs1) != pixGetDepth(pixs2))
1665 return (
PIX *)ERROR_PTR(
"depths of pixs* unequal", __func__, pixd);
1667 #if EQUAL_SIZE_WARNING
1669 L_WARNING(
"pixs1 and pixs2 not equal sizes\n", __func__);
1673 if ((pixd =
pixCopy(pixd, pixs1)) == NULL)
1674 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, pixd);
1677 pixRasterop(pixd, 0, 0, pixGetWidth(pixd), pixGetHeight(pixd),
1724 return (
PIX *)ERROR_PTR(
"pixs1 not defined", __func__, pixd);
1726 return (
PIX *)ERROR_PTR(
"pixs2 not defined", __func__, pixd);
1727 if (pixGetDepth(pixs1) != pixGetDepth(pixs2))
1728 return (
PIX *)ERROR_PTR(
"depths of pixs* unequal", __func__, pixd);
1730 #if EQUAL_SIZE_WARNING
1732 L_WARNING(
"pixs1 and pixs2 not equal sizes\n", __func__);
1740 }
else if (pixd == pixs1) {
1743 }
else if (pixd == pixs2) {
1780 l_int32 w, h, wpl, i, j, fullwords, endbits;
1782 l_uint32 *data, *line;
1785 return ERROR_INT(
"&empty not defined", __func__, 1);
1788 return ERROR_INT(
"pix not defined", __func__, 1);
1790 w = pixGetWidth(pix) * pixGetDepth(pix);
1791 h = pixGetHeight(pix);
1792 wpl = pixGetWpl(pix);
1796 endmask = (endbits == 0) ? 0 : (0xffffffffU << (32 - endbits));
1798 for (i = 0; i < h; i++) {
1799 line = data + wpl * i;
1800 for (j = 0; j < fullwords; j++)
1806 if (*line & endmask) {
1828 l_int32 w, h, count;
1831 return ERROR_INT(
"&fract not defined", __func__, 1);
1833 if (!pix || pixGetDepth(pix) != 1)
1834 return ERROR_INT(
"pix not defined or not 1 bpp", __func__, 1);
1838 *pfract = (l_float32)count / (l_float32)(w * h);
1852 l_int32 d, i, n, count;
1858 return (
NUMA *)ERROR_PTR(
"pix not defined", __func__, NULL);
1864 d = pixGetDepth(pix);
1867 return (
NUMA *)ERROR_PTR(
"pixa not 1 bpp", __func__, NULL);
1870 return (
NUMA *)ERROR_PTR(
"na not made", __func__, NULL);
1872 for (i = 0; i < n; i++) {
1898 l_int32 w, h, wpl, i, j;
1899 l_int32 fullwords, endbits, sum;
1904 return ERROR_INT(
"&count not defined", __func__, 1);
1906 if (!pixs || pixGetDepth(pixs) != 1)
1907 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
1911 wpl = pixGetWpl(pixs);
1915 endmask = (endbits == 0) ? 0 : (0xffffffffU << (32 - endbits));
1918 for (i = 0; i < h; i++, data += wpl) {
1919 for (j = 0; j < fullwords; j++) {
1920 l_uint32 word = data[j];
1922 sum += tab[word & 0xff] +
1923 tab[(word >> 8) & 0xff] +
1924 tab[(word >> 16) & 0xff] +
1925 tab[(word >> 24) & 0xff];
1929 l_uint32 word = data[j] & endmask;
1931 sum += tab[word & 0xff] +
1932 tab[(word >> 8) & 0xff] +
1933 tab[(word >> 16) & 0xff] +
1934 tab[(word >> 24) & 0xff];
1940 if (!tab8) LEPT_FREE(tab);
1960 l_int32 w, h, bx, by, bw, bh;
1965 return ERROR_INT(
"&count not defined", __func__, 1);
1967 if (!pixs || pixGetDepth(pixs) != 1)
1968 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
1973 return ERROR_INT(
"box1 not made", __func__, 1);
2005 l_int32 i, j, w, h, wpl, count, xstart, xend, ystart, yend, bw, bh;
2006 l_uint32 *line, *data;
2009 if (!pix || pixGetDepth(pix) != 1)
2010 return (
NUMA *)ERROR_PTR(
"pix undefined or not 1 bpp", __func__, NULL);
2017 return (
NUMA *)ERROR_PTR(
"invalid clipping box", __func__, NULL);
2020 return (
NUMA *)ERROR_PTR(
"na not made", __func__, NULL);
2023 wpl = pixGetWpl(pix);
2024 for (i = ystart; i < yend; i++) {
2026 line = data + i * wpl;
2027 for (j = xstart; j < xend; j++) {
2055 l_int32 i, j, w, h, wpl, count, xstart, xend, ystart, yend, bw, bh;
2056 l_uint32 *line, *data;
2059 if (!pix || pixGetDepth(pix) != 1)
2060 return (
NUMA *)ERROR_PTR(
"pix undefined or not 1 bpp", __func__, NULL);
2067 return (
NUMA *)ERROR_PTR(
"invalid clipping box", __func__, NULL);
2070 return (
NUMA *)ERROR_PTR(
"na not made", __func__, NULL);
2073 wpl = pixGetWpl(pix);
2074 for (j = xstart; j < xend; j++) {
2076 for (i = ystart; i < yend; i++) {
2077 line = data + i * wpl;
2099 l_int32 h, i, count;
2103 if (!pix || pixGetDepth(pix) != 1)
2104 return (
NUMA *)ERROR_PTR(
"pix undefined or not 1 bpp", __func__, NULL);
2106 h = pixGetHeight(pix);
2108 return (
NUMA *)ERROR_PTR(
"na not made", __func__, NULL);
2111 for (i = 0; i < h; i++) {
2116 if (!tab8) LEPT_FREE(tab);
2130 l_int32 i, j, w, h, wpl;
2131 l_uint32 *line, *data;
2135 if (!pix || pixGetDepth(pix) != 1)
2136 return (
NUMA *)ERROR_PTR(
"pix undefined or not 1 bpp", __func__, NULL);
2140 return (
NUMA *)ERROR_PTR(
"na not made", __func__, NULL);
2144 wpl = pixGetWpl(pix);
2145 for (i = 0; i < h; i++) {
2146 line = data + wpl * i;
2147 for (j = 0; j < w; j++) {
2172 l_uint32 word, endmask;
2173 l_int32 j, w, h, wpl;
2174 l_int32 fullwords, endbits, sum;
2179 return ERROR_INT(
"&count not defined", __func__, 1);
2181 if (!pix || pixGetDepth(pix) != 1)
2182 return ERROR_INT(
"pix not defined or not 1 bpp", __func__, 1);
2185 if (row < 0 || row >= h)
2186 return ERROR_INT(
"row out of bounds", __func__, 1);
2187 wpl = pixGetWpl(pix);
2191 endmask = (endbits == 0) ? 0 : (0xffffffffU << (32 - endbits));
2195 for (j = 0; j < fullwords; j++) {
2198 sum += tab[word & 0xff] +
2199 tab[(word >> 8) & 0xff] +
2200 tab[(word >> 16) & 0xff] +
2201 tab[(word >> 24) & 0xff];
2205 word = line[j] & endmask;
2207 sum += tab[word & 0xff] +
2208 tab[(word >> 8) & 0xff] +
2209 tab[(word >> 16) & 0xff] +
2210 tab[(word >> 24) & 0xff];
2215 if (!tab8) LEPT_FREE(tab);
2231 l_int32 i, j, w, h, wpl;
2232 l_uint32 *line, *data;
2236 if (!pix || pixGetDepth(pix) != 1)
2237 return (
NUMA *)ERROR_PTR(
"pix undefined or not 1 bpp", __func__, NULL);
2238 if (order != 1 && order != 2)
2239 return (
NUMA *)ERROR_PTR(
"order of moment not 1 or 2", __func__, NULL);
2243 return (
NUMA *)ERROR_PTR(
"na not made", __func__, NULL);
2247 wpl = pixGetWpl(pix);
2248 for (i = 0; i < h; i++) {
2249 line = data + wpl * i;
2250 for (j = 0; j < w; j++) {
2289 l_uint32 word, endmask;
2291 l_int32 w, h, wpl, i, j;
2292 l_int32 fullwords, endbits, sum;
2293 l_uint32 *line, *data;
2296 return ERROR_INT(
"&above not defined", __func__, 1);
2298 if (!pix || pixGetDepth(pix) != 1)
2299 return ERROR_INT(
"pix not defined or not 1 bpp", __func__, 1);
2303 wpl = pixGetWpl(pix);
2307 endmask = 0xffffffff << (32 - endbits);
2310 for (i = 0; i < h; i++) {
2311 line = data + wpl * i;
2312 for (j = 0; j < fullwords; j++) {
2315 sum += tab[word & 0xff] +
2316 tab[(word >> 8) & 0xff] +
2317 tab[(word >> 16) & 0xff] +
2318 tab[(word >> 24) & 0xff];
2322 word = line[j] & endmask;
2324 sum += tab[word & 0xff] +
2325 tab[(word >> 8) & 0xff] +
2326 tab[(word >> 16) & 0xff] +
2327 tab[(word >> 24) & 0xff];
2332 if (!tab8) LEPT_FREE(tab);
2337 if (!tab8) LEPT_FREE(tab);
2360 tab = (l_int32 *)LEPT_CALLOC(256,
sizeof(l_int32));
2361 for (i = 0; i < 256; i++) {
2363 tab[i] = (
byte & 0x1) +
2364 ((
byte >> 1) & 0x1) +
2365 ((
byte >> 2) & 0x1) +
2366 ((
byte >> 3) & 0x1) +
2367 ((
byte >> 4) & 0x1) +
2368 ((
byte >> 5) & 0x1) +
2369 ((
byte >> 6) & 0x1) +
2370 ((
byte >> 7) & 0x1);
2399 tab = (l_int32 *)LEPT_CALLOC(256,
sizeof(l_int32));
2402 for (i = 2; i < 4; i++) {
2403 tab[i] = tab[i - 2] + 6;
2405 for (i = 4; i < 8; i++) {
2406 tab[i] = tab[i - 4] + 5;
2408 for (i = 8; i < 16; i++) {
2409 tab[i] = tab[i - 8] + 4;
2411 for (i = 16; i < 32; i++) {
2412 tab[i] = tab[i - 16] + 3;
2414 for (i = 32; i < 64; i++) {
2415 tab[i] = tab[i - 32] + 2;
2417 for (i = 64; i < 128; i++) {
2418 tab[i] = tab[i - 64] + 1;
2420 for (i = 128; i < 256; i++) {
2421 tab[i] = tab[i - 128];
2451 l_int32 i, j, w, h, d, wpl, xstart, xend, ystart, yend, bw, bh;
2452 l_uint32 *line, *data;
2453 l_float64 norm, sum;
2457 return (
NUMA *)ERROR_PTR(
"pix not defined", __func__, NULL);
2459 if (d != 8 && d != 16)
2460 return (
NUMA *)ERROR_PTR(
"pix not 8 or 16 bpp", __func__, NULL);
2462 return (
NUMA *)ERROR_PTR(
"invalid type", __func__, NULL);
2463 if (pixGetColormap(pix) != NULL)
2464 return (
NUMA *)ERROR_PTR(
"pix colormapped", __func__, NULL);
2468 return (
NUMA *)ERROR_PTR(
"invalid clipping box", __func__, NULL);
2470 norm = 1. / (l_float32)bw;
2472 return (
NUMA *)ERROR_PTR(
"na not made", __func__, NULL);
2475 wpl = pixGetWpl(pix);
2476 for (i = ystart; i < yend; i++) {
2478 line = data + i * wpl;
2480 for (j = xstart; j < xend; j++)
2483 sum = bw * 255 - sum;
2485 for (j = xstart; j < xend; j++)
2488 sum = bw * 0xffff - sum;
2518 l_int32 i, j, w, h, d, wpl, xstart, xend, ystart, yend, bw, bh;
2519 l_uint32 *line, *data;
2520 l_float32 norm, sum;
2524 return (
NUMA *)ERROR_PTR(
"pix not defined", __func__, NULL);
2527 if (d != 8 && d != 16)
2528 return (
NUMA *)ERROR_PTR(
"pix not 8 or 16 bpp", __func__, NULL);
2530 return (
NUMA *)ERROR_PTR(
"invalid type", __func__, NULL);
2531 if (pixGetColormap(pix) != NULL)
2532 return (
NUMA *)ERROR_PTR(
"pix colormapped", __func__, NULL);
2536 return (
NUMA *)ERROR_PTR(
"invalid clipping box", __func__, NULL);
2539 return (
NUMA *)ERROR_PTR(
"na not made", __func__, NULL);
2541 norm = 1. / (l_float32)bh;
2543 wpl = pixGetWpl(pix);
2544 for (j = xstart; j < xend; j++) {
2547 for (i = ystart; i < yend; i++) {
2548 line = data + i * wpl;
2552 sum = bh * 255 - sum;
2554 for (i = ystart; i < yend; i++) {
2555 line = data + i * wpl;
2559 sum = bh * 0xffff - sum;
2607 l_int32 w, h, d, wpls, wm, hm, dm, wplm, val, count;
2608 l_int32 i, j, xstart, xend, ystart, yend;
2609 l_uint32 *datas, *datam, *lines, *linem;
2613 return ERROR_INT(
"&ave not defined", __func__, 1);
2616 return ERROR_INT(
"pixs not defined", __func__, 1);
2617 if (pixGetColormap(pixs) != NULL)
2618 return ERROR_INT(
"pixs is colormapped", __func__, 1);
2620 if (d != 1 && d != 2 && d != 4 && d != 8)
2621 return ERROR_INT(
"pixs not 1, 2, 4 or 8 bpp", __func__, 1);
2625 return ERROR_INT(
"pixm not 1 bpp", __func__, 1);
2630 return ERROR_INT(
"subsamp must be >= 1", __func__, 1);
2634 return ERROR_INT(
"invalid clipping box", __func__, 1);
2637 wpls = pixGetWpl(pixs);
2640 wplm = pixGetWpl(pixm);
2644 for (i = ystart; i < yend; i += subsamp) {
2645 lines = datas + i * wpls;
2647 linem = datam + i * wplm;
2648 for (j = xstart; j < xend; j += subsamp) {
2659 if (val >= minval && val <= maxval) {
2668 *pave = sum / (l_float32)count;
2710 l_int32 w, h, wpls, wm, hm, dm, wplm, i, j, xstart, xend, ystart, yend;
2711 l_int32 rval, gval, bval, rave, gave, bave, count;
2712 l_uint32 *datas, *datam, *lines, *linem;
2714 l_float64 rsum, gsum, bsum;
2717 return ERROR_INT(
"&ave not defined", __func__, 1);
2719 if (!pixs || pixGetDepth(pixs) != 32)
2720 return ERROR_INT(
"pixs undefined or not 32 bpp", __func__, 1);
2725 return ERROR_INT(
"pixm not 1 bpp", __func__, 1);
2730 return ERROR_INT(
"subsamp must be >= 1", __func__, 1);
2734 return ERROR_INT(
"invalid clipping box", __func__, 1);
2737 wpls = pixGetWpl(pixs);
2740 wplm = pixGetWpl(pixm);
2742 rsum = gsum = bsum = 0.0;
2744 for (i = ystart; i < yend; i += subsamp) {
2745 lines = datas + i * wpls;
2747 linem = datam + i * wplm;
2748 for (j = xstart; j < xend; j += subsamp) {
2751 pixel = *(lines + j);
2762 rave = (l_uint32)(rsum / (l_float64)count);
2763 gave = (l_uint32)(gsum / (l_float64)count);
2764 bave = (l_uint32)(bsum / (l_float64)count);
2792 l_int32 i, j, w, h, d, wpl, xstart, xend, ystart, yend, bw, bh, val;
2793 l_uint32 *line, *data;
2794 l_float64 sum1, sum2, norm, ave, var, rootvar;
2798 return (
NUMA *)ERROR_PTR(
"pix not defined", __func__, NULL);
2800 if (d != 8 && d != 16)
2801 return (
NUMA *)ERROR_PTR(
"pix not 8 or 16 bpp", __func__, NULL);
2802 if (pixGetColormap(pix) != NULL)
2803 return (
NUMA *)ERROR_PTR(
"pix colormapped", __func__, NULL);
2807 return (
NUMA *)ERROR_PTR(
"invalid clipping box", __func__, NULL);
2810 return (
NUMA *)ERROR_PTR(
"na not made", __func__, NULL);
2812 norm = 1. / (l_float32)bw;
2814 wpl = pixGetWpl(pix);
2815 for (i = ystart; i < yend; i++) {
2817 line = data + i * wpl;
2818 for (j = xstart; j < xend; j++) {
2824 sum2 += (l_float64)(val) * val;
2827 var = norm * sum2 - ave * ave;
2828 rootvar = sqrt(var);
2855 l_int32 i, j, w, h, d, wpl, xstart, xend, ystart, yend, bw, bh, val;
2856 l_uint32 *line, *data;
2857 l_float64 sum1, sum2, norm, ave, var, rootvar;
2861 return (
NUMA *)ERROR_PTR(
"pix not defined", __func__, NULL);
2863 if (d != 8 && d != 16)
2864 return (
NUMA *)ERROR_PTR(
"pix not 8 or 16 bpp", __func__, NULL);
2865 if (pixGetColormap(pix) != NULL)
2866 return (
NUMA *)ERROR_PTR(
"pix colormapped", __func__, NULL);
2870 return (
NUMA *)ERROR_PTR(
"invalid clipping box", __func__, NULL);
2873 return (
NUMA *)ERROR_PTR(
"na not made", __func__, NULL);
2875 norm = 1. / (l_float32)bh;
2877 wpl = pixGetWpl(pix);
2878 for (j = xstart; j < xend; j++) {
2880 for (i = ystart; i < yend; i++) {
2881 line = data + wpl * i;
2887 sum2 += (l_float64)(val) * val;
2890 var = norm * sum2 - ave * ave;
2891 rootvar = sqrt(var);
2910 l_float32 *prootvar)
2912 l_int32 w, h, d, wpl, i, j, xstart, xend, ystart, yend, bw, bh, val;
2913 l_uint32 *data, *line;
2914 l_float64 sum1, sum2, norm, ave, var;
2917 return ERROR_INT(
"&rootvar not defined", __func__, 1);
2920 return ERROR_INT(
"pix not defined", __func__, 1);
2922 if (d != 1 && d != 2 && d != 4 && d != 8)
2923 return ERROR_INT(
"pix not 1, 2, 4 or 8 bpp", __func__, 1);
2924 if (pixGetColormap(pix) != NULL)
2925 return ERROR_INT(
"pix is colormapped", __func__, 1);
2929 return ERROR_INT(
"invalid clipping box", __func__, 1);
2931 wpl = pixGetWpl(pix);
2934 for (i = ystart; i < yend; i++) {
2935 line = data + i * wpl;
2936 for (j = xstart; j < xend; j++) {
2940 sum2 += (l_float64)(val) * val;
2941 }
else if (d == 2) {
2944 sum2 += (l_float64)(val) * val;
2945 }
else if (d == 4) {
2948 sum2 += (l_float64)(val) * val;
2952 sum2 += (l_float64)(val) * val;
2956 norm = 1.0 / ((l_float64)(bw) * bh);
2958 var = norm * sum2 - ave * ave;
2959 *prootvar = (l_float32)sqrt(var);
2986 l_int32 i, j, w, h, wpl, xstart, xend, ystart, yend, bw, bh, val0, val1;
2987 l_uint32 *line, *data;
2988 l_float64 norm, sum;
2991 if (!pix || pixGetDepth(pix) != 8)
2992 return (
NUMA *)ERROR_PTR(
"pix undefined or not 8 bpp", __func__, NULL);
2993 if (pixGetColormap(pix) != NULL)
2994 return (
NUMA *)ERROR_PTR(
"pix colormapped", __func__, NULL);
2999 return (
NUMA *)ERROR_PTR(
"invalid clipping box", __func__, NULL);
3001 return (
NUMA *)ERROR_PTR(
"row width must be >= 2", __func__, NULL);
3003 norm = 1. / (l_float32)(bw - 1);
3005 return (
NUMA *)ERROR_PTR(
"na not made", __func__, NULL);
3008 wpl = pixGetWpl(pix);
3009 for (i = ystart; i < yend; i++) {
3011 line = data + i * wpl;
3013 for (j = xstart + 1; j < xend; j++) {
3015 sum += L_ABS(val1 - val0);
3045 l_int32 i, j, w, h, wpl, xstart, xend, ystart, yend, bw, bh, val0, val1;
3046 l_uint32 *line, *data;
3047 l_float64 norm, sum;
3050 if (!pix || pixGetDepth(pix) != 8)
3051 return (
NUMA *)ERROR_PTR(
"pix undefined or not 8 bpp", __func__, NULL);
3052 if (pixGetColormap(pix) != NULL)
3053 return (
NUMA *)ERROR_PTR(
"pix colormapped", __func__, NULL);
3058 return (
NUMA *)ERROR_PTR(
"invalid clipping box", __func__, NULL);
3060 return (
NUMA *)ERROR_PTR(
"column height must be >= 2", __func__, NULL);
3062 norm = 1. / (l_float32)(bh - 1);
3064 return (
NUMA *)ERROR_PTR(
"na not made", __func__, NULL);
3067 wpl = pixGetWpl(pix);
3068 for (j = xstart; j < xend; j++) {
3070 line = data + ystart * wpl;
3072 for (i = ystart + 1; i < yend; i++) {
3073 line = data + i * wpl;
3075 sum += L_ABS(val1 - val0);
3106 l_float32 *pabsdiff)
3108 l_int32 w, h, wpl, i, j, xstart, xend, ystart, yend, bw, bh, val0, val1;
3109 l_uint32 *data, *line;
3110 l_float64 norm, sum;
3113 return ERROR_INT(
"&absdiff not defined", __func__, 1);
3115 if (!pix || pixGetDepth(pix) != 8)
3116 return ERROR_INT(
"pix undefined or not 8 bpp", __func__, 1);
3118 return ERROR_INT(
"invalid direction", __func__, 1);
3119 if (pixGetColormap(pix) != NULL)
3120 return ERROR_INT(
"pix is colormapped", __func__, 1);
3125 return ERROR_INT(
"invalid clipping box", __func__, 1);
3127 wpl = pixGetWpl(pix);
3130 norm = 1. / (l_float32)(bh * (bw - 1));
3132 for (i = ystart; i < yend; i++) {
3133 line = data + i * wpl;
3135 for (j = xstart + 1; j < xend; j++) {
3137 sum += L_ABS(val1 - val0);
3142 norm = 1. / (l_float32)(bw * (bh - 1));
3144 for (j = xstart; j < xend; j++) {
3145 line = data + ystart * wpl;
3147 for (i = ystart + 1; i < yend; i++) {
3148 line = data + i * wpl;
3150 sum += L_ABS(val1 - val0);
3155 *pabsdiff = (l_float32)(norm * sum);
3183 l_float32 *pabsdiff)
3185 l_int32 w, h, i, j, dir, size, sum;
3186 l_uint32 val0, val1;
3189 return ERROR_INT(
"&absdiff not defined", __func__, 1);
3191 if (!pix || pixGetDepth(pix) != 8)
3192 return ERROR_INT(
"pix undefined or not 8 bpp", __func__, 1);
3195 }
else if (x1 == x2) {
3198 return ERROR_INT(
"line is neither horiz nor vert", __func__, 1);
3200 if (pixGetColormap(pix) != NULL)
3201 return ERROR_INT(
"pix is colormapped", __func__, 1);
3207 x2 = L_MIN(x2, w - 1);
3209 return ERROR_INT(
"x1 >= x2", __func__, 1);
3212 for (j = x1 + 1; j <= x2; j++) {
3214 sum += L_ABS((l_int32)val1 - (l_int32)val0);
3219 y2 = L_MIN(y2, h - 1);
3221 return ERROR_INT(
"y1 >= y2", __func__, 1);
3224 for (i = y1 + 1; i <= y2; i++) {
3226 sum += L_ABS((l_int32)val1 - (l_int32)val0);
3230 *pabsdiff = (l_float32)sum / (l_float32)size;
3264 l_int32 i, j, bx, by, bw, bh, w, h, d, wpl, pixval;
3265 l_uint32 *data, *line;
3268 return ERROR_INT(
"&count not defined", __func__, 1);
3271 return ERROR_INT(
"pixs not defined", __func__, 1);
3272 d = pixGetDepth(pixs);
3273 if (d != 1 && d != 2 && d != 4 && d != 8)
3274 return ERROR_INT(
"pixs not 1, 2, 4 or 8 bpp", __func__, 1);
3276 return ERROR_INT(
"val < 0", __func__, 1);
3277 if (val > (1 << d) - 1) {
3278 L_ERROR(
"invalid val = %d for depth %d\n", __func__, val, d);
3282 return ERROR_INT(
"sampling factor < 1", __func__, 1);
3286 wpl = pixGetWpl(pixs);
3288 for (i = 0; i < h; i += factor) {
3289 line = data + i * wpl;
3290 for (j = 0; j < w; j += factor) {
3293 }
else if (d == 1) {
3295 }
else if (d == 2) {
3300 if (pixval == val) (*pcount)++;
3305 for (i = 0; i < bh; i += factor) {
3306 if (by + i < 0 || by + i >= h)
continue;
3307 line = data + (by + i) * wpl;
3308 for (j = 0; j < bw; j += factor) {
3309 if (bx + j < 0 || bx + j >= w)
continue;
3312 }
else if (d == 1) {
3314 }
else if (d == 2) {
3319 if (pixval == val) (*pcount)++;
3325 *pcount = *pcount * factor * factor;
3359 l_int32 wt, ht, d, i, j, nx, ny;
3360 PIX *pixd, *pixsfx, *pixsfy, *pixsfxy, *pix;
3363 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
3365 if (wt <= 0 || ht <= 0)
3366 return (
PIX *)ERROR_PTR(
"pixs size illegal", __func__, NULL);
3367 if (d != 8 && d != 32)
3368 return (
PIX *)ERROR_PTR(
"depth not 32 bpp", __func__, NULL);
3370 if ((pixd =
pixCreate(w, h, d)) == NULL)
3371 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
3374 nx = (w + wt - 1) / wt;
3375 ny = (h + ht - 1) / ht;
3379 for (i = 0; i < ny; i++) {
3380 for (j = 0; j < nx; j++) {
3382 if ((i & 1) && !(j & 1))
3384 else if (!(i & 1) && (j & 1))
3386 else if ((i & 1) && (j & 1))
3437 l_int32 w, h, i, n, bestindex;
3438 l_float32 var_of_mean, median_of_mean, median_of_stdev, mean_val, stdev_val;
3439 l_float32 mindels, bestdelm, delm, dels, mean, stdev;
3441 NUMA *namean, *nastdev;
3446 return ERROR_INT(
"&boxtile not defined", __func__, 1);
3449 return ERROR_INT(
"pixs not defined", __func__, 1);
3451 return ERROR_INT(
"box not defined", __func__, 1);
3452 if (searchdir != L_HORIZ && searchdir != L_VERT)
3453 return ERROR_INT(
"invalid searchdir", __func__, 1);
3455 return ERROR_INT(
"mindist must be >= 0", __func__, 1);
3457 return ERROR_INT(
"tsize must be > 1", __func__, 1);
3459 L_WARNING(
"ntiles = %d; larger than suggested max of 7\n",
3468 return ERROR_INT(
"no tiles found", __func__, 1);
3475 for (i = 0; i < n; i++) {
3494 &median_of_mean, 0.0, NULL, NULL);
3496 &median_of_stdev, 0.0, NULL, NULL);
3500 for (i = 0; i < n; i++) {
3503 if (var_of_mean == 0.0) {
3507 delm = L_ABS(mean_val - median_of_mean) / sqrt(var_of_mean);
3508 dels = stdev_val / median_of_stdev;
3511 if (dels < mindels) {
3514 " stdev = %7.3f, dels = %7.3f\n",
3515 i, mean_val, delm, stdev_val, dels);
3526 L_INFO(
"median of mean = %7.3f\n", __func__, median_of_mean);
3527 L_INFO(
"standard dev of mean = %7.3f\n", __func__, sqrt(var_of_mean));
3528 L_INFO(
"median of stdev = %7.3f\n", __func__, median_of_stdev);
3529 L_INFO(
"best tile: index = %d\n", __func__, bestindex);
3530 L_INFO(
"delta from median in units of stdev = %5.3f\n",
3531 __func__, bestdelm);
3532 L_INFO(
"stdev as fraction of median stdev = %5.3f\n",
3569 l_int32 bx, by, bw, bh, left, right, top, bot, i, j, nrows, ncols;
3570 l_int32 x0, y0, x, y, w_avail, w_needed, h_avail, h_needed, t_avail;
3575 return (
BOXA *)ERROR_PTR(
"box not defined", __func__, NULL);
3577 return (
BOXA *)ERROR_PTR(
"no tiles requested", __func__, NULL);
3580 if (searchdir == L_HORIZ) {
3584 right = w - bx - bw + 1;
3585 w_avail = L_MAX(left, right) - mindist;
3586 if (tsize & 1) tsize++;
3587 if (w_avail < tsize) {
3588 L_ERROR(
"tsize = %d, w_avail = %d\n", __func__, tsize, w_avail);
3591 w_needed = tsize + (ntiles - 1) * (tsize / 2);
3592 if (w_needed > w_avail) {
3593 t_avail = 1 + 2 * (w_avail - tsize) / tsize;
3594 L_WARNING(
"ntiles = %d; room for only %d\n", __func__,
3597 w_needed = tsize + (ntiles - 1) * (tsize / 2);
3599 nrows = L_MAX(1, 1 + 2 * (bh - tsize) / tsize);
3606 x0 = bx + bw + mindist;
3607 for (i = 0; i < nrows; i++) {
3608 y = by + i * tsize / 2;
3609 for (j = 0; j < ntiles; j++) {
3610 x = x0 + j * tsize / 2;
3618 bot = h - by - bh + 1;
3619 h_avail = L_MAX(top, bot) - mindist;
3620 if (h_avail < tsize) {
3621 L_ERROR(
"tsize = %d, h_avail = %d\n", __func__, tsize, h_avail);
3624 h_needed = tsize + (ntiles - 1) * (tsize / 2);
3625 if (h_needed > h_avail) {
3626 t_avail = 1 + 2 * (h_avail - tsize) / tsize;
3627 L_WARNING(
"ntiles = %d; room for only %d\n", __func__,
3630 h_needed = tsize + (ntiles - 1) * (tsize / 2);
3632 ncols = L_MAX(1, 1 + 2 * (bw - tsize) / tsize);
3639 y0 = by + bh + mindist;
3640 for (j = 0; j < ncols; j++) {
3641 x = bx + j * tsize / 2;
3642 for (i = 0; i < ntiles; i++) {
3643 y = y0 + i * tsize / 2;
#define GET_DATA_QBIT(pdata, n)
#define GET_DATA_TWO_BYTES(pdata, n)
#define SET_DATA_BIT(pdata, n)
#define SET_DATA_DIBIT(pdata, n, val)
#define SET_DATA_TWO_BYTES(pdata, n, val)
#define GET_DATA_BYTE(pdata, n)
#define GET_DATA_DIBIT(pdata, n)
#define SET_DATA_BYTE(pdata, n, val)
#define GET_DATA_BIT(pdata, n)
#define SET_DATA_QBIT(pdata, n, val)
PIX * pixBlendWithGrayMask(PIX *pixs1, PIX *pixs2, PIX *pixg, l_int32 x, l_int32 y)
pixBlendWithGrayMask()
PIX * pixBlend(PIX *pixs1, PIX *pixs2, l_int32 x, l_int32 y, l_float32 fract)
pixBlend()
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 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 * boxCreate(l_int32 x, l_int32 y, l_int32 w, l_int32 h)
boxCreate()
BOXA * boxaCreate(l_int32 n)
boxaCreate()
l_ok boxPrintStreamInfo(FILE *fp, BOX *box)
boxPrintStreamInfo()
BOX * boxClipToRectangle(BOX *box, l_int32 wi, l_int32 hi)
boxClipToRectangle()
BOX * boxAdjustSides(BOX *boxd, BOX *boxs, l_int32 delleft, l_int32 delright, l_int32 deltop, l_int32 delbot)
boxAdjustSides()
l_ok boxClipToRectangleParams(BOX *box, l_int32 w, l_int32 h, l_int32 *pxstart, l_int32 *pystart, l_int32 *pxend, l_int32 *pyend, l_int32 *pbw, l_int32 *pbh)
boxClipToRectangleParams()
BOXA * pixConnComp(PIX *pixs, PIXA **ppixa, l_int32 connectivity)
pixConnComp()
PIX * pixThresholdToBinary(PIX *pixs, l_int32 thresh)
pixThresholdToBinary()
PIX * pixDilate(PIX *pixd, PIX *pixs, SEL *sel)
pixDilate()
PIX * pixDilateBrick(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixDilateBrick()
PIX * pixMorphSequence(PIX *pixs, const char *sequence, l_int32 dispsep)
pixMorphSequence()
l_ok numaAddNumber(NUMA *na, l_float32 val)
numaAddNumber()
l_ok numaGetFValue(NUMA *na, l_int32 index, l_float32 *pval)
numaGetFValue()
NUMA * numaCreate(l_int32 n)
numaCreate()
l_ok numaSetCount(NUMA *na, l_int32 newcount)
numaSetCount()
void numaDestroy(NUMA **pna)
numaDestroy()
l_ok numaSetParameters(NUMA *na, l_float32 startx, l_float32 delx)
numaSetParameters()
l_float32 * numaGetFArray(NUMA *na, l_int32 copyflag)
numaGetFArray()
l_ok numaGetStatsUsingHistogram(NUMA *na, l_int32 maxbins, l_float32 *pmin, l_float32 *pmax, l_float32 *pmean, l_float32 *pvariance, l_float32 *pmedian, l_float32 rank, l_float32 *prval, NUMA **phisto)
numaGetStatsUsingHistogram()
l_ok pixSetMaskedCmap(PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 rval, l_int32 gval, l_int32 bval)
pixSetMaskedCmap()
l_uint32 * pixGetData(PIX *pix)
pixGetData()
void pixDestroy(PIX **ppix)
pixDestroy()
l_ok pixGetDimensions(const PIX *pix, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixGetDimensions()
l_int32 pixSizesEqual(const PIX *pix1, const PIX *pix2)
pixSizesEqual()
l_ok pixCopySpp(PIX *pixd, const PIX *pixs)
pixCopySpp()
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()
PIX * pixGetRGBComponent(PIX *pixs, l_int32 comp)
pixGetRGBComponent()
PIX * pixDisplayLayersRGBA(PIX *pixs, l_uint32 val, l_int32 maxw)
pixDisplayLayersRGBA()
l_ok pixGetPixel(PIX *pix, l_int32 x, l_int32 y, l_uint32 *pval)
pixGetPixel()
l_ok pixSetAll(PIX *pix)
pixSetAll()
l_ok composeRGBPixel(l_int32 rval, l_int32 gval, l_int32 bval, l_uint32 *ppixel)
composeRGBPixel()
void extractRGBValues(l_uint32 pixel, l_int32 *prval, l_int32 *pgval, l_int32 *pbval)
extractRGBValues()
l_ok pixSetBlackOrWhite(PIX *pixs, l_int32 op)
pixSetBlackOrWhite()
l_ok pixSetAllArbitrary(PIX *pix, l_uint32 val)
pixSetAllArbitrary()
NUMA * pixVarianceByRow(PIX *pix, BOX *box)
pixVarianceByRow()
l_ok pixGetColorNearMaskBoundary(PIX *pixs, PIX *pixm, BOX *box, l_int32 dist, l_uint32 *pval, l_int32 debug)
pixGetColorNearMaskBoundary()
PIX * pixMirroredTiling(PIX *pixs, l_int32 w, l_int32 h)
pixMirroredTiling()
NUMA * pixVarianceByColumn(PIX *pix, BOX *box)
pixVarianceByColumn()
NUMA * pixCountByColumn(PIX *pix, BOX *box)
pixCountByColumn()
l_ok pixCombineMaskedGeneral(PIX *pixd, PIX *pixs, PIX *pixm, l_int32 x, l_int32 y)
pixCombineMaskedGeneral()
l_int32 pixCountArbInRect(PIX *pixs, BOX *box, l_int32 val, l_int32 factor, l_int32 *pcount)
pixCountArbInRect()
l_ok pixZero(PIX *pix, l_int32 *pempty)
pixZero()
NUMA * pixaCountPixels(PIXA *pixa)
pixaCountPixels()
NUMA * pixAverageByColumn(PIX *pix, BOX *box, l_int32 type)
pixAverageByColumn()
PIX * pixInvert(PIX *pixd, PIX *pixs)
pixInvert()
PIX * pixCopyWithBoxa(PIX *pixs, BOXA *boxa, l_int32 background)
pixCopyWithBoxa()
l_ok pixPaintThroughMask(PIX *pixd, PIX *pixm, l_int32 x, l_int32 y, l_uint32 val)
pixPaintThroughMask()
l_ok pixCountPixels(PIX *pixs, l_int32 *pcount, l_int32 *tab8)
pixCountPixels()
NUMA * pixAbsDiffByColumn(PIX *pix, BOX *box)
pixAbsDiffByColumn()
PIX * pixSetUnderTransparency(PIX *pixs, l_uint32 val, l_int32 debug)
pixSetUnderTransparency()
PIX * pixMakeAlphaFromMask(PIX *pixs, l_int32 dist, BOX **pbox)
pixMakeAlphaFromMask()
PIX * pixDisplaySelectedPixels(PIX *pixs, PIX *pixm, SEL *sel, l_uint32 val)
pixDisplaySelectedPixels()
PIX * pixOr(PIX *pixd, PIX *pixs1, PIX *pixs2)
pixOr()
NUMA * pixCountPixelsByColumn(PIX *pix)
pixCountPixelsByColumn()
PIX * pixAnd(PIX *pixd, PIX *pixs1, PIX *pixs2)
pixAnd()
static BOXA * findTileRegionsForSearch(BOX *box, l_int32 w, l_int32 h, l_int32 searchdir, l_int32 mindist, l_int32 tsize, l_int32 ntiles)
findTileRegionsForSearch()
l_ok pixCountPixelsInRect(PIX *pixs, BOX *box, l_int32 *pcount, l_int32 *tab8)
pixCountPixelsInRect()
l_ok pixSetMaskedGeneral(PIX *pixd, PIX *pixm, l_uint32 val, l_int32 x, l_int32 y)
pixSetMaskedGeneral()
l_ok pixAbsDiffInRect(PIX *pix, BOX *box, l_int32 dir, l_float32 *pabsdiff)
pixAbsDiffInRect()
l_ok pixPaintSelfThroughMask(PIX *pixd, PIX *pixm, l_int32 x, l_int32 y, l_int32 searchdir, l_int32 mindist, l_int32 tilesize, l_int32 ntiles, l_int32 distblend)
pixPaintSelfThroughMask()
l_ok pixAverageInRectRGB(PIX *pixs, PIX *pixm, BOX *box, l_int32 subsamp, l_uint32 *pave)
pixAverageInRectRGB()
l_ok pixCountPixelsInRow(PIX *pix, l_int32 row, l_int32 *pcount, l_int32 *tab8)
pixCountPixelsInRow()
l_ok pixAverageInRect(PIX *pixs, PIX *pixm, BOX *box, l_int32 minval, l_int32 maxval, l_int32 subsamp, l_float32 *pave)
pixAverageInRect()
l_ok pixSetMasked(PIX *pixd, PIX *pixm, l_uint32 val)
pixSetMasked()
NUMA * pixGetMomentByColumn(PIX *pix, l_int32 order)
pixGetMomentByColumn()
l_int32 * makePixelSumTab8(void)
makePixelSumTab8()
PIX * pixXor(PIX *pixd, PIX *pixs1, PIX *pixs2)
pixXor()
l_int32 * makePixelCentroidTab8(void)
makePixelCentroidTab8()
PIX * pixMakeMaskFromVal(PIX *pixs, l_int32 val)
pixMakeMaskFromVal()
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()
NUMA * pixCountByRow(PIX *pix, BOX *box)
pixCountByRow()
PIX * pixSubtract(PIX *pixd, PIX *pixs1, PIX *pixs2)
pixSubtract()
l_ok pixVarianceInRect(PIX *pix, BOX *box, l_float32 *prootvar)
pixVarianceInRect()
l_ok pixThresholdPixelSum(PIX *pix, l_int32 thresh, l_int32 *pabove, l_int32 *tab8)
pixThresholdPixelSum()
PIX * pixMakeMaskFromLUT(PIX *pixs, l_int32 *tab)
pixMakeMaskFromLUT()
l_ok pixFindRepCloseTile(PIX *pixs, BOX *box, l_int32 searchdir, l_int32 mindist, l_int32 tsize, l_int32 ntiles, BOX **pboxtile, l_int32 debug)
pixFindRepCloseTile()
PIX * pixMakeArbMaskFromRGB(PIX *pixs, l_float32 rc, l_float32 gc, l_float32 bc, l_float32 thresh)
pixMakeArbMaskFromRGB()
NUMA * pixAbsDiffByRow(PIX *pix, BOX *box)
pixAbsDiffByRow()
NUMA * pixAverageByRow(PIX *pix, BOX *box, l_int32 type)
pixAverageByRow()
l_ok pixAbsDiffOnLine(PIX *pix, l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2, l_float32 *pabsdiff)
pixAbsDiffOnLine()
l_ok pixGetAverageMasked(PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor, l_int32 type, l_float32 *pval)
pixGetAverageMasked()
l_ok pixGetAverageMaskedRGB(PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor, l_int32 type, l_float32 *prval, l_float32 *pgval, l_float32 *pbval)
pixGetAverageMaskedRGB()
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()
void pixaDestroy(PIXA **ppixa)
pixaDestroy()
BOX * pixaGetBox(PIXA *pixa, l_int32 index, l_int32 accesstype)
pixaGetBox()
l_int32 pixaGetCount(PIXA *pixa)
pixaGetCount()
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()
l_ok pixMultConstantGray(PIX *pixs, l_float32 val)
pixMultConstantGray()
PIX * pixUnpackBinary(PIX *pixs, l_int32 depth, l_int32 invert)
pixUnpackBinary()
PIX * pixConvertRGBToGray(PIX *pixs, l_float32 rwt, l_float32 gwt, l_float32 bwt)
pixConvertRGBToGray()
PIX * pixConvert1To8(PIX *pixd, PIX *pixs, l_uint8 val0, l_uint8 val1)
pixConvert1To8()
PIX * pixConvertRGBToGrayArb(PIX *pixs, l_float32 rc, l_float32 gc, l_float32 bc)
pixConvertRGBToGrayArb()
PIX * pixConvertTo32(PIX *pixs)
pixConvertTo32()
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 * pixFlipLR(PIX *pixd, PIX *pixs)
pixFlipLR()
PIX * pixFlipTB(PIX *pixd, PIX *pixs)
pixFlipTB()
PIX * pixDistanceFunction(PIX *pixs, l_int32 connectivity, l_int32 outdepth, l_int32 boundcond)
pixDistanceFunction()
void lept_stderr(const char *fmt,...)
lept_stderr()
l_int32 lept_rmdir(const char *subdir)
lept_rmdir()
l_int32 lept_mkdir(const char *subdir)
lept_mkdir()