86 #include <config_auto.h>
91 #include "allheaders.h"
118 l_int32 i, j, w, h, d, wpl, val, size, count;
119 l_uint32 *data, *line;
125 return (
NUMA *)ERROR_PTR(
"pixs not defined", __func__, NULL);
126 d = pixGetDepth(pixs);
128 return (
NUMA *)ERROR_PTR(
"depth not in {1,2,4,8,16}", __func__, NULL);
130 return (
NUMA *)ERROR_PTR(
"sampling must be >= 1", __func__, NULL);
132 if (pixGetColormap(pixs))
141 return (
NUMA *)ERROR_PTR(
"na not made", __func__, NULL);
148 array[0] = w * h - count;
154 wpl = pixGetWpl(pixg);
156 for (i = 0; i < h; i += factor) {
157 line = data + i * wpl;
159 for (j = 0; j < w; j += factor) {
164 for (j = 0; j < w; j += factor) {
169 for (j = 0; j < w; j += factor) {
174 for (j = 0; j < w; j += factor) {
215 l_int32 i, j, w, h, wm, hm, dm, wplg, wplm, val;
216 l_uint32 *datag, *datam, *lineg, *linem;
224 return (
NUMA *)ERROR_PTR(
"pixs not defined", __func__, NULL);
225 if (pixGetDepth(pixs) != 8 && !pixGetColormap(pixs))
226 return (
NUMA *)ERROR_PTR(
"pixs neither 8 bpp nor colormapped",
230 return (
NUMA *)ERROR_PTR(
"pixm not 1 bpp", __func__, NULL);
232 return (
NUMA *)ERROR_PTR(
"sampling must be >= 1", __func__, NULL);
235 return (
NUMA *)ERROR_PTR(
"na not made", __func__, NULL);
239 if (pixGetColormap(pixs))
245 wplg = pixGetWpl(pixg);
247 wplm = pixGetWpl(pixm);
250 for (i = 0; i < hm; i += factor) {
251 if (y + i < 0 || y + i >= h)
continue;
252 lineg = datag + (y + i) * wplg;
253 linem = datam + i * wplm;
254 for (j = 0; j < wm; j += factor) {
255 if (x + j < 0 || x + j >= w)
continue;
291 l_int32 i, j, bx, by, bw, bh, w, h, wplg, val;
292 l_uint32 *datag, *lineg;
300 return (
NUMA *)ERROR_PTR(
"pixs not defined", __func__, NULL);
301 if (pixGetDepth(pixs) != 8 && !pixGetColormap(pixs))
302 return (
NUMA *)ERROR_PTR(
"pixs neither 8 bpp nor colormapped",
305 return (
NUMA *)ERROR_PTR(
"sampling must be >= 1", __func__, NULL);
308 return (
NUMA *)ERROR_PTR(
"na not made", __func__, NULL);
312 if (pixGetColormap(pixs))
318 wplg = pixGetWpl(pixg);
322 for (i = 0; i < bh; i += factor) {
323 if (by + i < 0 || by + i >= h)
continue;
324 lineg = datag + (by + i) * wplg;
325 for (j = 0; j < bw; j += factor) {
326 if (bx + j < 0 || bx + j >= w)
continue;
365 return (
NUMAA *)ERROR_PTR(
"pixs not defined", __func__, NULL);
367 return (
NUMAA *)ERROR_PTR(
"sampling must be >= 1", __func__, NULL);
368 if (nx < 1 || ny < 1)
369 return (
NUMAA *)ERROR_PTR(
"nx and ny must both be > 0", __func__, NULL);
373 return (
NUMAA *)ERROR_PTR(
"naa not made", __func__, NULL);
377 for (i = 0; i < n; i++) {
414 l_int32 i, j, w, h, d, wpl, index, rval, gval, bval;
415 l_uint32 *data, *line;
416 l_float32 *rarray, *garray, *barray;
417 NUMA *nar, *nag, *nab;
420 if (pnar) *pnar = NULL;
421 if (pnag) *pnag = NULL;
422 if (pnab) *pnab = NULL;
423 if (!pnar || !pnag || !pnab)
424 return ERROR_INT(
"&nar, &nag, &nab not all defined", __func__, 1);
426 return ERROR_INT(
"pixs not defined", __func__, 1);
428 cmap = pixGetColormap(pixs);
429 if (cmap && (d != 2 && d != 4 && d != 8))
430 return ERROR_INT(
"colormap and not 2, 4, or 8 bpp", __func__, 1);
431 if (!cmap && d != 32)
432 return ERROR_INT(
"no colormap and not rgb", __func__, 1);
434 return ERROR_INT(
"sampling factor must be >= 1", __func__, 1);
452 wpl = pixGetWpl(pixs);
454 for (i = 0; i < h; i += factor) {
455 line = data + i * wpl;
456 for (j = 0; j < w; j += factor) {
470 for (i = 0; i < h; i += factor) {
471 line = data + i * wpl;
472 for (j = 0; j < w; j += factor) {
517 l_int32 i, j, w, h, d, wm, hm, dm, wpls, wplm, index, rval, gval, bval;
518 l_uint32 *datas, *datam, *lines, *linem;
519 l_float32 *rarray, *garray, *barray;
520 NUMA *nar, *nag, *nab;
526 if (pnar) *pnar = NULL;
527 if (pnag) *pnag = NULL;
528 if (pnab) *pnab = NULL;
529 if (!pnar || !pnag || !pnab)
530 return ERROR_INT(
"&nar, &nag, &nab not all defined", __func__, 1);
532 return ERROR_INT(
"pixs not defined", __func__, 1);
534 cmap = pixGetColormap(pixs);
535 if (cmap && (d != 2 && d != 4 && d != 8))
536 return ERROR_INT(
"colormap and not 2, 4, or 8 bpp", __func__, 1);
537 if (!cmap && d != 32)
538 return ERROR_INT(
"no colormap and not rgb", __func__, 1);
541 return ERROR_INT(
"pixm not 1 bpp", __func__, 1);
543 return ERROR_INT(
"sampling factor must be >= 1", __func__, 1);
561 wpls = pixGetWpl(pixs);
563 wplm = pixGetWpl(pixm);
565 for (i = 0; i < hm; i += factor) {
566 if (y + i < 0 || y + i >= h)
continue;
567 lines = datas + (y + i) * wpls;
568 linem = datam + i * wplm;
569 for (j = 0; j < wm; j += factor) {
570 if (x + j < 0 || x + j >= w)
continue;
586 for (i = 0; i < hm; i += factor) {
587 if (y + i < 0 || y + i >= h)
continue;
588 lines = datas + (y + i) * wpls;
589 linem = datam + i * wplm;
590 for (j = 0; j < wm; j += factor) {
591 if (x + j < 0 || x + j >= w)
continue;
624 l_int32 i, j, w, h, d, wpl, val, size;
625 l_uint32 *data, *line;
630 return (
NUMA *)ERROR_PTR(
"pixs not defined", __func__, NULL);
631 if (pixGetColormap(pixs) == NULL)
632 return (
NUMA *)ERROR_PTR(
"pixs not cmapped", __func__, NULL);
634 return (
NUMA *)ERROR_PTR(
"sampling must be >= 1", __func__, NULL);
636 if (d != 2 && d != 4 && d != 8)
637 return (
NUMA *)ERROR_PTR(
"d not 2, 4 or 8", __func__, NULL);
641 return (
NUMA *)ERROR_PTR(
"na not made", __func__, NULL);
645 wpl = pixGetWpl(pixs);
647 for (i = 0; i < h; i += factor) {
648 line = data + i * wpl;
649 for (j = 0; j < w; j += factor) {
690 l_int32 i, j, w, h, d, wm, hm, dm, wpls, wplm, val, size;
691 l_uint32 *datas, *datam, *lines, *linem;
699 return (
NUMA *)ERROR_PTR(
"pixs not defined", __func__, NULL);
700 if (pixGetColormap(pixs) == NULL)
701 return (
NUMA *)ERROR_PTR(
"pixs not cmapped", __func__, NULL);
704 return (
NUMA *)ERROR_PTR(
"pixm not 1 bpp", __func__, NULL);
706 return (
NUMA *)ERROR_PTR(
"sampling must be >= 1", __func__, NULL);
708 if (d != 2 && d != 4 && d != 8)
709 return (
NUMA *)ERROR_PTR(
"d not 2, 4 or 8", __func__, NULL);
713 return (
NUMA *)ERROR_PTR(
"na not made", __func__, NULL);
718 wpls = pixGetWpl(pixs);
720 wplm = pixGetWpl(pixm);
722 for (i = 0; i < hm; i += factor) {
723 if (y + i < 0 || y + i >= h)
continue;
724 lines = datas + (y + i) * wpls;
725 linem = datam + i * wplm;
726 for (j = 0; j < wm; j += factor) {
727 if (x + j < 0 || x + j >= w)
continue;
766 l_int32 i, j, bx, by, bw, bh, w, h, d, wpls, val, size;
767 l_uint32 *datas, *lines;
774 return (
NUMA *)ERROR_PTR(
"pixs not defined", __func__, NULL);
775 if (pixGetColormap(pixs) == NULL)
776 return (
NUMA *)ERROR_PTR(
"pixs not cmapped", __func__, NULL);
778 return (
NUMA *)ERROR_PTR(
"sampling must be >= 1", __func__, NULL);
780 if (d != 2 && d != 4 && d != 8)
781 return (
NUMA *)ERROR_PTR(
"d not 2, 4 or 8", __func__, NULL);
785 return (
NUMA *)ERROR_PTR(
"na not made", __func__, NULL);
790 wpls = pixGetWpl(pixs);
793 for (i = 0; i < bh; i += factor) {
794 if (by + i < 0 || by + i >= h)
continue;
795 lines = datas + (by + i) * wpls;
796 for (j = 0; j < bw; j += factor) {
797 if (bx + j < 0 || bx + j >= w)
continue;
832 return ERROR_INT(
"&ncolors not defined", __func__, 1);
834 if (!pixs || pixGetDepth(pixs) != 32)
835 return ERROR_INT(
"pixs not defined or not 32 bpp", __func__, 1);
867 return ERROR_INT(
"&ncolors not defined", __func__, 1);
869 if (!pixs || pixGetDepth(pixs) != 32)
870 return ERROR_INT(
"pixs not defined or not 32 bpp", __func__, 1);
872 return ERROR_INT(
"factor must be > 0", __func__, 1);
874 *pncolors = l_amapSize(amap);
875 l_amapDestroy(&amap);
897 l_int32 i, j, w, h, wpl;
898 l_uint32 *data, *line;
904 return (
L_AMAP *)ERROR_PTR(
"pixs not defined", __func__, NULL);
905 if (pixGetDepth(pixs) != 32)
906 return (
L_AMAP *)ERROR_PTR(
"pixs not 32 bpp", __func__, NULL);
908 return (
L_AMAP *)ERROR_PTR(
"factor must be > 0", __func__, NULL);
911 wpl = pixGetWpl(pixs);
912 amap = l_amapCreate(L_UINT_TYPE);
913 for (i = 0; i < h; i += factor) {
914 line = data + i * wpl;
915 for (j = 0; j < w; j += factor) {
917 pval = l_amapFind(amap, key);
921 value.itype = 1 + pval->itype;
922 l_amapInsert(amap, key, value);
950 return ERROR_INT(
"amap not defined", __func__, -1);
953 pval = l_amapFind(amap, key);
954 return (pval) ? pval->itype : 0;
986 l_float32 val, rval, gval, bval;
991 return ERROR_INT(
"&value not defined", __func__, 1);
994 return ERROR_INT(
"pixs not defined", __func__, 1);
995 d = pixGetDepth(pixs);
996 cmap = pixGetColormap(pixs);
997 if (d != 8 && d != 32 && !cmap)
998 return ERROR_INT(
"pixs not 8 or 32 bpp, or cmapped", __func__, 1);
1003 d = pixGetDepth(pixt);
1010 &rval, &gval, &bval);
1061 if (prval) *prval = 0.0;
1062 if (pgval) *pgval = 0.0;
1063 if (pbval) *pbval = 0.0;
1064 if (!prval && !pgval && !pbval)
1065 return ERROR_INT(
"no results requested", __func__, 1);
1067 return ERROR_INT(
"pixs not defined", __func__, 1);
1068 if (pixGetDepth(pixs) != 32)
1069 return ERROR_INT(
"pixs not 32 bpp", __func__, 1);
1070 if (pixm && pixGetDepth(pixm) != 1)
1071 return ERROR_INT(
"pixm not 1 bpp", __func__, 1);
1073 return ERROR_INT(
"sampling factor must be >= 1", __func__, 1);
1074 if (rank < 0.0 || rank > 1.0)
1075 return ERROR_INT(
"rank not in [0.0 ... 1.0]", __func__, 1);
1079 scale = 1.0 / (l_float32)factor;
1080 pixmt =
pixScale(pixm, scale, scale);
1085 factor, rank, prval, NULL);
1091 factor, rank, pgval, NULL);
1097 factor, rank, pbval, NULL);
1149 if (pna) *pna = NULL;
1151 return ERROR_INT(
"&val not defined", __func__, 1);
1154 return ERROR_INT(
"pixs not defined", __func__, 1);
1155 if (pixGetDepth(pixs) != 8 && !pixGetColormap(pixs))
1156 return ERROR_INT(
"pixs neither 8 bpp nor colormapped", __func__, 1);
1157 if (pixm && pixGetDepth(pixm) != 1)
1158 return ERROR_INT(
"pixm not 1 bpp", __func__, 1);
1160 return ERROR_INT(
"sampling factor must be >= 1", __func__, 1);
1161 if (rank < 0.0 || rank > 1.0)
1162 return ERROR_INT(
"rank not in [0.0 ... 1.0]", __func__, 1);
1165 return ERROR_INT(
"na not made", __func__, 1);
1214 l_int32 i, j, w, h, d, wm, hm, wpl1, wplm, val, rval, gval, bval, count;
1215 l_uint32 *data1, *datam, *line1, *linem;
1216 l_float64 sum, rsum, gsum, bsum;
1220 return ERROR_INT(
"&val not defined", __func__, 1);
1223 return ERROR_INT(
"pixs not defined", __func__, 1);
1224 d = pixGetDepth(pixs);
1225 if (d != 32 && !pixGetColormap(pixs))
1226 return ERROR_INT(
"pixs not rgb or colormapped", __func__, 1);
1227 if (pixm && pixGetDepth(pixm) != 1)
1228 return ERROR_INT(
"pixm not 1 bpp", __func__, 1);
1230 return ERROR_INT(
"sampling factor must be >= 1", __func__, 1);
1232 if (pixGetColormap(pixs))
1239 return ERROR_INT(
"pix1 is just 1 bpp", __func__, 1);
1242 wpl1 = pixGetWpl(pix1);
1244 sum = rsum = gsum = bsum = 0.0;
1247 for (i = 0; i < h; i += factor) {
1248 line1 = data1 + i * wpl1;
1249 for (j = 0; j < w; j += factor) {
1265 wplm = pixGetWpl(pixm);
1266 for (i = 0; i < hm; i += factor) {
1267 if (y + i < 0 || y + i >= h)
continue;
1268 line1 = data1 + (y + i) * wpl1;
1269 linem = datam + i * wplm;
1270 for (j = 0; j < wm; j += factor) {
1271 if (x + j < 0 || x + j >= w)
continue;
1290 return ERROR_INT(
"no pixels sampled", __func__, 1);
1292 *pval = (l_uint32)(sum / (l_float64)count);
1294 rval = (l_uint32)(rsum / (l_float64)count);
1295 gval = (l_uint32)(gsum / (l_float64)count);
1296 bval = (l_uint32)(bsum / (l_float64)count);
1329 l_float32 val, rval, gval, bval;
1334 return ERROR_INT(
"&value not defined", __func__, 1);
1337 return ERROR_INT(
"pixs not defined", __func__, 1);
1338 d = pixGetDepth(pixs);
1339 cmap = pixGetColormap(pixs);
1340 if (d != 8 && d != 32 && !cmap)
1341 return ERROR_INT(
"pixs not 8 or 32 bpp, or cmapped", __func__, 1);
1346 d = pixGetDepth(pixt);
1353 &rval, &gval, &bval);
1402 if (prval) *prval = 0.0;
1403 if (pgval) *pgval = 0.0;
1404 if (pbval) *pbval = 0.0;
1405 if (!prval && !pgval && !pbval)
1406 return ERROR_INT(
"no values requested", __func__, 1);
1408 return ERROR_INT(
"pixs not defined", __func__, 1);
1409 cmap = pixGetColormap(pixs);
1410 if (pixGetDepth(pixs) != 32 && !cmap)
1411 return ERROR_INT(
"pixs neither 32 bpp nor colormapped", __func__, 1);
1412 if (pixm && pixGetDepth(pixm) != 1)
1413 return ERROR_INT(
"pixm not 1 bpp", __func__, 1);
1415 return ERROR_INT(
"sampling factor must be >= 1", __func__, 1);
1418 return ERROR_INT(
"invalid measure type", __func__, 1);
1422 return ERROR_INT(
"empty mask", __func__, 1);
1496 l_int32 i, j, w, h, d, wm, hm, wplg, wplm, val, count, empty;
1497 l_uint32 *datag, *datam, *lineg, *linem;
1498 l_float64 sumave, summs, ave, meansq, var;
1502 return ERROR_INT(
"&val not defined", __func__, 1);
1505 return ERROR_INT(
"pixs not defined", __func__, 1);
1506 d = pixGetDepth(pixs);
1507 if (d != 8 && d != 16 && !pixGetColormap(pixs))
1508 return ERROR_INT(
"pixs not 8 or 16 bpp or colormapped", __func__, 1);
1509 if (pixm && pixGetDepth(pixm) != 1)
1510 return ERROR_INT(
"pixm not 1 bpp", __func__, 1);
1512 return ERROR_INT(
"sampling factor must be >= 1", __func__, 1);
1515 return ERROR_INT(
"invalid measure type", __func__, 1);
1519 return ERROR_INT(
"empty mask", __func__, 1);
1522 if (pixGetColormap(pixs))
1528 wplg = pixGetWpl(pixg);
1530 sumave = summs = 0.0;
1533 for (i = 0; i < h; i += factor) {
1534 lineg = datag + i * wplg;
1535 for (j = 0; j < w; j += factor) {
1543 summs += (l_float64)(val) * val;
1550 wplm = pixGetWpl(pixm);
1551 for (i = 0; i < hm; i += factor) {
1552 if (y + i < 0 || y + i >= h)
continue;
1553 lineg = datag + (y + i) * wplg;
1554 linem = datam + i * wplm;
1555 for (j = 0; j < wm; j += factor) {
1556 if (x + j < 0 || x + j >= w)
continue;
1565 summs += (l_float64)(val) * val;
1574 return ERROR_INT(
"no pixels sampled", __func__, 1);
1575 ave = sumave / (l_float64)count;
1576 meansq = summs / (l_float64)count;
1577 var = meansq - ave * ave;
1579 *pval = (l_float32)ave;
1581 *pval = (l_float32)sqrt(meansq);
1583 *pval = (l_float32)sqrt(var);
1585 *pval = (l_float32)var;
1621 if (ppixr) *ppixr = NULL;
1622 if (ppixg) *ppixg = NULL;
1623 if (ppixb) *ppixb = NULL;
1624 if (!ppixr && !ppixg && !ppixb)
1625 return ERROR_INT(
"no data requested", __func__, 1);
1627 return ERROR_INT(
"pixs not defined", __func__, 1);
1628 cmap = pixGetColormap(pixs);
1629 if (pixGetDepth(pixs) != 32 && !cmap)
1630 return ERROR_INT(
"pixs neither 32 bpp nor colormapped", __func__, 1);
1631 if (sx < 2 || sy < 2)
1632 return ERROR_INT(
"sx and sy not both > 1", __func__, 1);
1635 return ERROR_INT(
"invalid measure type", __func__, 1);
1690 l_int32 i, j, k, m, w, h, wd, hd, d, pos, wplt, wpld, valt;
1691 l_uint32 *datat, *datad, *linet, *lined, *startt;
1692 l_float64 sumave, summs, ave, meansq, normfact;
1696 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1698 if (d != 8 && !pixGetColormap(pixs))
1699 return (
PIX *)ERROR_PTR(
"pixs not 8 bpp or cmapped", __func__, NULL);
1700 if (sx < 2 || sy < 2)
1701 return (
PIX *)ERROR_PTR(
"sx and sy not both > 1", __func__, NULL);
1704 if (wd < 1 || hd < 1)
1705 return (
PIX *)ERROR_PTR(
"wd or hd == 0", __func__, NULL);
1708 return (
PIX *)ERROR_PTR(
"invalid measure type", __func__, NULL);
1713 wplt = pixGetWpl(pixt);
1715 wpld = pixGetWpl(pixd);
1716 normfact = 1. / (l_float64)(sx * sy);
1717 for (i = 0; i < hd; i++) {
1718 lined = datad + i * wpld;
1719 linet = datat + i * sy * wplt;
1720 for (j = 0; j < wd; j++) {
1723 for (k = 0; k < sy; k++) {
1724 startt = linet + k * wplt;
1725 for (m = 0; m < sx; m++) {
1731 ave = normfact * sumave;
1735 for (k = 0; k < sy; k++) {
1736 startt = linet + k * wplt;
1737 for (m = 0; m < sx; m++) {
1740 summs += (l_float64)(valt) * valt;
1743 meansq = normfact * summs;
1746 valt = (l_int32)(ave + 0.5);
1748 valt = (l_int32)(sqrt(meansq) + 0.5);
1750 valt = (l_int32)(sqrt(meansq - ave * ave) + 0.5);
1791 NUMA **pnamodecount,
1795 l_int32 i, j, k, w, h, val, wpls, sum, sumsq, target, max, modeval;
1796 l_int32 xstart, xend, ystart, yend, bw, bh;
1798 l_uint32 *lines, *datas;
1800 l_float32 *famean, *fameansq, *favar, *farootvar;
1801 l_float32 *famedian, *famode, *famodecount;
1803 if (pnamean) *pnamean = NULL;
1804 if (pnamedian) *pnamedian = NULL;
1805 if (pnamode) *pnamode = NULL;
1806 if (pnamodecount) *pnamodecount = NULL;
1807 if (pnavar) *pnavar = NULL;
1808 if (pnarootvar) *pnarootvar = NULL;
1809 if (!pixs || pixGetDepth(pixs) != 8)
1810 return ERROR_INT(
"pixs undefined or not 8 bpp", __func__, 1);
1811 famean = fameansq = favar = farootvar = NULL;
1812 famedian = famode = famodecount = NULL;
1817 return ERROR_INT(
"invalid clipping box", __func__, 1);
1821 wpls = pixGetWpl(pixs);
1822 if (pnamean || pnavar || pnarootvar) {
1823 norm = 1. / (l_float32)bw;
1824 famean = (l_float32 *)LEPT_CALLOC(bh,
sizeof(l_float32));
1825 fameansq = (l_float32 *)LEPT_CALLOC(bh,
sizeof(l_float32));
1826 if (pnavar || pnarootvar) {
1827 favar = (l_float32 *)LEPT_CALLOC(bh,
sizeof(l_float32));
1829 farootvar = (l_float32 *)LEPT_CALLOC(bh,
sizeof(l_float32));
1831 for (i = ystart; i < yend; i++) {
1833 lines = datas + i * wpls;
1834 for (j = xstart; j < xend; j++) {
1839 famean[i] = norm * sum;
1840 fameansq[i] = norm * sumsq;
1841 if (pnavar || pnarootvar) {
1842 favar[i] = fameansq[i] - famean[i] * famean[i];
1844 farootvar[i] = sqrtf(favar[i]);
1847 LEPT_FREE(fameansq);
1861 if (pnamedian || pnamode || pnamodecount) {
1862 histo = (l_int32 *)LEPT_CALLOC(256,
sizeof(l_int32));
1875 for (i = ystart; i < yend; i++) {
1876 lines = datas + i * wpls;
1877 memset(histo, 0, 1024);
1878 for (j = xstart; j < xend; j++) {
1885 target = (bw + 1) / 2;
1886 for (k = 0; k < 256; k++) {
1888 if (sum >= target) {
1895 if (pnamode || pnamodecount) {
1898 for (k = 0; k < 256; k++) {
1899 if (histo[k] > max) {
1905 famode[i] = modeval;
1907 famodecount[i] = max;
1949 NUMA **pnamodecount,
1953 l_int32 i, j, k, w, h, val, wpls, sum, sumsq, target, max, modeval;
1954 l_int32 xstart, xend, ystart, yend, bw, bh;
1956 l_uint32 *lines, *datas;
1958 l_float32 *famean, *fameansq, *favar, *farootvar;
1959 l_float32 *famedian, *famode, *famodecount;
1961 if (pnamean) *pnamean = NULL;
1962 if (pnamedian) *pnamedian = NULL;
1963 if (pnamode) *pnamode = NULL;
1964 if (pnamodecount) *pnamodecount = NULL;
1965 if (pnavar) *pnavar = NULL;
1966 if (pnarootvar) *pnarootvar = NULL;
1967 if (!pixs || pixGetDepth(pixs) != 8)
1968 return ERROR_INT(
"pixs undefined or not 8 bpp", __func__, 1);
1969 famean = fameansq = favar = farootvar = NULL;
1970 famedian = famode = famodecount = NULL;
1975 return ERROR_INT(
"invalid clipping box", __func__, 1);
1979 wpls = pixGetWpl(pixs);
1980 if (pnamean || pnavar || pnarootvar) {
1981 norm = 1. / (l_float32)bh;
1982 famean = (l_float32 *)LEPT_CALLOC(bw,
sizeof(l_float32));
1983 fameansq = (l_float32 *)LEPT_CALLOC(bw,
sizeof(l_float32));
1984 if (pnavar || pnarootvar) {
1985 favar = (l_float32 *)LEPT_CALLOC(bw,
sizeof(l_float32));
1987 farootvar = (l_float32 *)LEPT_CALLOC(bw,
sizeof(l_float32));
1989 for (j = xstart; j < xend; j++) {
1991 for (i = ystart, lines = datas; i < yend; lines += wpls, i++) {
1996 famean[j] = norm * sum;
1997 fameansq[j] = norm * sumsq;
1998 if (pnavar || pnarootvar) {
1999 favar[j] = fameansq[j] - famean[j] * famean[j];
2001 farootvar[j] = sqrtf(favar[j]);
2004 LEPT_FREE(fameansq);
2018 if (pnamedian || pnamode || pnamodecount) {
2019 histo = (l_int32 *)LEPT_CALLOC(256,
sizeof(l_int32));
2032 for (j = xstart; j < xend; j++) {
2033 memset(histo, 0, 1024);
2034 for (i = ystart, lines = datas; i < yend; lines += wpls, i++) {
2041 target = (bh + 1) / 2;
2042 for (k = 0; k < 256; k++) {
2044 if (sum >= target) {
2051 if (pnamode || pnamodecount) {
2054 for (k = 0; k < 256; k++) {
2055 if (histo[k] > max) {
2061 famode[j] = modeval;
2063 famodecount[j] = max;
2098 if (pminval) *pminval = 0;
2099 if (pmaxval) *pmaxval = 0;
2100 if (!pminval && !pmaxval)
2101 return ERROR_INT(
"no result requested", __func__, 1);
2103 return ERROR_INT(
"pixs not defined", __func__, 1);
2105 cmap = pixGetColormap(pixs);
2111 return ERROR_INT(
"sampling factor must be >= 1", __func__, 1);
2112 d = pixGetDepth(pixs);
2113 if (d != 8 && d != 32)
2114 return ERROR_INT(
"pixs not 8 or 32 bpp", __func__, 1);
2118 NULL, NULL, NULL, pminval);
2120 NULL, NULL, NULL, pmaxval);
2123 pminval, NULL, NULL, NULL);
2125 pmaxval, NULL, NULL, NULL);
2128 NULL, pminval, NULL, NULL);
2130 NULL, pmaxval, NULL, NULL);
2133 NULL, NULL, pminval, NULL);
2135 NULL, NULL, pmaxval, NULL);
2137 return ERROR_INT(
"invalid color", __func__, 1);
2173 l_int32 i, j, w, h, d, wpl;
2174 l_int32 val, extval, rval, gval, bval, extrval, extgval, extbval;
2176 l_uint32 *data, *line;
2179 if (prval) *prval = -1;
2180 if (pgval) *pgval = -1;
2181 if (pbval) *pbval = -1;
2182 if (pgrayval) *pgrayval = -1;
2184 return ERROR_INT(
"pixs not defined", __func__, 1);
2186 return ERROR_INT(
"invalid type", __func__, 1);
2188 cmap = pixGetColormap(pixs);
2210 return ERROR_INT(
"sampling factor must be >= 1", __func__, 1);
2211 if (d != 8 && d != 32)
2212 return ERROR_INT(
"pixs not 8 or 32 bpp", __func__, 1);
2213 if (d == 8 && !pgrayval)
2214 return ERROR_INT(
"can't return result in grayval", __func__, 1);
2215 if (d == 32 && !prval && !pgval && !pbval)
2216 return ERROR_INT(
"can't return result in r/g/b-val", __func__, 1);
2219 wpl = pixGetWpl(pixs);
2226 for (i = 0; i < h; i += factor) {
2227 line = data + i * wpl;
2228 for (j = 0; j < w; j += factor) {
2249 for (i = 0; i < h; i += factor) {
2250 line = data + i * wpl;
2251 for (j = 0; j < w; j += factor) {
2254 rval = (pixel >> L_RED_SHIFT) & 0xff;
2260 gval = (pixel >> L_GREEN_SHIFT) & 0xff;
2266 bval = (pixel >> L_BLUE_SHIFT) & 0xff;
2273 if (prval) *prval = extrval;
2274 if (pgval) *pgval = extgval;
2275 if (pbval) *pbval = extbval;
2306 l_int32 i, j, w, h, d, wpl, bw, bh;
2307 l_int32 xstart, ystart, xend, yend, xmax, ymax;
2308 l_uint32 val, maxval;
2309 l_uint32 *data, *line;
2311 if (pmaxval) *pmaxval = 0;
2312 if (pxmax) *pxmax = 0;
2313 if (pymax) *pymax = 0;
2314 if (!pmaxval && !pxmax && !pymax)
2315 return ERROR_INT(
"no data requested", __func__, 1);
2317 return ERROR_INT(
"pixs not defined", __func__, 1);
2318 if (pixGetColormap(pixs) != NULL)
2319 return ERROR_INT(
"pixs has colormap", __func__, 1);
2321 if (d != 8 && d != 16 && d != 32)
2322 return ERROR_INT(
"pixs not 8, 16 or 32 bpp", __func__, 1);
2324 xstart = ystart = 0;
2329 xend = xstart + bw - 1;
2330 yend = ystart + bh - 1;
2334 wpl = pixGetWpl(pixs);
2337 for (i = ystart; i <= yend; i++) {
2338 line = data + i * wpl;
2339 for (j = xstart; j <= xend; j++) {
2354 xmax = (xstart + xend) / 2;
2355 ymax = (ystart + yend) / 2;
2358 if (pmaxval) *pmaxval = maxval;
2359 if (pxmax) *pxmax = xmax;
2360 if (pymax) *pymax = ymax;
2376 l_int32 i, j, w, h, d, wpl, val, max, maxval, empty;
2377 l_uint32 *data, *line;
2380 return ERROR_INT(
"&maxindex not defined", __func__, 1);
2383 return ERROR_INT(
"pixs not defined", __func__, 1);
2385 if (d != 1 && d != 2 && d != 4 && d != 8)
2386 return ERROR_INT(
"invalid pixs depth; not in (1,2,4,8}", __func__, 1);
2388 wpl = pixGetWpl(pixs);
2391 maxval = (1 << d) - 1;
2394 if (!empty) max = 1;
2398 for (i = 0; i < h; i++) {
2399 line = data + i * wpl;
2401 for (j = 0; j < w; j++) {
2403 if (val > max) max = val;
2405 }
else if (d == 4) {
2406 for (j = 0; j < w; j++) {
2408 if (val > max) max = val;
2410 }
else if (d == 8) {
2411 for (j = 0; j < w; j++) {
2413 if (val > max) max = val;
2416 if (max == maxval)
break;
2454 l_int32 i, minval, maxval, rval, gval, bval;
2458 if (pminval) *pminval = 0;
2459 if (pmaxval) *pmaxval = 0;
2460 if (pcarray) *pcarray = NULL;
2461 if (!pminval && !pmaxval)
2462 return ERROR_INT(
"no result requested", __func__, 1);
2463 if (!pixs || pixGetDepth(pixs) != 32)
2464 return ERROR_INT(
"pixs not defined or not 32 bpp", __func__, 1);
2466 return ERROR_INT(
"sampling factor must be >= 1", __func__, 1);
2469 return ERROR_INT(
"invalid color", __func__, 1);
2470 if (fontsize < 0 || fontsize > 20 || fontsize & 1 || fontsize == 2)
2471 return ERROR_INT(
"invalid fontsize", __func__, 1);
2475 return ERROR_INT(
"carray not made", __func__, 1);
2478 for (i = 0; i < nbins; i++)
2479 L_INFO(
"c[%d] = %x\n", __func__, i, carray[i]);
2481 pixDisplay(pixt, 100, 100);
2498 if (pminval) *pminval = minval;
2499 if (pmaxval) *pmaxval = maxval;
2550 l_int32 ret, w, h, samplesperbin;
2552 PIX *pix1, *pixc, *pixg, *pixd;
2556 return ERROR_INT(
"&carray not defined", __func__, 1);
2559 return ERROR_INT(
"sampling factor must be >= 1", __func__, 1);
2561 return ERROR_INT(
"nbins must be at least 2", __func__, 1);
2563 return ERROR_INT(
"pixs not defined", __func__, 1);
2564 cmap = pixGetColormap(pixs);
2565 if (pixGetDepth(pixs) != 32 && !cmap)
2566 return ERROR_INT(
"pixs neither 32 bpp nor cmapped", __func__, 1);
2571 return ERROR_INT(
"invalid type", __func__, 1);
2573 if (fontsize < 0 || fontsize > 20 || fontsize & 1 || fontsize == 2) {
2574 L_WARNING(
"invalid fontsize %d; setting to 6\n", __func__,
2580 samplesperbin = (w * h) / (factor * factor * nbins);
2581 if (samplesperbin < 10) {
2582 L_ERROR(
"samplesperbin = %d < 10\n", __func__, samplesperbin);
2601 if ((array = *pcarray) == NULL) {
2602 L_ERROR(
"color array not returned\n", __func__);
2605 if (array && pixadb) {
2607 pixWriteDebug(
"/tmp/lept/regout/rankhisto.png", pixd, IFF_PNG);
2652 l_int32 i, j, w, h, wpls, wplg;
2653 l_int32 count, bincount, binindex, binsize, npts, avepts, ntot;
2654 l_int32 rval, gval, bval, grayval, rave, gave, bave;
2655 l_uint32 *datas, *datag, *lines, *lineg, *carray;
2656 l_float64 val64, rsum, gsum, bsum;
2662 return ERROR_INT(
"&carray not defined", __func__, 1);
2664 if (!pixs || pixGetDepth(pixs) != 32)
2665 return ERROR_INT(
"pixs undefined or not 32 bpp", __func__, 1);
2666 if (!pixg || pixGetDepth(pixg) != 8)
2667 return ERROR_INT(
"pixg undefined or not 8 bpp", __func__, 1);
2669 L_WARNING(
"sampling factor less than 1; setting to 1\n", __func__);
2672 if (nbins < 1 || nbins > 100)
2673 return ERROR_INT(
"nbins not in [1,100]", __func__, 1);
2677 npts = (w + factor - 1) * (h + factor - 1) / (factor * factor);
2678 avepts = (npts + nbins - 1) / nbins;
2680 L_ERROR(
"avepts = %d; must be >= 5\n", __func__, avepts);
2693 wpls = pixGetWpl(pixs);
2695 wplg = pixGetWpl(pixg);
2697 for (i = 0; i < h; i += factor) {
2698 lines = datas + i * wpls;
2699 lineg = datag + i * wplg;
2700 for (j = 0; j < w; j += factor) {
2707 NUMA *na, *nabinval, *narank;
2709 for (i = 0; i < 256; i++)
2727 return ERROR_INT(
"naeach not made", __func__, 1);
2732 carray = (l_uint32 *)LEPT_CALLOC(nbins,
sizeof(l_uint32));
2733 rsum = gsum = bsum = 0.0;
2737 for (i = 0; i < 256; i++) {
2739 for (j = 0; j < count; j++) {
2746 if (bincount == binsize) {
2747 rave = (l_int32)(rsum / binsize + 0.5);
2748 gave = (l_int32)(gsum / binsize + 0.5);
2749 bave = (l_int32)(bsum / binsize + 0.5);
2751 rsum = gsum = bsum = 0.0;
2754 if (binindex == nbins)
break;
2758 if (binindex == nbins)
break;
2760 if (binindex != nbins)
2761 L_ERROR(
"binindex = %d != nbins = %d\n", __func__, binindex, nbins);
2764 NUMA *nared, *nagreen, *nablue;
2768 for (i = 0; i < nbins; i++) {
2820 l_int32 i, rval, gval, bval;
2822 PIX *pix1, *pix2, *pix3, *pix4;
2826 return (
PIX *)ERROR_PTR(
"carray not defined", __func__, NULL);
2827 if (fontsize < 0 || fontsize > 20 || fontsize & 1 || fontsize == 2)
2828 return (
PIX *)ERROR_PTR(
"invalid fontsize", __func__, NULL);
2830 bmf = (fontsize == 0) ? NULL :
bmfCreate(NULL, fontsize);
2832 for (i = 0; i < ncolors; i++) {
2838 snprintf(textstr,
sizeof(textstr),
2839 "%d: (%d %d %d)", i, rval, gval, bval);
2893 l_int32 i, j, w, h, mindim, nstrips;
2896 PIX *pix1, *pix2, *pixd;
2901 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
2902 cmap = pixGetColormap(pixs);
2903 if (pixGetDepth(pixs) != 32 && !cmap)
2904 return (
PIX *)ERROR_PTR(
"pixs neither 32 bpp nor cmapped",
2907 return (
PIX *)ERROR_PTR(
"invalid direction", __func__, NULL);
2909 return (
PIX *)ERROR_PTR(
"size < 1", __func__, NULL);
2911 return (
PIX *)ERROR_PTR(
"nbins must be at least 2", __func__, NULL);
2916 return (
PIX *)ERROR_PTR(
"invalid type", __func__, NULL);
2918 mindim = L_MIN(w, h);
2919 if (mindim < 20 || nbins > mindim)
2920 return (
PIX *)ERROR_PTR(
"pix too small and/or too many bins",
2936 for (i = 0; i < nstrips; i++) {
2940 for (j = 0; j < nbins; j++)
2948 for (i = 0; i < nstrips; i++) {
2952 for (j = 0; j < nbins; j++)
2997 l_int32 j, n, w, h, d;
3002 return (
PIX *)ERROR_PTR(
"pixa not defined", __func__, NULL);
3005 return (
PIX *)ERROR_PTR(
"invalid type", __func__, NULL);
3008 return (
PIX *)ERROR_PTR(
"no pix in pixa", __func__, NULL);
3011 return (
PIX *)ERROR_PTR(
"pix not 8 bpp", __func__, NULL);
3015 colvect = (l_float32 *)LEPT_CALLOC(h,
sizeof(l_float32));
3016 for (j = 0; j < w; j++) {
3041 l_int32 i, k, n, w, h, ht, val, wplt, wpld;
3042 l_uint32 *datad, *datat;
3046 return ERROR_INT(
"pixa not defined", __func__, 1);
3047 if (!pixd || pixGetDepth(pixd) != 8)
3048 return ERROR_INT(
"pixd not defined or not 8 bpp", __func__, 1);
3052 return ERROR_INT(
"pix width != n", __func__, 1);
3054 wplt = pixGetWpl(pixt);
3058 return ERROR_INT(
"pixd height != column height", __func__, 1);
3061 wpld = pixGetWpl(pixd);
3062 for (k = 0; k < n; k++) {
3065 for (i = 0; i < h; i++) {
3116 l_int32 i, j, k, w, h, val, wpls, sum, target, max, modeval;
3117 l_int32 *histo, *gray2bin, *bin2gray;
3118 l_uint32 *lines, *datas;
3120 if (!pixs || pixGetDepth(pixs) != 8)
3121 return ERROR_INT(
"pixs not defined or not 8 bpp", __func__, 1);
3123 return ERROR_INT(
"colvect not defined", __func__, 1);
3126 return ERROR_INT(
"invalid type", __func__, 1);
3128 return ERROR_INT(
"invalid nbins", __func__, 1);
3132 wpls = pixGetWpl(pixs);
3134 for (i = 0; i < h; i++) {
3136 lines = datas + i * wpls;
3137 for (j = 0; j < w; j++)
3139 colvect[i] = (l_float32)sum / (l_float32)w;
3145 histo = (l_int32 *)LEPT_CALLOC(nbins,
sizeof(l_int32));
3146 gray2bin = (l_int32 *)LEPT_CALLOC(256,
sizeof(l_int32));
3147 bin2gray = (l_int32 *)LEPT_CALLOC(nbins,
sizeof(l_int32));
3148 for (i = 0; i < 256; i++)
3149 gray2bin[i] = (i * nbins) / 256;
3150 for (i = 0; i < nbins; i++)
3151 bin2gray[i] = (i * 256 + 128) / nbins;
3153 for (i = 0; i < h; i++) {
3154 lines = datas + i * wpls;
3155 for (k = 0; k < nbins; k++)
3157 for (j = 0; j < w; j++) {
3159 histo[gray2bin[val]]++;
3164 target = (w + 1) / 2;
3165 for (k = 0; k < nbins; k++) {
3167 if (sum >= target) {
3168 colvect[i] = bin2gray[k];
3175 for (k = 0; k < nbins; k++) {
3176 if (histo[k] > max) {
3184 colvect[i] = bin2gray[modeval];
3187 for (k = 0; k < nbins; k++) {
3196 LEPT_FREE(gray2bin);
3197 LEPT_FREE(bin2gray);
3236 l_int32 i, j, k, w, h, val, wpls, sum, target, max, modeval;
3237 l_int32 *histo, *gray2bin, *bin2gray;
3240 if (!pixs || pixGetDepth(pixs) != 8)
3241 return ERROR_INT(
"pixs not defined or not 8 bpp", __func__, 1);
3243 return ERROR_INT(
"rowvect not defined", __func__, 1);
3246 return ERROR_INT(
"invalid type", __func__, 1);
3248 return ERROR_INT(
"invalid nbins", __func__, 1);
3252 wpls = pixGetWpl(pixs);
3254 for (j = 0; j < w; j++) {
3256 for (i = 0; i < h; i++)
3258 rowvect[j] = (l_float32)sum / (l_float32)h;
3264 histo = (l_int32 *)LEPT_CALLOC(nbins,
sizeof(l_int32));
3265 gray2bin = (l_int32 *)LEPT_CALLOC(256,
sizeof(l_int32));
3266 bin2gray = (l_int32 *)LEPT_CALLOC(nbins,
sizeof(l_int32));
3267 for (i = 0; i < 256; i++)
3268 gray2bin[i] = (i * nbins) / 256;
3269 for (i = 0; i < nbins; i++)
3270 bin2gray[i] = (i * 256 + 128) / nbins;
3272 for (j = 0; j < w; j++) {
3273 for (i = 0; i < h; i++) {
3275 histo[gray2bin[val]]++;
3280 target = (h + 1) / 2;
3281 for (k = 0; k < nbins; k++) {
3283 if (sum >= target) {
3284 rowvect[j] = bin2gray[k];
3291 for (k = 0; k < nbins; k++) {
3292 if (histo[k] > max) {
3300 rowvect[j] = bin2gray[modeval];
3303 for (k = 0; k < nbins; k++) {
3309 for (k = 0; k < nbins; k++)
3314 LEPT_FREE(gray2bin);
3315 LEPT_FREE(bin2gray);
3333 l_int32 i, w, h, wpl;
3336 if (!pix || pixGetDepth(pix) != 8)
3337 return ERROR_INT(
"pix not defined or not 8 bpp", __func__, 1);
3339 return ERROR_INT(
"colvect not defined", __func__, 1);
3341 if (col < 0 || col > w)
3342 return ERROR_INT(
"invalid col", __func__, 1);
3345 wpl = pixGetWpl(pix);
3346 for (i = 0; i < h; i++)
3376 if (pfgval) *pfgval = 0;
3377 if (pbgval) *pbgval = 0;
3378 if (!pfgval && !pbgval)
3379 return ERROR_INT(
"no data requested", __func__, 1);
3381 return ERROR_INT(
"pixs not defined", __func__, 1);
3389 *pfgval = (l_int32)(fval + 0.5);
3395 *pbgval = (l_int32)(fval + 0.5);
3425 l_float32 scorefract,
3434 l_float32 avefg, avebg, maxnum;
3436 NUMA *na, *nascore, *nax, *nay;
3439 if (pthresh) *pthresh = 0;
3440 if (pfgval) *pfgval = 0;
3441 if (pbgval) *pbgval = 0;
3442 if (ppixdb) *ppixdb = NULL;
3443 if (!pthresh && !pfgval && !pbgval)
3444 return ERROR_INT(
"no data requested", __func__, 1);
3446 return ERROR_INT(
"pixs not defined", __func__, 1);
3455 NULL, NULL, &nascore);
3462 if (pthresh) *pthresh = thresh;
3463 if (pfgval) *pfgval = (l_int32)(avefg + 0.5);
3464 if (pbgval) *pbgval = (l_int32)(avebg + 0.5);
3468 gplot =
gplotCreate(
"/tmp/lept/redout/histplot", GPLOT_PNG,
"Histogram",
3469 "Grayscale value",
"Number of pixels");
3475 snprintf(buf,
sizeof(buf),
"score fract = %3.1f", scorefract);
#define GET_DATA_QBIT(pdata, n)
#define GET_DATA_TWO_BYTES(pdata, n)
#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)
void bmfDestroy(L_BMF **pbmf)
bmfDestroy()
L_BMF * bmfCreate(const char *dir, l_int32 fontsize)
bmfCreate()
l_ok boxGetGeometry(const BOX *box, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
boxGetGeometry()
void boxaDestroy(BOXA **pboxa)
boxaDestroy()
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 * makeMosaicStrips(l_int32 w, l_int32 h, l_int32 direction, l_int32 size)
makeMosaicStrips()
l_ok pixcmapGetColor(PIXCMAP *cmap, l_int32 index, l_int32 *prval, l_int32 *pgval, l_int32 *pbval)
pixcmapGetColor()
l_ok pixcmapGetRangeValues(PIXCMAP *cmap, l_int32 select, l_int32 *pminval, l_int32 *pmaxval, l_int32 *pminindex, l_int32 *pmaxindex)
pixcmapGetRangeValues()
l_int32 l_dnaaGetDnaCount(L_DNAA *daa, l_int32 index)
l_dnaaGetDnaCount()
L_DNAA * l_dnaaCreateFull(l_int32 nptr, l_int32 n)
l_dnaaCreateFull()
l_ok l_dnaaAddNumber(L_DNAA *daa, l_int32 index, l_float64 val)
l_dnaaAddNumber()
l_int32 l_dnaaGetNumberCount(L_DNAA *daa)
l_dnaaGetNumberCount()
l_ok l_dnaaGetValue(L_DNAA *daa, l_int32 i, l_int32 j, l_float64 *pval)
l_dnaaGetValue()
void l_dnaDestroy(L_DNA **pda)
l_dnaDestroy()
l_int32 l_dnaGetCount(L_DNA *da)
l_dnaGetCount()
void l_dnaaDestroy(L_DNAA **pdaa)
l_dnaaDestroy()
l_ok l_dnaRemoveDupsByHmap(L_DNA *das, L_DNA **pdad, L_HASHMAP **phmap)
l_dnaRemoveDupsByHmap()
L_DNA * pixConvertDataToDna(PIX *pix)
pixConvertDataToDna()
l_ok gplotAddPlot(GPLOT *gplot, NUMA *nax, NUMA *nay, l_int32 plotstyle, const char *plotlabel)
gplotAddPlot()
GPLOT * gplotCreate(const char *rootname, l_int32 outformat, const char *title, const char *xlabel, const char *ylabel)
gplotCreate()
PIX * gplotMakeOutputPix(GPLOT *gplot)
gplotMakeOutputPix()
void gplotDestroy(GPLOT **pgplot)
gplotDestroy()
PIX * gplotSimplePix1(NUMA *na, const char *title)
gplotSimplePix1()
PIX * pixThresholdToBinary(PIX *pixs, l_int32 thresh)
pixThresholdToBinary()
l_ok numaAddNumber(NUMA *na, l_float32 val)
numaAddNumber()
l_ok numaReplaceNumber(NUMA *na, l_int32 index, l_float32 val)
numaReplaceNumber()
NUMA * numaCreate(l_int32 n)
numaCreate()
l_ok numaSetCount(NUMA *na, l_int32 newcount)
numaSetCount()
void numaDestroy(NUMA **pna)
numaDestroy()
NUMAA * numaaCreate(l_int32 n)
numaaCreate()
l_ok numaGetIValue(NUMA *na, l_int32 index, l_int32 *pival)
numaGetIValue()
l_ok numaaAddNuma(NUMAA *naa, NUMA *na, l_int32 copyflag)
numaaAddNuma()
NUMA * numaCreateFromFArray(l_float32 *farray, l_int32 size, l_int32 copyflag)
numaCreateFromFArray()
l_float32 * numaGetFArray(NUMA *na, l_int32 copyflag)
numaGetFArray()
NUMA * numaMakeConstant(l_float32 val, l_int32 size)
numaMakeConstant()
l_ok numaGetMax(NUMA *na, l_float32 *pmaxval, l_int32 *pimaxloc)
numaGetMax()
l_ok numaDiscretizeHistoInBins(NUMA *na, l_int32 nbins, NUMA **pnabinval, NUMA **pnarank)
numaDiscretizeHistoInBins()
l_ok numaSplitDistribution(NUMA *na, l_float32 scorefract, l_int32 *psplitindex, l_float32 *pave1, l_float32 *pave2, l_float32 *pnum1, l_float32 *pnum2, NUMA **pnascore)
numaSplitDistribution()
l_ok numaHistogramGetValFromRank(NUMA *na, l_float32 rank, l_float32 *prval)
numaHistogramGetValFromRank()
NUMA * numaGetUniformBinSizes(l_int32 ntotal, l_int32 nbins)
numaGetUniformBinSizes()
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()
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()
l_ok pixSetPixel(PIX *pix, l_int32 x, l_int32 y, l_uint32 val)
pixSetPixel()
PIX * pixAddBorder(PIX *pixs, l_int32 npix, l_uint32 val)
pixAddBorder()
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 pixSetAllArbitrary(PIX *pix, l_uint32 val)
pixSetAllArbitrary()
PIX * pixGetRGBComponentCmap(PIX *pixs, l_int32 comp)
pixGetRGBComponentCmap()
l_ok pixZero(PIX *pix, l_int32 *pempty)
pixZero()
PIX * pixInvert(PIX *pixd, PIX *pixs)
pixInvert()
l_ok pixCountPixels(PIX *pixs, l_int32 *pcount, l_int32 *tab8)
pixCountPixels()
l_ok pixCountRGBColorsByHash(PIX *pixs, l_int32 *pncolors)
pixCountRGBColorsByHash()
l_ok pixGetAverageMasked(PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor, l_int32 type, l_float32 *pval)
pixGetAverageMasked()
NUMA * pixGetGrayHistogramInRect(PIX *pixs, BOX *box, l_int32 factor)
pixGetGrayHistogramInRect()
l_ok pixGetColorHistogram(PIX *pixs, l_int32 factor, NUMA **pnar, NUMA **pnag, NUMA **pnab)
pixGetColorHistogram()
PIX * pixDisplayColorArray(l_uint32 *carray, l_int32 ncolors, l_int32 side, l_int32 ncols, l_int32 fontsize)
pixDisplayColorArray()
PIX * pixRankBinByStrip(PIX *pixs, l_int32 direction, l_int32 size, l_int32 nbins, l_int32 type)
pixRankBinByStrip()
l_ok pixGetRankValueMasked(PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor, l_float32 rank, l_float32 *pval, NUMA **pna)
pixGetRankValueMasked()
L_AMAP * pixGetColorAmapHistogram(PIX *pixs, l_int32 factor)
pixGetColorAmapHistogram()
l_ok pixGetBinnedComponentRange(PIX *pixs, l_int32 nbins, l_int32 factor, l_int32 color, l_int32 *pminval, l_int32 *pmaxval, l_uint32 **pcarray, l_int32 fontsize)
pixGetBinnedComponentRange()
NUMA * pixGetGrayHistogram(PIX *pixs, l_int32 factor)
pixGetGrayHistogram()
NUMA * pixGetCmapHistogramInRect(PIX *pixs, BOX *box, l_int32 factor)
pixGetCmapHistogramInRect()
NUMA * pixGetGrayHistogramMasked(PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor)
pixGetGrayHistogramMasked()
l_ok pixGetColorHistogramMasked(PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor, NUMA **pnar, NUMA **pnag, NUMA **pnab)
pixGetColorHistogramMasked()
l_ok pixGetMaxColorIndex(PIX *pixs, l_int32 *pmaxindex)
pixGetMaxColorIndex()
l_ok pixGetRangeValues(PIX *pixs, l_int32 factor, l_int32 color, l_int32 *pminval, l_int32 *pmaxval)
pixGetRangeValues()
l_ok pixGetRankValueMaskedRGB(PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor, l_float32 rank, l_float32 *prval, l_float32 *pgval, l_float32 *pbval)
pixGetRankValueMaskedRGB()
l_ok pixSplitDistributionFgBg(PIX *pixs, l_float32 scorefract, l_int32 factor, l_int32 *pthresh, l_int32 *pfgval, l_int32 *pbgval, PIX **ppixdb)
pixSplitDistributionFgBg()
l_ok pixGetRowStats(PIX *pixs, l_int32 type, l_int32 nbins, l_int32 thresh, l_float32 *colvect)
pixGetRowStats()
NUMA * pixGetCmapHistogramMasked(PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor)
pixGetCmapHistogramMasked()
l_ok pixaExtractColumnFromEachPix(PIXA *pixa, l_int32 col, PIX *pixd)
pixaExtractColumnFromEachPix()
l_ok pixGetRankColorArray(PIX *pixs, l_int32 nbins, l_int32 type, l_int32 factor, l_uint32 **pcarray, PIXA *pixadb, l_int32 fontsize)
pixGetRankColorArray()
l_ok pixGetAverageTiledRGB(PIX *pixs, l_int32 sx, l_int32 sy, l_int32 type, PIX **ppixr, PIX **ppixg, PIX **ppixb)
pixGetAverageTiledRGB()
PIX * pixGetAverageTiled(PIX *pixs, l_int32 sx, l_int32 sy, l_int32 type)
pixGetAverageTiled()
l_int32 pixColumnStats(PIX *pixs, BOX *box, NUMA **pnamean, NUMA **pnamedian, NUMA **pnamode, NUMA **pnamodecount, NUMA **pnavar, NUMA **pnarootvar)
pixColumnStats()
l_ok pixGetPixelStats(PIX *pixs, l_int32 factor, l_int32 type, l_uint32 *pvalue)
pixGetPixelStats()
l_ok pixCountRGBColors(PIX *pixs, l_int32 factor, l_int32 *pncolors)
pixCountRGBColors()
l_ok pixGetBinnedColor(PIX *pixs, PIX *pixg, l_int32 factor, l_int32 nbins, l_uint32 **pcarray, PIXA *pixadb)
pixGetBinnedColor()
l_ok pixGetExtremeValue(PIX *pixs, l_int32 factor, l_int32 type, l_int32 *prval, l_int32 *pgval, l_int32 *pbval, l_int32 *pgrayval)
pixGetExtremeValue()
NUMAA * pixGetGrayHistogramTiled(PIX *pixs, l_int32 factor, l_int32 nx, l_int32 ny)
pixGetGrayHistogramTiled()
l_ok pixSetPixelColumn(PIX *pix, l_int32 col, l_float32 *colvect)
pixSetPixelColumn()
l_ok pixThresholdForFgBg(PIX *pixs, l_int32 factor, l_int32 thresh, l_int32 *pfgval, l_int32 *pbgval)
pixThresholdForFgBg()
l_ok pixGetRankValue(PIX *pixs, l_int32 factor, l_float32 rank, l_uint32 *pvalue)
pixGetRankValue()
l_int32 pixRowStats(PIX *pixs, BOX *box, NUMA **pnamean, NUMA **pnamedian, NUMA **pnamode, NUMA **pnamodecount, NUMA **pnavar, NUMA **pnarootvar)
pixRowStats()
NUMA * pixGetCmapHistogram(PIX *pixs, l_int32 factor)
pixGetCmapHistogram()
PIX * pixaGetAlignedStats(PIXA *pixa, l_int32 type, l_int32 nbins, l_int32 thresh)
pixaGetAlignedStats()
l_ok pixGetMaxValueInRect(PIX *pixs, BOX *box, l_uint32 *pmaxval, l_int32 *pxmax, l_int32 *pymax)
pixGetMaxValueInRect()
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()
l_int32 amapGetCountForColor(L_AMAP *amap, l_uint32 val)
amapGetCountForColor()
l_ok pixGetPixelAverage(PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor, l_uint32 *pval)
pixGetPixelAverage()
l_ok pixGetColumnStats(PIX *pixs, l_int32 type, l_int32 nbins, l_int32 thresh, l_float32 *rowvect)
pixGetColumnStats()
PIXA * pixClipRectangles(PIX *pixs, BOXA *boxa)
pixClipRectangles()
@ REMOVE_CMAP_TO_FULL_COLOR
@ REMOVE_CMAP_TO_GRAYSCALE
@ REMOVE_CMAP_BASED_ON_SRC
l_ok pixaAddPix(PIXA *pixa, PIX *pix, l_int32 copyflag)
pixaAddPix()
void pixaDestroy(PIXA **ppixa)
pixaDestroy()
PIXA * pixaCreate(l_int32 n)
pixaCreate()
PIXA * pixaSplitPix(PIX *pixs, l_int32 nx, l_int32 ny, l_int32 borderwidth, l_uint32 bordercolor)
pixaSplitPix()
l_ok pixaGetPixDimensions(PIXA *pixa, l_int32 index, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixaGetPixDimensions()
l_int32 pixaGetCount(PIXA *pixa)
pixaGetCount()
PIX * pixaGetPix(PIXA *pixa, l_int32 index, l_int32 accesstype)
pixaGetPix()
PIX * pixaDisplayTiledInColumns(PIXA *pixas, l_int32 nx, l_float32 scalefactor, l_int32 spacing, l_int32 border)
pixaDisplayTiledInColumns()
PIX * pixConvertRGBToGrayGeneral(PIX *pixs, l_int32 type, l_float32 rwt, l_float32 gwt, l_float32 bwt)
pixConvertRGBToGrayGeneral()
PIX * pixRemoveColormap(PIX *pixs, l_int32 type)
pixRemoveColormap()
PIX * pixConvertTo8BySampling(PIX *pixs, l_int32 factor, l_int32 cmapflag)
pixConvertTo8BySampling()
PIX * pixConvertTo8(PIX *pixs, l_int32 cmapflag)
pixConvertTo8()
PIX * pixScaleRGBToGrayFast(PIX *pixs, l_int32 factor, l_int32 color)
pixScaleRGBToGrayFast()
PIX * pixScale(PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScale()
PIX * pixScaleByIntSampling(PIX *pixs, l_int32 factor)
pixScaleByIntSampling()
PIX * pixAddSingleTextblock(PIX *pixs, L_BMF *bmf, const char *textstr, l_uint32 val, l_int32 location, l_int32 *poverflow)
pixAddSingleTextblock()
l_int32 lept_roundftoi(l_float32 fval)
lept_roundftoi()
l_int32 lept_mkdir(const char *subdir)
lept_mkdir()