106 #include <config_auto.h>
111 #include "allheaders.h"
114 static const l_float32 TINY = 0.00001;
117 l_int32 *pnx, l_int32 *pny, l_int32 debug);
119 l_int32 factor, l_int32 n,
120 l_float32 *pscore,
PIXA *pixadebug);
187 l_int32 w1, h1, d1, w2, h2, d2, wpl1, wpl2;
188 l_int32 spp1, spp2, i, j, color, mismatch, opaque;
189 l_int32 fullwords, linebits, endbits;
190 l_uint32 endmask, wordmask;
191 l_uint32 *data1, *data2, *line1, *line2;
192 PIX *pixs1, *pixs2, *pixt1, *pixt2, *pixalpha;
196 return ERROR_INT(
"psame not defined", __func__, 1);
199 return ERROR_INT(
"pix1 and pix2 not both defined", __func__, 1);
202 if (w1 != w2 || h1 != h2) {
203 L_INFO(
"pix sizes differ\n", __func__);
214 spp1 = pixGetSpp(pix1);
215 spp2 = pixGetSpp(pix2);
217 if (use_alpha && d1 == 32 && d2 == 32) {
218 mismatch = ((spp1 == 4 && spp2 != 4) || (spp1 != 4 && spp2 == 4));
220 pixalpha = (spp1 == 4) ? pix1 : pix2;
223 L_INFO(
"just one pix has a non-opaque alpha layer\n", __func__);
229 cmap1 = pixGetColormap(pix1);
230 cmap2 = pixGetColormap(pix2);
231 if (!cmap1 && !cmap2 && (d1 != d2) && (d1 == 32 || d2 == 32)) {
232 L_INFO(
"no colormaps, pix depths unequal, and one of them is RGB\n",
237 if (cmap1 && cmap2 && (d1 == d2))
242 if (cmap1 && !cmap2) {
244 if (color && d2 <= 8)
254 }
else if (!cmap1 && cmap2) {
256 if (color && d1 <= 8)
266 }
else if (cmap1 && cmap2) {
275 d1 = pixGetDepth(pixs1);
276 d2 = pixGetDepth(pixs2);
278 if (d1 == 16 || d2 == 16) {
279 L_INFO(
"one pix is 16 bpp\n", __func__);
286 if (!pixt1 || !pixt2) {
287 L_INFO(
"failure to convert to 8 bpp\n", __func__);
302 d1 = pixGetDepth(pixt1);
303 d2 = pixGetDepth(pixt2);
304 wpl1 = pixGetWpl(pixt1);
305 wpl2 = pixGetWpl(pixt2);
310 if (use_alpha && !mismatch)
311 wordmask = (spp1 == 3) ? 0xffffff00 : 0xffffffff;
313 wordmask = 0xffffff00;
314 for (i = 0; i < h1; i++) {
315 line1 = data1 + wpl1 * i;
316 line2 = data2 + wpl2 * i;
317 for (j = 0; j < wpl1; j++) {
318 if ((*line1 ^ *line2) & wordmask) {
329 fullwords = linebits / 32;
330 endbits = linebits & 31;
331 endmask = (endbits == 0) ? 0 : (0xffffffff << (32 - endbits));
332 for (i = 0; i < h1; i++) {
333 line1 = data1 + wpl1 * i;
334 line2 = data2 + wpl2 * i;
335 for (j = 0; j < fullwords; j++) {
336 if (*line1 ^ *line2) {
345 if ((*line1 ^ *line2) & endmask) {
386 l_int32 d, w, h, wpl1, wpl2, i, j, linebits, fullwords, endbits;
387 l_int32 rval1, rval2, gval1, gval2, bval1, bval2, samecmaps;
388 l_uint32 endmask, val1, val2;
389 l_uint32 *data1, *data2, *line1, *line2;
393 return ERROR_INT(
"&same not defined", __func__, 1);
396 return ERROR_INT(
"pix1 not defined", __func__, 1);
398 return ERROR_INT(
"pix2 not defined", __func__, 1);
402 cmap1 = pixGetColormap(pix1);
403 cmap2 = pixGetColormap(pix2);
404 if (!cmap1 || !cmap2) {
405 L_INFO(
"both images don't have colormap\n", __func__);
409 if (d != 1 && d != 2 && d != 4 && d != 8) {
410 L_INFO(
"pix depth not in {1, 2, 4, 8}\n", __func__);
415 if (samecmaps == TRUE) {
417 wpl1 = pixGetWpl(pix1);
418 wpl2 = pixGetWpl(pix2);
421 fullwords = linebits / 32;
422 endbits = linebits & 31;
423 endmask = (endbits == 0) ? 0 : (0xffffffff << (32 - endbits));
424 for (i = 0; i < h; i++) {
425 line1 = data1 + wpl1 * i;
426 line2 = data2 + wpl2 * i;
427 for (j = 0; j < fullwords; j++) {
434 if ((*line1 ^ *line2) & endmask)
443 for (i = 0; i < h; i++) {
444 for (j = 0; j < w; j++) {
449 if (rval1 != rval2 || gval1 != gval2 || bval1 != bval2)
481 l_int32 n1, n2, i, rval1, rval2, gval1, gval2, bval1, bval2, aval1, aval2;
484 return ERROR_INT(
"&same not defined", __func__, 1);
487 return ERROR_INT(
"cmap1 not defined", __func__, 1);
489 return ERROR_INT(
"cmap2 not defined", __func__, 1);
490 if (ncomps != 3 && ncomps != 4)
491 return ERROR_INT(
"ncomps not 3 or 4", __func__, 1);
496 L_INFO(
"colormap sizes are different\n", __func__);
500 for (i = 0; i < n1; i++) {
503 if (rval1 != rval2 || gval1 != gval2 || bval1 != bval2)
505 if (ncomps == 4 && aval1 != aval2)
535 l_int32 n, i, rval, gval, bval, numpix;
540 return ERROR_INT(
"&color not defined", __func__, 1);
543 return ERROR_INT(
"pixs not defined", __func__, 1);
545 if ((cmap = pixGetColormap(pixs)) == NULL)
555 for (i = 0; i < n; i++) {
558 if ((rval != gval || rval != bval) && numpix) {
600 l_int32 count1, count2, countn;
605 return ERROR_INT(
"&pval not defined", __func__, 1);
608 return ERROR_INT(
"pix1 not defined", __func__, 1);
610 return ERROR_INT(
"pix2 not defined", __func__, 1);
615 if (count1 == 0 || count2 == 0) {
619 pixn =
pixAnd(NULL, pix1, pix2);
621 *pval = (l_float32)countn * (l_float32)countn /
622 ((l_float32)count1 * (l_float32)count2);
655 l_int32 w1, h1, d1, w2, h2, d2, minw, minh;
660 return (
PIX *)ERROR_PTR(
"pix1, pix2 not both defined", __func__, NULL);
663 if (d1 != 1 || d2 != 1)
664 return (
PIX *)ERROR_PTR(
"pix1 and pix2 not 1 bpp", __func__, NULL);
665 minw = L_MIN(w1, w2);
666 minh = L_MIN(h1, h2);
676 pixt =
pixAnd(NULL, pix1, pix2);
716 if (ppixdiff) *ppixdiff = NULL;
718 return ERROR_INT(
"&pfract not defined", __func__, 1);
720 if (!pix1 || pixGetDepth(pix1) != 1)
721 return ERROR_INT(
"pix1 not defined or not 1 bpp", __func__, 1);
722 if (!pix2 || pixGetDepth(pix2) != 1)
723 return ERROR_INT(
"pix2 not defined or not 1 bpp", __func__, 1);
724 if (comptype != L_COMPARE_XOR && comptype != L_COMPARE_SUBTRACT)
725 return ERROR_INT(
"invalid comptype", __func__, 1);
727 if (comptype == L_COMPARE_XOR)
728 pixt =
pixXor(NULL, pix1, pix2);
733 *pfract = (l_float32)(count) / (l_float32)(w * h);
794 l_int32 retval, d1, d2;
795 PIX *pixt1, *pixt2, *pixs1, *pixs2;
797 if (psame) *psame = 0;
798 if (pdiff) *pdiff = 255.0;
799 if (prmsdiff) *prmsdiff = 255.0;
800 if (ppixdiff) *ppixdiff = NULL;
801 if (!pix1 || pixGetDepth(pix1) == 1)
802 return ERROR_INT(
"pix1 not defined or 1 bpp", __func__, 1);
803 if (!pix2 || pixGetDepth(pix2) == 1)
804 return ERROR_INT(
"pix2 not defined or 1 bpp", __func__, 1);
805 if (comptype != L_COMPARE_SUBTRACT && comptype != L_COMPARE_ABS_DIFF)
806 return ERROR_INT(
"invalid comptype", __func__, 1);
807 if (plottype < 0 || plottype >= NUM_GPLOT_OUTPUTS)
808 return ERROR_INT(
"invalid plottype", __func__, 1);
812 d1 = pixGetDepth(pixt1);
813 d2 = pixGetDepth(pixt2);
824 d1 = pixGetDepth(pixs1);
825 d2 = pixGetDepth(pixs2);
829 return ERROR_INT(
"intrinsic depths are not equal", __func__, 1);
832 if (d1 == 8 || d1 == 16)
834 pdiff, prmsdiff, ppixdiff);
836 retval =
pixCompareRGB(pixs1, pixs2, comptype, plottype, psame,
837 pdiff, prmsdiff, ppixdiff);
876 static l_int32 index = 0;
877 l_int32 d1, d2, same, first, last;
882 if (psame) *psame = 0;
883 if (pdiff) *pdiff = 255.0;
884 if (prmsdiff) *prmsdiff = 255.0;
885 if (ppixdiff) *ppixdiff = NULL;
887 return ERROR_INT(
"pix1 not defined", __func__, 1);
889 return ERROR_INT(
"pix2 not defined", __func__, 1);
890 d1 = pixGetDepth(pix1);
891 d2 = pixGetDepth(pix2);
892 if ((d1 != d2) || (d1 != 8 && d1 != 16))
893 return ERROR_INT(
"depths unequal or not 8 or 16 bpp", __func__, 1);
894 if (pixGetColormap(pix1) || pixGetColormap(pix2))
895 return ERROR_INT(
"pix1 and/or pix2 are colormapped", __func__, 1);
896 if (comptype != L_COMPARE_SUBTRACT && comptype != L_COMPARE_ABS_DIFF)
897 return ERROR_INT(
"invalid comptype", __func__, 1);
898 if (plottype < 0 || plottype >= NUM_GPLOT_OUTPUTS)
899 return ERROR_INT(
"invalid plottype", __func__, 1);
903 if (comptype == L_COMPARE_SUBTRACT)
910 L_INFO(
"Images are pixel-wise identical\n", __func__);
911 if (psame) *psame = same;
917 if (plottype && !same) {
918 L_INFO(
"Images differ: output plots will be generated\n", __func__);
922 snprintf(buf,
sizeof(buf),
"/tmp/lept/comp/compare_gray%d", index);
924 "Pixel Difference Histogram",
"diff val",
929 snprintf(buf,
sizeof(buf),
"/tmp/lept/comp/compare_gray%d.png",
931 l_fileDisplay(buf, 100, 100, 1.0);
937 *ppixdiff =
pixCopy(NULL, pixt);
940 if (comptype == L_COMPARE_SUBTRACT) {
983 static l_int32 index = 0;
984 l_int32 rsame, gsame, bsame, same, first, rlast, glast, blast, last;
985 l_float32 rdiff, gdiff, bdiff;
987 NUMA *nar, *nag, *nab, *narc, *nagc, *nabc;
988 PIX *pixr1, *pixr2, *pixg1, *pixg2, *pixb1, *pixb2;
989 PIX *pixr, *pixg, *pixb;
991 if (psame) *psame = 0;
992 if (pdiff) *pdiff = 0.0;
993 if (prmsdiff) *prmsdiff = 0.0;
994 if (ppixdiff) *ppixdiff = NULL;
995 if (!pix1 || pixGetDepth(pix1) != 32)
996 return ERROR_INT(
"pix1 not defined or not 32 bpp", __func__, 1);
997 if (!pix2 || pixGetDepth(pix2) != 32)
998 return ERROR_INT(
"pix2 not defined or not ew bpp", __func__, 1);
999 if (comptype != L_COMPARE_SUBTRACT && comptype != L_COMPARE_ABS_DIFF)
1000 return ERROR_INT(
"invalid comptype", __func__, 1);
1001 if (plottype < 0 || plottype >= NUM_GPLOT_OUTPUTS)
1002 return ERROR_INT(
"invalid plottype", __func__, 1);
1012 if (comptype == L_COMPARE_SUBTRACT) {
1025 same = rsame && gsame && bsame;
1027 L_INFO(
"Images are pixel-wise identical\n", __func__);
1028 if (psame) *psame = same;
1034 *pdiff = (rdiff + gdiff + bdiff) / 3.0;
1038 if (plottype && !same) {
1039 L_INFO(
"Images differ: output plots will be generated\n", __func__);
1046 last = L_MAX(rlast, glast);
1047 last = L_MAX(last, blast);
1051 snprintf(buf,
sizeof(buf),
"/tmp/lept/comp/compare_rgb%d", index);
1053 "Pixel Difference Histogram",
"diff val",
1054 "number of pixels");
1060 snprintf(buf,
sizeof(buf),
"/tmp/lept/comp/compare_rgb%d.png",
1062 l_fileDisplay(buf, 100, 100, 1.0);
1075 if (comptype == L_COMPARE_SUBTRACT) {
1086 *prmsdiff = (rdiff + gdiff + bdiff) / 3.0;
1134 l_int32 d1, d2, w, h;
1135 PIX *pixt, *pixr, *pixg, *pixb;
1136 PIX *pixrdiff, *pixgdiff, *pixbdiff;
1140 return ERROR_INT(
"&pixdiff not defined", __func__, 1);
1143 return ERROR_INT(
"pix1 not defined", __func__, 1);
1145 return ERROR_INT(
"pix2 not defined", __func__, 1);
1146 d1 = pixGetDepth(pix1);
1147 d2 = pixGetDepth(pix2);
1149 return ERROR_INT(
"depths not equal", __func__, 1);
1150 if (d1 != 8 && d1 != 32)
1151 return ERROR_INT(
"pix1 not 8 or 32 bpp", __func__, 1);
1152 if (d2 != 8 && d2 != 32)
1153 return ERROR_INT(
"pix2 not 8 or 32 bpp", __func__, 1);
1154 if (sx < 2 || sy < 2)
1155 return ERROR_INT(
"sx and sy not both > 1", __func__, 1);
1157 return ERROR_INT(
"invalid type", __func__, 1);
1224 l_float32 *array1, *array2;
1225 NUMA *nah, *nan, *nad;
1228 return (
NUMA *)ERROR_PTR(
"pix1 not defined", __func__, NULL);
1230 return (
NUMA *)ERROR_PTR(
"pix2 not defined", __func__, NULL);
1233 return (
NUMA *)ERROR_PTR(
"na not made", __func__, NULL);
1244 for (i = 1; i < 256; i++)
1245 array2[i] = array2[i - 1] - array1[i - 1];
1311 l_float32 fractdiff, avediff;
1314 return ERROR_INT(
"&similar not defined", __func__, 1);
1317 return ERROR_INT(
"pix1 not defined", __func__, 1);
1319 return ERROR_INT(
"pix2 not defined", __func__, 1);
1321 return ERROR_INT(
"pix sizes not equal", __func__, 1);
1323 return ERROR_INT(
"mindiff must be > 0", __func__, 1);
1326 &fractdiff, &avediff, details))
1327 return ERROR_INT(
"diff stats not found", __func__, 1);
1329 if (maxave <= 0.0) maxave = 256.0;
1330 if (fractdiff <= maxfract && avediff <= maxave)
1383 l_float32 *pfractdiff,
1384 l_float32 *pavediff,
1387 l_int32 i, first, last, diff;
1388 l_float32 fract, ave;
1390 NUMA *nah, *nan, *nac;
1392 if (pfractdiff) *pfractdiff = 0.0;
1393 if (pavediff) *pavediff = 0.0;
1395 return ERROR_INT(
"&fractdiff not defined", __func__, 1);
1397 return ERROR_INT(
"&avediff not defined", __func__, 1);
1399 return ERROR_INT(
"pix1 not defined", __func__, 1);
1401 return ERROR_INT(
"pix2 not defined", __func__, 1);
1403 return ERROR_INT(
"mindiff must be > 0", __func__, 1);
1406 return ERROR_INT(
"na not made", __func__, 1);
1410 return ERROR_INT(
"nan not made", __func__, 1);
1419 "Difference histogram");
1420 l_fileDisplay(
"/tmp/lept/comp/histo.png", 500, 0, 1.0);
1421 lept_stderr(
"\nNonzero values in normalized histogram:");
1425 lept_stderr(
" -----------------------------------\n");
1426 for (diff = 1; diff < L_MIN(2 * mindiff, last); diff++) {
1429 for (i = diff; i <= last; i++) {
1431 ave += (l_float32)i * array[i];
1433 ave = (fract == 0.0) ? 0.0 : ave / fract;
1438 lept_stderr(
" -----------------------------------\n");
1443 for (i = mindiff; i < 256; i++) {
1445 ave += (l_float32)i * array[i];
1447 ave = (fract == 0.0) ? 0.0 : ave / fract;
1450 *pfractdiff = fract;
1483 l_int32 w1, h1, d1, w2, h2, d2, w, h, wpl1, wpl2;
1484 l_int32 i, j, val, val1, val2;
1485 l_int32 rval1, rval2, gval1, gval2, bval1, bval2;
1486 l_int32 rdiff, gdiff, bdiff, maxdiff;
1487 l_uint32 *data1, *data2, *line1, *line2;
1493 return (
NUMA *)ERROR_PTR(
"pix1 not defined", __func__, NULL);
1495 return (
NUMA *)ERROR_PTR(
"pix2 not defined", __func__, NULL);
1496 d1 = pixGetDepth(pix1);
1497 d2 = pixGetDepth(pix2);
1498 if (d1 == 16 || d2 == 16)
1499 return (
NUMA *)ERROR_PTR(
"d == 16 not supported", __func__, NULL);
1500 if (d1 < 8 && !pixGetColormap(pix1))
1501 return (
NUMA *)ERROR_PTR(
"pix1 depth < 8 bpp and not cmapped",
1503 if (d2 < 8 && !pixGetColormap(pix2))
1504 return (
NUMA *)ERROR_PTR(
"pix2 depth < 8 bpp and not cmapped",
1513 return (
NUMA *)ERROR_PTR(
"pix depths not equal", __func__, NULL);
1515 if (factor < 1) factor = 1;
1524 wpl1 = pixGetWpl(pixt1);
1525 wpl2 = pixGetWpl(pixt2);
1527 for (i = 0; i < h; i += factor) {
1528 line1 = data1 + i * wpl1;
1529 line2 = data2 + i * wpl2;
1530 for (j = 0; j < w; j += factor) {
1533 val = L_ABS(val1 - val2);
1538 for (i = 0; i < h; i += factor) {
1539 line1 = data1 + i * wpl1;
1540 line2 = data2 + i * wpl2;
1541 for (j = 0; j < w; j += factor) {
1544 rdiff = L_ABS(rval1 - rval2);
1545 gdiff = L_ABS(gval1 - gval2);
1546 bdiff = L_ABS(bval1 - bval2);
1547 maxdiff = L_MAX(rdiff, gdiff);
1548 maxdiff = L_MAX(maxdiff, bdiff);
1617 l_int32 d1, d2, w, h, count;
1618 PIX *pix1, *pix2, *pix3, *pix4, *pix5, *pix6, *pix7, *pix8, *pix9;
1621 if (ppixdiff1) *ppixdiff1 = NULL;
1622 if (ppixdiff2) *ppixdiff2 = NULL;
1624 return ERROR_INT(
"&fract not defined", __func__, 1);
1626 if ((dilation & 1) == 0)
1627 return ERROR_INT(
"dilation must be odd", __func__, 1);
1629 return ERROR_INT(
"pixs1 not defined", __func__, 1);
1631 return ERROR_INT(
"pixs2 not defined", __func__, 1);
1632 d1 = pixGetDepth(pixs1);
1633 d2 = pixGetDepth(pixs2);
1634 if (!pixGetColormap(pixs1) && d1 < 8)
1635 return ERROR_INT(
"pixs1 not cmapped and < 8 bpp", __func__, 1);
1636 if (!pixGetColormap(pixs2) && d2 < 8)
1637 return ERROR_INT(
"pixs2 not cmapped and < 8 bpp", __func__, 1);
1649 if (pixGetColormap(pix1)) {
1651 d1 = pixGetDepth(pix3);
1655 if (pixGetColormap(pix2)) {
1657 d2 = pixGetDepth(pix4);
1663 if (d1 != d2 || (d1 != 8 && d1 != 32)) {
1666 L_INFO(
"depths unequal or not in {8,32}: d1 = %d, d2 = %d\n",
1681 pixCompareGray(pix4, pix5, L_COMPARE_SUBTRACT, 0, NULL, NULL, NULL,
1684 pixCompareGray(pix3, pix6, L_COMPARE_SUBTRACT, 0, NULL, NULL, NULL,
1686 pix9 =
pixMinOrMax(NULL, pix7, pix8, L_CHOOSE_MAX);
1691 *pfract = (w <= 0 || h <= 0) ? 0.0 :
1692 (l_float32)count / (l_float32)(w * h);
1706 pix5 =
pixColorMorph(pix3, L_MORPH_DILATE, dilation, dilation);
1707 pixCompareRGB(pix4, pix5, L_COMPARE_SUBTRACT, 0, NULL, NULL, NULL,
1709 pix6 =
pixColorMorph(pix4, L_MORPH_DILATE, dilation, dilation);
1710 pixCompareRGB(pix3, pix6, L_COMPARE_SUBTRACT, 0, NULL, NULL, NULL,
1712 pix9 =
pixMinOrMax(NULL, pix7, pix8, L_CHOOSE_MAX);
1718 *pfract = (w <= 0 || h <= 0) ? 0.0 :
1719 (l_float32)count / (l_float32)(w * h);
1778 l_int32 same, i, j, w, h, d, wpl1, wpl2, v1, v2, r1, g1, b1, r2, g2, b2;
1779 l_uint32 *data1, *data2, *line1, *line2;
1783 return ERROR_INT(
"&psnr not defined", __func__, 1);
1786 return ERROR_INT(
"empty input pix", __func__, 1);
1788 return ERROR_INT(
"pix sizes unequal", __func__, 1);
1789 if (pixGetColormap(pix1))
1790 return ERROR_INT(
"pix1 has colormap", __func__, 1);
1791 if (pixGetColormap(pix2))
1792 return ERROR_INT(
"pix2 has colormap", __func__, 1);
1794 if (d != 8 && d != 32)
1795 return ERROR_INT(
"pix not 8 or 32 bpp", __func__, 1);
1797 return ERROR_INT(
"invalid sampling factor", __func__, 1);
1807 wpl1 = pixGetWpl(pix1);
1808 wpl2 = pixGetWpl(pix2);
1811 for (i = 0; i < h; i += factor) {
1812 line1 = data1 + i * wpl1;
1813 line2 = data2 + i * wpl2;
1814 for (j = 0; j < w; j += factor) {
1817 mse += (l_float32)(v1 - v2) * (v1 - v2);
1821 for (i = 0; i < h; i += factor) {
1822 line1 = data1 + i * wpl1;
1823 line2 = data2 + i * wpl2;
1824 for (j = 0; j < w; j += factor) {
1827 mse += ((l_float32)(r1 - r2) * (r1 - r2) +
1828 (g1 - g2) * (g1 - g2) +
1829 (b1 - b2) * (b1 - b2)) / 3.0;
1833 mse = mse / ((l_float32)(w) * h);
1835 *ppsnr = -4.3429448 * log(mse / (255 * 255));
1898 l_float32 textthresh,
1901 l_float32 simthresh,
1903 l_float32 **pscores,
1908 l_int32 i, j, nim, w, h, w1, h1, w2, h2, ival, index, classid;
1911 NUMA *nai, *naw, *nah;
1916 if (pscores) *pscores = NULL;
1917 if (ppixd) *ppixd = NULL;
1919 return ERROR_INT(
"&na not defined", __func__, 1);
1922 return ERROR_INT(
"pixa not defined", __func__, 1);
1923 if (minratio < 0.0 || minratio > 1.0)
1924 return ERROR_INT(
"minratio not in [0.0 ... 1.0]", __func__, 1);
1925 if (textthresh <= 0.0) textthresh = 1.3;
1927 return ERROR_INT(
"subsampling factor must be >= 1", __func__, 1);
1928 if (n < 1 || n > 7) {
1929 L_WARNING(
"n = %d is invalid; setting to 4\n", __func__, n);
1932 if (simthresh <= 0.0) simthresh = 0.25;
1933 if (simthresh > 1.0)
1934 return ERROR_INT(
"simthresh invalid; should be near 0.25", __func__, 1);
1938 if ((n3a = (
NUMAA **)LEPT_CALLOC(nim,
sizeof(
NUMAA *))) == NULL)
1939 return ERROR_INT(
"calloc fail for n3a", __func__, 1);
1942 for (i = 0; i < nim; i++) {
1946 index = (debug) ? i : 0;
1948 &naa, &w, &h, index);
1966 (l_float32 *)LEPT_CALLOC((
size_t)nim * nim,
sizeof(l_float32)))
1968 L_ERROR(
"calloc fail for scores\n", __func__);
1972 for (i = 0, classid = 0; i < nim; i++) {
1973 scores[nim * i + i] = 1.0;
1978 if (n3a[i] == NULL) {
1984 for (j = i + 1; j < nim; j++) {
1994 scores[nim * i + j] = score;
1995 scores[nim * j + i] = score;
1997 if (score > simthresh) {
2000 "Setting %d similar to %d, in class %d; score %5.3f\n",
2001 j, i, classid, score);
2016 l_uint32 *line, *data;
2020 wpl = pixGetWpl(pix2);
2021 for (i = 0; i < nim; i++) {
2022 line = data + i * wpl;
2023 for (j = 0; j < nim; j++) {
2025 L_MIN(255, 4.0 * 255 * scores[nim * i + j]));
2028 fact = L_MAX(2, 1000 / nim);
2030 lept_stderr(
"Writing to /tmp/lept/comp/scorearray.png\n");
2032 pixWrite(
"/tmp/lept/comp/scorearray.png", pix3, IFF_PNG);
2049 for (i = 0; i < nim; i++)
2126 l_int32 w1, h1, w2, h2, w1c, h1c, w2c, h2c, debugindex;
2127 l_float32 wratio, hratio;
2133 return ERROR_INT(
"&score not defined", __func__, 1);
2136 return ERROR_INT(
"pix1 and pix2 not both defined", __func__, 1);
2137 if (minratio < 0.5 || minratio > 1.0)
2138 return ERROR_INT(
"minratio not in [0.5 ... 1.0]", __func__, 1);
2140 return ERROR_INT(
"subsampling factor must be >= 1", __func__, 1);
2141 if (n < 1 || n > 7) {
2142 L_WARNING(
"n = %d is invalid; setting to 4\n", __func__, n);
2161 wratio = (w1 < w2) ? (l_float32)w1 / (l_float32)w2 :
2162 (l_float32)w2 / (l_float32)w1;
2163 hratio = (h1 < h2) ? (l_float32)h1 / (l_float32)h2 :
2164 (l_float32)h2 / (l_float32)h1;
2165 if (wratio < minratio || hratio < minratio)
2175 if (!naa1)
return 0;
2182 if (!naa2)
return 0;
2243 PIX *pix1, *pix2, *pix3, *pixm;
2246 if (pnaa) *pnaa = NULL;
2250 return ERROR_INT(
"&naa not defined", __func__, 1);
2252 return ERROR_INT(
"&w and &h not both defined", __func__, 1);
2253 if (!pixs || pixGetDepth(pixs) == 1)
2254 return ERROR_INT(
"pixs not defined or 1 bpp", __func__, 1);
2256 return ERROR_INT(
"subsampling factor must be >= 1", __func__, 1);
2257 if (thresh <= 0.0) thresh = 1.3;
2258 if (n < 1 || n > 7) {
2259 L_WARNING(
"n = %d is invalid; setting to 4\n", __func__, n);
2264 if (debugindex > 0) {
2286 if (debugindex > 0) {
2287 PIX *pix4, *pix5, *pix6, *pix7, *pix8;
2309 *pw = pixGetWidth(pix3);
2310 *ph = pixGetHeight(pix3);
2314 snprintf(buf,
sizeof(buf),
"/tmp/lept/comp/tiledhistos.%d.pdf",
2347 l_int32 xs, ys, delx, dely, icx, icy, ws, hs, wd, hd;
2351 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
2353 return (
PIX *)ERROR_PTR(
"invalid sampling factor", __func__, NULL);
2357 icx = (l_int32)(cx + 0.5);
2358 icy = (l_int32)(cy + 0.5);
2360 delx = ws - 2 * icx;
2361 dely = hs - 2 * icy;
2362 xs = L_MAX(0, delx);
2363 ys = L_MAX(0, dely);
2364 wd = 2 * L_MAX(icx, ws - icx);
2365 hd = 2 * L_MAX(icy, hs - icy);
2368 pixCopyResolution(pixd, pixs);
2399 l_int32 i, j, w, h, wpl, val;
2400 l_float32 sumx, sumy, sumv;
2401 l_uint32 *data, *line;
2404 if (pcx) *pcx = 0.0;
2405 if (pcy) *pcy = 0.0;
2406 if (!pixs || pixGetDepth(pixs) != 8)
2407 return ERROR_INT(
"pixs undefined or not 8 bpp", __func__, 1);
2409 return ERROR_INT(
"subsampling factor must be >= 1", __func__, 1);
2411 return ERROR_INT(
"&cx and &cy not both defined", __func__, 1);
2416 wpl = pixGetWpl(pix1);
2417 sumx = sumy = sumv = 0.0;
2418 for (i = 0; i < h; i++) {
2419 line = data + i * wpl;
2420 for (j = 0; j < w; j++) {
2430 L_INFO(
"input image is white\n", __func__);
2431 *pcx = (l_float32)(w) / 2;
2432 *pcy = (l_float32)(h) / 2;
2486 l_int32 i, w, h, nx, ny, ngrids, istext, isphoto;
2487 l_float32 maxval, sum1, sum2, ratio;
2489 NUMA *na1, *na2, *na3, *narv;
2492 PIXA *pixa1, *pixa2, *pixa3;
2495 return ERROR_INT(
"&naa not defined", __func__, 1);
2497 if (!pix || pixGetDepth(pix) != 8 || pixGetColormap(pix))
2498 return ERROR_INT(
"pix undefined or invalid", __func__, 1);
2499 if (n < 1 || n > 7) {
2500 L_WARNING(
"n = %d is invalid; setting to 4\n", __func__, n);
2503 if (thresh <= 0.0) thresh = 1.3;
2508 L_INFO(
"Image is text\n", __func__);
2514 if (w == 0 || h == 0)
2515 return ERROR_INT(
"invalid pix dimension", __func__, 1);
2521 bmf = (pixadebug) ?
bmfCreate(NULL, 6) : NULL;
2527 for (i = 0; i < ngrids; i++) {
2537 snprintf(buf,
sizeof(buf),
"/tmp/lept/compplot/plot.%d", i);
2573 ratio = sum1 / sum2;
2574 isphoto = (ratio > thresh) ? 1 : 0;
2578 L_INFO(
"ratio %f > %f; isphoto is true\n",
2579 __func__, ratio, thresh);
2581 L_INFO(
"ratio %f < %f; isphoto is false\n",
2582 __func__, ratio, thresh);
2628 l_int32 nx, ny, max;
2631 ratio = (l_float32)w / (l_float32)h;
2634 while (nx > 1 && ny > 1) {
2639 lept_stderr(
"nx = %d, ny = %d, ratio w/h = %4.2f\n",
2641 }
else if (ratio < 0.5) {
2645 lept_stderr(
"nx = %d, ny = %d, ratio w/h = %4.2f\n",
2649 lept_stderr(
"nx = %d, ny = %d, ratio w/h = %4.2f\n",
2653 ratio = (l_float32)(ny * w) / (l_float32)(nx * h);
2694 char buf1[128], buf2[128];
2696 l_float32 wratio, hratio, score, minscore, dist;
2698 NUMA *na1, *na2, *nadist, *nascore;
2701 return ERROR_INT(
"&score not defined", __func__, 1);
2704 return ERROR_INT(
"naa1 and naa2 not both defined", __func__, 1);
2707 wratio = (w1 < w2) ? (l_float32)w1 / (l_float32)w2 :
2708 (l_float32)w2 / (l_float32)w1;
2709 hratio = (h1 < h2) ? (l_float32)h1 / (l_float32)h2 :
2710 (l_float32)h2 / (l_float32)h1;
2711 if (wratio < minratio || hratio < minratio) {
2713 L_INFO(
"Sizes differ: wratio = %f, hratio = %f\n",
2714 __func__, wratio, hratio);
2719 L_INFO(
"naa1 and naa2 sizes are different\n", __func__);
2736 bmf = (pixadebug) ?
bmfCreate(NULL, 6) : NULL;
2737 for (i = 0; i < n; i++) {
2748 score = L_MAX(0.0, 1.0 - 10.0 * (dist / 255.));
2751 minscore = L_MIN(minscore, score);
2753 snprintf(buf1,
sizeof(buf1),
"/tmp/lept/comptile/plot.%d", i);
2762 for (i = 0; i < n; i++) {
2764 snprintf(buf1,
sizeof(buf1),
"/tmp/lept/comptile/plot.%d.png", i);
2768 snprintf(buf2,
sizeof(buf2),
2769 "Image %d\ndist = %5.3f, score = %5.3f", i, dist, score);
2774 lept_stderr(
"Writing to /tmp/lept/comptile/comparegray.pdf\n");
2776 "/tmp/lept/comptile/comparegray.pdf");
2871 l_int32 w1, h1, w2, h2;
2872 l_float32 wratio, hratio;
2874 PIX *pix3, *pix4, *pix5, *pix6, *pix7, *pix8;
2878 return ERROR_INT(
"&score not defined", __func__, 1);
2881 return ERROR_INT(
"pix1 and pix2 not both defined", __func__, 1);
2882 if (minratio < 0.5 || minratio > 1.0)
2883 return ERROR_INT(
"minratio not in [0.5 ... 1.0]", __func__, 1);
2885 return ERROR_INT(
"invalid maxgray; should be >= 200", __func__, 1);
2886 maxgray = L_MIN(255, maxgray);
2888 return ERROR_INT(
"subsampling factor must be >= 1", __func__, 1);
2889 if (n < 1 || n > 7) {
2890 L_WARNING(
"n = %d is invalid; setting to 4\n", __func__, n);
2906 wratio = (w1 < w2) ? (l_float32)w1 / (l_float32)w2 :
2907 (l_float32)w2 / (l_float32)w1;
2908 hratio = (h1 < h2) ? (l_float32)h1 / (l_float32)h2 :
2909 (l_float32)h2 / (l_float32)h1;
2910 if (wratio < minratio || hratio < minratio)
2931 PIX *pix9, *pix10, *pix11, *pix12, *pix13;
2994 l_int32 w, h, i, j, nx, ny, ngr;
2995 l_float32 score, minscore, maxval1, maxval2, dist;
2997 NUMA *na1, *na2, *na3, *na4, *na5, *na6, *na7;
2999 PIXA *pixa1, *pixa2;
3002 return ERROR_INT(
"&score not defined", __func__, 1);
3005 return ERROR_INT(
"pix1 and pix2 not both defined", __func__, 1);
3016 bmf = (pixadebug) ?
bmfCreate(NULL, 6) : NULL;
3018 for (i = 0; i < ngr; i++) {
3025 if (maxgray < 255) {
3026 for (j = maxgray + 1; j <= 255; j++) {
3038 gplotSimple2(na5, na6, GPLOT_PNG,
"/tmp/lept/comp/plot1",
"Histos");
3046 score = L_MAX(0.0, 1.0 - 8.0 * (dist / 255.));
3048 minscore = L_MIN(minscore, score);
3050 PIX *pix5, *pix6, *pix7, *pix8, *pix9, *pix10;
3052 l_int32 w, h, wscale;
3055 wscale = (w > h) ? 700 : 400;
3060 pix7 =
pixRead(
"/tmp/lept/comp/plot1.png");
3062 snprintf(buf,
sizeof(buf),
"%5.3f", score);
3084 "/tmp/lept/comp/comparegray.pdf");
3119 l_float32 cx1, cy1, cx2, cy2;
3120 l_int32 w1, h1, w2, h2, icx1, icy1, icx2, icy2;
3121 l_int32 xm, xm1, xm2, xp, xp1, xp2, ym, ym1, ym2, yp, yp1, yp2;
3124 if (pbox1) *pbox1 = NULL;
3125 if (pbox2) *pbox2 = NULL;
3127 return ERROR_INT(
"pix1 and pix2 not both defined", __func__, 1);
3129 return ERROR_INT(
"subsampling factor must be >= 1", __func__, 1);
3130 if (!pbox1 || !pbox2)
3131 return ERROR_INT(
"&box1 and &box2 not both defined", __func__, 1);
3142 icx1 = (l_int32)(cx1 + 0.5);
3143 icy1 = (l_int32)(cy1 + 0.5);
3144 icx2 = (l_int32)(cx2 + 0.5);
3145 icy2 = (l_int32)(cy2 + 0.5);
3146 xm = L_MIN(icx1, icx2);
3149 xp = L_MIN(w1 - icx1, w2 - icx2);
3152 ym = L_MIN(icy1, icy2);
3155 yp = L_MIN(h1 - icy1, h2 - icy2);
3158 *pbox1 =
boxCreate(xm1, ym1, xp1 - xm1, yp1 - ym1);
3159 *pbox2 =
boxCreate(xm2, ym2, xp2 - xm2, yp2 - ym2);
3192 l_int32 i, j, n, nn, ival;
3197 return (l_uint8 *)ERROR_PTR(
"&size not defined", __func__, NULL);
3200 return (l_uint8 *)ERROR_PTR(
"naa not defined", __func__, NULL);
3202 for (i = 0; i < n; i++) {
3205 L_ERROR(
"%d numbers in numa[%d]\n", __func__, nn, i);
3210 if ((bytea = (l_uint8 *)LEPT_CALLOC(8 + 256 * n,
sizeof(l_uint8))) == NULL)
3211 return (l_uint8 *)ERROR_PTR(
"bytea not made", __func__, NULL);
3212 *psize = 8 + 256 * n;
3215 for (i = 0; i < n; i++) {
3219 for (j = 0; j < 256; j++) {
3221 bytea[8 + 256 * i + j] = ival;
3264 return (
NUMAA *)ERROR_PTR(
"&w and &h not both defined", __func__, NULL);
3266 return (
NUMAA *)ERROR_PTR(
"bytea not defined", __func__, NULL);
3267 n = (size - 8) / 256;
3268 if ((size - 8) % 256 != 0)
3269 return (
NUMAA *)ERROR_PTR(
"bytea size is invalid", __func__, NULL);
3274 for (i = 0; i < n; i++) {
3276 for (j = 0; j < 256; j++)
3328 l_int32 i, level, area1, area2, delx, dely;
3329 l_int32 etransx, etransy, maxshift, dbint;
3330 l_int32 *stab, *ctab;
3331 l_float32 cx1, cx2, cy1, cy2, score;
3332 PIX *pixb1, *pixb2, *pixt1, *pixt2, *pixt3, *pixt4;
3333 PIXA *pixa1, *pixa2, *pixadb;
3335 if (pdelx) *pdelx = 0;
3336 if (pdely) *pdely = 0;
3337 if (pscore) *pscore = 0.0;
3338 if (!pdelx || !pdely)
3339 return ERROR_INT(
"&delx and &dely not defined", __func__, 1);
3341 return ERROR_INT(
"&score not defined", __func__, 1);
3343 return ERROR_INT(
"pix1 not defined", __func__, 1);
3345 return ERROR_INT(
"pix2 not defined", __func__, 1);
3364 for (i = 0; i < 3; i++) {
3377 for (level = 3; level >= 0; level--) {
3393 dbint = (debugflag) ? level + 1 : 0;
3395 maxshift, stab, &delx, &dely, &score, dbint);
3397 lept_stderr(
"Level %d: delx = %d, dely = %d, score = %7.4f\n",
3398 level, delx, dely, score);
3411 "/tmp/lept/comp/compare.pdf");
3413 0,
"Correlation scores at levels 1 through 5",
3414 "/tmp/lept/comp/correl.pdf");
3484 l_int32 shiftx, shifty, delx, dely;
3486 l_float32 maxscore, score;
3490 if (pdelx) *pdelx = 0;
3491 if (pdely) *pdely = 0;
3492 if (pscore) *pscore = 0.0;
3493 if (!pix1 || pixGetDepth(pix1) != 1)
3494 return ERROR_INT(
"pix1 not defined or not 1 bpp", __func__, 1);
3495 if (!pix2 || pixGetDepth(pix2) != 1)
3496 return ERROR_INT(
"pix2 not defined or not 1 bpp", __func__, 1);
3497 if (!area1 || !area2)
3498 return ERROR_INT(
"areas must be > 0", __func__, 1);
3501 fpix =
fpixCreate(2 * maxshift + 1, 2 * maxshift + 1);
3512 for (shifty = -maxshift; shifty <= maxshift; shifty++) {
3513 for (shiftx = -maxshift; shiftx <= maxshift; shiftx++) {
3514 pixCorrelationScoreShifted(pix1, pix2, area1, area2,
3516 etransy + shifty, tab, &score);
3517 if (debugflag > 0) {
3518 fpixSetPixel(fpix, maxshift + shiftx, maxshift + shifty,
3523 if (score > maxscore) {
3525 delx = etransx + shiftx;
3526 dely = etransy + shifty;
3531 if (debugflag > 0) {
3536 snprintf(buf,
sizeof(buf),
"/tmp/lept/comp/correl_%d.png",
3538 pixWrite(buf, pix4, IFF_PNG);
3544 if (pdelx) *pdelx = delx;
3545 if (pdely) *pdely = dely;
3546 if (pscore) *pscore = maxscore;
3547 if (!tab8) LEPT_FREE(tab);
void l_setDataFourBytes(void *line, l_int32 n, l_int32 val)
l_setDataFourBytes()
l_int32 l_getDataFourBytes(const void *line, l_int32 n)
l_getDataFourBytes()
#define GET_DATA_BYTE(pdata, n)
#define SET_DATA_BYTE(pdata, n, val)
l_uint8 * makeSubsampleTab2x(void)
makeSubsampleTab2x()
PIX * pixReduceRankBinary2(PIX *pixs, l_int32 level, l_uint8 *intab)
pixReduceRankBinary2()
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 boxDestroy(BOX **pbox)
boxDestroy()
BOX * boxCreate(l_int32 x, l_int32 y, l_int32 w, l_int32 h)
boxCreate()
l_ok pixcmapHasColor(PIXCMAP *cmap, l_int32 *pcolor)
pixcmapHasColor()
l_int32 pixcmapGetCount(const PIXCMAP *cmap)
pixcmapGetCount()
PIXCMAP * pixcmapCreate(l_int32 depth)
pixcmapCreate()
l_ok pixcmapGetColor(PIXCMAP *cmap, l_int32 index, l_int32 *prval, l_int32 *pgval, l_int32 *pbval)
pixcmapGetColor()
l_ok pixcmapGetRGBA(PIXCMAP *cmap, l_int32 index, l_int32 *prval, l_int32 *pgval, l_int32 *pbval, l_int32 *paval)
pixcmapGetRGBA()
l_ok pixcmapAddColor(PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval)
pixcmapAddColor()
PIX * pixColorMorph(PIX *pixs, l_int32 type, l_int32 hsize, l_int32 vsize)
pixColorMorph()
l_ok pixCompareGrayOrRGB(PIX *pix1, PIX *pix2, l_int32 comptype, l_int32 plottype, l_int32 *psame, l_float32 *pdiff, l_float32 *prmsdiff, PIX **ppixdiff)
pixCompareGrayOrRGB()
l_ok compareTilesByHisto(NUMAA *naa1, NUMAA *naa2, l_float32 minratio, l_int32 w1, l_int32 h1, l_int32 w2, l_int32 h2, l_float32 *pscore, PIXA *pixadebug)
compareTilesByHisto()
l_ok pixaComparePhotoRegionsByHisto(PIXA *pixa, l_float32 minratio, l_float32 textthresh, l_int32 factor, l_int32 n, l_float32 simthresh, NUMA **pnai, l_float32 **pscores, PIX **ppixd, l_int32 debug)
pixaComparePhotoRegionsByHisto()
l_ok pixGetDifferenceStats(PIX *pix1, PIX *pix2, l_int32 factor, l_int32 mindiff, l_float32 *pfractdiff, l_float32 *pavediff, l_int32 details)
pixGetDifferenceStats()
l_ok pixCropAlignedToCentroid(PIX *pix1, PIX *pix2, l_int32 factor, BOX **pbox1, BOX **pbox2)
pixCropAlignedToCentroid()
l_ok pixCompareGrayByHisto(PIX *pix1, PIX *pix2, BOX *box1, BOX *box2, l_float32 minratio, l_int32 maxgray, l_int32 factor, l_int32 n, l_float32 *pscore, l_int32 debugflag)
pixCompareGrayByHisto()
l_ok pixDecideIfPhotoImage(PIX *pix, l_int32 factor, l_float32 thresh, l_int32 n, NUMAA **pnaa, PIXA *pixadebug)
pixDecideIfPhotoImage()
NUMA * pixCompareRankDifference(PIX *pix1, PIX *pix2, l_int32 factor)
pixCompareRankDifference()
l_ok pixCompareRGB(PIX *pix1, PIX *pix2, l_int32 comptype, l_int32 plottype, l_int32 *psame, l_float32 *pdiff, l_float32 *prmsdiff, PIX **ppixdiff)
pixCompareRGB()
PIX * pixPadToCenterCentroid(PIX *pixs, l_int32 factor)
pixPadToCenterCentroid()
l_ok pixGenPhotoHistos(PIX *pixs, BOX *box, l_int32 factor, l_float32 thresh, l_int32 n, NUMAA **pnaa, l_int32 *pw, l_int32 *ph, l_int32 debugindex)
pixGenPhotoHistos()
l_ok pixGetPSNR(PIX *pix1, PIX *pix2, l_int32 factor, l_float32 *ppsnr)
pixGetPSNR()
l_ok pixBestCorrelation(PIX *pix1, PIX *pix2, l_int32 area1, l_int32 area2, l_int32 etransx, l_int32 etransy, l_int32 maxshift, l_int32 *tab8, l_int32 *pdelx, l_int32 *pdely, l_float32 *pscore, l_int32 debugflag)
pixBestCorrelation()
l_ok cmapEqual(PIXCMAP *cmap1, PIXCMAP *cmap2, l_int32 ncomps, l_int32 *psame)
cmapEqual()
static l_ok pixCompareTilesByHisto(PIX *pix1, PIX *pix2, l_int32 maxgray, l_int32 factor, l_int32 n, l_float32 *pscore, PIXA *pixadebug)
pixCompareTilesByHisto()
l_ok pixCompareWithTranslation(PIX *pix1, PIX *pix2, l_int32 thresh, l_int32 *pdelx, l_int32 *pdely, l_float32 *pscore, l_int32 debugflag)
pixCompareWithTranslation()
PIX * pixDisplayDiffBinary(PIX *pix1, PIX *pix2)
pixDisplayDiffBinary()
NUMA * pixGetDifferenceHistogram(PIX *pix1, PIX *pix2, l_int32 factor)
pixGetDifferenceHistogram()
l_ok pixEqual(PIX *pix1, PIX *pix2, l_int32 *psame)
pixEqual()
l_ok pixComparePhotoRegionsByHisto(PIX *pix1, PIX *pix2, BOX *box1, BOX *box2, l_float32 minratio, l_int32 factor, l_int32 n, l_float32 *pscore, l_int32 debugflag)
pixComparePhotoRegionsByHisto()
l_ok pixEqualWithCmap(PIX *pix1, PIX *pix2, l_int32 *psame)
pixEqualWithCmap()
l_ok pixCompareGray(PIX *pix1, PIX *pix2, l_int32 comptype, l_int32 plottype, l_int32 *psame, l_float32 *pdiff, l_float32 *prmsdiff, PIX **ppixdiff)
pixCompareGray()
l_ok pixTestForSimilarity(PIX *pix1, PIX *pix2, l_int32 factor, l_int32 mindiff, l_float32 maxfract, l_float32 maxave, l_int32 *psimilar, l_int32 details)
pixTestForSimilarity()
l_ok pixCorrelationBinary(PIX *pix1, PIX *pix2, l_float32 *pval)
pixCorrelationBinary()
NUMAA * l_uncompressGrayHistograms(l_uint8 *bytea, size_t size, l_int32 *pw, l_int32 *ph)
l_uncompressGrayHistograms()
l_ok pixCompareTiled(PIX *pix1, PIX *pix2, l_int32 sx, l_int32 sy, l_int32 type, PIX **ppixdiff)
pixCompareTiled()
l_ok pixCompareBinary(PIX *pix1, PIX *pix2, l_int32 comptype, l_float32 *pfract, PIX **ppixdiff)
pixCompareBinary()
l_ok pixUsesCmapColor(PIX *pixs, l_int32 *pcolor)
pixUsesCmapColor()
l_uint8 * l_compressGrayHistograms(NUMAA *naa, l_int32 w, l_int32 h, size_t *psize)
l_compressGrayHistograms()
static l_ok findHistoGridDimensions(l_int32 n, l_int32 w, l_int32 h, l_int32 *pnx, l_int32 *pny, l_int32 debug)
findHistoGridDimensions()
l_ok pixGetPerceptualDiff(PIX *pixs1, PIX *pixs2, l_int32 sampling, l_int32 dilation, l_int32 mindiff, l_float32 *pfract, PIX **ppixdiff1, PIX **ppixdiff2)
pixGetPerceptualDiff()
l_ok pixCentroid8(PIX *pixs, l_int32 factor, l_float32 *pcx, l_float32 *pcy)
pixCentroid8()
l_ok pixEqualWithAlpha(PIX *pix1, PIX *pix2, l_int32 use_alpha, l_int32 *psame)
pixEqualWithAlpha()
l_ok fpixSetPixel(FPIX *fpix, l_int32 x, l_int32 y, l_float32 val)
fpixSetPixel()
void fpixDestroy(FPIX **pfpix)
fpixDestroy()
FPIX * fpixCreate(l_int32 width, l_int32 height)
fpixCreate()
PIX * fpixDisplayMaxDynamicRange(FPIX *fpixs)
fpixDisplayMaxDynamicRange()
l_ok gplotAddPlot(GPLOT *gplot, NUMA *nax, NUMA *nay, l_int32 plotstyle, const char *plotlabel)
gplotAddPlot()
l_ok gplotMakeOutput(GPLOT *gplot)
gplotMakeOutput()
GPLOT * gplotCreate(const char *rootname, l_int32 outformat, const char *title, const char *xlabel, const char *ylabel)
gplotCreate()
void gplotDestroy(GPLOT **pgplot)
gplotDestroy()
l_ok gplotSimple2(NUMA *na1, NUMA *na2, l_int32 outformat, const char *outroot, const char *title)
gplotSimple2()
l_ok gplotSimple1(NUMA *na, l_int32 outformat, const char *outroot, const char *title)
gplotSimple1()
l_ok pixRenderBoxArb(PIX *pix, BOX *box, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval)
pixRenderBoxArb()
PIX * pixDilateGray(PIX *pixs, l_int32 hsize, l_int32 vsize)
pixDilateGray()
PIX * pixThresholdToBinary(PIX *pixs, l_int32 thresh)
pixThresholdToBinary()
l_ok pixCentroid(PIX *pix, l_int32 *centtab, l_int32 *sumtab, l_float32 *pxave, l_float32 *pyave)
pixCentroid()
l_ok numaAddNumber(NUMA *na, l_float32 val)
numaAddNumber()
l_ok numaGetFValue(NUMA *na, l_int32 index, l_float32 *pval)
numaGetFValue()
l_ok numaWriteStderr(NUMA *na)
numaWriteStderr()
NUMA * numaCreate(l_int32 n)
numaCreate()
l_int32 numaaGetCount(NUMAA *naa)
numaaGetCount()
NUMA * numaaGetNuma(NUMAA *naa, l_int32 index, l_int32 accessflag)
numaaGetNuma()
l_int32 numaaGetNumaCount(NUMAA *naa, l_int32 index)
numaaGetNumaCount()
l_ok numaSetCount(NUMA *na, l_int32 newcount)
numaSetCount()
void numaDestroy(NUMA **pna)
numaDestroy()
NUMAA * numaaCreate(l_int32 n)
numaaCreate()
l_ok numaSetValue(NUMA *na, l_int32 index, l_float32 val)
numaSetValue()
l_ok numaGetIValue(NUMA *na, l_int32 index, l_int32 *pival)
numaGetIValue()
l_ok numaaAddNuma(NUMAA *naa, NUMA *na, l_int32 copyflag)
numaaAddNuma()
l_ok numaWriteDebug(const char *filename, NUMA *na)
numaWriteDebug()
void numaaDestroy(NUMAA **pnaa)
numaaDestroy()
l_float32 * numaGetFArray(NUMA *na, l_int32 copyflag)
numaGetFArray()
l_ok numaGetSumOnInterval(NUMA *na, l_int32 first, l_int32 last, l_float32 *psum)
numaGetSumOnInterval()
NUMA * numaMakeConstant(l_float32 val, l_int32 size)
numaMakeConstant()
NUMA * numaClipToInterval(NUMA *nas, l_int32 first, l_int32 last)
numaClipToInterval()
l_ok numaGetMax(NUMA *na, l_float32 *pmaxval, l_int32 *pimaxloc)
numaGetMax()
l_ok numaGetNonzeroRange(NUMA *na, l_float32 eps, l_int32 *pfirst, l_int32 *plast)
numaGetNonzeroRange()
l_ok numaEarthMoverDistance(NUMA *na1, NUMA *na2, l_float32 *pdist)
numaEarthMoverDistance()
NUMA * numaWindowedMean(NUMA *nas, l_int32 wc)
numaWindowedMean()
NUMA * numaNormalizeHistogram(NUMA *nas, l_float32 tsum)
numaNormalizeHistogram()
NUMA * numaTransform(NUMA *nas, l_float32 shift, l_float32 scale)
numaTransform()
l_ok grayInterHistogramStats(NUMAA *naa, l_int32 wc, NUMA **pnam, NUMA **pnams, NUMA **pnav, NUMA **pnarv)
grayInterHistogramStats()
l_ok pixDecideIfText(PIX *pixs, BOX *box, l_int32 *pistext, PIXA *pixadb)
pixDecideIfText()
l_ok pixaConvertToPdf(PIXA *pixa, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, const char *title, const char *fileout)
pixaConvertToPdf()
l_ok convertFilesToPdf(const char *dirname, const char *substr, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, const char *title, const char *fileout)
convertFilesToPdf()
l_uint32 * pixGetData(PIX *pix)
pixGetData()
l_ok pixSetColormap(PIX *pix, PIXCMAP *colormap)
pixSetColormap()
l_ok pixSetResolution(PIX *pix, l_int32 xres, l_int32 yres)
pixSetResolution()
void pixDestroy(PIX **ppix)
pixDestroy()
l_ok pixGetDimensions(const PIX *pix, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixGetDimensions()
l_int32 pixSizesEqual(const PIX *pix1, const PIX *pix2)
pixSizesEqual()
char * pixGetText(PIX *pix)
pixGetText()
PIX * pixCopy(PIX *pixd, const PIX *pixs)
pixCopy()
PIX * pixCreate(l_int32 width, l_int32 height, l_int32 depth)
pixCreate()
PIX * pixClone(PIX *pixs)
pixClone()
l_ok pixAlphaIsOpaque(PIX *pix, l_int32 *popaque)
pixAlphaIsOpaque()
PIX * pixGetRGBComponent(PIX *pixs, l_int32 comp)
pixGetRGBComponent()
l_ok pixGetPixel(PIX *pix, l_int32 x, l_int32 y, l_uint32 *pval)
pixGetPixel()
PIX * pixCreateRGBImage(PIX *pixr, PIX *pixg, PIX *pixb)
pixCreateRGBImage()
l_ok pixSetAll(PIX *pix)
pixSetAll()
void extractRGBValues(l_uint32 pixel, l_int32 *prval, l_int32 *pgval, l_int32 *pbval)
extractRGBValues()
l_ok pixZero(PIX *pix, l_int32 *pempty)
pixZero()
PIX * pixInvert(PIX *pixd, PIX *pixs)
pixInvert()
l_ok pixPaintThroughMask(PIX *pixd, PIX *pixm, l_int32 x, l_int32 y, l_uint32 val)
pixPaintThroughMask()
l_ok pixCountPixels(PIX *pixs, l_int32 *pcount, l_int32 *tab8)
pixCountPixels()
PIX * pixAnd(PIX *pixd, PIX *pixs1, PIX *pixs2)
pixAnd()
l_ok pixSetMaskedGeneral(PIX *pixd, PIX *pixm, l_uint32 val, l_int32 x, l_int32 y)
pixSetMaskedGeneral()
l_int32 * makePixelSumTab8(void)
makePixelSumTab8()
PIX * pixXor(PIX *pixd, PIX *pixs1, PIX *pixs2)
pixXor()
l_int32 * makePixelCentroidTab8(void)
makePixelCentroidTab8()
PIX * pixSubtract(PIX *pixd, PIX *pixs1, PIX *pixs2)
pixSubtract()
l_ok pixGetAverageMasked(PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor, l_int32 type, l_float32 *pval)
pixGetAverageMasked()
NUMA * pixGetGrayHistogram(PIX *pixs, l_int32 factor)
pixGetGrayHistogram()
PIX * pixGetAverageTiled(PIX *pixs, l_int32 sx, l_int32 sy, l_int32 type)
pixGetAverageTiled()
PIX * pixClipRectangle(PIX *pixs, BOX *box, BOX **pboxc)
pixClipRectangle()
@ 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_int32 pixaGetCount(PIXA *pixa)
pixaGetCount()
PIX * pixaGetPix(PIXA *pixa, l_int32 index, l_int32 accesstype)
pixaGetPix()
PIX * pixaccFinal(PIXACC *pixacc, l_int32 outdepth)
pixaccFinal()
l_ok pixaccAdd(PIXACC *pixacc, PIX *pix)
pixaccAdd()
void pixaccDestroy(PIXACC **ppixacc)
pixaccDestroy()
PIXACC * pixaccCreate(l_int32 w, l_int32 h, l_int32 negflag)
pixaccCreate()
l_ok pixaccMultConst(PIXACC *pixacc, l_float32 factor)
pixaccMultConst()
PIXA * pixaScale(PIXA *pixas, l_float32 scalex, l_float32 scaley)
pixaScale()
PIX * pixaDisplayTiledInRows(PIXA *pixa, l_int32 outdepth, l_int32 maxwidth, l_float32 scalefactor, l_int32 background, l_int32 spacing, l_int32 border)
pixaDisplayTiledInRows()
PIX * pixaDisplayTiledInColumns(PIXA *pixas, l_int32 nx, l_float32 scalefactor, l_int32 spacing, l_int32 border)
pixaDisplayTiledInColumns()
PIX * pixaDisplayTiledByIndex(PIXA *pixa, NUMA *na, l_int32 width, l_int32 spacing, l_int32 border, l_int32 fontsize, l_uint32 textcolor)
pixaDisplayTiledByIndex()
PIX * pixSubtractGray(PIX *pixd, PIX *pixs1, PIX *pixs2)
pixSubtractGray()
PIX * pixMinOrMax(PIX *pixd, PIX *pixs1, PIX *pixs2, l_int32 type)
pixMinOrMax()
PIX * pixAbsDifference(PIX *pixs1, PIX *pixs2)
pixAbsDifference()
PIX * pixConvertRGBToGrayMinMax(PIX *pixs, l_int32 type)
pixConvertRGBToGrayMinMax()
PIX * pixRemoveColormap(PIX *pixs, l_int32 type)
pixRemoveColormap()
PIX * pixConvertTo1(PIX *pixs, l_int32 threshold)
pixConvertTo1()
PIX * pixConvertTo8(PIX *pixs, l_int32 cmapflag)
pixConvertTo8()
PIX * pixConvertLossless(PIX *pixs, l_int32 d)
pixConvertLossless()
PIX * pixConvertTo32(PIX *pixs)
pixConvertTo32()
PIXA * pixaReadFiles(const char *dirname, const char *substr)
pixaReadFiles()
PIX * pixRead(const char *filename)
pixRead()
l_ok pixRasteropIP(PIX *pixd, l_int32 hshift, l_int32 vshift, l_int32 incolor)
pixRasteropIP()
l_ok pixRasterop(PIX *pixd, l_int32 dx, l_int32 dy, l_int32 dw, l_int32 dh, l_int32 op, PIX *pixs, l_int32 sx, l_int32 sy)
pixRasterop()
PIX * pixScaleToSize(PIX *pixs, l_int32 wd, l_int32 hd)
pixScaleToSize()
PIX * pixScaleByIntSampling(PIX *pixs, l_int32 factor)
pixScaleByIntSampling()
PIX * pixExpandReplicate(PIX *pixs, l_int32 factor)
pixExpandReplicate()
PIX * pixAddTextlines(PIX *pixs, L_BMF *bmf, const char *textstr, l_uint32 val, l_int32 location)
pixAddTextlines()
void lept_stderr(const char *fmt,...)
lept_stderr()
l_int32 lept_roundftoi(l_float32 fval)
lept_roundftoi()
l_int32 lept_rmdir(const char *subdir)
lept_rmdir()
l_int32 lept_mkdir(const char *subdir)
lept_mkdir()