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;
124 PROCNAME(
"pixGetGrayHistogram");
127 return (
NUMA *)ERROR_PTR(
"pixs not defined", procName, NULL);
128 d = pixGetDepth(pixs);
130 return (
NUMA *)ERROR_PTR(
"depth not in {1,2,4,8,16}", procName, NULL);
132 return (
NUMA *)ERROR_PTR(
"sampling must be >= 1", procName, NULL);
134 if (pixGetColormap(pixs))
143 return (
NUMA *)ERROR_PTR(
"na not made", procName, NULL);
150 array[0] = w * h - count;
156 wpl = pixGetWpl(pixg);
158 for (i = 0; i < h; i += factor) {
159 line = data + i * wpl;
161 for (j = 0; j < w; j += factor) {
166 for (j = 0; j < w; j += factor) {
171 for (j = 0; j < w; j += factor) {
176 for (j = 0; j < w; j += factor) {
217 l_int32 i, j, w, h, wm, hm, dm, wplg, wplm, val;
218 l_uint32 *datag, *datam, *lineg, *linem;
223 PROCNAME(
"pixGetGrayHistogramMasked");
228 return (
NUMA *)ERROR_PTR(
"pixs not defined", procName, NULL);
229 if (pixGetDepth(pixs) != 8 && !pixGetColormap(pixs))
230 return (
NUMA *)ERROR_PTR(
"pixs neither 8 bpp nor colormapped",
234 return (
NUMA *)ERROR_PTR(
"pixm not 1 bpp", procName, NULL);
236 return (
NUMA *)ERROR_PTR(
"sampling must be >= 1", procName, NULL);
239 return (
NUMA *)ERROR_PTR(
"na not made", procName, NULL);
243 if (pixGetColormap(pixs))
249 wplg = pixGetWpl(pixg);
251 wplm = pixGetWpl(pixm);
254 for (i = 0; i < hm; i += factor) {
255 if (y + i < 0 || y + i >= h)
continue;
256 lineg = datag + (y + i) * wplg;
257 linem = datam + i * wplm;
258 for (j = 0; j < wm; j += factor) {
259 if (x + j < 0 || x + j >= w)
continue;
295 l_int32 i, j, bx, by, bw, bh, w, h, wplg, val;
296 l_uint32 *datag, *lineg;
301 PROCNAME(
"pixGetGrayHistogramInRect");
306 return (
NUMA *)ERROR_PTR(
"pixs not defined", procName, NULL);
307 if (pixGetDepth(pixs) != 8 && !pixGetColormap(pixs))
308 return (
NUMA *)ERROR_PTR(
"pixs neither 8 bpp nor colormapped",
311 return (
NUMA *)ERROR_PTR(
"sampling must be >= 1", procName, NULL);
314 return (
NUMA *)ERROR_PTR(
"na not made", procName, NULL);
318 if (pixGetColormap(pixs))
324 wplg = pixGetWpl(pixg);
328 for (i = 0; i < bh; i += factor) {
329 if (by + i < 0 || by + i >= h)
continue;
330 lineg = datag + (by + i) * wplg;
331 for (j = 0; j < bw; j += factor) {
332 if (bx + j < 0 || bx + j >= w)
continue;
370 PROCNAME(
"pixGetGrayHistogramTiled");
373 return (
NUMAA *)ERROR_PTR(
"pixs not defined", procName, NULL);
375 return (
NUMAA *)ERROR_PTR(
"sampling must be >= 1", procName, NULL);
376 if (nx < 1 || ny < 1)
377 return (
NUMAA *)ERROR_PTR(
"nx and ny must both be > 0", procName, NULL);
381 return (
NUMAA *)ERROR_PTR(
"naa not made", procName, NULL);
385 for (i = 0; i < n; i++) {
422 l_int32 i, j, w, h, d, wpl, index, rval, gval, bval;
423 l_uint32 *data, *line;
424 l_float32 *rarray, *garray, *barray;
425 NUMA *nar, *nag, *nab;
428 PROCNAME(
"pixGetColorHistogram");
430 if (pnar) *pnar = NULL;
431 if (pnag) *pnag = NULL;
432 if (pnab) *pnab = NULL;
433 if (!pnar || !pnag || !pnab)
434 return ERROR_INT(
"&nar, &nag, &nab not all defined", procName, 1);
436 return ERROR_INT(
"pixs not defined", procName, 1);
438 cmap = pixGetColormap(pixs);
439 if (cmap && (d != 2 && d != 4 && d != 8))
440 return ERROR_INT(
"colormap and not 2, 4, or 8 bpp", procName, 1);
441 if (!cmap && d != 32)
442 return ERROR_INT(
"no colormap and not rgb", procName, 1);
444 return ERROR_INT(
"sampling factor must be >= 1", procName, 1);
462 wpl = pixGetWpl(pixs);
464 for (i = 0; i < h; i += factor) {
465 line = data + i * wpl;
466 for (j = 0; j < w; j += factor) {
480 for (i = 0; i < h; i += factor) {
481 line = data + i * wpl;
482 for (j = 0; j < w; j += factor) {
527 l_int32 i, j, w, h, d, wm, hm, dm, wpls, wplm, index, rval, gval, bval;
528 l_uint32 *datas, *datam, *lines, *linem;
529 l_float32 *rarray, *garray, *barray;
530 NUMA *nar, *nag, *nab;
533 PROCNAME(
"pixGetColorHistogramMasked");
538 if (pnar) *pnar = NULL;
539 if (pnag) *pnag = NULL;
540 if (pnab) *pnab = NULL;
541 if (!pnar || !pnag || !pnab)
542 return ERROR_INT(
"&nar, &nag, &nab not all defined", procName, 1);
544 return ERROR_INT(
"pixs not defined", procName, 1);
546 cmap = pixGetColormap(pixs);
547 if (cmap && (d != 2 && d != 4 && d != 8))
548 return ERROR_INT(
"colormap and not 2, 4, or 8 bpp", procName, 1);
549 if (!cmap && d != 32)
550 return ERROR_INT(
"no colormap and not rgb", procName, 1);
553 return ERROR_INT(
"pixm not 1 bpp", procName, 1);
555 return ERROR_INT(
"sampling factor must be >= 1", procName, 1);
573 wpls = pixGetWpl(pixs);
575 wplm = pixGetWpl(pixm);
577 for (i = 0; i < hm; i += factor) {
578 if (y + i < 0 || y + i >= h)
continue;
579 lines = datas + (y + i) * wpls;
580 linem = datam + i * wplm;
581 for (j = 0; j < wm; j += factor) {
582 if (x + j < 0 || x + j >= w)
continue;
598 for (i = 0; i < hm; i += factor) {
599 if (y + i < 0 || y + i >= h)
continue;
600 lines = datas + (y + i) * wpls;
601 linem = datam + i * wplm;
602 for (j = 0; j < wm; j += factor) {
603 if (x + j < 0 || x + j >= w)
continue;
636 l_int32 i, j, w, h, d, wpl, val, size;
637 l_uint32 *data, *line;
641 PROCNAME(
"pixGetCmapHistogram");
644 return (
NUMA *)ERROR_PTR(
"pixs not defined", procName, NULL);
645 if (pixGetColormap(pixs) == NULL)
646 return (
NUMA *)ERROR_PTR(
"pixs not cmapped", procName, NULL);
648 return (
NUMA *)ERROR_PTR(
"sampling must be >= 1", procName, NULL);
650 if (d != 2 && d != 4 && d != 8)
651 return (
NUMA *)ERROR_PTR(
"d not 2, 4 or 8", procName, NULL);
655 return (
NUMA *)ERROR_PTR(
"na not made", procName, NULL);
659 wpl = pixGetWpl(pixs);
661 for (i = 0; i < h; i += factor) {
662 line = data + i * wpl;
663 for (j = 0; j < w; j += factor) {
704 l_int32 i, j, w, h, d, wm, hm, dm, wpls, wplm, val, size;
705 l_uint32 *datas, *datam, *lines, *linem;
709 PROCNAME(
"pixGetCmapHistogramMasked");
715 return (
NUMA *)ERROR_PTR(
"pixs not defined", procName, NULL);
716 if (pixGetColormap(pixs) == NULL)
717 return (
NUMA *)ERROR_PTR(
"pixs not cmapped", procName, NULL);
720 return (
NUMA *)ERROR_PTR(
"pixm not 1 bpp", procName, NULL);
722 return (
NUMA *)ERROR_PTR(
"sampling must be >= 1", procName, NULL);
724 if (d != 2 && d != 4 && d != 8)
725 return (
NUMA *)ERROR_PTR(
"d not 2, 4 or 8", procName, NULL);
729 return (
NUMA *)ERROR_PTR(
"na not made", procName, NULL);
734 wpls = pixGetWpl(pixs);
736 wplm = pixGetWpl(pixm);
738 for (i = 0; i < hm; i += factor) {
739 if (y + i < 0 || y + i >= h)
continue;
740 lines = datas + (y + i) * wpls;
741 linem = datam + i * wplm;
742 for (j = 0; j < wm; j += factor) {
743 if (x + j < 0 || x + j >= w)
continue;
782 l_int32 i, j, bx, by, bw, bh, w, h, d, wpls, val, size;
783 l_uint32 *datas, *lines;
787 PROCNAME(
"pixGetCmapHistogramInRect");
792 return (
NUMA *)ERROR_PTR(
"pixs not defined", procName, NULL);
793 if (pixGetColormap(pixs) == NULL)
794 return (
NUMA *)ERROR_PTR(
"pixs not cmapped", procName, NULL);
796 return (
NUMA *)ERROR_PTR(
"sampling must be >= 1", procName, NULL);
798 if (d != 2 && d != 4 && d != 8)
799 return (
NUMA *)ERROR_PTR(
"d not 2, 4 or 8", procName, NULL);
803 return (
NUMA *)ERROR_PTR(
"na not made", procName, NULL);
808 wpls = pixGetWpl(pixs);
811 for (i = 0; i < bh; i += factor) {
812 if (by + i < 0 || by + i >= h)
continue;
813 lines = datas + (by + i) * wpls;
814 for (j = 0; j < bw; j += factor) {
815 if (bx + j < 0 || bx + j >= w)
continue;
849 PROCNAME(
"pixCountRGBColorsByHash");
852 return ERROR_INT(
"&ncolors not defined", procName, 1);
854 if (!pixs || pixGetDepth(pixs) != 32)
855 return ERROR_INT(
"pixs not defined or not 32 bpp", procName, 1);
886 PROCNAME(
"pixCountRGBColors");
889 return ERROR_INT(
"&ncolors not defined", procName, 1);
891 if (!pixs || pixGetDepth(pixs) != 32)
892 return ERROR_INT(
"pixs not defined or not 32 bpp", procName, 1);
894 return ERROR_INT(
"factor must be > 0", procName, 1);
896 *pncolors = l_amapSize(amap);
897 l_amapDestroy(&amap);
919 l_int32 i, j, w, h, wpl;
920 l_uint32 *data, *line;
925 PROCNAME(
"pixGetColorAmapHistogram");
928 return (
L_AMAP *)ERROR_PTR(
"pixs not defined", procName, NULL);
929 if (pixGetDepth(pixs) != 32)
930 return (
L_AMAP *)ERROR_PTR(
"pixs not 32 bpp", procName, NULL);
932 return (
L_AMAP *)ERROR_PTR(
"factor must be > 0", procName, NULL);
935 wpl = pixGetWpl(pixs);
936 amap = l_amapCreate(L_UINT_TYPE);
937 for (i = 0; i < h; i += factor) {
938 line = data + i * wpl;
939 for (j = 0; j < w; j += factor) {
941 pval = l_amapFind(amap, key);
945 value.itype = 1 + pval->itype;
946 l_amapInsert(amap, key, value);
973 PROCNAME(
"amapGetCountForColor");
976 return ERROR_INT(
"amap not defined", procName, -1);
979 pval = l_amapFind(amap, key);
980 return (pval) ? pval->itype : 0;
1012 l_float32 val, rval, gval, bval;
1016 PROCNAME(
"pixGetRankValue");
1019 return ERROR_INT(
"&value not defined", procName, 1);
1022 return ERROR_INT(
"pixs not defined", procName, 1);
1023 d = pixGetDepth(pixs);
1024 cmap = pixGetColormap(pixs);
1025 if (d != 8 && d != 32 && !cmap)
1026 return ERROR_INT(
"pixs not 8 or 32 bpp, or cmapped", procName, 1);
1031 d = pixGetDepth(pixt);
1038 &rval, &gval, &bval);
1089 PROCNAME(
"pixGetRankValueMaskedRGB");
1091 if (prval) *prval = 0.0;
1092 if (pgval) *pgval = 0.0;
1093 if (pbval) *pbval = 0.0;
1094 if (!prval && !pgval && !pbval)
1095 return ERROR_INT(
"no results requested", procName, 1);
1097 return ERROR_INT(
"pixs not defined", procName, 1);
1098 if (pixGetDepth(pixs) != 32)
1099 return ERROR_INT(
"pixs not 32 bpp", procName, 1);
1100 if (pixm && pixGetDepth(pixm) != 1)
1101 return ERROR_INT(
"pixm not 1 bpp", procName, 1);
1103 return ERROR_INT(
"sampling factor must be >= 1", procName, 1);
1104 if (rank < 0.0 || rank > 1.0)
1105 return ERROR_INT(
"rank not in [0.0 ... 1.0]", procName, 1);
1109 scale = 1.0 / (l_float32)factor;
1110 pixmt =
pixScale(pixm, scale, scale);
1115 factor, rank, prval, NULL);
1121 factor, rank, pgval, NULL);
1127 factor, rank, pbval, NULL);
1179 PROCNAME(
"pixGetRankValueMasked");
1181 if (pna) *pna = NULL;
1183 return ERROR_INT(
"&val not defined", procName, 1);
1186 return ERROR_INT(
"pixs not defined", procName, 1);
1187 if (pixGetDepth(pixs) != 8 && !pixGetColormap(pixs))
1188 return ERROR_INT(
"pixs neither 8 bpp nor colormapped", procName, 1);
1189 if (pixm && pixGetDepth(pixm) != 1)
1190 return ERROR_INT(
"pixm not 1 bpp", procName, 1);
1192 return ERROR_INT(
"sampling factor must be >= 1", procName, 1);
1193 if (rank < 0.0 || rank > 1.0)
1194 return ERROR_INT(
"rank not in [0.0 ... 1.0]", procName, 1);
1197 return ERROR_INT(
"na not made", procName, 1);
1246 l_int32 i, j, w, h, d, wm, hm, wpl1, wplm, val, rval, gval, bval, count;
1247 l_uint32 *data1, *datam, *line1, *linem;
1248 l_float64 sum, rsum, gsum, bsum;
1251 PROCNAME(
"pixGetPixelAverage");
1254 return ERROR_INT(
"&val not defined", procName, 1);
1257 return ERROR_INT(
"pixs not defined", procName, 1);
1258 d = pixGetDepth(pixs);
1259 if (d != 32 && !pixGetColormap(pixs))
1260 return ERROR_INT(
"pixs not rgb or colormapped", procName, 1);
1261 if (pixm && pixGetDepth(pixm) != 1)
1262 return ERROR_INT(
"pixm not 1 bpp", procName, 1);
1264 return ERROR_INT(
"sampling factor must be >= 1", procName, 1);
1266 if (pixGetColormap(pixs))
1273 return ERROR_INT(
"pix1 is just 1 bpp", procName, 1);
1276 wpl1 = pixGetWpl(pix1);
1278 sum = rsum = gsum = bsum = 0.0;
1281 for (i = 0; i < h; i += factor) {
1282 line1 = data1 + i * wpl1;
1283 for (j = 0; j < w; j += factor) {
1299 wplm = pixGetWpl(pixm);
1300 for (i = 0; i < hm; i += factor) {
1301 if (y + i < 0 || y + i >= h)
continue;
1302 line1 = data1 + (y + i) * wpl1;
1303 linem = datam + i * wplm;
1304 for (j = 0; j < wm; j += factor) {
1305 if (x + j < 0 || x + j >= w)
continue;
1324 return ERROR_INT(
"no pixels sampled", procName, 1);
1326 *pval = (l_uint32)(sum / (l_float64)count);
1328 rval = (l_uint32)(rsum / (l_float64)count);
1329 gval = (l_uint32)(gsum / (l_float64)count);
1330 bval = (l_uint32)(bsum / (l_float64)count);
1363 l_float32 val, rval, gval, bval;
1367 PROCNAME(
"pixGetPixelStats");
1370 return ERROR_INT(
"&value not defined", procName, 1);
1373 return ERROR_INT(
"pixs not defined", procName, 1);
1374 d = pixGetDepth(pixs);
1375 cmap = pixGetColormap(pixs);
1376 if (d != 8 && d != 32 && !cmap)
1377 return ERROR_INT(
"pixs not 8 or 32 bpp, or cmapped", procName, 1);
1382 d = pixGetDepth(pixt);
1389 &rval, &gval, &bval);
1438 PROCNAME(
"pixGetAverageMaskedRGB");
1440 if (prval) *prval = 0.0;
1441 if (pgval) *pgval = 0.0;
1442 if (pbval) *pbval = 0.0;
1443 if (!prval && !pgval && !pbval)
1444 return ERROR_INT(
"no values requested", procName, 1);
1446 return ERROR_INT(
"pixs not defined", procName, 1);
1447 cmap = pixGetColormap(pixs);
1448 if (pixGetDepth(pixs) != 32 && !cmap)
1449 return ERROR_INT(
"pixs neither 32 bpp nor colormapped", procName, 1);
1450 if (pixm && pixGetDepth(pixm) != 1)
1451 return ERROR_INT(
"pixm not 1 bpp", procName, 1);
1453 return ERROR_INT(
"sampling factor must be >= 1", procName, 1);
1456 return ERROR_INT(
"invalid measure type", procName, 1);
1460 return ERROR_INT(
"empty mask", procName, 1);
1534 l_int32 i, j, w, h, d, wm, hm, wplg, wplm, val, count, empty;
1535 l_uint32 *datag, *datam, *lineg, *linem;
1536 l_float64 sumave, summs, ave, meansq, var;
1539 PROCNAME(
"pixGetAverageMasked");
1542 return ERROR_INT(
"&val not defined", procName, 1);
1545 return ERROR_INT(
"pixs not defined", procName, 1);
1546 d = pixGetDepth(pixs);
1547 if (d != 8 && d != 16 && !pixGetColormap(pixs))
1548 return ERROR_INT(
"pixs not 8 or 16 bpp or colormapped", procName, 1);
1549 if (pixm && pixGetDepth(pixm) != 1)
1550 return ERROR_INT(
"pixm not 1 bpp", procName, 1);
1552 return ERROR_INT(
"sampling factor must be >= 1", procName, 1);
1555 return ERROR_INT(
"invalid measure type", procName, 1);
1559 return ERROR_INT(
"empty mask", procName, 1);
1562 if (pixGetColormap(pixs))
1568 wplg = pixGetWpl(pixg);
1570 sumave = summs = 0.0;
1573 for (i = 0; i < h; i += factor) {
1574 lineg = datag + i * wplg;
1575 for (j = 0; j < w; j += factor) {
1583 summs += (l_float64)(val) * val;
1590 wplm = pixGetWpl(pixm);
1591 for (i = 0; i < hm; i += factor) {
1592 if (y + i < 0 || y + i >= h)
continue;
1593 lineg = datag + (y + i) * wplg;
1594 linem = datam + i * wplm;
1595 for (j = 0; j < wm; j += factor) {
1596 if (x + j < 0 || x + j >= w)
continue;
1605 summs += (l_float64)(val) * val;
1614 return ERROR_INT(
"no pixels sampled", procName, 1);
1615 ave = sumave / (l_float64)count;
1616 meansq = summs / (l_float64)count;
1617 var = meansq - ave * ave;
1619 *pval = (l_float32)ave;
1621 *pval = (l_float32)sqrt(meansq);
1623 *pval = (l_float32)sqrt(var);
1625 *pval = (l_float32)var;
1661 PROCNAME(
"pixGetAverageTiledRGB");
1663 if (ppixr) *ppixr = NULL;
1664 if (ppixg) *ppixg = NULL;
1665 if (ppixb) *ppixb = NULL;
1666 if (!ppixr && !ppixg && !ppixb)
1667 return ERROR_INT(
"no data requested", procName, 1);
1669 return ERROR_INT(
"pixs not defined", procName, 1);
1670 cmap = pixGetColormap(pixs);
1671 if (pixGetDepth(pixs) != 32 && !cmap)
1672 return ERROR_INT(
"pixs neither 32 bpp nor colormapped", procName, 1);
1673 if (sx < 2 || sy < 2)
1674 return ERROR_INT(
"sx and sy not both > 1", procName, 1);
1677 return ERROR_INT(
"invalid measure type", procName, 1);
1732 l_int32 i, j, k, m, w, h, wd, hd, d, pos, wplt, wpld, valt;
1733 l_uint32 *datat, *datad, *linet, *lined, *startt;
1734 l_float64 sumave, summs, ave, meansq, normfact;
1737 PROCNAME(
"pixGetAverageTiled");
1740 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1742 if (d != 8 && !pixGetColormap(pixs))
1743 return (
PIX *)ERROR_PTR(
"pixs not 8 bpp or cmapped", procName, NULL);
1744 if (sx < 2 || sy < 2)
1745 return (
PIX *)ERROR_PTR(
"sx and sy not both > 1", procName, NULL);
1748 if (wd < 1 || hd < 1)
1749 return (
PIX *)ERROR_PTR(
"wd or hd == 0", procName, NULL);
1752 return (
PIX *)ERROR_PTR(
"invalid measure type", procName, NULL);
1757 wplt = pixGetWpl(pixt);
1759 wpld = pixGetWpl(pixd);
1760 normfact = 1. / (l_float64)(sx * sy);
1761 for (i = 0; i < hd; i++) {
1762 lined = datad + i * wpld;
1763 linet = datat + i * sy * wplt;
1764 for (j = 0; j < wd; j++) {
1767 for (k = 0; k < sy; k++) {
1768 startt = linet + k * wplt;
1769 for (m = 0; m < sx; m++) {
1775 ave = normfact * sumave;
1779 for (k = 0; k < sy; k++) {
1780 startt = linet + k * wplt;
1781 for (m = 0; m < sx; m++) {
1784 summs += (l_float64)(valt) * valt;
1787 meansq = normfact * summs;
1790 valt = (l_int32)(ave + 0.5);
1792 valt = (l_int32)(sqrt(meansq) + 0.5);
1794 valt = (l_int32)(sqrt(meansq - ave * ave) + 0.5);
1835 NUMA **pnamodecount,
1839 l_int32 i, j, k, w, h, val, wpls, sum, sumsq, target, max, modeval;
1840 l_int32 xstart, xend, ystart, yend, bw, bh;
1842 l_uint32 *lines, *datas;
1844 l_float32 *famean, *fameansq, *favar, *farootvar;
1845 l_float32 *famedian, *famode, *famodecount;
1847 PROCNAME(
"pixRowStats");
1849 if (pnamean) *pnamean = NULL;
1850 if (pnamedian) *pnamedian = NULL;
1851 if (pnamode) *pnamode = NULL;
1852 if (pnamodecount) *pnamodecount = NULL;
1853 if (pnavar) *pnavar = NULL;
1854 if (pnarootvar) *pnarootvar = NULL;
1855 if (!pixs || pixGetDepth(pixs) != 8)
1856 return ERROR_INT(
"pixs undefined or not 8 bpp", procName, 1);
1857 famean = fameansq = favar = farootvar = NULL;
1858 famedian = famode = famodecount = NULL;
1863 return ERROR_INT(
"invalid clipping box", procName, 1);
1867 wpls = pixGetWpl(pixs);
1868 if (pnamean || pnavar || pnarootvar) {
1869 norm = 1. / (l_float32)bw;
1870 famean = (l_float32 *)LEPT_CALLOC(bh,
sizeof(l_float32));
1871 fameansq = (l_float32 *)LEPT_CALLOC(bh,
sizeof(l_float32));
1872 if (pnavar || pnarootvar) {
1873 favar = (l_float32 *)LEPT_CALLOC(bh,
sizeof(l_float32));
1875 farootvar = (l_float32 *)LEPT_CALLOC(bh,
sizeof(l_float32));
1877 for (i = ystart; i < yend; i++) {
1879 lines = datas + i * wpls;
1880 for (j = xstart; j < xend; j++) {
1885 famean[i] = norm * sum;
1886 fameansq[i] = norm * sumsq;
1887 if (pnavar || pnarootvar) {
1888 favar[i] = fameansq[i] - famean[i] * famean[i];
1890 farootvar[i] = sqrtf(favar[i]);
1893 LEPT_FREE(fameansq);
1907 if (pnamedian || pnamode || pnamodecount) {
1908 histo = (l_int32 *)LEPT_CALLOC(256,
sizeof(l_int32));
1921 for (i = ystart; i < yend; i++) {
1922 lines = datas + i * wpls;
1923 memset(histo, 0, 1024);
1924 for (j = xstart; j < xend; j++) {
1931 target = (bw + 1) / 2;
1932 for (k = 0; k < 256; k++) {
1934 if (sum >= target) {
1941 if (pnamode || pnamodecount) {
1944 for (k = 0; k < 256; k++) {
1945 if (histo[k] > max) {
1951 famode[i] = modeval;
1953 famodecount[i] = max;
1995 NUMA **pnamodecount,
1999 l_int32 i, j, k, w, h, val, wpls, sum, sumsq, target, max, modeval;
2000 l_int32 xstart, xend, ystart, yend, bw, bh;
2002 l_uint32 *lines, *datas;
2004 l_float32 *famean, *fameansq, *favar, *farootvar;
2005 l_float32 *famedian, *famode, *famodecount;
2007 PROCNAME(
"pixColumnStats");
2009 if (pnamean) *pnamean = NULL;
2010 if (pnamedian) *pnamedian = NULL;
2011 if (pnamode) *pnamode = NULL;
2012 if (pnamodecount) *pnamodecount = NULL;
2013 if (pnavar) *pnavar = NULL;
2014 if (pnarootvar) *pnarootvar = NULL;
2015 if (!pixs || pixGetDepth(pixs) != 8)
2016 return ERROR_INT(
"pixs undefined or not 8 bpp", procName, 1);
2017 famean = fameansq = favar = farootvar = NULL;
2018 famedian = famode = famodecount = NULL;
2023 return ERROR_INT(
"invalid clipping box", procName, 1);
2027 wpls = pixGetWpl(pixs);
2028 if (pnamean || pnavar || pnarootvar) {
2029 norm = 1. / (l_float32)bh;
2030 famean = (l_float32 *)LEPT_CALLOC(bw,
sizeof(l_float32));
2031 fameansq = (l_float32 *)LEPT_CALLOC(bw,
sizeof(l_float32));
2032 if (pnavar || pnarootvar) {
2033 favar = (l_float32 *)LEPT_CALLOC(bw,
sizeof(l_float32));
2035 farootvar = (l_float32 *)LEPT_CALLOC(bw,
sizeof(l_float32));
2037 for (j = xstart; j < xend; j++) {
2039 for (i = ystart, lines = datas; i < yend; lines += wpls, i++) {
2044 famean[j] = norm * sum;
2045 fameansq[j] = norm * sumsq;
2046 if (pnavar || pnarootvar) {
2047 favar[j] = fameansq[j] - famean[j] * famean[j];
2049 farootvar[j] = sqrtf(favar[j]);
2052 LEPT_FREE(fameansq);
2066 if (pnamedian || pnamode || pnamodecount) {
2067 histo = (l_int32 *)LEPT_CALLOC(256,
sizeof(l_int32));
2080 for (j = xstart; j < xend; j++) {
2081 memset(histo, 0, 1024);
2082 for (i = ystart, lines = datas; i < yend; lines += wpls, i++) {
2089 target = (bh + 1) / 2;
2090 for (k = 0; k < 256; k++) {
2092 if (sum >= target) {
2099 if (pnamode || pnamodecount) {
2102 for (k = 0; k < 256; k++) {
2103 if (histo[k] > max) {
2109 famode[j] = modeval;
2111 famodecount[j] = max;
2146 PROCNAME(
"pixGetRangeValues");
2148 if (pminval) *pminval = 0;
2149 if (pmaxval) *pmaxval = 0;
2150 if (!pminval && !pmaxval)
2151 return ERROR_INT(
"no result requested", procName, 1);
2153 return ERROR_INT(
"pixs not defined", procName, 1);
2155 cmap = pixGetColormap(pixs);
2161 return ERROR_INT(
"sampling factor must be >= 1", procName, 1);
2162 d = pixGetDepth(pixs);
2163 if (d != 8 && d != 32)
2164 return ERROR_INT(
"pixs not 8 or 32 bpp", procName, 1);
2168 NULL, NULL, NULL, pminval);
2170 NULL, NULL, NULL, pmaxval);
2173 pminval, NULL, NULL, NULL);
2175 pmaxval, NULL, NULL, NULL);
2178 NULL, pminval, NULL, NULL);
2180 NULL, pmaxval, NULL, NULL);
2183 NULL, NULL, pminval, NULL);
2185 NULL, NULL, pmaxval, NULL);
2187 return ERROR_INT(
"invalid color", procName, 1);
2223 l_int32 i, j, w, h, d, wpl;
2224 l_int32 val, extval, rval, gval, bval, extrval, extgval, extbval;
2226 l_uint32 *data, *line;
2229 PROCNAME(
"pixGetExtremeValue");
2231 if (prval) *prval = -1;
2232 if (pgval) *pgval = -1;
2233 if (pbval) *pbval = -1;
2234 if (pgrayval) *pgrayval = -1;
2236 return ERROR_INT(
"pixs not defined", procName, 1);
2238 return ERROR_INT(
"invalid type", procName, 1);
2240 cmap = pixGetColormap(pixs);
2262 return ERROR_INT(
"sampling factor must be >= 1", procName, 1);
2263 if (d != 8 && d != 32)
2264 return ERROR_INT(
"pixs not 8 or 32 bpp", procName, 1);
2265 if (d == 8 && !pgrayval)
2266 return ERROR_INT(
"can't return result in grayval", procName, 1);
2267 if (d == 32 && !prval && !pgval && !pbval)
2268 return ERROR_INT(
"can't return result in r/g/b-val", procName, 1);
2271 wpl = pixGetWpl(pixs);
2278 for (i = 0; i < h; i += factor) {
2279 line = data + i * wpl;
2280 for (j = 0; j < w; j += factor) {
2301 for (i = 0; i < h; i += factor) {
2302 line = data + i * wpl;
2303 for (j = 0; j < w; j += factor) {
2306 rval = (pixel >> L_RED_SHIFT) & 0xff;
2312 gval = (pixel >> L_GREEN_SHIFT) & 0xff;
2318 bval = (pixel >> L_BLUE_SHIFT) & 0xff;
2325 if (prval) *prval = extrval;
2326 if (pgval) *pgval = extgval;
2327 if (pbval) *pbval = extbval;
2358 l_int32 i, j, w, h, d, wpl, bw, bh;
2359 l_int32 xstart, ystart, xend, yend, xmax, ymax;
2360 l_uint32 val, maxval;
2361 l_uint32 *data, *line;
2363 PROCNAME(
"pixGetMaxValueInRect");
2365 if (pmaxval) *pmaxval = 0;
2366 if (pxmax) *pxmax = 0;
2367 if (pymax) *pymax = 0;
2368 if (!pmaxval && !pxmax && !pymax)
2369 return ERROR_INT(
"no data requested", procName, 1);
2371 return ERROR_INT(
"pixs not defined", procName, 1);
2372 if (pixGetColormap(pixs) != NULL)
2373 return ERROR_INT(
"pixs has colormap", procName, 1);
2375 if (d != 8 && d != 16 && d != 32)
2376 return ERROR_INT(
"pixs not 8, 16 or 32 bpp", procName, 1);
2378 xstart = ystart = 0;
2383 xend = xstart + bw - 1;
2384 yend = ystart + bh - 1;
2388 wpl = pixGetWpl(pixs);
2391 for (i = ystart; i <= yend; i++) {
2392 line = data + i * wpl;
2393 for (j = xstart; j <= xend; j++) {
2408 xmax = (xstart + xend) / 2;
2409 ymax = (ystart + yend) / 2;
2412 if (pmaxval) *pmaxval = maxval;
2413 if (pxmax) *pxmax = xmax;
2414 if (pymax) *pymax = ymax;
2430 l_int32 i, j, w, h, d, wpl, val, max, maxval, empty;
2431 l_uint32 *data, *line;
2433 PROCNAME(
"pixGetMaxColorIndex");
2436 return ERROR_INT(
"&maxindex not defined", procName, 1);
2439 return ERROR_INT(
"pixs not defined", procName, 1);
2441 if (d != 1 && d != 2 && d != 4 && d != 8)
2442 return ERROR_INT(
"invalid pixs depth; not in (1,2,4,8}", procName, 1);
2444 wpl = pixGetWpl(pixs);
2447 maxval = (1 << d) - 1;
2450 if (!empty) max = 1;
2454 for (i = 0; i < h; i++) {
2455 line = data + i * wpl;
2457 for (j = 0; j < w; j++) {
2459 if (val > max) max = val;
2461 }
else if (d == 4) {
2462 for (j = 0; j < w; j++) {
2464 if (val > max) max = val;
2466 }
else if (d == 8) {
2467 for (j = 0; j < w; j++) {
2469 if (val > max) max = val;
2472 if (max == maxval)
break;
2510 l_int32 i, minval, maxval, rval, gval, bval;
2514 PROCNAME(
"pixGetBinnedComponentRange");
2516 if (pminval) *pminval = 0;
2517 if (pmaxval) *pmaxval = 0;
2518 if (pcarray) *pcarray = NULL;
2519 if (!pminval && !pmaxval)
2520 return ERROR_INT(
"no result requested", procName, 1);
2521 if (!pixs || pixGetDepth(pixs) != 32)
2522 return ERROR_INT(
"pixs not defined or not 32 bpp", procName, 1);
2524 return ERROR_INT(
"sampling factor must be >= 1", procName, 1);
2527 return ERROR_INT(
"invalid color", procName, 1);
2528 if (fontsize < 0 || fontsize > 20 || fontsize & 1 || fontsize == 2)
2529 return ERROR_INT(
"invalid fontsize", procName, 1);
2533 return ERROR_INT(
"carray not made", procName, 1);
2536 for (i = 0; i < nbins; i++)
2537 L_INFO(
"c[%d] = %x\n", procName, i, carray[i]);
2539 pixDisplay(pixt, 100, 100);
2556 if (pminval) *pminval = minval;
2557 if (pmaxval) *pmaxval = maxval;
2608 l_int32 ret, w, h, samplesperbin;
2610 PIX *pix1, *pixc, *pixg, *pixd;
2613 PROCNAME(
"pixGetRankColorArray");
2616 return ERROR_INT(
"&carray not defined", procName, 1);
2619 return ERROR_INT(
"sampling factor must be >= 1", procName, 1);
2621 return ERROR_INT(
"nbins must be at least 2", procName, 1);
2623 return ERROR_INT(
"pixs not defined", procName, 1);
2624 cmap = pixGetColormap(pixs);
2625 if (pixGetDepth(pixs) != 32 && !cmap)
2626 return ERROR_INT(
"pixs neither 32 bpp nor cmapped", procName, 1);
2631 return ERROR_INT(
"invalid type", procName, 1);
2633 if (fontsize < 0 || fontsize > 20 || fontsize & 1 || fontsize == 2) {
2634 L_WARNING(
"invalid fontsize %d; setting to 6\n", procName,
2640 samplesperbin = (w * h) / (factor * factor * nbins);
2641 if (samplesperbin < 10) {
2642 L_ERROR(
"samplesperbin = %d < 10\n", procName, samplesperbin);
2661 if ((array = *pcarray) == NULL) {
2662 L_ERROR(
"color array not returned\n", procName);
2665 if (array && pixadb) {
2667 pixWriteDebug(
"/tmp/lept/regout/rankhisto.png", pixd, IFF_PNG);
2712 l_int32 i, j, k, w, h, wpls, wplg;
2713 l_int32 count, bincount, binindex, binsize, npts, avepts, ntot;
2714 l_int32 rval, gval, bval, grayval, rave, gave, bave;
2715 l_uint32 *datas, *datag, *lines, *lineg, *carray;
2716 l_float64 val64, rsum, gsum, bsum;
2721 PROCNAME(
"pixGetBinnedColor");
2724 return ERROR_INT(
"&carray not defined", procName, 1);
2726 if (!pixs || pixGetDepth(pixs) != 32)
2727 return ERROR_INT(
"pixs undefined or not 32 bpp", procName, 1);
2728 if (!pixg || pixGetDepth(pixg) != 8)
2729 return ERROR_INT(
"pixg undefined or not 8 bpp", procName, 1);
2731 L_WARNING(
"sampling factor less than 1; setting to 1\n", procName);
2734 if (nbins < 1 || nbins > 100)
2735 return ERROR_INT(
"nbins not in [1,100]", procName, 1);
2739 npts = (w + factor - 1) * (h + factor - 1) / (factor * factor);
2740 avepts = (npts + nbins - 1) / nbins;
2742 L_ERROR(
"avepts = %d; must be >= 5\n", procName, avepts);
2755 wpls = pixGetWpl(pixs);
2757 wplg = pixGetWpl(pixg);
2759 for (i = 0; i < h; i += factor) {
2760 lines = datas + i * wpls;
2761 lineg = datag + i * wplg;
2762 for (j = 0; j < w; j += factor) {
2769 NUMA *na, *nabinval, *narank;
2771 for (i = 0; i < 256; i++)
2789 return ERROR_INT(
"naeach not made", procName, 1);
2794 carray = (l_uint32 *)LEPT_CALLOC(nbins,
sizeof(l_uint32));
2795 rsum = gsum = bsum = 0.0;
2800 for (i = 0; i < 256; i++) {
2802 for (j = 0; j < count; j++) {
2810 if (bincount == binsize) {
2811 rave = (l_int32)(rsum / binsize + 0.5);
2812 gave = (l_int32)(gsum / binsize + 0.5);
2813 bave = (l_int32)(bsum / binsize + 0.5);
2815 rsum = gsum = bsum = 0.0;
2818 if (binindex == nbins)
break;
2822 if (binindex == nbins)
break;
2824 if (binindex != nbins)
2825 L_ERROR(
"binindex = %d != nbins = %d\n", procName, binindex, nbins);
2828 NUMA *nared, *nagreen, *nablue;
2832 for (i = 0; i < nbins; i++) {
2884 l_int32 i, rval, gval, bval;
2886 PIX *pix1, *pix2, *pix3, *pix4;
2889 PROCNAME(
"pixDisplayColorArray");
2892 return (
PIX *)ERROR_PTR(
"carray not defined", procName, NULL);
2893 if (fontsize < 0 || fontsize > 20 || fontsize & 1 || fontsize == 2)
2894 return (
PIX *)ERROR_PTR(
"invalid fontsize", procName, NULL);
2896 bmf = (fontsize == 0) ? NULL :
bmfCreate(NULL, fontsize);
2898 for (i = 0; i < ncolors; i++) {
2904 snprintf(textstr,
sizeof(textstr),
2905 "%d: (%d %d %d)", i, rval, gval, bval);
2959 l_int32 i, j, w, h, mindim, nstrips;
2962 PIX *pix1, *pix2, *pixd;
2966 PROCNAME(
"pixRankBinByStrip");
2969 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
2970 cmap = pixGetColormap(pixs);
2971 if (pixGetDepth(pixs) != 32 && !cmap)
2972 return (
PIX *)ERROR_PTR(
"pixs neither 32 bpp nor cmapped",
2975 return (
PIX *)ERROR_PTR(
"invalid direction", procName, NULL);
2977 return (
PIX *)ERROR_PTR(
"size < 1", procName, NULL);
2979 return (
PIX *)ERROR_PTR(
"nbins must be at least 2", procName, NULL);
2984 return (
PIX *)ERROR_PTR(
"invalid type", procName, NULL);
2986 mindim = L_MIN(w, h);
2987 if (mindim < 20 || nbins > mindim)
2988 return (
PIX *)ERROR_PTR(
"pix too small and/or too many bins",
3004 for (i = 0; i < nstrips; i++) {
3008 for (j = 0; j < nbins; j++)
3016 for (i = 0; i < nstrips; i++) {
3020 for (j = 0; j < nbins; j++)
3065 l_int32 j, n, w, h, d;
3069 PROCNAME(
"pixaGetAlignedStats");
3072 return (
PIX *)ERROR_PTR(
"pixa not defined", procName, NULL);
3075 return (
PIX *)ERROR_PTR(
"invalid type", procName, NULL);
3078 return (
PIX *)ERROR_PTR(
"no pix in pixa", procName, NULL);
3081 return (
PIX *)ERROR_PTR(
"pix not 8 bpp", procName, NULL);
3085 colvect = (l_float32 *)LEPT_CALLOC(h,
sizeof(l_float32));
3086 for (j = 0; j < w; j++) {
3111 l_int32 i, k, n, w, h, ht, val, wplt, wpld;
3112 l_uint32 *datad, *datat;
3115 PROCNAME(
"pixaExtractColumnFromEachPix");
3118 return ERROR_INT(
"pixa not defined", procName, 1);
3119 if (!pixd || pixGetDepth(pixd) != 8)
3120 return ERROR_INT(
"pixd not defined or not 8 bpp", procName, 1);
3124 return ERROR_INT(
"pix width != n", procName, 1);
3126 wplt = pixGetWpl(pixt);
3130 return ERROR_INT(
"pixd height != column height", procName, 1);
3133 wpld = pixGetWpl(pixd);
3134 for (k = 0; k < n; k++) {
3137 for (i = 0; i < h; i++) {
3188 l_int32 i, j, k, w, h, val, wpls, sum, target, max, modeval;
3189 l_int32 *histo, *gray2bin, *bin2gray;
3190 l_uint32 *lines, *datas;
3192 PROCNAME(
"pixGetRowStats");
3194 if (!pixs || pixGetDepth(pixs) != 8)
3195 return ERROR_INT(
"pixs not defined or not 8 bpp", procName, 1);
3197 return ERROR_INT(
"colvect not defined", procName, 1);
3200 return ERROR_INT(
"invalid type", procName, 1);
3202 return ERROR_INT(
"invalid nbins", procName, 1);
3206 wpls = pixGetWpl(pixs);
3208 for (i = 0; i < h; i++) {
3210 lines = datas + i * wpls;
3211 for (j = 0; j < w; j++)
3213 colvect[i] = (l_float32)sum / (l_float32)w;
3219 histo = (l_int32 *)LEPT_CALLOC(nbins,
sizeof(l_int32));
3220 gray2bin = (l_int32 *)LEPT_CALLOC(256,
sizeof(l_int32));
3221 bin2gray = (l_int32 *)LEPT_CALLOC(nbins,
sizeof(l_int32));
3222 for (i = 0; i < 256; i++)
3223 gray2bin[i] = (i * nbins) / 256;
3224 for (i = 0; i < nbins; i++)
3225 bin2gray[i] = (i * 256 + 128) / nbins;
3227 for (i = 0; i < h; i++) {
3228 lines = datas + i * wpls;
3229 for (k = 0; k < nbins; k++)
3231 for (j = 0; j < w; j++) {
3233 histo[gray2bin[val]]++;
3238 target = (w + 1) / 2;
3239 for (k = 0; k < nbins; k++) {
3241 if (sum >= target) {
3242 colvect[i] = bin2gray[k];
3249 for (k = 0; k < nbins; k++) {
3250 if (histo[k] > max) {
3258 colvect[i] = bin2gray[modeval];
3261 for (k = 0; k < nbins; k++) {
3270 LEPT_FREE(gray2bin);
3271 LEPT_FREE(bin2gray);
3310 l_int32 i, j, k, w, h, val, wpls, sum, target, max, modeval;
3311 l_int32 *histo, *gray2bin, *bin2gray;
3314 PROCNAME(
"pixGetColumnStats");
3316 if (!pixs || pixGetDepth(pixs) != 8)
3317 return ERROR_INT(
"pixs not defined or not 8 bpp", procName, 1);
3319 return ERROR_INT(
"rowvect not defined", procName, 1);
3322 return ERROR_INT(
"invalid type", procName, 1);
3324 return ERROR_INT(
"invalid nbins", procName, 1);
3328 wpls = pixGetWpl(pixs);
3330 for (j = 0; j < w; j++) {
3332 for (i = 0; i < h; i++)
3334 rowvect[j] = (l_float32)sum / (l_float32)h;
3340 histo = (l_int32 *)LEPT_CALLOC(nbins,
sizeof(l_int32));
3341 gray2bin = (l_int32 *)LEPT_CALLOC(256,
sizeof(l_int32));
3342 bin2gray = (l_int32 *)LEPT_CALLOC(nbins,
sizeof(l_int32));
3343 for (i = 0; i < 256; i++)
3344 gray2bin[i] = (i * nbins) / 256;
3345 for (i = 0; i < nbins; i++)
3346 bin2gray[i] = (i * 256 + 128) / nbins;
3348 for (j = 0; j < w; j++) {
3349 for (i = 0; i < h; i++) {
3351 histo[gray2bin[val]]++;
3356 target = (h + 1) / 2;
3357 for (k = 0; k < nbins; k++) {
3359 if (sum >= target) {
3360 rowvect[j] = bin2gray[k];
3367 for (k = 0; k < nbins; k++) {
3368 if (histo[k] > max) {
3376 rowvect[j] = bin2gray[modeval];
3379 for (k = 0; k < nbins; k++) {
3385 for (k = 0; k < nbins; k++)
3390 LEPT_FREE(gray2bin);
3391 LEPT_FREE(bin2gray);
3409 l_int32 i, w, h, wpl;
3412 PROCNAME(
"pixSetCPixelColumn");
3414 if (!pix || pixGetDepth(pix) != 8)
3415 return ERROR_INT(
"pix not defined or not 8 bpp", procName, 1);
3417 return ERROR_INT(
"colvect not defined", procName, 1);
3419 if (col < 0 || col > w)
3420 return ERROR_INT(
"invalid col", procName, 1);
3423 wpl = pixGetWpl(pix);
3424 for (i = 0; i < h; i++)
3454 PROCNAME(
"pixThresholdForFgBg");
3456 if (pfgval) *pfgval = 0;
3457 if (pbgval) *pbgval = 0;
3458 if (!pfgval && !pbgval)
3459 return ERROR_INT(
"no data requested", procName, 1);
3461 return ERROR_INT(
"pixs not defined", procName, 1);
3469 *pfgval = (l_int32)(fval + 0.5);
3475 *pbgval = (l_int32)(fval + 0.5);
3505 l_float32 scorefract,
3514 l_float32 avefg, avebg, maxnum;
3516 NUMA *na, *nascore, *nax, *nay;
3519 PROCNAME(
"pixSplitDistributionFgBg");
3521 if (pthresh) *pthresh = 0;
3522 if (pfgval) *pfgval = 0;
3523 if (pbgval) *pbgval = 0;
3524 if (ppixdb) *ppixdb = NULL;
3525 if (!pthresh && !pfgval && !pbgval)
3526 return ERROR_INT(
"no data requested", procName, 1);
3528 return ERROR_INT(
"pixs not defined", procName, 1);
3537 NULL, NULL, &nascore);
3544 if (pthresh) *pthresh = thresh;
3545 if (pfgval) *pfgval = (l_int32)(avefg + 0.5);
3546 if (pbgval) *pbgval = (l_int32)(avebg + 0.5);
3550 gplot =
gplotCreate(
"/tmp/lept/redout/histplot", GPLOT_PNG,
"Histogram",
3551 "Grayscale value",
"Number of pixels");
3557 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(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()