85 #include "allheaders.h" 112 l_int32 i, j, w, h, d, wpl, val, size, count;
113 l_uint32 *data, *line;
118 PROCNAME(
"pixGetGrayHistogram");
121 return (
NUMA *)ERROR_PTR(
"pixs not defined", procName, NULL);
122 d = pixGetDepth(pixs);
124 return (
NUMA *)ERROR_PTR(
"depth not in {1,2,4,8,16}", procName, NULL);
126 return (
NUMA *)ERROR_PTR(
"sampling must be >= 1", procName, NULL);
128 if (pixGetColormap(pixs))
137 return (
NUMA *)ERROR_PTR(
"na not made", procName, NULL);
144 array[0] = w * h - count;
150 wpl = pixGetWpl(pixg);
152 for (i = 0; i < h; i += factor) {
153 line = data + i * wpl;
155 for (j = 0; j < w; j += factor) {
160 for (j = 0; j < w; j += factor) {
165 for (j = 0; j < w; j += factor) {
170 for (j = 0; j < w; j += factor) {
211 l_int32 i, j, w, h, wm, hm, dm, wplg, wplm, val;
212 l_uint32 *datag, *datam, *lineg, *linem;
217 PROCNAME(
"pixGetGrayHistogramMasked");
222 return (
NUMA *)ERROR_PTR(
"pixs not defined", procName, NULL);
223 if (pixGetDepth(pixs) != 8 && !pixGetColormap(pixs))
224 return (
NUMA *)ERROR_PTR(
"pixs neither 8 bpp nor colormapped",
228 return (
NUMA *)ERROR_PTR(
"pixm not 1 bpp", procName, NULL);
230 return (
NUMA *)ERROR_PTR(
"sampling must be >= 1", procName, NULL);
233 return (
NUMA *)ERROR_PTR(
"na not made", procName, NULL);
237 if (pixGetColormap(pixs))
243 wplg = pixGetWpl(pixg);
245 wplm = pixGetWpl(pixm);
248 for (i = 0; i < hm; i += factor) {
249 if (y + i < 0 || y + i >= h)
continue;
250 lineg = datag + (y + i) * wplg;
251 linem = datam + i * wplm;
252 for (j = 0; j < wm; j += factor) {
253 if (x + j < 0 || x + j >= w)
continue;
289 l_int32 i, j, bx, by, bw, bh, w, h, wplg, val;
290 l_uint32 *datag, *lineg;
295 PROCNAME(
"pixGetGrayHistogramInRect");
300 return (
NUMA *)ERROR_PTR(
"pixs not defined", procName, 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", procName, NULL);
308 return (
NUMA *)ERROR_PTR(
"na not made", procName, 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;
364 PROCNAME(
"pixGetGrayHistogramTiled");
367 return (
NUMAA *)ERROR_PTR(
"pixs not defined", procName, NULL);
369 return (
NUMAA *)ERROR_PTR(
"sampling must be >= 1", procName, NULL);
370 if (nx < 1 || ny < 1)
371 return (
NUMAA *)ERROR_PTR(
"nx and ny must both be > 0", procName, NULL);
375 return (
NUMAA *)ERROR_PTR(
"naa not made", procName, NULL);
379 for (i = 0; i < n; i++) {
416 l_int32 i, j, w, h, d, wpl, index, rval, gval, bval;
417 l_uint32 *data, *line;
418 l_float32 *rarray, *garray, *barray;
419 NUMA *nar, *nag, *nab;
422 PROCNAME(
"pixGetColorHistogram");
424 if (pnar) *pnar = NULL;
425 if (pnag) *pnag = NULL;
426 if (pnab) *pnab = NULL;
427 if (!pnar || !pnag || !pnab)
428 return ERROR_INT(
"&nar, &nag, &nab not all defined", procName, 1);
430 return ERROR_INT(
"pixs not defined", procName, 1);
432 cmap = pixGetColormap(pixs);
433 if (cmap && (d != 2 && d != 4 && d != 8))
434 return ERROR_INT(
"colormap and not 2, 4, or 8 bpp", procName, 1);
435 if (!cmap && d != 32)
436 return ERROR_INT(
"no colormap and not rgb", procName, 1);
438 return ERROR_INT(
"sampling factor must be >= 1", procName, 1);
456 wpl = pixGetWpl(pixs);
458 for (i = 0; i < h; i += factor) {
459 line = data + i * wpl;
460 for (j = 0; j < w; j += factor) {
474 for (i = 0; i < h; i += factor) {
475 line = data + i * wpl;
476 for (j = 0; j < w; j += factor) {
521 l_int32 i, j, w, h, d, wm, hm, dm, wpls, wplm, index, rval, gval, bval;
522 l_uint32 *datas, *datam, *lines, *linem;
523 l_float32 *rarray, *garray, *barray;
524 NUMA *nar, *nag, *nab;
527 PROCNAME(
"pixGetColorHistogramMasked");
532 if (pnar) *pnar = NULL;
533 if (pnag) *pnag = NULL;
534 if (pnab) *pnab = NULL;
535 if (!pnar || !pnag || !pnab)
536 return ERROR_INT(
"&nar, &nag, &nab not all defined", procName, 1);
538 return ERROR_INT(
"pixs not defined", procName, 1);
540 cmap = pixGetColormap(pixs);
541 if (cmap && (d != 2 && d != 4 && d != 8))
542 return ERROR_INT(
"colormap and not 2, 4, or 8 bpp", procName, 1);
543 if (!cmap && d != 32)
544 return ERROR_INT(
"no colormap and not rgb", procName, 1);
547 return ERROR_INT(
"pixm not 1 bpp", procName, 1);
549 return ERROR_INT(
"sampling factor must be >= 1", procName, 1);
567 wpls = pixGetWpl(pixs);
569 wplm = pixGetWpl(pixm);
571 for (i = 0; i < hm; i += factor) {
572 if (y + i < 0 || y + i >= h)
continue;
573 lines = datas + (y + i) * wpls;
574 linem = datam + i * wplm;
575 for (j = 0; j < wm; j += factor) {
576 if (x + j < 0 || x + j >= w)
continue;
592 for (i = 0; i < hm; i += factor) {
593 if (y + i < 0 || y + i >= h)
continue;
594 lines = datas + (y + i) * wpls;
595 linem = datam + i * wplm;
596 for (j = 0; j < wm; j += factor) {
597 if (x + j < 0 || x + j >= w)
continue;
630 l_int32 i, j, w, h, d, wpl, val, size;
631 l_uint32 *data, *line;
635 PROCNAME(
"pixGetCmapHistogram");
638 return (
NUMA *)ERROR_PTR(
"pixs not defined", procName, NULL);
639 if (pixGetColormap(pixs) == NULL)
640 return (
NUMA *)ERROR_PTR(
"pixs not cmapped", procName, NULL);
642 return (
NUMA *)ERROR_PTR(
"sampling must be >= 1", procName, NULL);
644 if (d != 2 && d != 4 && d != 8)
645 return (
NUMA *)ERROR_PTR(
"d not 2, 4 or 8", procName, NULL);
649 return (
NUMA *)ERROR_PTR(
"na not made", procName, NULL);
653 wpl = pixGetWpl(pixs);
655 for (i = 0; i < h; i += factor) {
656 line = data + i * wpl;
657 for (j = 0; j < w; j += factor) {
698 l_int32 i, j, w, h, d, wm, hm, dm, wpls, wplm, val, size;
699 l_uint32 *datas, *datam, *lines, *linem;
703 PROCNAME(
"pixGetCmapHistogramMasked");
709 return (
NUMA *)ERROR_PTR(
"pixs not defined", procName, NULL);
710 if (pixGetColormap(pixs) == NULL)
711 return (
NUMA *)ERROR_PTR(
"pixs not cmapped", procName, NULL);
714 return (
NUMA *)ERROR_PTR(
"pixm not 1 bpp", procName, NULL);
716 return (
NUMA *)ERROR_PTR(
"sampling must be >= 1", procName, NULL);
718 if (d != 2 && d != 4 && d != 8)
719 return (
NUMA *)ERROR_PTR(
"d not 2, 4 or 8", procName, NULL);
723 return (
NUMA *)ERROR_PTR(
"na not made", procName, NULL);
728 wpls = pixGetWpl(pixs);
730 wplm = pixGetWpl(pixm);
732 for (i = 0; i < hm; i += factor) {
733 if (y + i < 0 || y + i >= h)
continue;
734 lines = datas + (y + i) * wpls;
735 linem = datam + i * wplm;
736 for (j = 0; j < wm; j += factor) {
737 if (x + j < 0 || x + j >= w)
continue;
776 l_int32 i, j, bx, by, bw, bh, w, h, d, wpls, val, size;
777 l_uint32 *datas, *lines;
781 PROCNAME(
"pixGetCmapHistogramInRect");
786 return (
NUMA *)ERROR_PTR(
"pixs not defined", procName, NULL);
787 if (pixGetColormap(pixs) == NULL)
788 return (
NUMA *)ERROR_PTR(
"pixs not cmapped", procName, NULL);
790 return (
NUMA *)ERROR_PTR(
"sampling must be >= 1", procName, NULL);
792 if (d != 2 && d != 4 && d != 8)
793 return (
NUMA *)ERROR_PTR(
"d not 2, 4 or 8", procName, NULL);
797 return (
NUMA *)ERROR_PTR(
"na not made", procName, NULL);
802 wpls = pixGetWpl(pixs);
805 for (i = 0; i < bh; i += factor) {
806 if (by + i < 0 || by + i >= h)
continue;
807 lines = datas + (by + i) * wpls;
808 for (j = 0; j < bw; j += factor) {
809 if (bx + j < 0 || bx + j >= w)
continue;
836 PROCNAME(
"pixCountRGBColors");
838 if (!pixs || pixGetDepth(pixs) != 32)
839 return ERROR_INT(
"pixs not defined or not 32 bpp", procName, -1);
841 ncolors = l_amapSize(amap);
842 l_amapDestroy(&amap);
864 l_int32 i, j, w, h, wpl;
865 l_uint32 *data, *line;
870 PROCNAME(
"pixGetColorAmapHistogram");
873 return (
L_AMAP *)ERROR_PTR(
"pixs not defined", procName, NULL);
874 if (pixGetDepth(pixs) != 32)
875 return (
L_AMAP *)ERROR_PTR(
"pixs not 32 bpp", procName, NULL);
878 wpl = pixGetWpl(pixs);
879 amap = l_amapCreate(L_UINT_TYPE);
880 for (i = 0; i < h; i += factor) {
881 line = data + i * wpl;
882 for (j = 0; j < w; j += factor) {
884 pval = l_amapFind(amap, key);
888 value.itype = 1 + pval->itype;
889 l_amapInsert(amap, key, value);
916 PROCNAME(
"amapGetCountForColor");
919 return ERROR_INT(
"amap not defined", procName, -1);
922 pval = l_amapFind(amap, key);
923 return (pval) ? pval->itype : 0;
951 l_float32 val, rval, gval, bval;
955 PROCNAME(
"pixGetRankValue");
958 return ERROR_INT(
"&value not defined", procName, 1);
961 return ERROR_INT(
"pixs not defined", procName, 1);
962 d = pixGetDepth(pixs);
963 cmap = pixGetColormap(pixs);
964 if (d != 8 && d != 32 && !cmap)
965 return ERROR_INT(
"pixs not 8 or 32 bpp, or cmapped", procName, 1);
970 d = pixGetDepth(pixt);
977 &rval, &gval, &bval);
1028 PROCNAME(
"pixGetRankValueMaskedRGB");
1030 if (prval) *prval = 0.0;
1031 if (pgval) *pgval = 0.0;
1032 if (pbval) *pbval = 0.0;
1033 if (!prval && !pgval && !pbval)
1034 return ERROR_INT(
"no results requested", procName, 1);
1036 return ERROR_INT(
"pixs not defined", procName, 1);
1037 if (pixGetDepth(pixs) != 32)
1038 return ERROR_INT(
"pixs not 32 bpp", procName, 1);
1039 if (pixm && pixGetDepth(pixm) != 1)
1040 return ERROR_INT(
"pixm not 1 bpp", procName, 1);
1042 return ERROR_INT(
"sampling factor must be >= 1", procName, 1);
1043 if (rank < 0.0 || rank > 1.0)
1044 return ERROR_INT(
"rank not in [0.0 ... 1.0]", procName, 1);
1048 scale = 1.0 / (l_float32)factor;
1049 pixmt =
pixScale(pixm, scale, scale);
1054 factor, rank, prval, NULL);
1060 factor, rank, pgval, NULL);
1066 factor, rank, pbval, NULL);
1118 PROCNAME(
"pixGetRankValueMasked");
1120 if (pna) *pna = NULL;
1122 return ERROR_INT(
"&val not defined", procName, 1);
1125 return ERROR_INT(
"pixs not defined", procName, 1);
1126 if (pixGetDepth(pixs) != 8 && !pixGetColormap(pixs))
1127 return ERROR_INT(
"pixs neither 8 bpp nor colormapped", procName, 1);
1128 if (pixm && pixGetDepth(pixm) != 1)
1129 return ERROR_INT(
"pixm not 1 bpp", procName, 1);
1131 return ERROR_INT(
"sampling factor must be >= 1", procName, 1);
1132 if (rank < 0.0 || rank > 1.0)
1133 return ERROR_INT(
"rank not in [0.0 ... 1.0]", procName, 1);
1136 return ERROR_INT(
"na not made", procName, 1);
1183 l_int32 i, j, w, h, d, wm, hm, wpl1, wplm, val, rval, gval, bval, count;
1184 l_uint32 *data1, *datam, *line1, *linem;
1185 l_float64 sum, rsum, gsum, bsum;
1188 PROCNAME(
"pixGetPixelAverage");
1191 return ERROR_INT(
"&val not defined", procName, 1);
1194 return ERROR_INT(
"pixs not defined", procName, 1);
1195 d = pixGetDepth(pixs);
1196 if (d != 32 && !pixGetColormap(pixs))
1197 return ERROR_INT(
"pixs not rgb or colormapped", procName, 1);
1198 if (pixm && pixGetDepth(pixm) != 1)
1199 return ERROR_INT(
"pixm not 1 bpp", procName, 1);
1201 return ERROR_INT(
"sampling factor must be >= 1", procName, 1);
1203 if (pixGetColormap(pixs))
1210 return ERROR_INT(
"pix1 is just 1 bpp", procName, 1);
1213 wpl1 = pixGetWpl(pix1);
1215 sum = rsum = gsum = bsum = 0.0;
1218 for (i = 0; i < h; i += factor) {
1219 line1 = data1 + i * wpl1;
1220 for (j = 0; j < w; j += factor) {
1236 wplm = pixGetWpl(pixm);
1237 for (i = 0; i < hm; i += factor) {
1238 if (y + i < 0 || y + i >= h)
continue;
1239 line1 = data1 + (y + i) * wpl1;
1240 linem = datam + i * wplm;
1241 for (j = 0; j < wm; j += factor) {
1242 if (x + j < 0 || x + j >= w)
continue;
1261 return ERROR_INT(
"no pixels sampled", procName, 1);
1263 *pval = (l_uint32)((l_float64)sum / (l_float64)count);
1265 rval = (l_uint32)((l_float64)rsum / (l_float64)count);
1266 gval = (l_uint32)((l_float64)gsum / (l_float64)count);
1267 bval = (l_uint32)((l_float64)bsum / (l_float64)count);
1300 l_float32 val, rval, gval, bval;
1304 PROCNAME(
"pixGetPixelStats");
1307 return ERROR_INT(
"&value not defined", procName, 1);
1310 return ERROR_INT(
"pixs not defined", procName, 1);
1311 d = pixGetDepth(pixs);
1312 cmap = pixGetColormap(pixs);
1313 if (d != 8 && d != 32 && !cmap)
1314 return ERROR_INT(
"pixs not 8 or 32 bpp, or cmapped", procName, 1);
1319 d = pixGetDepth(pixt);
1326 &rval, &gval, &bval);
1374 PROCNAME(
"pixGetAverageMaskedRGB");
1376 if (prval) *prval = 0.0;
1377 if (pgval) *pgval = 0.0;
1378 if (pbval) *pbval = 0.0;
1379 if (!prval && !pgval && !pbval)
1380 return ERROR_INT(
"no values requested", procName, 1);
1382 return ERROR_INT(
"pixs not defined", procName, 1);
1383 cmap = pixGetColormap(pixs);
1384 if (pixGetDepth(pixs) != 32 && !cmap)
1385 return ERROR_INT(
"pixs neither 32 bpp nor colormapped", procName, 1);
1386 if (pixm && pixGetDepth(pixm) != 1)
1387 return ERROR_INT(
"pixm not 1 bpp", procName, 1);
1389 return ERROR_INT(
"sampling factor must be >= 1", procName, 1);
1392 return ERROR_INT(
"invalid measure type", procName, 1);
1465 l_int32 i, j, w, h, d, wm, hm, wplg, wplm, val, count;
1466 l_uint32 *datag, *datam, *lineg, *linem;
1467 l_float64 sumave, summs, ave, meansq, var;
1470 PROCNAME(
"pixGetAverageMasked");
1473 return ERROR_INT(
"&val not defined", procName, 1);
1476 return ERROR_INT(
"pixs not defined", procName, 1);
1477 d = pixGetDepth(pixs);
1478 if (d != 8 && d != 16 && !pixGetColormap(pixs))
1479 return ERROR_INT(
"pixs not 8 or 16 bpp or colormapped", procName, 1);
1480 if (pixm && pixGetDepth(pixm) != 1)
1481 return ERROR_INT(
"pixm not 1 bpp", procName, 1);
1483 return ERROR_INT(
"sampling factor must be >= 1", procName, 1);
1486 return ERROR_INT(
"invalid measure type", procName, 1);
1488 if (pixGetColormap(pixs))
1494 wplg = pixGetWpl(pixg);
1496 sumave = summs = 0.0;
1499 for (i = 0; i < h; i += factor) {
1500 lineg = datag + i * wplg;
1501 for (j = 0; j < w; j += factor) {
1509 summs += (l_float64)(val) * val;
1516 wplm = pixGetWpl(pixm);
1517 for (i = 0; i < hm; i += factor) {
1518 if (y + i < 0 || y + i >= h)
continue;
1519 lineg = datag + (y + i) * wplg;
1520 linem = datam + i * wplm;
1521 for (j = 0; j < wm; j += factor) {
1522 if (x + j < 0 || x + j >= w)
continue;
1531 summs += (l_float64)(val) * val;
1540 return ERROR_INT(
"no pixels sampled", procName, 1);
1541 ave = sumave / (l_float64)count;
1542 meansq = summs / (l_float64)count;
1543 var = meansq - ave * ave;
1545 *pval = (l_float32)ave;
1547 *pval = (l_float32)sqrt(meansq);
1549 *pval = (l_float32)sqrt(var);
1551 *pval = (l_float32)var;
1587 PROCNAME(
"pixGetAverageTiledRGB");
1589 if (ppixr) *ppixr = NULL;
1590 if (ppixg) *ppixg = NULL;
1591 if (ppixb) *ppixb = NULL;
1592 if (!ppixr && !ppixg && !ppixb)
1593 return ERROR_INT(
"no data requested", procName, 1);
1595 return ERROR_INT(
"pixs not defined", procName, 1);
1596 cmap = pixGetColormap(pixs);
1597 if (pixGetDepth(pixs) != 32 && !cmap)
1598 return ERROR_INT(
"pixs neither 32 bpp nor colormapped", procName, 1);
1599 if (sx < 2 || sy < 2)
1600 return ERROR_INT(
"sx and sy not both > 1", procName, 1);
1603 return ERROR_INT(
"invalid measure type", procName, 1);
1658 l_int32 i, j, k, m, w, h, wd, hd, d, pos, wplt, wpld, valt;
1659 l_uint32 *datat, *datad, *linet, *lined, *startt;
1660 l_float64 sumave, summs, ave, meansq, normfact;
1663 PROCNAME(
"pixGetAverageTiled");
1666 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1668 if (d != 8 && !pixGetColormap(pixs))
1669 return (
PIX *)ERROR_PTR(
"pixs not 8 bpp or cmapped", procName, NULL);
1670 if (sx < 2 || sy < 2)
1671 return (
PIX *)ERROR_PTR(
"sx and sy not both > 1", procName, NULL);
1674 if (wd < 1 || hd < 1)
1675 return (
PIX *)ERROR_PTR(
"wd or hd == 0", procName, NULL);
1678 return (
PIX *)ERROR_PTR(
"invalid measure type", procName, NULL);
1683 wplt = pixGetWpl(pixt);
1685 wpld = pixGetWpl(pixd);
1686 normfact = 1. / (l_float64)(sx * sy);
1687 for (i = 0; i < hd; i++) {
1688 lined = datad + i * wpld;
1689 linet = datat + i * sy * wplt;
1690 for (j = 0; j < wd; j++) {
1693 for (k = 0; k < sy; k++) {
1694 startt = linet + k * wplt;
1695 for (m = 0; m < sx; m++) {
1701 ave = normfact * sumave;
1705 for (k = 0; k < sy; k++) {
1706 startt = linet + k * wplt;
1707 for (m = 0; m < sx; m++) {
1710 summs += (l_float64)(valt) * valt;
1713 meansq = normfact * summs;
1716 valt = (l_int32)(ave + 0.5);
1718 valt = (l_int32)(sqrt(meansq) + 0.5);
1720 valt = (l_int32)(sqrt(meansq - ave * ave) + 0.5);
1761 NUMA **pnamodecount,
1765 l_int32 i, j, k, w, h, val, wpls, sum, sumsq, target, max, modeval;
1766 l_int32 xstart, xend, ystart, yend, bw, bh;
1768 l_uint32 *lines, *datas;
1770 l_float32 *famean, *fameansq, *favar, *farootvar;
1771 l_float32 *famedian, *famode, *famodecount;
1773 PROCNAME(
"pixRowStats");
1775 if (pnamean) *pnamean = NULL;
1776 if (pnamedian) *pnamedian = NULL;
1777 if (pnamode) *pnamode = NULL;
1778 if (pnamodecount) *pnamodecount = NULL;
1779 if (pnavar) *pnavar = NULL;
1780 if (pnarootvar) *pnarootvar = NULL;
1781 if (!pixs || pixGetDepth(pixs) != 8)
1782 return ERROR_INT(
"pixs undefined or not 8 bpp", procName, 1);
1783 famean = fameansq = favar = farootvar = NULL;
1784 famedian = famode = famodecount = NULL;
1789 return ERROR_INT(
"invalid clipping box", procName, 1);
1793 wpls = pixGetWpl(pixs);
1794 if (pnamean || pnavar || pnarootvar) {
1795 norm = 1. / (l_float32)bw;
1796 famean = (l_float32 *)LEPT_CALLOC(bh,
sizeof(l_float32));
1797 fameansq = (l_float32 *)LEPT_CALLOC(bh,
sizeof(l_float32));
1798 if (pnavar || pnarootvar) {
1799 favar = (l_float32 *)LEPT_CALLOC(bh,
sizeof(l_float32));
1801 farootvar = (l_float32 *)LEPT_CALLOC(bh,
sizeof(l_float32));
1803 for (i = ystart; i < yend; i++) {
1805 lines = datas + i * wpls;
1806 for (j = xstart; j < xend; j++) {
1811 famean[i] = norm * sum;
1812 fameansq[i] = norm * sumsq;
1813 if (pnavar || pnarootvar) {
1814 favar[i] = fameansq[i] - famean[i] * famean[i];
1816 farootvar[i] = sqrtf(favar[i]);
1819 LEPT_FREE(fameansq);
1833 if (pnamedian || pnamode || pnamodecount) {
1834 histo = (l_int32 *)LEPT_CALLOC(256,
sizeof(l_int32));
1847 for (i = ystart; i < yend; i++) {
1848 lines = datas + i * wpls;
1849 memset(histo, 0, 1024);
1850 for (j = xstart; j < xend; j++) {
1857 target = (bw + 1) / 2;
1858 for (k = 0; k < 256; k++) {
1860 if (sum >= target) {
1867 if (pnamode || pnamodecount) {
1870 for (k = 0; k < 256; k++) {
1871 if (histo[k] > max) {
1877 famode[i] = modeval;
1879 famodecount[i] = max;
1921 NUMA **pnamodecount,
1925 l_int32 i, j, k, w, h, val, wpls, sum, sumsq, target, max, modeval;
1926 l_int32 xstart, xend, ystart, yend, bw, bh;
1928 l_uint32 *lines, *datas;
1930 l_float32 *famean, *fameansq, *favar, *farootvar;
1931 l_float32 *famedian, *famode, *famodecount;
1933 PROCNAME(
"pixColumnStats");
1935 if (pnamean) *pnamean = NULL;
1936 if (pnamedian) *pnamedian = NULL;
1937 if (pnamode) *pnamode = NULL;
1938 if (pnamodecount) *pnamodecount = NULL;
1939 if (pnavar) *pnavar = NULL;
1940 if (pnarootvar) *pnarootvar = NULL;
1941 if (!pixs || pixGetDepth(pixs) != 8)
1942 return ERROR_INT(
"pixs undefined or not 8 bpp", procName, 1);
1943 famean = fameansq = favar = farootvar = NULL;
1944 famedian = famode = famodecount = NULL;
1949 return ERROR_INT(
"invalid clipping box", procName, 1);
1953 wpls = pixGetWpl(pixs);
1954 if (pnamean || pnavar || pnarootvar) {
1955 norm = 1. / (l_float32)bh;
1956 famean = (l_float32 *)LEPT_CALLOC(bw,
sizeof(l_float32));
1957 fameansq = (l_float32 *)LEPT_CALLOC(bw,
sizeof(l_float32));
1958 if (pnavar || pnarootvar) {
1959 favar = (l_float32 *)LEPT_CALLOC(bw,
sizeof(l_float32));
1961 farootvar = (l_float32 *)LEPT_CALLOC(bw,
sizeof(l_float32));
1963 for (j = xstart; j < xend; j++) {
1965 for (i = ystart, lines = datas; i < yend; lines += wpls, i++) {
1970 famean[j] = norm * sum;
1971 fameansq[j] = norm * sumsq;
1972 if (pnavar || pnarootvar) {
1973 favar[j] = fameansq[j] - famean[j] * famean[j];
1975 farootvar[j] = sqrtf(favar[j]);
1978 LEPT_FREE(fameansq);
1992 if (pnamedian || pnamode || pnamodecount) {
1993 histo = (l_int32 *)LEPT_CALLOC(256,
sizeof(l_int32));
2006 for (j = xstart; j < xend; j++) {
2007 memset(histo, 0, 1024);
2008 for (i = ystart, lines = datas; i < yend; lines += wpls, i++) {
2015 target = (bh + 1) / 2;
2016 for (k = 0; k < 256; k++) {
2018 if (sum >= target) {
2025 if (pnamode || pnamodecount) {
2028 for (k = 0; k < 256; k++) {
2029 if (histo[k] > max) {
2035 famode[j] = modeval;
2037 famodecount[j] = max;
2072 PROCNAME(
"pixGetRangeValues");
2074 if (pminval) *pminval = 0;
2075 if (pmaxval) *pmaxval = 0;
2076 if (!pminval && !pmaxval)
2077 return ERROR_INT(
"no result requested", procName, 1);
2079 return ERROR_INT(
"pixs not defined", procName, 1);
2081 cmap = pixGetColormap(pixs);
2087 return ERROR_INT(
"sampling factor must be >= 1", procName, 1);
2088 d = pixGetDepth(pixs);
2089 if (d != 8 && d != 32)
2090 return ERROR_INT(
"pixs not 8 or 32 bpp", procName, 1);
2094 NULL, NULL, NULL, pminval);
2096 NULL, NULL, NULL, pmaxval);
2099 pminval, NULL, NULL, NULL);
2101 pmaxval, NULL, NULL, NULL);
2104 NULL, pminval, NULL, NULL);
2106 NULL, pmaxval, NULL, NULL);
2109 NULL, NULL, pminval, NULL);
2111 NULL, NULL, pmaxval, NULL);
2113 return ERROR_INT(
"invalid color", procName, 1);
2149 l_int32 i, j, w, h, d, wpl;
2150 l_int32 val, extval, rval, gval, bval, extrval, extgval, extbval;
2152 l_uint32 *data, *line;
2155 PROCNAME(
"pixGetExtremeValue");
2157 if (prval) *prval = -1;
2158 if (pgval) *pgval = -1;
2159 if (pbval) *pbval = -1;
2160 if (pgrayval) *pgrayval = -1;
2162 return ERROR_INT(
"pixs not defined", procName, 1);
2164 return ERROR_INT(
"invalid type", procName, 1);
2166 cmap = pixGetColormap(pixs);
2188 return ERROR_INT(
"sampling factor must be >= 1", procName, 1);
2189 if (d != 8 && d != 32)
2190 return ERROR_INT(
"pixs not 8 or 32 bpp", procName, 1);
2191 if (d == 8 && !pgrayval)
2192 return ERROR_INT(
"can't return result in grayval", procName, 1);
2193 if (d == 32 && !prval && !pgval && !pbval)
2194 return ERROR_INT(
"can't return result in r/g/b-val", procName, 1);
2197 wpl = pixGetWpl(pixs);
2204 for (i = 0; i < h; i += factor) {
2205 line = data + i * wpl;
2206 for (j = 0; j < w; j += factor) {
2227 for (i = 0; i < h; i += factor) {
2228 line = data + i * wpl;
2229 for (j = 0; j < w; j += factor) {
2232 rval = (pixel >> L_RED_SHIFT) & 0xff;
2238 gval = (pixel >> L_GREEN_SHIFT) & 0xff;
2244 bval = (pixel >> L_BLUE_SHIFT) & 0xff;
2251 if (prval) *prval = extrval;
2252 if (pgval) *pgval = extgval;
2253 if (pbval) *pbval = extbval;
2284 l_int32 i, j, w, h, d, wpl, bw, bh;
2285 l_int32 xstart, ystart, xend, yend, xmax, ymax;
2286 l_uint32 val, maxval;
2287 l_uint32 *data, *line;
2289 PROCNAME(
"pixGetMaxValueInRect");
2291 if (pmaxval) *pmaxval = 0;
2292 if (pxmax) *pxmax = 0;
2293 if (pymax) *pymax = 0;
2294 if (!pmaxval && !pxmax && !pymax)
2295 return ERROR_INT(
"no data requested", procName, 1);
2297 return ERROR_INT(
"pixs not defined", procName, 1);
2298 if (pixGetColormap(pixs) != NULL)
2299 return ERROR_INT(
"pixs has colormap", procName, 1);
2301 if (d != 8 && d != 16 && d != 32)
2302 return ERROR_INT(
"pixs not 8, 16 or 32 bpp", procName, 1);
2304 xstart = ystart = 0;
2309 xend = xstart + bw - 1;
2310 yend = ystart + bh - 1;
2314 wpl = pixGetWpl(pixs);
2317 for (i = ystart; i <= yend; i++) {
2318 line = data + i * wpl;
2319 for (j = xstart; j <= xend; j++) {
2334 xmax = (xstart + xend) / 2;
2335 ymax = (ystart + yend) / 2;
2338 if (pmaxval) *pmaxval = maxval;
2339 if (pxmax) *pxmax = xmax;
2340 if (pymax) *pymax = ymax;
2376 l_int32 i, minval, maxval, rval, gval, bval;
2380 PROCNAME(
"pixGetBinnedComponentRange");
2382 if (pminval) *pminval = 0;
2383 if (pmaxval) *pmaxval = 0;
2384 if (pcarray) *pcarray = NULL;
2385 if (!pminval && !pmaxval)
2386 return ERROR_INT(
"no result requested", procName, 1);
2387 if (!pixs || pixGetDepth(pixs) != 32)
2388 return ERROR_INT(
"pixs not defined or not 32 bpp", procName, 1);
2390 return ERROR_INT(
"sampling factor must be >= 1", procName, 1);
2393 return ERROR_INT(
"invalid color", procName, 1);
2394 if (fontsize < 0 || fontsize > 20 || fontsize & 1 || fontsize == 2)
2395 return ERROR_INT(
"invalid fontsize", procName, 1);
2399 for (i = 0; i < nbins; i++)
2400 L_INFO(
"c[%d] = %x\n", procName, i, carray[i]);
2402 pixDisplay(pixt, 100, 100);
2419 if (pminval) *pminval = minval;
2420 if (pmaxval) *pmaxval = maxval;
2477 NUMA *na, *nan, *narbin;
2478 PIX *pixt, *pixc, *pixg, *pixd;
2481 PROCNAME(
"pixGetRankColorArray");
2484 return ERROR_INT(
"&carray not defined", procName, 1);
2487 return ERROR_INT(
"sampling factor must be >= 1", procName, 1);
2489 return ERROR_INT(
"nbins must be at least 2", procName, 1);
2491 return ERROR_INT(
"pixs not defined", procName, 1);
2492 cmap = pixGetColormap(pixs);
2493 if (pixGetDepth(pixs) != 32 && !cmap)
2494 return ERROR_INT(
"pixs neither 32 bpp nor cmapped", procName, 1);
2499 return ERROR_INT(
"invalid type", procName, 1);
2500 if (debugflag > 0) {
2501 if (fontsize < 0 || fontsize > 20 || fontsize & 1 || fontsize == 2)
2502 return ERROR_INT(
"invalid fontsize", procName, 1);
2533 return ERROR_INT(
"na not made", procName, 1);
2549 NUMA *nai, *nar, *nabb;
2553 "Normalized Histogram");
2555 "Cumulative Histogram");
2557 "Intensity vs. rank bin");
2558 gplotSimple1(narbin, GPLOT_PNG,
"/tmp/lept/regout/rtnarbin",
2559 "LUT: rank bin vs. Intensity");
2560 gplotSimple1(nabb, GPLOT_PNG,
"/tmp/lept/regout/rtnabb",
2561 "Intensity of right edge vs. rank bin");
2577 if ((array = *pcarray) == NULL) {
2578 L_ERROR(
"color array not returned\n", procName);
2585 pixDisplayWithTitle(pixd, 0, 500,
"binned colors", 1);
2587 pixWriteDebug(
"/tmp/lept/regout/rankhisto.png", pixd, IFF_PNG);
2637 l_int32 i, j, w, h, wpls, wplg, grayval, bin, rval, gval, bval, success;
2638 l_int32 npts, avepts, maxpts;
2639 l_uint32 *datas, *datag, *lines, *lineg, *carray;
2641 l_float64 *rarray, *garray, *barray, *narray;
2643 PROCNAME(
"pixGetBinnedColor");
2646 return ERROR_INT(
"&carray not defined", procName, 1);
2649 return ERROR_INT(
"pixs not defined", procName, 1);
2651 return ERROR_INT(
"pixg not defined", procName, 1);
2653 return ERROR_INT(
"nalut not defined", procName, 1);
2655 L_WARNING(
"sampling factor less than 1; setting to 1\n", procName);
2666 npts = (w + factor - 1) * (h + factor - 1) / (factor * factor);
2667 avepts = (npts + nbins - 1) / nbins;
2668 maxpts = (l_int32)((1.0 + 0.5 / (l_float32)nbins) * avepts);
2670 wpls = pixGetWpl(pixs);
2672 wplg = pixGetWpl(pixg);
2673 rarray = (l_float64 *)LEPT_CALLOC(nbins,
sizeof(l_float64));
2674 garray = (l_float64 *)LEPT_CALLOC(nbins,
sizeof(l_float64));
2675 barray = (l_float64 *)LEPT_CALLOC(nbins,
sizeof(l_float64));
2676 narray = (l_float64 *)LEPT_CALLOC(nbins,
sizeof(l_float64));
2677 for (i = 0; i < h; i += factor) {
2678 lines = datas + i * wpls;
2679 lineg = datag + i * wplg;
2680 for (j = 0; j < w; j += factor) {
2684 while (narray[bin] >= maxpts && bin < nbins - 1)
2686 rarray[bin] += rval;
2687 garray[bin] += gval;
2688 barray[bin] += bval;
2693 for (i = 0; i < nbins; i++) {
2694 norm = 1. / narray[i];
2702 NUMA *nared, *nagreen, *nablue;
2706 for (i = 0; i < nbins; i++) {
2712 gplotSimple1(nared, GPLOT_PNG,
"/tmp/lept/regout/rtnared",
2713 "Average red val vs. rank bin");
2714 gplotSimple1(nagreen, GPLOT_PNG,
"/tmp/lept/regout/rtnagreen",
2715 "Average green val vs. rank bin");
2716 gplotSimple1(nablue, GPLOT_PNG,
"/tmp/lept/regout/rtnablue",
2717 "Average blue val vs. rank bin");
2725 if ((carray = (l_uint32 *)LEPT_CALLOC(nbins,
sizeof(l_uint32))) == NULL) {
2727 L_ERROR(
"carray not made\n", procName);
2728 goto cleanup_arrays;
2731 for (i = 0; i < nbins; i++) {
2732 rval = (l_int32)(rarray[i] + 0.5);
2733 gval = (l_int32)(garray[i] + 0.5);
2734 bval = (l_int32)(barray[i] + 0.5);
2743 return (success) ? 0 : 1;
2766 l_int32 i, rval, gval, bval;
2771 PROCNAME(
"pixDisplayColorArray");
2774 return (
PIX *)ERROR_PTR(
"carray not defined", procName, NULL);
2775 if (fontsize < 0 || fontsize > 20 || fontsize & 1 || fontsize == 2)
2776 return (
PIX *)ERROR_PTR(
"invalid fontsize", procName, NULL);
2778 bmf = (fontsize == 0) ? NULL :
bmfCreate(NULL, fontsize);
2780 for (i = 0; i < ncolors; i++) {
2785 snprintf(textstr,
sizeof(textstr),
2786 "%d: (%d %d %d)", i, rval, gval, bval);
2787 pixSaveTiledWithText(pixt, pixa, side, (i % ncols == 0) ? 1 : 0,
2790 pixSaveTiled(pixt, pixa, 1.0, (i % ncols == 0) ? 1 : 0, 20, 32);
2837 l_int32 i, j, w, h, nstrips;
2840 PIX *pix1, *pix2, *pixd;
2844 PROCNAME(
"pixRankBinByStrip");
2847 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
2848 cmap = pixGetColormap(pixs);
2849 if (pixGetDepth(pixs) != 32 && !cmap)
2850 return (
PIX *)ERROR_PTR(
"pixs neither 32 bpp nor cmapped",
2853 return (
PIX *)ERROR_PTR(
"invalid direction", procName, NULL);
2855 return (
PIX *)ERROR_PTR(
"size < 1", procName, NULL);
2857 return (
PIX *)ERROR_PTR(
"nbins must be at least 2", procName, NULL);
2861 return (
PIX *)ERROR_PTR(
"invalid type", procName, NULL);
2876 for (i = 0; i < nstrips; i++) {
2879 for (j = 0; j < nbins; j++)
2886 for (i = 0; i < nstrips; i++) {
2889 for (j = 0; j < nbins; j++)
2933 l_int32 j, n, w, h, d;
2937 PROCNAME(
"pixaGetAlignedStats");
2940 return (
PIX *)ERROR_PTR(
"pixa not defined", procName, NULL);
2943 return (
PIX *)ERROR_PTR(
"invalid type", procName, NULL);
2946 return (
PIX *)ERROR_PTR(
"no pix in pixa", procName, NULL);
2949 return (
PIX *)ERROR_PTR(
"pix not 8 bpp", procName, NULL);
2953 colvect = (l_float32 *)LEPT_CALLOC(h,
sizeof(l_float32));
2954 for (j = 0; j < w; j++) {
2979 l_int32 i, k, n, w, h, ht, val, wplt, wpld;
2980 l_uint32 *datad, *datat;
2983 PROCNAME(
"pixaExtractColumnFromEachPix");
2986 return ERROR_INT(
"pixa not defined", procName, 1);
2987 if (!pixd || pixGetDepth(pixd) != 8)
2988 return ERROR_INT(
"pixd not defined or not 8 bpp", procName, 1);
2992 return ERROR_INT(
"pix width != n", procName, 1);
2994 wplt = pixGetWpl(pixt);
2998 return ERROR_INT(
"pixd height != column height", procName, 1);
3001 wpld = pixGetWpl(pixd);
3002 for (k = 0; k < n; k++) {
3005 for (i = 0; i < h; i++) {
3056 l_int32 i, j, k, w, h, val, wpls, sum, target, max, modeval;
3057 l_int32 *histo, *gray2bin, *bin2gray;
3058 l_uint32 *lines, *datas;
3060 PROCNAME(
"pixGetRowStats");
3062 if (!pixs || pixGetDepth(pixs) != 8)
3063 return ERROR_INT(
"pixs not defined or not 8 bpp", procName, 1);
3065 return ERROR_INT(
"colvect not defined", procName, 1);
3068 return ERROR_INT(
"invalid type", procName, 1);
3070 return ERROR_INT(
"invalid nbins", procName, 1);
3074 wpls = pixGetWpl(pixs);
3076 for (i = 0; i < h; i++) {
3078 lines = datas + i * wpls;
3079 for (j = 0; j < w; j++)
3081 colvect[i] = (l_float32)sum / (l_float32)w;
3087 histo = (l_int32 *)LEPT_CALLOC(nbins,
sizeof(l_int32));
3088 gray2bin = (l_int32 *)LEPT_CALLOC(256,
sizeof(l_int32));
3089 bin2gray = (l_int32 *)LEPT_CALLOC(nbins,
sizeof(l_int32));
3090 for (i = 0; i < 256; i++)
3091 gray2bin[i] = (i * nbins) / 256;
3092 for (i = 0; i < nbins; i++)
3093 bin2gray[i] = (i * 256 + 128) / nbins;
3095 for (i = 0; i < h; i++) {
3096 lines = datas + i * wpls;
3097 for (k = 0; k < nbins; k++)
3099 for (j = 0; j < w; j++) {
3101 histo[gray2bin[val]]++;
3106 target = (w + 1) / 2;
3107 for (k = 0; k < nbins; k++) {
3109 if (sum >= target) {
3110 colvect[i] = bin2gray[k];
3117 for (k = 0; k < nbins; k++) {
3118 if (histo[k] > max) {
3126 colvect[i] = bin2gray[modeval];
3129 for (k = 0; k < nbins; k++) {
3138 LEPT_FREE(gray2bin);
3139 LEPT_FREE(bin2gray);
3178 l_int32 i, j, k, w, h, val, wpls, sum, target, max, modeval;
3179 l_int32 *histo, *gray2bin, *bin2gray;
3182 PROCNAME(
"pixGetColumnStats");
3184 if (!pixs || pixGetDepth(pixs) != 8)
3185 return ERROR_INT(
"pixs not defined or not 8 bpp", procName, 1);
3187 return ERROR_INT(
"rowvect not defined", procName, 1);
3190 return ERROR_INT(
"invalid type", procName, 1);
3192 return ERROR_INT(
"invalid nbins", procName, 1);
3196 wpls = pixGetWpl(pixs);
3198 for (j = 0; j < w; j++) {
3200 for (i = 0; i < h; i++)
3202 rowvect[j] = (l_float32)sum / (l_float32)h;
3208 histo = (l_int32 *)LEPT_CALLOC(nbins,
sizeof(l_int32));
3209 gray2bin = (l_int32 *)LEPT_CALLOC(256,
sizeof(l_int32));
3210 bin2gray = (l_int32 *)LEPT_CALLOC(nbins,
sizeof(l_int32));
3211 for (i = 0; i < 256; i++)
3212 gray2bin[i] = (i * nbins) / 256;
3213 for (i = 0; i < nbins; i++)
3214 bin2gray[i] = (i * 256 + 128) / nbins;
3216 for (j = 0; j < w; j++) {
3217 for (i = 0; i < h; i++) {
3219 histo[gray2bin[val]]++;
3224 target = (h + 1) / 2;
3225 for (k = 0; k < nbins; k++) {
3227 if (sum >= target) {
3228 rowvect[j] = bin2gray[k];
3235 for (k = 0; k < nbins; k++) {
3236 if (histo[k] > max) {
3244 rowvect[j] = bin2gray[modeval];
3247 for (k = 0; k < nbins; k++) {
3253 for (k = 0; k < nbins; k++)
3258 LEPT_FREE(gray2bin);
3259 LEPT_FREE(bin2gray);
3277 l_int32 i, w, h, wpl;
3280 PROCNAME(
"pixSetCPixelColumn");
3282 if (!pix || pixGetDepth(pix) != 8)
3283 return ERROR_INT(
"pix not defined or not 8 bpp", procName, 1);
3285 return ERROR_INT(
"colvect not defined", procName, 1);
3287 if (col < 0 || col > w)
3288 return ERROR_INT(
"invalid col", procName, 1);
3291 wpl = pixGetWpl(pix);
3292 for (i = 0; i < h; i++)
3322 PROCNAME(
"pixThresholdForFgBg");
3324 if (pfgval) *pfgval = 0;
3325 if (pbgval) *pbgval = 0;
3326 if (!pfgval && !pbgval)
3327 return ERROR_INT(
"no data requested", procName, 1);
3329 return ERROR_INT(
"pixs not defined", procName, 1);
3337 *pfgval = (l_int32)(fval + 0.5);
3343 *pbgval = (l_int32)(fval + 0.5);
3373 l_float32 scorefract,
3382 l_float32 avefg, avebg, maxnum;
3384 NUMA *na, *nascore, *nax, *nay;
3387 PROCNAME(
"pixSplitDistributionFgBg");
3389 if (pthresh) *pthresh = 0;
3390 if (pfgval) *pfgval = 0;
3391 if (pbgval) *pbgval = 0;
3392 if (ppixdb) *ppixdb = NULL;
3393 if (!pthresh && !pfgval && !pbgval)
3394 return ERROR_INT(
"no data requested", procName, 1);
3396 return ERROR_INT(
"pixs not defined", procName, 1);
3405 NULL, NULL, &nascore);
3412 if (pthresh) *pthresh = thresh;
3413 if (pfgval) *pfgval = (l_int32)(avefg + 0.5);
3414 if (pbgval) *pbgval = (l_int32)(avebg + 0.5);
3418 gplot =
gplotCreate(
"/tmp/lept/redout/histplot", GPLOT_PNG,
"Histogram",
3419 "Grayscale value",
"Number of pixels");
3425 snprintf(buf,
sizeof(buf),
"score fract = %3.1f", scorefract);
3431 *ppixdb =
pixRead(
"/tmp/lept/redout/histplot.png");
void gplotDestroy(GPLOT **pgplot)
gplotDestroy()
l_int32 pixRowStats(PIX *pixs, BOX *box, NUMA **pnamean, NUMA **pnamedian, NUMA **pnamode, NUMA **pnamodecount, NUMA **pnavar, NUMA **pnarootvar)
pixRowStats()
NUMA * pixGetGrayHistogram(PIX *pixs, l_int32 factor)
pixGetGrayHistogram()
void bmfDestroy(L_BMF **pbmf)
bmfDestroy()
BOXA * makeMosaicStrips(l_int32 w, l_int32 h, l_int32 direction, l_int32 size)
makeMosaicStrips()
PIX * pixRemoveColormap(PIX *pixs, l_int32 type)
pixRemoveColormap()
NUMA * pixGetGrayHistogramMasked(PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor)
pixGetGrayHistogramMasked()
l_int32 lept_mkdir(const char *subdir)
lept_mkdir()
NUMA * pixGetGrayHistogramInRect(PIX *pixs, BOX *box, l_int32 factor)
pixGetGrayHistogramInRect()
l_ok pixGetPixelStats(PIX *pixs, l_int32 factor, l_int32 type, l_uint32 *pvalue)
pixGetPixelStats()
PIX * pixaGetAlignedStats(PIXA *pixa, l_int32 type, l_int32 nbins, l_int32 thresh)
pixaGetAlignedStats()
l_ok gplotAddPlot(GPLOT *gplot, NUMA *nax, NUMA *nay, l_int32 plotstyle, const char *plottitle)
gplotAddPlot()
l_int32 lept_roundftoi(l_float32 fval)
lept_roundftoi()
PIX * pixScaleRGBToGrayFast(PIX *pixs, l_int32 factor, l_int32 color)
pixScaleRGBToGrayFast()
NUMA * pixGetCmapHistogramInRect(PIX *pixs, BOX *box, l_int32 factor)
pixGetCmapHistogramInRect()
l_ok numaAddNumber(NUMA *na, l_float32 val)
numaAddNumber()
PIX * pixConvertRGBToHue(PIX *pixs)
pixConvertRGBToHue()
NUMA * pixGetCmapHistogram(PIX *pixs, l_int32 factor)
pixGetCmapHistogram()
PIXA * pixaCreate(l_int32 n)
pixaCreate()
l_ok gplotMakeOutput(GPLOT *gplot)
gplotMakeOutput()
GPLOT * gplotCreate(const char *rootname, l_int32 outformat, const char *title, const char *xlabel, const char *ylabel)
gplotCreate()
l_ok pixGetColorHistogram(PIX *pixs, l_int32 factor, NUMA **pnar, NUMA **pnag, NUMA **pnab)
pixGetColorHistogram()
PIX * pixConvertTo8(PIX *pixs, l_int32 cmapflag)
pixConvertTo8()
l_ok pixGetBinnedColor(PIX *pixs, PIX *pixg, l_int32 factor, l_int32 nbins, NUMA *nalut, l_uint32 **pcarray, l_int32 debugflag)
pixGetBinnedColor()
NUMA * numaMakeConstant(l_float32 val, l_int32 size)
numaMakeConstant()
PIX * pixGetAverageTiled(PIX *pixs, l_int32 sx, l_int32 sy, l_int32 type)
pixGetAverageTiled()
PIX * pixCreate(l_int32 width, l_int32 height, l_int32 depth)
pixCreate()
PIXA * pixaSplitPix(PIX *pixs, l_int32 nx, l_int32 ny, l_int32 borderwidth, l_uint32 bordercolor)
pixaSplitPix()
PIX * pixInvert(PIX *pixd, PIX *pixs)
pixInvert()
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()
NUMA * numaCreate(l_int32 n)
numaCreate()
void boxaDestroy(BOXA **pboxa)
boxaDestroy()
l_uint32 * pixGetData(PIX *pix)
pixGetData()
l_ok numaSetCount(NUMA *na, l_int32 newcount)
numaSetCount()
PIX * pixThresholdToBinary(PIX *pixs, l_int32 thresh)
pixThresholdToBinary()
PIX * pixaDisplay(PIXA *pixa, l_int32 w, l_int32 h)
pixaDisplay()
l_ok pixGetPixelAverage(PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor, l_uint32 *pval)
pixGetPixelAverage()
l_ok pixcmapGetRangeValues(PIXCMAP *cmap, l_int32 select, l_int32 *pminval, l_int32 *pmaxval, l_int32 *pminindex, l_int32 *pmaxindex)
pixcmapGetRangeValues()
#define GET_DATA_BIT(pdata, n)
NUMAA * numaaCreate(l_int32 n)
numaaCreate()
l_int32 amapGetCountForColor(L_AMAP *amap, l_uint32 val)
amapGetCountForColor()
l_ok pixThresholdForFgBg(PIX *pixs, l_int32 factor, l_int32 thresh, l_int32 *pfgval, l_int32 *pbgval)
pixThresholdForFgBg()
L_AMAP * pixGetColorAmapHistogram(PIX *pixs, l_int32 factor)
pixGetColorAmapHistogram()
PIX * pixGetRGBComponent(PIX *pixs, l_int32 comp)
pixGetRGBComponent()
l_ok pixSetPixelColumn(PIX *pix, l_int32 col, l_float32 *colvect)
pixSetPixelColumn()
l_ok pixGetAverageTiledRGB(PIX *pixs, l_int32 sx, l_int32 sy, l_int32 type, PIX **ppixr, PIX **ppixg, PIX **ppixb)
pixGetAverageTiledRGB()
l_ok pixSetAllArbitrary(PIX *pix, l_uint32 val)
pixSetAllArbitrary()
l_ok pixGetRankColorArray(PIX *pixs, l_int32 nbins, l_int32 type, l_int32 factor, l_uint32 **pcarray, l_int32 debugflag, l_int32 fontsize)
pixGetRankColorArray()
l_ok numaGetIValue(NUMA *na, l_int32 index, l_int32 *pival)
numaGetIValue()
l_ok pixGetAverageMasked(PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor, l_int32 type, l_float32 *pval)
pixGetAverageMasked()
l_ok pixGetExtremeValue(PIX *pixs, l_int32 factor, l_int32 type, l_int32 *prval, l_int32 *pgval, l_int32 *pbval, l_int32 *pgrayval)
pixGetExtremeValue()
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 numaDiscretizeRankAndIntensity(NUMA *na, l_int32 nbins, NUMA **pnarbin, NUMA **pnam, NUMA **pnar, NUMA **pnabb)
numaDiscretizeRankAndIntensity()
l_int32 pixColumnStats(PIX *pixs, BOX *box, NUMA **pnamean, NUMA **pnamedian, NUMA **pnamode, NUMA **pnamodecount, NUMA **pnavar, NUMA **pnarootvar)
pixColumnStats()
l_ok pixGetRangeValues(PIX *pixs, l_int32 factor, l_int32 color, l_int32 *pminval, l_int32 *pmaxval)
pixGetRangeValues()
l_ok pixSetPixel(PIX *pix, l_int32 x, l_int32 y, l_uint32 val)
pixSetPixel()
l_ok pixcmapGetColor(PIXCMAP *cmap, l_int32 index, l_int32 *prval, l_int32 *pgval, l_int32 *pbval)
pixcmapGetColor()
l_ok pixCountPixels(PIX *pixs, l_int32 *pcount, l_int32 *tab8)
pixCountPixels()
l_ok pixGetColorHistogramMasked(PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor, NUMA **pnar, NUMA **pnag, NUMA **pnab)
pixGetColorHistogramMasked()
#define SET_DATA_BYTE(pdata, n, val)
PIXA * pixClipRectangles(PIX *pixs, BOXA *boxa)
pixClipRectangles()
#define GET_DATA_QBIT(pdata, n)
PIX * pixConvertRGBToGrayMinMax(PIX *pixs, l_int32 type)
pixConvertRGBToGrayMinMax()
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()
#define GET_DATA_BYTE(pdata, n)
l_ok pixGetRankValue(PIX *pixs, l_int32 factor, l_float32 rank, l_uint32 *pvalue)
pixGetRankValue()
PIX * pixConvertTo8BySampling(PIX *pixs, l_int32 factor, l_int32 cmapflag)
pixConvertTo8BySampling()
PIX * pixClone(PIX *pixs)
pixClone()
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_ok numaHistogramGetValFromRank(NUMA *na, l_float32 rank, l_float32 *prval)
numaHistogramGetValFromRank()
void pixDestroy(PIX **ppix)
pixDestroy()
PIX * pixScaleByIntSampling(PIX *pixs, l_int32 factor)
pixScaleByIntSampling()
PIX * pixGetRGBComponentCmap(PIX *pixs, l_int32 comp)
pixGetRGBComponentCmap()
void numaDestroy(NUMA **pna)
numaDestroy()
l_ok pixGetDimensions(const PIX *pix, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixGetDimensions()
PIX * pixConvertRGBToGray(PIX *pixs, l_float32 rwt, l_float32 gwt, l_float32 bwt)
pixConvertRGBToGray()
NUMAA * pixGetGrayHistogramTiled(PIX *pixs, l_int32 factor, l_int32 nx, l_int32 ny)
pixGetGrayHistogramTiled()
NUMA * pixGetCmapHistogramMasked(PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor)
pixGetCmapHistogramMasked()
PIX * pixRead(const char *filename)
pixRead()
l_ok pixGetColumnStats(PIX *pixs, l_int32 type, l_int32 nbins, l_int32 thresh, l_float32 *rowvect)
pixGetColumnStats()
PIX * pixConvertRGBToSaturation(PIX *pixs)
pixConvertRGBToSaturation()
l_float32 * numaGetFArray(NUMA *na, l_int32 copyflag)
numaGetFArray()
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()
#define GET_DATA_TWO_BYTES(pdata, n)
l_ok pixGetRowStats(PIX *pixs, l_int32 type, l_int32 nbins, l_int32 thresh, l_float32 *colvect)
pixGetRowStats()
#define GET_DATA_DIBIT(pdata, n)
PIX * pixaGetPix(PIXA *pixa, l_int32 index, l_int32 accesstype)
pixaGetPix()
PIX * pixRankBinByStrip(PIX *pixs, l_int32 direction, l_int32 size, l_int32 nbins, l_int32 type)
pixRankBinByStrip()
l_ok pixGetMaxValueInRect(PIX *pixs, BOX *box, l_uint32 *pmaxval, l_int32 *pxmax, l_int32 *pymax)
pixGetMaxValueInRect()
l_ok pixaGetPixDimensions(PIXA *pixa, l_int32 index, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixaGetPixDimensions()
l_ok numaReplaceNumber(NUMA *na, l_int32 index, l_float32 val)
numaReplaceNumber()
NUMA * numaNormalizeHistogram(NUMA *nas, l_float32 tsum)
numaNormalizeHistogram()
l_int32 pixCountRGBColors(PIX *pixs)
pixCountRGBColors()
l_ok pixaExtractColumnFromEachPix(PIXA *pixa, l_int32 col, PIX *pixd)
pixaExtractColumnFromEachPix()
l_ok numaGetMax(NUMA *na, l_float32 *pmaxval, l_int32 *pimaxloc)
numaGetMax()
PIX * pixDisplayColorArray(l_uint32 *carray, l_int32 ncolors, l_int32 side, l_int32 ncols, l_int32 fontsize)
pixDisplayColorArray()
l_ok composeRGBPixel(l_int32 rval, l_int32 gval, l_int32 bval, l_uint32 *ppixel)
composeRGBPixel()
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()
NUMA * numaCreateFromFArray(l_float32 *farray, l_int32 size, l_int32 copyflag)
numaCreateFromFArray()
l_ok boxGetGeometry(BOX *box, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
boxGetGeometry()
PIX * pixScale(PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScale()
void pixaDestroy(PIXA **ppixa)
pixaDestroy()
void extractRGBValues(l_uint32 pixel, l_int32 *prval, l_int32 *pgval, l_int32 *pbval)
extractRGBValues()
l_int32 pixaGetCount(PIXA *pixa)
pixaGetCount()
l_ok gplotSimple1(NUMA *na, l_int32 outformat, const char *outroot, const char *title)
gplotSimple1()
l_ok numaaAddNuma(NUMAA *naa, NUMA *na, l_int32 copyflag)
numaaAddNuma()
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()
L_BMF * bmfCreate(const char *dir, l_int32 fontsize)
bmfCreate()