135#include <config_auto.h>
138#include "allheaders.h"
157 l_int32 mindiff, l_int32 smoothx, l_int32 smoothy,
158 PIX **ppixmin,
PIX **ppixmax);
161 PIX *pixmin,
PIX *pixmax);
165#define DEBUG_GLOBAL 0
207 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
208 d = pixGetDepth(pixs);
209 if (d != 8 && d != 32)
210 return (
PIX *)ERROR_PTR(
"depth not 8 or 32", __func__, NULL);
211 if (whiteval > 200) {
212 L_WARNING(
"white value %d must not exceed 200; reset to 190",
219 return (
PIX *)ERROR_PTR(
"background norm failedd", __func__, NULL);
220 pixGammaTRC(pixd, pixd, gamma, blackval, whiteval);
332PIX *pixm, *pixmi, *pixd;
333PIX *pixmr, *pixmg, *pixmb, *pixmri, *pixmgi, *pixmbi;
336 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
337 d = pixGetDepth(pixs);
338 if (d != 8 && d != 32)
339 return (
PIX *)ERROR_PTR(
"pixs not 8 or 32 bpp", __func__, NULL);
340 if (sx < 4 || sy < 4)
341 return (
PIX *)ERROR_PTR(
"sx and sy must be >= 4", __func__, NULL);
342 if (mincount > sx * sy) {
343 L_WARNING(
"mincount too large for tile size\n", __func__);
344 mincount = (sx * sy) / 3;
349 pixInvert(pixim, pixim);
350 pixZero(pixim, &allfg);
351 pixInvert(pixim, pixim);
353 return (
PIX *)ERROR_PTR(
"pixim all foreground", __func__, NULL);
361 L_WARNING(
"map not made; return a copy of the source\n", __func__);
362 return pixCopy(NULL, pixs);
367 L_WARNING(
"pixmi not made; return a copy of source\n", __func__);
369 return pixCopy(NULL, pixs);
378 pixmr = pixmg = pixmb = NULL;
380 mincount, &pixmr, &pixmg, &pixmb);
381 if (!pixmr || !pixmg || !pixmb) {
385 L_WARNING(
"map not made; return a copy of the source\n", __func__);
386 return pixCopy(NULL, pixs);
392 if (!pixmri || !pixmgi || !pixmbi) {
393 L_WARNING(
"not all pixm*i are made; return src copy\n", __func__);
394 pixd = pixCopy(NULL, pixs);
409 ERROR_PTR(
"pixd not made", __func__, NULL);
410 pixCopyResolution(pixd, pixs);
462PIX *pixm, *pixmi, *pixd;
463PIX *pixmr, *pixmg, *pixmb, *pixmri, *pixmgi, *pixmbi;
466 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
467 d = pixGetDepth(pixs);
468 if (d != 8 && d != 32)
469 return (
PIX *)ERROR_PTR(
"pixs not 8 or 32 bpp", __func__, NULL);
470 if (reduction < 2 || reduction > 16)
471 return (
PIX *)ERROR_PTR(
"reduction must be between 2 and 16",
476 pixInvert(pixim, pixim);
477 pixZero(pixim, &allfg);
478 pixInvert(pixim, pixim);
480 return (
PIX *)ERROR_PTR(
"pixim all foreground", __func__, NULL);
487 return (
PIX *)ERROR_PTR(
"pixm not made", __func__, NULL);
490 ERROR_PTR(
"pixmi not made", __func__, NULL);
493 reduction, reduction);
498 pixmr = pixmg = pixmb = NULL;
500 &pixmr, &pixmg, &pixmb);
501 if (!pixmr || !pixmg || !pixmb) {
505 return (
PIX *)ERROR_PTR(
"not all pixm*", __func__, NULL);
511 if (!pixmri || !pixmgi || !pixmbi)
512 ERROR_PTR(
"not all pixm*i are made", __func__, NULL);
515 reduction, reduction);
526 ERROR_PTR(
"pixd not made", __func__, NULL);
527 pixCopyResolution(pixd, pixs);
579 return ERROR_INT(
"&pixd not defined", __func__, 1);
581 if (!pixs || pixGetDepth(pixs) != 8)
582 return ERROR_INT(
"pixs not defined or not 8 bpp", __func__, 1);
583 if (pixGetColormap(pixs))
584 return ERROR_INT(
"pixs is colormapped", __func__, 1);
585 if (pixim && pixGetDepth(pixim) != 1)
586 return ERROR_INT(
"pixim not 1 bpp", __func__, 1);
587 if (sx < 4 || sy < 4)
588 return ERROR_INT(
"sx and sy must be >= 4", __func__, 1);
589 if (mincount > sx * sy) {
590 L_WARNING(
"mincount too large for tile size\n", __func__);
591 mincount = (sx * sy) / 3;
596 pixInvert(pixim, pixim);
597 pixZero(pixim, &allfg);
598 pixInvert(pixim, pixim);
600 return ERROR_INT(
"pixim all foreground", __func__, 1);
605 return ERROR_INT(
"pixm not made", __func__, 1);
607 pixCopyResolution(*ppixd, pixs);
654PIX *pixmr, *pixmg, *pixmb;
656 if (!ppixr || !ppixg || !ppixb)
657 return ERROR_INT(
"&pixr, &pixg, &pixb not all defined", __func__, 1);
658 *ppixr = *ppixg = *ppixb = NULL;
660 return ERROR_INT(
"pixs not defined", __func__, 1);
661 if (pixGetDepth(pixs) != 32)
662 return ERROR_INT(
"pixs not 32 bpp", __func__, 1);
663 if (pixim && pixGetDepth(pixim) != 1)
664 return ERROR_INT(
"pixim not 1 bpp", __func__, 1);
665 if (sx < 4 || sy < 4)
666 return ERROR_INT(
"sx and sy must be >= 4", __func__, 1);
667 if (mincount > sx * sy) {
668 L_WARNING(
"mincount too large for tile size\n", __func__);
669 mincount = (sx * sy) / 3;
674 pixInvert(pixim, pixim);
675 pixZero(pixim, &allfg);
676 pixInvert(pixim, pixim);
678 return ERROR_INT(
"pixim all foreground", __func__, 1);
682 &pixmr, &pixmg, &pixmb);
683 if (!pixmr || !pixmg || !pixmb) {
687 return ERROR_INT(
"not all pixm* made", __func__, 1);
731 return ERROR_INT(
"&pixd not defined", __func__, 1);
734 return ERROR_INT(
"pixs not defined", __func__, 1);
735 if (pixGetDepth(pixs) != 8)
736 return ERROR_INT(
"pixs not 8 bpp", __func__, 1);
737 if (pixim && pixGetDepth(pixim) != 1)
738 return ERROR_INT(
"pixim not 1 bpp", __func__, 1);
739 if (reduction < 2 || reduction > 16)
740 return ERROR_INT(
"reduction must be between 2 and 16", __func__, 1);
744 pixInvert(pixim, pixim);
745 pixZero(pixim, &allfg);
746 pixInvert(pixim, pixim);
748 return ERROR_INT(
"pixim all foreground", __func__, 1);
753 return ERROR_INT(
"pixm not made", __func__, 1);
755 pixCopyResolution(*ppixd, pixs);
793PIX *pixmr, *pixmg, *pixmb;
795 if (!ppixr || !ppixg || !ppixb)
796 return ERROR_INT(
"&pixr, &pixg, &pixb not all defined", __func__, 1);
797 *ppixr = *ppixg = *ppixb = NULL;
799 return ERROR_INT(
"pixs not defined", __func__, 1);
800 if (pixGetDepth(pixs) != 32)
801 return ERROR_INT(
"pixs not 32 bpp", __func__, 1);
802 if (pixim && pixGetDepth(pixim) != 1)
803 return ERROR_INT(
"pixim not 1 bpp", __func__, 1);
804 if (reduction < 2 || reduction > 16)
805 return ERROR_INT(
"reduction must be between 2 and 16", __func__, 1);
809 pixInvert(pixim, pixim);
810 pixZero(pixim, &allfg);
811 pixInvert(pixim, pixim);
813 return ERROR_INT(
"pixim all foreground", __func__, 1);
817 &pixmr, &pixmg, &pixmb);
818 if (!pixmr || !pixmg || !pixmb) {
822 return ERROR_INT(
"not all pixm* made", __func__, 1);
866l_int32 w, h, wd, hd, wim, him, wpls, wplim, wpld, wplf;
867l_int32 xim, yim, delx, nx, ny, i, j, k, m;
868l_int32 count, sum, val8;
869l_int32 empty, fgpixels;
870l_uint32 *datas, *dataim, *datad, *dataf, *lines, *lineim, *lined, *linef;
871l_float32 scalex, scaley;
872PIX *pixd, *piximi, *pixb, *pixf, *pixims;
875 return ERROR_INT(
"&pixd not defined", __func__, 1);
877 if (!pixs || pixGetDepth(pixs) != 8)
878 return ERROR_INT(
"pixs not defined or not 8 bpp", __func__, 1);
879 if (pixGetColormap(pixs))
880 return ERROR_INT(
"pixs is colormapped", __func__, 1);
881 if (pixim && pixGetDepth(pixim) != 1)
882 return ERROR_INT(
"pixim not 1 bpp", __func__, 1);
883 if (sx < 4 || sy < 4)
884 return ERROR_INT(
"sx and sy must be >= 4", __func__, 1);
885 if (mincount > sx * sy) {
886 L_WARNING(
"mincount too large for tile size\n", __func__);
887 mincount = (sx * sy) / 3;
894 piximi = pixInvert(NULL, pixim);
895 pixZero(piximi, &empty);
898 return ERROR_INT(
"pixim all fg; no background", __func__, 1);
899 pixZero(pixim, &empty);
907 pixb = pixThresholdToBinary(pixs, thresh);
908 pixf = pixMorphSequence(pixb,
"d7.1 + d1.7", 0);
911 return ERROR_INT(
"pixf not made", __func__, 1);
916 w = pixGetWidth(pixs);
917 h = pixGetHeight(pixs);
918 wd = (w + sx - 1) / sx;
919 hd = (h + sy - 1) / sy;
920 pixd = pixCreate(wd, hd, 8);
927 wpls = pixGetWpl(pixs);
928 datas = pixGetData(pixs);
929 wpld = pixGetWpl(pixd);
930 datad = pixGetData(pixd);
931 wplf = pixGetWpl(pixf);
932 dataf = pixGetData(pixf);
933 for (i = 0; i < ny; i++) {
934 lines = datas + sy * i * wpls;
935 linef = dataf + sy * i * wplf;
936 lined = datad + i * wpld;
937 for (j = 0; j < nx; j++) {
941 for (k = 0; k < sy; k++) {
942 for (m = 0; m < sx; m++) {
949 if (count >= mincount) {
968 if (pixim && fgpixels) {
969 wim = pixGetWidth(pixim);
970 him = pixGetHeight(pixim);
971 dataim = pixGetData(pixim);
972 wplim = pixGetWpl(pixim);
973 for (i = 0; i < ny; i++) {
974 yim = i * sy + sy / 2;
977 lineim = dataim + yim * wplim;
978 for (j = 0; j < nx; j++) {
979 xim = j * sx + sx / 2;
983 pixSetPixel(pixd, j, i, 0);
991 L_WARNING(
"can't make the map\n", __func__);
1000 if (pixim && fgpixels) {
1001 scalex = 1. / (l_float32)sx;
1002 scaley = 1. / (l_float32)sy;
1003 pixims = pixScaleBySampling(pixim, scalex, scaley);
1005 pixDestroy(&pixims);
1009 pixCopyResolution(*ppixd, pixs);
1049l_int32 w, h, wm, hm, wim, him, wpls, wplim, wplf;
1050l_int32 xim, yim, delx, nx, ny, i, j, k, m;
1051l_int32 count, rsum, gsum, bsum, rval, gval, bval;
1052l_int32 empty, fgpixels;
1054l_uint32 *datas, *dataim, *dataf, *lines, *lineim, *linef;
1055l_float32 scalex, scaley;
1056PIX *piximi, *pixgc, *pixb, *pixf, *pixims;
1057PIX *pixmr, *pixmg, *pixmb;
1059 if (!ppixmr || !ppixmg || !ppixmb)
1060 return ERROR_INT(
"&pixm* not all defined", __func__, 1);
1061 *ppixmr = *ppixmg = *ppixmb = NULL;
1063 return ERROR_INT(
"pixs not defined", __func__, 1);
1064 if (pixGetDepth(pixs) != 32)
1065 return ERROR_INT(
"pixs not 32 bpp", __func__, 1);
1066 if (pixim && pixGetDepth(pixim) != 1)
1067 return ERROR_INT(
"pixim not 1 bpp", __func__, 1);
1068 if (sx < 4 || sy < 4)
1069 return ERROR_INT(
"sx and sy must be >= 4", __func__, 1);
1070 if (mincount > sx * sy) {
1071 L_WARNING(
"mincount too large for tile size\n", __func__);
1072 mincount = (sx * sy) / 3;
1078 piximi = pixInvert(NULL, pixim);
1079 pixZero(piximi, &empty);
1080 pixDestroy(&piximi);
1082 return ERROR_INT(
"pixim all fg; no background", __func__, 1);
1083 pixZero(pixim, &empty);
1091 pixgc = pixClone(pixg);
1093 pixgc = pixConvertRGBToGrayFast(pixs);
1094 pixb = pixThresholdToBinary(pixgc, thresh);
1095 pixf = pixMorphSequence(pixb,
"d7.1 + d1.7", 0);
1100 w = pixGetWidth(pixs);
1101 h = pixGetHeight(pixs);
1102 wm = (w + sx - 1) / sx;
1103 hm = (h + sy - 1) / sy;
1104 pixmr = pixCreate(wm, hm, 8);
1105 pixmg = pixCreate(wm, hm, 8);
1106 pixmb = pixCreate(wm, hm, 8);
1114 wpls = pixGetWpl(pixs);
1115 datas = pixGetData(pixs);
1116 wplf = pixGetWpl(pixf);
1117 dataf = pixGetData(pixf);
1118 for (i = 0; i < ny; i++) {
1119 lines = datas + sy * i * wpls;
1120 linef = dataf + sy * i * wplf;
1121 for (j = 0; j < nx; j++) {
1123 rsum = gsum = bsum = 0;
1125 for (k = 0; k < sy; k++) {
1126 for (m = 0; m < sx; m++) {
1128 pixel = *(lines + k * wpls + delx + m);
1129 rsum += (pixel >> 24);
1130 gsum += ((pixel >> 16) & 0xff);
1131 bsum += ((pixel >> 8) & 0xff);
1136 if (count >= mincount) {
1137 rval = rsum / count;
1138 gval = gsum / count;
1139 bval = bsum / count;
1140 pixSetPixel(pixmr, j, i, rval);
1141 pixSetPixel(pixmg, j, i, gval);
1142 pixSetPixel(pixmb, j, i, bval);
1154 wim = pixGetWidth(pixim);
1155 him = pixGetHeight(pixim);
1156 dataim = pixGetData(pixim);
1157 wplim = pixGetWpl(pixim);
1158 for (i = 0; i < ny; i++) {
1159 yim = i * sy + sy / 2;
1162 lineim = dataim + yim * wplim;
1163 for (j = 0; j < nx; j++) {
1164 xim = j * sx + sx / 2;
1168 pixSetPixel(pixmr, j, i, 0);
1169 pixSetPixel(pixmg, j, i, 0);
1170 pixSetPixel(pixmb, j, i, 0);
1183 L_WARNING(
"can't make the maps\n", __func__);
1189 if (pixim && fgpixels) {
1190 scalex = 1. / (l_float32)sx;
1191 scaley = 1. / (l_float32)sy;
1192 pixims = pixScaleBySampling(pixim, scalex, scaley);
1196 pixDestroy(&pixims);
1202 pixCopyResolution(*ppixmr, pixs);
1203 pixCopyResolution(*ppixmg, pixs);
1204 pixCopyResolution(*ppixmb, pixs);
1227l_int32 nx, ny, empty, fgpixels;
1229PIX *pixm, *pix1, *pix2, *pix3, *pixims;
1232 return ERROR_INT(
"&pixm not defined", __func__, 1);
1234 if (!pixs || pixGetDepth(pixs) != 8)
1235 return ERROR_INT(
"pixs not defined or not 8 bpp", __func__, 1);
1236 if (pixGetColormap(pixs))
1237 return ERROR_INT(
"pixs is colormapped", __func__, 1);
1238 if (pixim && pixGetDepth(pixim) != 1)
1239 return ERROR_INT(
"pixim not 1 bpp", __func__, 1);
1244 pixInvert(pixim, pixim);
1245 pixZero(pixim, &empty);
1247 return ERROR_INT(
"pixim all fg; no background", __func__, 1);
1248 pixInvert(pixim, pixim);
1249 pixZero(pixim, &empty);
1255 scale = 1. / (l_float32)reduction;
1256 pix1 = pixScaleBySampling(pixs, scale, scale);
1257 pix2 = pixCloseGray(pix1, size, size);
1266 pixims = pixScale(pixim, scale, scale);
1267 pixm = pixConvertTo8(pixims, FALSE);
1268 pixAnd(pixm, pixm, pix3);
1271 pixm = pixClone(pix3);
1275 nx = pixGetWidth(pixs) / reduction;
1276 ny = pixGetHeight(pixs) / reduction;
1279 pixDestroy(&pixims);
1280 L_WARNING(
"can't make the map\n", __func__);
1286 if (pixim && fgpixels)
1288 pixDestroy(&pixims);
1291 pixCopyResolution(*ppixm, pixs);
1318l_int32 nx, ny, empty, fgpixels;
1320PIX *pixm, *pixmr, *pixmg, *pixmb, *pix1, *pix2, *pix3, *pixims;
1322 if (!ppixmr || !ppixmg || !ppixmb)
1323 return ERROR_INT(
"&pixm* not all defined", __func__, 1);
1324 *ppixmr = *ppixmg = *ppixmb = NULL;
1326 return ERROR_INT(
"pixs not defined", __func__, 1);
1327 if (pixGetDepth(pixs) != 32)
1328 return ERROR_INT(
"pixs not 32 bpp", __func__, 1);
1329 if (pixim && pixGetDepth(pixim) != 1)
1330 return ERROR_INT(
"pixim not 1 bpp", __func__, 1);
1335 pixInvert(pixim, pixim);
1336 pixZero(pixim, &empty);
1338 return ERROR_INT(
"pixim all fg; no background", __func__, 1);
1339 pixInvert(pixim, pixim);
1340 pixZero(pixim, &empty);
1346 scale = 1. / (l_float32)reduction;
1350 pixims = pixScale(pixim, scale, scale);
1351 pixm = pixConvertTo8(pixims, FALSE);
1357 pix1 = pixScaleRGBToGrayFast(pixs, reduction,
COLOR_RED);
1358 pix2 = pixCloseGray(pix1, size, size);
1361 pixmr = pixAnd(NULL, pixm, pix3);
1363 pixmr = pixClone(pix3);
1368 pix1 = pixScaleRGBToGrayFast(pixs, reduction,
COLOR_GREEN);
1369 pix2 = pixCloseGray(pix1, size, size);
1372 pixmg = pixAnd(NULL, pixm, pix3);
1374 pixmg = pixClone(pix3);
1379 pix1 = pixScaleRGBToGrayFast(pixs, reduction,
COLOR_BLUE);
1380 pix2 = pixCloseGray(pix1, size, size);
1383 pixmb = pixAnd(NULL, pixm, pix3);
1385 pixmb = pixClone(pix3);
1392 nx = pixGetWidth(pixs) / reduction;
1393 ny = pixGetHeight(pixs) / reduction;
1400 pixDestroy(&pixims);
1401 L_WARNING(
"can't make the maps\n", __func__);
1408 if (pixim && fgpixels) {
1412 pixDestroy(&pixims);
1418 pixCopyResolution(*ppixmr, pixs);
1419 pixCopyResolution(*ppixmg, pixs);
1420 pixCopyResolution(*ppixmb, pixs);
1467l_int32 w, h, y, nmiss, goodcol, i, j, found, ival, valtest;
1468l_uint32 val, lastval;
1471 if (!pix || pixGetDepth(pix) != 8)
1472 return ERROR_INT(
"pix not defined or not 8 bpp", __func__, 1);
1473 if (pixGetColormap(pix))
1474 return ERROR_INT(
"pix is colormapped", __func__, 1);
1477 pixGetDimensions(pix, &w, &h, NULL);
1481 for (j = 0; j < nx; j++) {
1483 for (i = 0; i < ny; i++) {
1484 pixGetPixel(pix, j, i, &val);
1485 if (val != valtest) {
1491 if (found == FALSE) {
1492 numaAddNumber(na, 0);
1496 numaAddNumber(na, 1);
1497 for (i = y - 1; i >= 0; i--)
1498 pixSetPixel(pix, j, i, val);
1499 pixGetPixel(pix, j, 0, &lastval);
1500 for (i = 1; i < h; i++) {
1501 pixGetPixel(pix, j, i, &val);
1503 pixSetPixel(pix, j, i, lastval);
1512 L_WARNING(
"no bg found; no data in any column\n", __func__);
1520 for (j = 0; j < w; j++) {
1521 numaGetIValue(na, j, &ival);
1528 for (j = goodcol - 1; j >= 0; j--)
1529 pixRasterop(pix, j, 0, 1, h,
PIX_SRC, pix, j + 1, 0);
1531 for (j = goodcol + 1; j < w; j++) {
1532 numaGetIValue(na, j, &ival);
1535 pixRasterop(pix, j, 0, 1, h,
PIX_SRC, pix, j - 1, 0);
1540 pixRasterop(pix, w - 1, 0, 1, h,
PIX_SRC, pix, w - 2, 0);
1570 if (!pixs || pixGetDepth(pixs) != 8)
1571 return (
PIX *)ERROR_PTR(
"pixs undefined or not 8 bpp", __func__, NULL);
1573 if (addw == 0 && addh == 0)
1574 return pixCopy(NULL, pixs);
1576 pixGetDimensions(pixs, &w, &h, NULL);
1577 if ((pixd = pixCreate(w + addw, h + addh, 8)) == NULL)
1578 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
1579 pixRasterop(pixd, 0, 0, w, h,
PIX_SRC, pixs, 0, 0);
1582 for (i = 0; i < h; i++) {
1583 pixGetPixel(pixd, w - 1, i, &val);
1584 for (j = 0; j < addw; j++)
1585 pixSetPixel(pixd, w + j, i, val);
1590 for (j = 0; j < w + addw; j++) {
1591 pixGetPixel(pixd, j, h - 1, &val);
1592 for (i = 0; i < addh; i++)
1593 pixSetPixel(pixd, j, h + i, val);
1597 pixCopyResolution(pixd, pixs);
1627l_int32 empty, i, n, x, y;
1633 if (!pixs || pixGetDepth(pixs) != 8)
1634 return ERROR_INT(
"pixs not defined or not 8 bpp", __func__, 1);
1635 if (pixGetColormap(pixs))
1636 return ERROR_INT(
"pixs has colormap", __func__, 1);
1638 L_INFO(
"pixm not defined\n", __func__);
1641 if (pixGetDepth(pixm) != 1)
1642 return ERROR_INT(
"pixm not 1 bpp", __func__, 1);
1643 pixZero(pixm, &empty);
1645 L_INFO(
"pixm has no fg pixels; nothing to do\n", __func__);
1649 boxa = pixConnComp(pixm, &pixa, 8);
1650 n = boxaGetCount(boxa);
1651 for (i = 0; i < n; i++) {
1652 if ((pixmc = pixaGetPix(pixa, i,
L_CLONE)) == NULL) {
1653 L_WARNING(
"missing pixmc!\n", __func__);
1656 boxaGetBoxGeometry(boxa, i, &x, &y, NULL, NULL);
1657 pixGetAverageMasked(pixs, pixmc, x, y, factor,
L_MEAN_ABSVAL, &aveval);
1658 pixPaintThroughMask(pixs, pixmc, x, y, (l_int32)aveval);
1710pixGetForegroundGrayMap(
PIX *pixs,
1717l_int32 w, h, d, wd, hd;
1718l_int32 empty, fgpixels;
1719PIX *pixd, *piximi, *pixim2, *pixims, *pixs2, *pixb, *pixt1, *pixt2, *pixt3;
1722 return ERROR_INT(
"&pixd not defined", __func__, 1);
1725 return ERROR_INT(
"pixs not defined", __func__, 1);
1726 pixGetDimensions(pixs, &w, &h, &d);
1728 return ERROR_INT(
"pixs not 8 bpp", __func__, 1);
1729 if (pixim && pixGetDepth(pixim) != 1)
1730 return ERROR_INT(
"pixim not 1 bpp", __func__, 1);
1731 if (sx < 2 || sy < 2)
1732 return ERROR_INT(
"sx and sy must be >= 2", __func__, 1);
1735 wd = (w + sx - 1) / sx;
1736 hd = (h + sy - 1) / sy;
1737 pixd = pixCreate(wd, hd, 8);
1744 piximi = pixInvert(NULL, pixim);
1745 pixZero(piximi, &empty);
1746 pixDestroy(&piximi);
1749 pixZero(pixim, &empty);
1755 pixs2 = pixScaleBySampling(pixs, 0.5, 0.5);
1756 if (pixim && fgpixels) {
1757 pixim2 = pixReduceBinary2(pixim, NULL);
1758 pixPaintThroughMask(pixs2, pixim2, 0, 0, 255);
1759 pixDestroy(&pixim2);
1763 pixt1 = pixScaleGrayMinMax(pixs2, sx, sy, L_CHOOSE_MIN);
1768 pixb = pixThresholdToBinary(pixt1, thresh);
1769 pixInvert(pixb, pixb);
1770 pixPaintThroughMask(pixt1, pixb, 0, 0, 255);
1774 pixt2 = pixExpandReplicate(pixt1, 2);
1784 pixt3 = pixBlockconv(pixt2, 8, 8);
1785 pixRasterop(pixd, 0, 0, wd, hd,
PIX_SRC, pixt3, 0, 0);
1788 pixims = pixScaleBySampling(pixim, 1. / sx, 1. / sy);
1789 pixPaintThroughMask(pixd, pixims, 0, 0, 0);
1825l_int32 w, h, wplsm, wpld, i, j;
1827l_uint32 *datasm, *datad, *linesm, *lined;
1830 if (!pixs || pixGetDepth(pixs) != 8)
1831 return (
PIX *)ERROR_PTR(
"pixs undefined or not 8 bpp", __func__, NULL);
1832 if (pixGetColormap(pixs))
1833 return (
PIX *)ERROR_PTR(
"pixs has colormap", __func__, NULL);
1834 pixGetDimensions(pixs, &w, &h, NULL);
1836 return (
PIX *)ERROR_PTR(
"w and h must be >= 5", __func__, NULL);
1839 pixsm = pixBlockconv(pixs, smoothx, smoothy);
1840 datasm = pixGetData(pixsm);
1841 wplsm = pixGetWpl(pixsm);
1844 pixd = pixCreate(w, h, 16);
1845 datad = pixGetData(pixd);
1846 wpld = pixGetWpl(pixd);
1847 for (i = 0; i < h; i++) {
1848 linesm = datasm + i * wplsm;
1849 lined = datad + i * wpld;
1850 for (j = 0; j < w; j++) {
1853 val16 = (256 * bgval) / val;
1855 L_WARNING(
"smoothed bg has 0 pixel!\n", __func__);
1863 pixCopyResolution(pixd, pixs);
1886l_int32 w, h, wm, hm, wpls, wpld, i, j, k, m, xoff, yoff;
1889l_uint32 *datas, *datad, *lines, *lined, *flines, *flined;
1892 if (!pixs || pixGetDepth(pixs) != 8)
1893 return (
PIX *)ERROR_PTR(
"pixs undefined or not 8 bpp", __func__, NULL);
1894 if (pixGetColormap(pixs))
1895 return (
PIX *)ERROR_PTR(
"pixs has colormap", __func__, NULL);
1896 if (!pixm || pixGetDepth(pixm) != 16)
1897 return (
PIX *)ERROR_PTR(
"pixm undefined or not 16 bpp", __func__, NULL);
1898 if (sx == 0 || sy == 0)
1899 return (
PIX *)ERROR_PTR(
"invalid sx and/or sy", __func__, NULL);
1901 datas = pixGetData(pixs);
1902 wpls = pixGetWpl(pixs);
1903 pixGetDimensions(pixs, &w, &h, NULL);
1904 pixGetDimensions(pixm, &wm, &hm, NULL);
1905 if ((pixd = pixCreateTemplate(pixs)) == NULL)
1906 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
1907 datad = pixGetData(pixd);
1908 wpld = pixGetWpl(pixd);
1909 for (i = 0; i < hm; i++) {
1910 lines = datas + sy * i * wpls;
1911 lined = datad + sy * i * wpld;
1913 for (j = 0; j < wm; j++) {
1914 pixGetPixel(pixm, j, i, &val16);
1916 for (k = 0; k < sy && yoff + k < h; k++) {
1917 flines = lines + k * wpls;
1918 flined = lined + k * wpld;
1919 for (m = 0; m < sx && xoff + m < w; m++) {
1921 vald = (vals * val16) / 256;
1922 vald = L_MIN(vald, 255);
1952l_int32 w, h, wm, hm, wpls, wpld, i, j, k, m, xoff, yoff;
1953l_int32 rvald, gvald, bvald;
1955l_uint32 rval16, gval16, bval16;
1956l_uint32 *datas, *datad, *lines, *lined, *flines, *flined;
1960 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1961 if (pixGetDepth(pixs) != 32)
1962 return (
PIX *)ERROR_PTR(
"pixs not 32 bpp", __func__, NULL);
1963 if (!pixmr || !pixmg || !pixmb)
1964 return (
PIX *)ERROR_PTR(
"pix maps not all defined", __func__, NULL);
1965 if (pixGetDepth(pixmr) != 16 || pixGetDepth(pixmg) != 16 ||
1966 pixGetDepth(pixmb) != 16)
1967 return (
PIX *)ERROR_PTR(
"pix maps not all 16 bpp", __func__, NULL);
1968 if (sx == 0 || sy == 0)
1969 return (
PIX *)ERROR_PTR(
"invalid sx and/or sy", __func__, NULL);
1971 datas = pixGetData(pixs);
1972 wpls = pixGetWpl(pixs);
1973 w = pixGetWidth(pixs);
1974 h = pixGetHeight(pixs);
1975 wm = pixGetWidth(pixmr);
1976 hm = pixGetHeight(pixmr);
1977 if ((pixd = pixCreateTemplate(pixs)) == NULL)
1978 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
1979 datad = pixGetData(pixd);
1980 wpld = pixGetWpl(pixd);
1981 for (i = 0; i < hm; i++) {
1982 lines = datas + sy * i * wpls;
1983 lined = datad + sy * i * wpld;
1985 for (j = 0; j < wm; j++) {
1986 pixGetPixel(pixmr, j, i, &rval16);
1987 pixGetPixel(pixmg, j, i, &gval16);
1988 pixGetPixel(pixmb, j, i, &bval16);
1990 for (k = 0; k < sy && yoff + k < h; k++) {
1991 flines = lines + k * wpls;
1992 flined = lined + k * wpld;
1993 for (m = 0; m < sx && xoff + m < w; m++) {
1994 vals = *(flines + xoff + m);
1995 rvald = ((vals >> 24) * rval16) / 256;
1996 rvald = L_MIN(rvald, 255);
1997 gvald = (((vals >> 16) & 0xff) * gval16) / 256;
1998 gvald = L_MIN(gvald, 255);
1999 bvald = (((vals >> 8) & 0xff) * bval16) / 256;
2000 bvald = L_MIN(bvald, 255);
2001 composeRGBPixel(rvald, gvald, bvald, flined + xoff + m);
2045l_int32 i, j, w, h, d, wpls, wplg, wpld, vals, valg, vald;
2047l_uint32 *datas, *datag, *datad, *lines, *lineg, *lined;
2052 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
2054 return (
PIX *)ERROR_PTR(
"pixg not defined", __func__, NULL);
2055 if (!pixSizesEqual(pixs, pixg))
2056 return (
PIX *)ERROR_PTR(
"pix sizes not equal", __func__, NULL);
2057 pixGetDimensions(pixs, &w, &h, &d);
2059 return (
PIX *)ERROR_PTR(
"depth not 8 bpp", __func__, NULL);
2069 if (w * h > 100000) {
2070 lut = (l_uint8 *)LEPT_CALLOC(0x10000,
sizeof(l_uint8));
2071 for (i = 0; i < 256; i++) {
2072 for (j = 0; j < 256; j++) {
2073 fval = (l_float32)(i * target) / (j + 0.5);
2074 lut[(i << 8) + j] = L_MIN(255, (l_int32)(fval + 0.5));
2079 if ((pixd = pixCreate(w, h, 8)) == NULL) {
2081 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
2083 pixCopyResolution(pixd, pixs);
2084 datad = pixGetData(pixd);
2085 wpld = pixGetWpl(pixd);
2086 datas = pixGetData(pixs);
2087 wpls = pixGetWpl(pixs);
2088 datag = pixGetData(pixg);
2089 wplg = pixGetWpl(pixg);
2090 for (i = 0; i < h; i++) {
2091 lines = datas + i * wpls;
2092 lineg = datag + i * wplg;
2093 lined = datad + i * wpld;
2095 for (j = 0; j < w; j++) {
2098 vald = lut[(vals << 8) + valg];
2103 for (j = 0; j < w; j++) {
2106 fval = (l_float32)(vals * target) / (valg + 0.5);
2107 vald = L_MIN(255, (l_int32)(fval + 0.5));
2163l_int32 w, h, d, i, j, ncolors, rv, gv, bv, wpl;
2164l_int32 *rarray, *garray, *barray;
2165l_uint32 *data, *line;
2166NUMA *nar, *nag, *nab;
2170 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
2171 cmap = pixGetColormap(pixs);
2172 pixGetDimensions(pixs, &w, &h, &d);
2173 if (!cmap && d != 32)
2174 return (
PIX *)ERROR_PTR(
"pixs not cmapped or 32 bpp", __func__, NULL);
2176 L_WARNING(
"mapval must be > 0; setting to 255\n", __func__);
2181 if ((pixd = pixCopy(pixd, pixs)) == NULL)
2182 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
2186 nar = numaGammaTRC(1.0, 0, L_MAX(1, 255 * rval / mapval));
2187 nag = numaGammaTRC(1.0, 0, L_MAX(1, 255 * gval / mapval));
2188 nab = numaGammaTRC(1.0, 0, L_MAX(1, 255 * bval / mapval));
2191 rarray = numaGetIArray(nar);
2192 garray = numaGetIArray(nag);
2193 barray = numaGetIArray(nab);
2194 if (!nar || !nag || !nab || !rarray || !garray || !barray) {
2195 L_ERROR(
"allocation failure in arrays\n", __func__);
2196 goto cleanup_arrays;
2200 ncolors = pixcmapGetCount(cmap);
2201 for (i = 0; i < ncolors; i++) {
2202 pixcmapGetColor(cmap, i, &rv, &gv, &bv);
2203 pixcmapResetColor(cmap, i, rarray[rv], garray[gv], barray[bv]);
2207 data = pixGetData(pixd);
2208 wpl = pixGetWpl(pixd);
2209 for (i = 0; i < h; i++) {
2210 line = data + i * wpl;
2211 for (j = 0; j < w; j++) {
2212 extractRGBValues(line[j], &rv, &gv, &bv);
2213 composeRGBPixel(rarray[rv], garray[gv], barray[bv], line + j);
2272l_float32 rankrval, rankgval, rankbval;
2273l_float32 rfract, gfract, bfract, maxfract;
2276 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
2277 if (pixGetDepth(pixs) != 32)
2278 return (
PIX *)ERROR_PTR(
"pixs not 32 bpp", __func__, NULL);
2280 return (
PIX *)ERROR_PTR(
"sampling factor < 1", __func__, NULL);
2281 if (rank < 0.0 || rank > 1.0)
2282 return (
PIX *)ERROR_PTR(
"rank not in [0.0 ... 1.0]", __func__, NULL);
2283 if (rval <= 0 || gval <= 0 || bval <= 0)
2284 return (
PIX *)ERROR_PTR(
"invalid estim. color values", __func__, NULL);
2296 pixGetRankValueMaskedRGB(pixs, NULL, 0, 0, factor, rank, &rankrval,
2297 &rankgval, &rankbval);
2298 rfract = rankrval / (l_float32)rval;
2299 gfract = rankgval / (l_float32)gval;
2300 bfract = rankbval / (l_float32)bval;
2301 maxfract = L_MAX(rfract, gfract);
2302 maxfract = L_MAX(maxfract, bfract);
2304 lept_stderr(
"rankrval = %7.2f, rankgval = %7.2f, rankbval = %7.2f\n",
2305 rankrval, rankgval, rankbval);
2306 lept_stderr(
"rfract = %7.4f, gfract = %7.4f, bfract = %7.4f\n",
2307 rfract, gfract, bfract);
2310 mapval = (l_int32)(255. / maxfract);
2371 l_int32 targetthresh,
2376PIX *pixe, *pixet, *pixsd, *pixg1, *pixg2, *pixth;
2378 if (ppixth) *ppixth = NULL;
2379 if (ppixb) *ppixb = NULL;
2380 if (ppixd) *ppixd = NULL;
2381 if (!pixs || pixGetDepth(pixs) != 8)
2382 return ERROR_INT(
"pixs not defined or not 8 bpp", __func__, 1);
2383 if (pixGetColormap(pixs))
2384 return ERROR_INT(
"pixs is colormapped", __func__, 1);
2385 if (!ppixth && !ppixb && !ppixd)
2386 return ERROR_INT(
"no output requested", __func__, 1);
2388 return ERROR_INT(
"invalid filter type", __func__, 1);
2396 pixet = pixThresholdToBinary(pixe, edgethresh);
2397 pixInvert(pixet, pixet);
2401 pixsd = pixCreateTemplate(pixs);
2402 pixCombineMasked(pixsd, pixs, pixet);
2405 pixg1 = pixSeedspread(pixsd, 4);
2406 pixg2 = pixBlockconv(pixg1, smoothx, smoothy);
2409 pixth = pixGammaTRC(NULL, pixg2, gamma, minval, maxval);
2415 *ppixb = pixThresholdToBinary(*ppixd, targetthresh);
2418 *ppixb = pixVarThresholdToBinary(pixs, pixth);
2474l_float32 scalex, scaley;
2475PIX *pixt, *pixsd, *pixmin, *pixbg, *pixbgi, *pixd;
2477 if (!pixs || pixGetDepth(pixs) != 8)
2478 return (
PIX *)ERROR_PTR(
"pixs undefined or not 8 bpp", __func__, NULL);
2479 if (pixGetColormap(pixs))
2480 return (
PIX *)ERROR_PTR(
"pixs is colormapped", __func__, NULL);
2481 if (sx < 3 || sy < 3)
2482 return (
PIX *)ERROR_PTR(
"sx and/or sy less than 3", __func__, NULL);
2483 if (sx > 10 || sy > 10)
2484 return (
PIX *)ERROR_PTR(
"sx and/or sy exceed 10", __func__, NULL);
2485 if (smoothx < 1 || smoothy < 1)
2486 return (
PIX *)ERROR_PTR(
"smooth params less than 1", __func__, NULL);
2487 if (smoothx > 3 || smoothy > 3)
2488 return (
PIX *)ERROR_PTR(
"smooth params exceed 3", __func__, NULL);
2491 scalex = 1. / (l_float32)sx;
2492 scaley = 1. / (l_float32)sy;
2493 pixt = pixScaleSmooth(pixs, scalex, scaley);
2497 pixsd = pixClone(pixt);
2499 pixLocalExtrema(pixt, 0, 0, &pixmin, NULL);
2500 pixsd = pixSeedfillGrayBasin(pixmin, pixt, delta, 4);
2501 pixDestroy(&pixmin);
2512 pixDestroy(&pixbgi);
2568PIX *pixmin, *pixmax;
2570 if (!pixs || pixGetDepth(pixs) != 8)
2571 return (
PIX *)ERROR_PTR(
"pixs undefined or not 8 bpp", __func__, pixd);
2572 if (pixd && pixd != pixs)
2573 return (
PIX *)ERROR_PTR(
"pixd not null or == pixs", __func__, pixd);
2574 if (pixGetColormap(pixs))
2575 return (
PIX *)ERROR_PTR(
"pixs is colormapped", __func__, pixd);
2576 if (sx < 5 || sy < 5)
2577 return (
PIX *)ERROR_PTR(
"sx and/or sy less than 5", __func__, pixd);
2578 if (smoothx < 0 || smoothy < 0)
2579 return (
PIX *)ERROR_PTR(
"smooth params less than 0", __func__, pixd);
2580 if (smoothx > 8 || smoothy > 8)
2581 return (
PIX *)ERROR_PTR(
"smooth params exceed 8", __func__, pixd);
2585 pixMinMaxTiles(pixs, sx, sy, mindiff, smoothx, smoothy, &pixmin, &pixmax);
2592 pixDestroy(&pixmin);
2593 pixDestroy(&pixmax);
2628PIX *pixmin1, *pixmax1, *pixmin2, *pixmax2;
2630 if (ppixmin) *ppixmin = NULL;
2631 if (ppixmax) *ppixmax = NULL;
2632 if (!ppixmin || !ppixmax)
2633 return ERROR_INT(
"&pixmin or &pixmax undefined", __func__, 1);
2634 if (!pixs || pixGetDepth(pixs) != 8)
2635 return ERROR_INT(
"pixs undefined or not 8 bpp", __func__, 1);
2636 if (pixGetColormap(pixs))
2637 return ERROR_INT(
"pixs is colormapped", __func__, 1);
2638 if (sx < 5 || sy < 5)
2639 return ERROR_INT(
"sx and/or sy less than 3", __func__, 1);
2640 if (smoothx < 0 || smoothy < 0)
2641 return ERROR_INT(
"smooth params less than 0", __func__, 1);
2642 if (smoothx > 5 || smoothy > 5)
2643 return ERROR_INT(
"smooth params exceed 5", __func__, 1);
2646 pixmin1 = pixScaleGrayMinMax(pixs, sx, sy, L_CHOOSE_MIN);
2647 pixmax1 = pixScaleGrayMinMax(pixs, sx, sy, L_CHOOSE_MAX);
2651 pixDestroy(&pixmin1);
2652 pixDestroy(&pixmax1);
2655 pixAddConstantGray(pixmin2, 1);
2656 pixAddConstantGray(pixmax2, 1);
2662 pixGetDimensions(pixmin2, &w, &h, NULL);
2667 if (smoothx > 0 || smoothy > 0) {
2668 smoothx = L_MIN(smoothx, (w - 1) / 2);
2669 smoothy = L_MIN(smoothy, (h - 1) / 2);
2670 *ppixmin = pixBlockconv(pixmin2, smoothx, smoothy);
2671 *ppixmax = pixBlockconv(pixmax2, smoothx, smoothy);
2674 *ppixmin = pixClone(pixmin2);
2675 *ppixmax = pixClone(pixmax2);
2677 pixCopyResolution(*ppixmin, pixs);
2678 pixCopyResolution(*ppixmax, pixs);
2679 pixDestroy(&pixmin2);
2680 pixDestroy(&pixmax2);
2711l_int32 i, j, w, h, d, wpl, val1, val2, found;
2712l_uint32 *data1, *data2, *line1, *line2;
2714 if (!pixs1 || !pixs2)
2715 return ERROR_INT(
"pixs1 and pixs2 not both defined", __func__, 1);
2716 if (pixSizesEqual(pixs1, pixs2) == 0)
2717 return ERROR_INT(
"pixs1 and pixs2 not equal size", __func__, 1);
2718 pixGetDimensions(pixs1, &w, &h, &d);
2720 return ERROR_INT(
"depth not 8 bpp", __func__, 1);
2721 if (mindiff > 254)
return 0;
2723 data1 = pixGetData(pixs1);
2724 data2 = pixGetData(pixs2);
2725 wpl = pixGetWpl(pixs1);
2727 for (i = 0; i < h; i++) {
2728 line1 = data1 + i * wpl;
2729 line2 = data2 + i * wpl;
2730 for (j = 0; j < w; j++) {
2733 if (L_ABS(val1 - val2) >= mindiff) {
2741 L_WARNING(
"no pixel pair diffs as large as mindiff\n", __func__);
2747 for (i = 0; i < h; i++) {
2748 line1 = data1 + i * wpl;
2749 line2 = data2 + i * wpl;
2750 for (j = 0; j < w; j++) {
2753 if (L_ABS(val1 - val2) < mindiff) {
2795l_int32 i, j, k, m, w, h, wt, ht, wpl, wplt, xoff, yoff;
2796l_int32 minval, maxval, val, sval;
2799l_uint32 *data, *datamin, *datamax, *line, *tline, *linemin, *linemax;
2801 if (!pixs || pixGetDepth(pixs) != 8)
2802 return (
PIX *)ERROR_PTR(
"pixs undefined or not 8 bpp", __func__, pixd);
2803 if (pixd && pixd != pixs)
2804 return (
PIX *)ERROR_PTR(
"pixd not null or == pixs", __func__, pixd);
2805 if (pixGetColormap(pixs))
2806 return (
PIX *)ERROR_PTR(
"pixs is colormapped", __func__, pixd);
2807 if (!pixmin || !pixmax)
2808 return (
PIX *)ERROR_PTR(
"pixmin & pixmax not defined", __func__, pixd);
2809 if (sx < 5 || sy < 5)
2810 return (
PIX *)ERROR_PTR(
"sx and/or sy less than 5", __func__, pixd);
2812 iaa = (l_int32 **)LEPT_CALLOC(256,
sizeof(l_int32 *));
2813 if ((pixd = pixCopy(pixd, pixs)) == NULL) {
2815 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
2817 pixGetDimensions(pixd, &w, &h, NULL);
2819 data = pixGetData(pixd);
2820 wpl = pixGetWpl(pixd);
2821 datamin = pixGetData(pixmin);
2822 datamax = pixGetData(pixmax);
2823 wplt = pixGetWpl(pixmin);
2824 pixGetDimensions(pixmin, &wt, &ht, NULL);
2825 for (i = 0; i < ht; i++) {
2826 line = data + sy * i * wpl;
2827 linemin = datamin + i * wplt;
2828 linemax = datamax + i * wplt;
2830 for (j = 0; j < wt; j++) {
2834 if (maxval == minval) {
2835 L_ERROR(
"shouldn't happen! i,j = %d,%d, minval = %d\n",
2836 __func__, i, j, minval);
2840 L_ERROR(
"failure to make ia for j = %d!\n", __func__, j);
2843 for (k = 0; k < sy && yoff + k < h; k++) {
2844 tline = line + k * wpl;
2845 for (m = 0; m < sx && xoff + m < w; m++) {
2847 sval = val - minval;
2848 sval = L_MAX(0, sval);
2855 for (i = 0; i < 256; i++)
2880 return (l_int32 *)ERROR_PTR(
"iaa not defined", __func__, NULL);
2882 if (iaa[diff] != NULL)
2885 ia = (l_int32 *)LEPT_CALLOC(256,
sizeof(l_int32));
2888 for (i = 0; i < 256; i++)
2892 factor = 255. / (l_float32)diff;
2893 for (i = 0; i < diff + 1; i++)
2894 ia[i] = (l_int32)(factor * i + 0.5);
2895 for (i = diff + 1; i < 256; i++)
l_ok pixGetBackgroundRGBMap(PIX *pixs, PIX *pixim, PIX *pixg, l_int32 sx, l_int32 sy, l_int32 thresh, l_int32 mincount, PIX **ppixmr, PIX **ppixmg, PIX **ppixmb)
pixGetBackgroundRGBMap()
PIX * pixApplyVariableGrayMap(PIX *pixs, PIX *pixg, l_int32 target)
pixApplyVariableGrayMap()
PIX * pixBackgroundNormMorph(PIX *pixs, PIX *pixim, l_int32 reduction, l_int32 size, l_int32 bgval)
pixBackgroundNormMorph()
l_ok pixBackgroundNormRGBArraysMorph(PIX *pixs, PIX *pixim, l_int32 reduction, l_int32 size, l_int32 bgval, PIX **ppixr, PIX **ppixg, PIX **ppixb)
pixBackgroundNormRGBArraysMorph()
static const l_int32 DefaultFgThreshold
static const l_int32 DefaultTileHeight
static l_int32 * iaaGetLinearTRC(l_int32 **iaa, l_int32 diff)
iaaGetLinearTRC()
PIX * pixBackgroundNormFlex(PIX *pixs, l_int32 sx, l_int32 sy, l_int32 smoothx, l_int32 smoothy, l_int32 delta)
pixBackgroundNormFlex()
l_ok pixBackgroundNormRGBArrays(PIX *pixs, PIX *pixim, PIX *pixg, l_int32 sx, l_int32 sy, l_int32 thresh, l_int32 mincount, l_int32 bgval, l_int32 smoothx, l_int32 smoothy, PIX **ppixr, PIX **ppixg, PIX **ppixb)
pixBackgroundNormRGBArrays()
l_ok pixSmoothConnectedRegions(PIX *pixs, PIX *pixm, l_int32 factor)
pixSmoothConnectedRegions()
PIX * pixApplyInvBackgroundGrayMap(PIX *pixs, PIX *pixm, l_int32 sx, l_int32 sy)
pixApplyInvBackgroundGrayMap()
PIX * pixGlobalNormNoSatRGB(PIX *pixd, PIX *pixs, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 factor, l_float32 rank)
pixGlobalNormNoSatRGB()
l_ok pixBackgroundNormGrayArrayMorph(PIX *pixs, PIX *pixim, l_int32 reduction, l_int32 size, l_int32 bgval, PIX **ppixd)
pixBackgroundNormGrayArrayMorph()
l_ok pixGetBackgroundGrayMap(PIX *pixs, PIX *pixim, l_int32 sx, l_int32 sy, l_int32 thresh, l_int32 mincount, PIX **ppixd)
pixGetBackgroundGrayMap()
PIX * pixApplyInvBackgroundRGBMap(PIX *pixs, PIX *pixmr, PIX *pixmg, PIX *pixmb, l_int32 sx, l_int32 sy)
pixApplyInvBackgroundRGBMap()
l_ok pixGetBackgroundRGBMapMorph(PIX *pixs, PIX *pixim, l_int32 reduction, l_int32 size, PIX **ppixmr, PIX **ppixmg, PIX **ppixmb)
pixGetBackgroundRGBMapMorph()
PIX * pixBackgroundNormSimple(PIX *pixs, PIX *pixim, PIX *pixg)
pixBackgroundNormSimple()
static l_int32 pixSetLowContrast(PIX *pixs1, PIX *pixs2, l_int32 mindiff)
pixSetLowContrast()
PIX * pixExtendByReplication(PIX *pixs, l_int32 addw, l_int32 addh)
pixExtendByReplication()
PIX * pixGlobalNormRGB(PIX *pixd, PIX *pixs, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 mapval)
pixGlobalNormRGB()
static const l_int32 DefaultBgVal
l_ok pixBackgroundNormGrayArray(PIX *pixs, PIX *pixim, l_int32 sx, l_int32 sy, l_int32 thresh, l_int32 mincount, l_int32 bgval, l_int32 smoothx, l_int32 smoothy, PIX **ppixd)
pixBackgroundNormGrayArray()
PIX * pixContrastNorm(PIX *pixd, PIX *pixs, l_int32 sx, l_int32 sy, l_int32 mindiff, l_int32 smoothx, l_int32 smoothy)
pixContrastNorm()
static const l_int32 DefaultTileWidth
static const l_int32 DefaultMinCount
l_ok pixFillMapHoles(PIX *pix, l_int32 nx, l_int32 ny, l_int32 filltype)
pixFillMapHoles()
PIX * pixBackgroundNorm(PIX *pixs, PIX *pixim, PIX *pixg, l_int32 sx, l_int32 sy, l_int32 thresh, l_int32 mincount, l_int32 bgval, l_int32 smoothx, l_int32 smoothy)
pixBackgroundNorm()
l_ok pixGetBackgroundGrayMapMorph(PIX *pixs, PIX *pixim, l_int32 reduction, l_int32 size, PIX **ppixm)
pixGetBackgroundGrayMapMorph()
PIX * pixGetInvBackgroundMap(PIX *pixs, l_int32 bgval, l_int32 smoothx, l_int32 smoothy)
pixGetInvBackgroundMap()
static l_int32 pixMinMaxTiles(PIX *pixs, l_int32 sx, l_int32 sy, l_int32 mindiff, l_int32 smoothx, l_int32 smoothy, PIX **ppixmin, PIX **ppixmax)
pixMinMaxTiles()
static const l_int32 DefaultXSmoothSize
static PIX * pixLinearTRCTiled(PIX *pixd, PIX *pixs, l_int32 sx, l_int32 sy, PIX *pixmin, PIX *pixmax)
pixLinearTRCTiled()
PIX * pixCleanBackgroundToWhite(PIX *pixs, PIX *pixim, PIX *pixg, l_float32 gamma, l_int32 blackval, l_int32 whiteval)
pixCleanBackgroundToWhite()
static const l_int32 DefaultYSmoothSize
l_ok pixThresholdSpreadNorm(PIX *pixs, l_int32 filtertype, l_int32 edgethresh, l_int32 smoothx, l_int32 smoothy, l_float32 gamma, l_int32 minval, l_int32 maxval, l_int32 targetthresh, PIX **ppixth, PIX **ppixb, PIX **ppixd)
pixThresholdSpreadNorm()
#define SET_DATA_TWO_BYTES(pdata, n, val)
#define GET_DATA_BYTE(pdata, n)
#define SET_DATA_BYTE(pdata, n, val)
#define GET_DATA_BIT(pdata, n)
struct PixColormap PIXCMAP