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;
195 PROCNAME(
"pixEqualWithAlpha");
198 return ERROR_INT(
"psame not defined", procName, 1);
201 return ERROR_INT(
"pix1 and pix2 not both defined", procName, 1);
204 if (w1 != w2 || h1 != h2) {
205 L_INFO(
"pix sizes differ\n", procName);
216 spp1 = pixGetSpp(pix1);
217 spp2 = pixGetSpp(pix2);
219 if (use_alpha && d1 == 32 && d2 == 32) {
220 mismatch = ((spp1 == 4 && spp2 != 4) || (spp1 != 4 && spp2 == 4));
222 pixalpha = (spp1 == 4) ? pix1 : pix2;
225 L_INFO(
"just one pix has a non-opaque alpha layer\n", procName);
231 cmap1 = pixGetColormap(pix1);
232 cmap2 = pixGetColormap(pix2);
233 if (!cmap1 && !cmap2 && (d1 != d2) && (d1 == 32 || d2 == 32)) {
234 L_INFO(
"no colormaps, pix depths unequal, and one of them is RGB\n",
239 if (cmap1 && cmap2 && (d1 == d2))
244 if (cmap1 && !cmap2) {
246 if (color && d2 <= 8)
256 }
else if (!cmap1 && cmap2) {
258 if (color && d1 <= 8)
268 }
else if (cmap1 && cmap2) {
277 d1 = pixGetDepth(pixs1);
278 d2 = pixGetDepth(pixs2);
280 if (d1 == 16 || d2 == 16) {
281 L_INFO(
"one pix is 16 bpp\n", procName);
288 if (!pixt1 || !pixt2) {
289 L_INFO(
"failure to convert to 8 bpp\n", procName);
304 d1 = pixGetDepth(pixt1);
305 d2 = pixGetDepth(pixt2);
306 wpl1 = pixGetWpl(pixt1);
307 wpl2 = pixGetWpl(pixt2);
312 if (use_alpha && !mismatch)
313 wordmask = (spp1 == 3) ? 0xffffff00 : 0xffffffff;
315 wordmask = 0xffffff00;
316 for (i = 0; i < h1; i++) {
317 line1 = data1 + wpl1 * i;
318 line2 = data2 + wpl2 * i;
319 for (j = 0; j < wpl1; j++) {
320 if ((*line1 ^ *line2) & wordmask) {
331 fullwords = linebits / 32;
332 endbits = linebits & 31;
333 endmask = (endbits == 0) ? 0 : (0xffffffff << (32 - endbits));
334 for (i = 0; i < h1; i++) {
335 line1 = data1 + wpl1 * i;
336 line2 = data2 + wpl2 * i;
337 for (j = 0; j < fullwords; j++) {
338 if (*line1 ^ *line2) {
347 if ((*line1 ^ *line2) & endmask) {
388 l_int32 d, w, h, wpl1, wpl2, i, j, linebits, fullwords, endbits;
389 l_int32 rval1, rval2, gval1, gval2, bval1, bval2, samecmaps;
390 l_uint32 endmask, val1, val2;
391 l_uint32 *data1, *data2, *line1, *line2;
394 PROCNAME(
"pixEqualWithCmap");
397 return ERROR_INT(
"&same not defined", procName, 1);
400 return ERROR_INT(
"pix1 not defined", procName, 1);
402 return ERROR_INT(
"pix2 not defined", procName, 1);
406 cmap1 = pixGetColormap(pix1);
407 cmap2 = pixGetColormap(pix2);
408 if (!cmap1 || !cmap2) {
409 L_INFO(
"both images don't have colormap\n", procName);
413 if (d != 1 && d != 2 && d != 4 && d != 8) {
414 L_INFO(
"pix depth not in {1, 2, 4, 8}\n", procName);
419 if (samecmaps == TRUE) {
421 wpl1 = pixGetWpl(pix1);
422 wpl2 = pixGetWpl(pix2);
425 fullwords = linebits / 32;
426 endbits = linebits & 31;
427 endmask = (endbits == 0) ? 0 : (0xffffffff << (32 - endbits));
428 for (i = 0; i < h; i++) {
429 line1 = data1 + wpl1 * i;
430 line2 = data2 + wpl2 * i;
431 for (j = 0; j < fullwords; j++) {
438 if ((*line1 ^ *line2) & endmask)
447 for (i = 0; i < h; i++) {
448 for (j = 0; j < w; j++) {
453 if (rval1 != rval2 || gval1 != gval2 || bval1 != bval2)
485 l_int32 n1, n2, i, rval1, rval2, gval1, gval2, bval1, bval2, aval1, aval2;
487 PROCNAME(
"cmapEqual");
490 return ERROR_INT(
"&same not defined", procName, 1);
493 return ERROR_INT(
"cmap1 not defined", procName, 1);
495 return ERROR_INT(
"cmap2 not defined", procName, 1);
496 if (ncomps != 3 && ncomps != 4)
497 return ERROR_INT(
"ncomps not 3 or 4", procName, 1);
502 L_INFO(
"colormap sizes are different\n", procName);
506 for (i = 0; i < n1; i++) {
509 if (rval1 != rval2 || gval1 != gval2 || bval1 != bval2)
511 if (ncomps == 4 && aval1 != aval2)
541 l_int32 n, i, rval, gval, bval, numpix;
545 PROCNAME(
"pixUsesCmapColor");
548 return ERROR_INT(
"&color not defined", procName, 1);
551 return ERROR_INT(
"pixs not defined", procName, 1);
553 if ((cmap = pixGetColormap(pixs)) == NULL)
563 for (i = 0; i < n; i++) {
566 if ((rval != gval || rval != bval) && numpix) {
608 l_int32 count1, count2, countn;
612 PROCNAME(
"pixCorrelationBinary");
615 return ERROR_INT(
"&pval not defined", procName, 1);
618 return ERROR_INT(
"pix1 not defined", procName, 1);
620 return ERROR_INT(
"pix2 not defined", procName, 1);
625 if (count1 == 0 || count2 == 0) {
629 pixn =
pixAnd(NULL, pix1, pix2);
631 *pval = (l_float32)countn * (l_float32)countn /
632 ((l_float32)count1 * (l_float32)count2);
665 l_int32 w1, h1, d1, w2, h2, d2, minw, minh;
669 PROCNAME(
"pixDisplayDiffBinary");
672 return (
PIX *)ERROR_PTR(
"pix1, pix2 not both defined", procName, NULL);
675 if (d1 != 1 || d2 != 1)
676 return (
PIX *)ERROR_PTR(
"pix1 and pix2 not 1 bpp", procName, NULL);
677 minw = L_MIN(w1, w2);
678 minh = L_MIN(h1, h2);
688 pixt =
pixAnd(NULL, pix1, pix2);
728 PROCNAME(
"pixCompareBinary");
730 if (ppixdiff) *ppixdiff = NULL;
732 return ERROR_INT(
"&pfract not defined", procName, 1);
734 if (!pix1 || pixGetDepth(pix1) != 1)
735 return ERROR_INT(
"pix1 not defined or not 1 bpp", procName, 1);
736 if (!pix2 || pixGetDepth(pix2) != 1)
737 return ERROR_INT(
"pix2 not defined or not 1 bpp", procName, 1);
738 if (comptype != L_COMPARE_XOR && comptype != L_COMPARE_SUBTRACT)
739 return ERROR_INT(
"invalid comptype", procName, 1);
741 if (comptype == L_COMPARE_XOR)
742 pixt =
pixXor(NULL, pix1, pix2);
747 *pfract = (l_float32)(count) / (l_float32)(w * h);
808 l_int32 retval, d1, d2;
809 PIX *pixt1, *pixt2, *pixs1, *pixs2;
811 PROCNAME(
"pixCompareGrayOrRGB");
813 if (psame) *psame = 0;
814 if (pdiff) *pdiff = 255.0;
815 if (prmsdiff) *prmsdiff = 255.0;
816 if (ppixdiff) *ppixdiff = NULL;
817 if (!pix1 || pixGetDepth(pix1) == 1)
818 return ERROR_INT(
"pix1 not defined or 1 bpp", procName, 1);
819 if (!pix2 || pixGetDepth(pix2) == 1)
820 return ERROR_INT(
"pix2 not defined or 1 bpp", procName, 1);
821 if (comptype != L_COMPARE_SUBTRACT && comptype != L_COMPARE_ABS_DIFF)
822 return ERROR_INT(
"invalid comptype", procName, 1);
823 if (plottype < 0 || plottype >= NUM_GPLOT_OUTPUTS)
824 return ERROR_INT(
"invalid plottype", procName, 1);
828 d1 = pixGetDepth(pixt1);
829 d2 = pixGetDepth(pixt2);
840 d1 = pixGetDepth(pixs1);
841 d2 = pixGetDepth(pixs2);
845 return ERROR_INT(
"intrinsic depths are not equal", procName, 1);
848 if (d1 == 8 || d1 == 16)
850 pdiff, prmsdiff, ppixdiff);
852 retval =
pixCompareRGB(pixs1, pixs2, comptype, plottype, psame,
853 pdiff, prmsdiff, ppixdiff);
892 static l_int32 index = 0;
893 l_int32 d1, d2, same, first, last;
898 PROCNAME(
"pixCompareGray");
900 if (psame) *psame = 0;
901 if (pdiff) *pdiff = 255.0;
902 if (prmsdiff) *prmsdiff = 255.0;
903 if (ppixdiff) *ppixdiff = NULL;
905 return ERROR_INT(
"pix1 not defined", procName, 1);
907 return ERROR_INT(
"pix2 not defined", procName, 1);
908 d1 = pixGetDepth(pix1);
909 d2 = pixGetDepth(pix2);
910 if ((d1 != d2) || (d1 != 8 && d1 != 16))
911 return ERROR_INT(
"depths unequal or not 8 or 16 bpp", procName, 1);
912 if (pixGetColormap(pix1) || pixGetColormap(pix2))
913 return ERROR_INT(
"pix1 and/or pix2 are colormapped", procName, 1);
914 if (comptype != L_COMPARE_SUBTRACT && comptype != L_COMPARE_ABS_DIFF)
915 return ERROR_INT(
"invalid comptype", procName, 1);
916 if (plottype < 0 || plottype >= NUM_GPLOT_OUTPUTS)
917 return ERROR_INT(
"invalid plottype", procName, 1);
921 if (comptype == L_COMPARE_SUBTRACT)
928 L_INFO(
"Images are pixel-wise identical\n", procName);
929 if (psame) *psame = same;
935 if (plottype && !same) {
936 L_INFO(
"Images differ: output plots will be generated\n", procName);
940 snprintf(buf,
sizeof(buf),
"/tmp/lept/comp/compare_gray%d", index);
942 "Pixel Difference Histogram",
"diff val",
947 snprintf(buf,
sizeof(buf),
"/tmp/lept/comp/compare_gray%d.png",
949 l_fileDisplay(buf, 100, 100, 1.0);
955 *ppixdiff =
pixCopy(NULL, pixt);
958 if (comptype == L_COMPARE_SUBTRACT) {
1001 static l_int32 index = 0;
1002 l_int32 rsame, gsame, bsame, same, first, rlast, glast, blast, last;
1003 l_float32 rdiff, gdiff, bdiff;
1005 NUMA *nar, *nag, *nab, *narc, *nagc, *nabc;
1006 PIX *pixr1, *pixr2, *pixg1, *pixg2, *pixb1, *pixb2;
1007 PIX *pixr, *pixg, *pixb;
1009 PROCNAME(
"pixCompareRGB");
1011 if (psame) *psame = 0;
1012 if (pdiff) *pdiff = 0.0;
1013 if (prmsdiff) *prmsdiff = 0.0;
1014 if (ppixdiff) *ppixdiff = NULL;
1015 if (!pix1 || pixGetDepth(pix1) != 32)
1016 return ERROR_INT(
"pix1 not defined or not 32 bpp", procName, 1);
1017 if (!pix2 || pixGetDepth(pix2) != 32)
1018 return ERROR_INT(
"pix2 not defined or not ew bpp", procName, 1);
1019 if (comptype != L_COMPARE_SUBTRACT && comptype != L_COMPARE_ABS_DIFF)
1020 return ERROR_INT(
"invalid comptype", procName, 1);
1021 if (plottype < 0 || plottype >= NUM_GPLOT_OUTPUTS)
1022 return ERROR_INT(
"invalid plottype", procName, 1);
1032 if (comptype == L_COMPARE_SUBTRACT) {
1045 same = rsame && gsame && bsame;
1047 L_INFO(
"Images are pixel-wise identical\n", procName);
1048 if (psame) *psame = same;
1054 *pdiff = (rdiff + gdiff + bdiff) / 3.0;
1058 if (plottype && !same) {
1059 L_INFO(
"Images differ: output plots will be generated\n", procName);
1066 last = L_MAX(rlast, glast);
1067 last = L_MAX(last, blast);
1071 snprintf(buf,
sizeof(buf),
"/tmp/lept/comp/compare_rgb%d", index);
1073 "Pixel Difference Histogram",
"diff val",
1074 "number of pixels");
1080 snprintf(buf,
sizeof(buf),
"/tmp/lept/comp/compare_rgb%d.png",
1082 l_fileDisplay(buf, 100, 100, 1.0);
1095 if (comptype == L_COMPARE_SUBTRACT) {
1106 *prmsdiff = (rdiff + gdiff + bdiff) / 3.0;
1154 l_int32 d1, d2, w, h;
1155 PIX *pixt, *pixr, *pixg, *pixb;
1156 PIX *pixrdiff, *pixgdiff, *pixbdiff;
1159 PROCNAME(
"pixCompareTiled");
1162 return ERROR_INT(
"&pixdiff not defined", procName, 1);
1165 return ERROR_INT(
"pix1 not defined", procName, 1);
1167 return ERROR_INT(
"pix2 not defined", procName, 1);
1168 d1 = pixGetDepth(pix1);
1169 d2 = pixGetDepth(pix2);
1171 return ERROR_INT(
"depths not equal", procName, 1);
1172 if (d1 != 8 && d1 != 32)
1173 return ERROR_INT(
"pix1 not 8 or 32 bpp", procName, 1);
1174 if (d2 != 8 && d2 != 32)
1175 return ERROR_INT(
"pix2 not 8 or 32 bpp", procName, 1);
1176 if (sx < 2 || sy < 2)
1177 return ERROR_INT(
"sx and sy not both > 1", procName, 1);
1179 return ERROR_INT(
"invalid type", procName, 1);
1246 l_float32 *array1, *array2;
1247 NUMA *nah, *nan, *nad;
1249 PROCNAME(
"pixCompareRankDifference");
1252 return (
NUMA *)ERROR_PTR(
"pix1 not defined", procName, NULL);
1254 return (
NUMA *)ERROR_PTR(
"pix2 not defined", procName, NULL);
1257 return (
NUMA *)ERROR_PTR(
"na not made", procName, NULL);
1268 for (i = 1; i < 256; i++)
1269 array2[i] = array2[i - 1] - array1[i - 1];
1335 l_float32 fractdiff, avediff;
1337 PROCNAME(
"pixTestForSimilarity");
1340 return ERROR_INT(
"&similar not defined", procName, 1);
1343 return ERROR_INT(
"pix1 not defined", procName, 1);
1345 return ERROR_INT(
"pix2 not defined", procName, 1);
1347 return ERROR_INT(
"pix sizes not equal", procName, 1);
1349 return ERROR_INT(
"mindiff must be > 0", procName, 1);
1352 &fractdiff, &avediff, details))
1353 return ERROR_INT(
"diff stats not found", procName, 1);
1355 if (maxave <= 0.0) maxave = 256.0;
1356 if (fractdiff <= maxfract && avediff <= maxave)
1409 l_float32 *pfractdiff,
1410 l_float32 *pavediff,
1413 l_int32 i, first, last, diff;
1414 l_float32 fract, ave;
1416 NUMA *nah, *nan, *nac;
1418 PROCNAME(
"pixGetDifferenceStats");
1420 if (pfractdiff) *pfractdiff = 0.0;
1421 if (pavediff) *pavediff = 0.0;
1423 return ERROR_INT(
"&fractdiff not defined", procName, 1);
1425 return ERROR_INT(
"&avediff not defined", procName, 1);
1427 return ERROR_INT(
"pix1 not defined", procName, 1);
1429 return ERROR_INT(
"pix2 not defined", procName, 1);
1431 return ERROR_INT(
"mindiff must be > 0", procName, 1);
1434 return ERROR_INT(
"na not made", procName, 1);
1438 return ERROR_INT(
"nan not made", procName, 1);
1447 "Difference histogram");
1448 l_fileDisplay(
"/tmp/lept/comp/histo.png", 500, 0, 1.0);
1449 lept_stderr(
"\nNonzero values in normalized histogram:");
1453 lept_stderr(
" -----------------------------------\n");
1454 for (diff = 1; diff < L_MIN(2 * mindiff, last); diff++) {
1457 for (i = diff; i <= last; i++) {
1459 ave += (l_float32)i * array[i];
1461 ave = (fract == 0.0) ? 0.0 : ave / fract;
1466 lept_stderr(
" -----------------------------------\n");
1471 for (i = mindiff; i < 256; i++) {
1473 ave += (l_float32)i * array[i];
1475 ave = (fract == 0.0) ? 0.0 : ave / fract;
1478 *pfractdiff = fract;
1511 l_int32 w1, h1, d1, w2, h2, d2, w, h, wpl1, wpl2;
1512 l_int32 i, j, val, val1, val2;
1513 l_int32 rval1, rval2, gval1, gval2, bval1, bval2;
1514 l_int32 rdiff, gdiff, bdiff, maxdiff;
1515 l_uint32 *data1, *data2, *line1, *line2;
1520 PROCNAME(
"pixGetDifferenceHistogram");
1523 return (
NUMA *)ERROR_PTR(
"pix1 not defined", procName, NULL);
1525 return (
NUMA *)ERROR_PTR(
"pix2 not defined", procName, NULL);
1526 d1 = pixGetDepth(pix1);
1527 d2 = pixGetDepth(pix2);
1528 if (d1 == 16 || d2 == 16)
1529 return (
NUMA *)ERROR_PTR(
"d == 16 not supported", procName, NULL);
1530 if (d1 < 8 && !pixGetColormap(pix1))
1531 return (
NUMA *)ERROR_PTR(
"pix1 depth < 8 bpp and not cmapped",
1533 if (d2 < 8 && !pixGetColormap(pix2))
1534 return (
NUMA *)ERROR_PTR(
"pix2 depth < 8 bpp and not cmapped",
1543 return (
NUMA *)ERROR_PTR(
"pix depths not equal", procName, NULL);
1545 if (factor < 1) factor = 1;
1554 wpl1 = pixGetWpl(pixt1);
1555 wpl2 = pixGetWpl(pixt2);
1557 for (i = 0; i < h; i += factor) {
1558 line1 = data1 + i * wpl1;
1559 line2 = data2 + i * wpl2;
1560 for (j = 0; j < w; j += factor) {
1563 val = L_ABS(val1 - val2);
1568 for (i = 0; i < h; i += factor) {
1569 line1 = data1 + i * wpl1;
1570 line2 = data2 + i * wpl2;
1571 for (j = 0; j < w; j += factor) {
1574 rdiff = L_ABS(rval1 - rval2);
1575 gdiff = L_ABS(gval1 - gval2);
1576 bdiff = L_ABS(bval1 - bval2);
1577 maxdiff = L_MAX(rdiff, gdiff);
1578 maxdiff = L_MAX(maxdiff, bdiff);
1647 l_int32 d1, d2, w, h, count;
1648 PIX *pix1, *pix2, *pix3, *pix4, *pix5, *pix6, *pix7, *pix8, *pix9;
1651 PROCNAME(
"pixGetPerceptualDiff");
1653 if (ppixdiff1) *ppixdiff1 = NULL;
1654 if (ppixdiff2) *ppixdiff2 = NULL;
1656 return ERROR_INT(
"&fract not defined", procName, 1);
1658 if ((dilation & 1) == 0)
1659 return ERROR_INT(
"dilation must be odd", procName, 1);
1661 return ERROR_INT(
"pixs1 not defined", procName, 1);
1663 return ERROR_INT(
"pixs2 not defined", procName, 1);
1664 d1 = pixGetDepth(pixs1);
1665 d2 = pixGetDepth(pixs2);
1666 if (!pixGetColormap(pixs1) && d1 < 8)
1667 return ERROR_INT(
"pixs1 not cmapped and < 8 bpp", procName, 1);
1668 if (!pixGetColormap(pixs2) && d2 < 8)
1669 return ERROR_INT(
"pixs2 not cmapped and < 8 bpp", procName, 1);
1681 if (pixGetColormap(pix1)) {
1683 d1 = pixGetDepth(pix3);
1687 if (pixGetColormap(pix2)) {
1689 d2 = pixGetDepth(pix4);
1695 if (d1 != d2 || (d1 != 8 && d1 != 32)) {
1698 L_INFO(
"depths unequal or not in {8,32}: d1 = %d, d2 = %d\n",
1713 pixCompareGray(pix4, pix5, L_COMPARE_SUBTRACT, 0, NULL, NULL, NULL,
1716 pixCompareGray(pix3, pix6, L_COMPARE_SUBTRACT, 0, NULL, NULL, NULL,
1718 pix9 =
pixMinOrMax(NULL, pix7, pix8, L_CHOOSE_MAX);
1723 *pfract = (w <= 0 || h <= 0) ? 0.0 :
1724 (l_float32)count / (l_float32)(w * h);
1738 pix5 =
pixColorMorph(pix3, L_MORPH_DILATE, dilation, dilation);
1739 pixCompareRGB(pix4, pix5, L_COMPARE_SUBTRACT, 0, NULL, NULL, NULL,
1741 pix6 =
pixColorMorph(pix4, L_MORPH_DILATE, dilation, dilation);
1742 pixCompareRGB(pix3, pix6, L_COMPARE_SUBTRACT, 0, NULL, NULL, NULL,
1744 pix9 =
pixMinOrMax(NULL, pix7, pix8, L_CHOOSE_MAX);
1750 *pfract = (w <= 0 || h <= 0) ? 0.0 :
1751 (l_float32)count / (l_float32)(w * h);
1810 l_int32 same, i, j, w, h, d, wpl1, wpl2, v1, v2, r1, g1, b1, r2, g2, b2;
1811 l_uint32 *data1, *data2, *line1, *line2;
1814 PROCNAME(
"pixGetPSNR");
1817 return ERROR_INT(
"&psnr not defined", procName, 1);
1820 return ERROR_INT(
"empty input pix", procName, 1);
1822 return ERROR_INT(
"pix sizes unequal", procName, 1);
1823 if (pixGetColormap(pix1))
1824 return ERROR_INT(
"pix1 has colormap", procName, 1);
1825 if (pixGetColormap(pix2))
1826 return ERROR_INT(
"pix2 has colormap", procName, 1);
1828 if (d != 8 && d != 32)
1829 return ERROR_INT(
"pix not 8 or 32 bpp", procName, 1);
1831 return ERROR_INT(
"invalid sampling factor", procName, 1);
1841 wpl1 = pixGetWpl(pix1);
1842 wpl2 = pixGetWpl(pix2);
1845 for (i = 0; i < h; i += factor) {
1846 line1 = data1 + i * wpl1;
1847 line2 = data2 + i * wpl2;
1848 for (j = 0; j < w; j += factor) {
1851 mse += (l_float32)(v1 - v2) * (v1 - v2);
1855 for (i = 0; i < h; i += factor) {
1856 line1 = data1 + i * wpl1;
1857 line2 = data2 + i * wpl2;
1858 for (j = 0; j < w; j += factor) {
1861 mse += ((l_float32)(r1 - r2) * (r1 - r2) +
1862 (g1 - g2) * (g1 - g2) +
1863 (b1 - b2) * (b1 - b2)) / 3.0;
1867 mse = mse / ((l_float32)(w) * h);
1869 *ppsnr = -4.3429448 * log(mse / (255 * 255));
1932 l_float32 textthresh,
1935 l_float32 simthresh,
1937 l_float32 **pscores,
1942 l_int32 i, j, nim, w, h, w1, h1, w2, h2, ival, index, classid;
1945 NUMA *nai, *naw, *nah;
1950 PROCNAME(
"pixaComparePhotoRegionsByHisto");
1952 if (pscores) *pscores = NULL;
1953 if (ppixd) *ppixd = NULL;
1955 return ERROR_INT(
"&na not defined", procName, 1);
1958 return ERROR_INT(
"pixa not defined", procName, 1);
1959 if (minratio < 0.0 || minratio > 1.0)
1960 return ERROR_INT(
"minratio not in [0.0 ... 1.0]", procName, 1);
1961 if (textthresh <= 0.0) textthresh = 1.3;
1963 return ERROR_INT(
"subsampling factor must be >= 1", procName, 1);
1964 if (n < 1 || n > 7) {
1965 L_WARNING(
"n = %d is invalid; setting to 4\n", procName, n);
1968 if (simthresh <= 0.0) simthresh = 0.25;
1969 if (simthresh > 1.0)
1970 return ERROR_INT(
"simthresh invalid; should be near 0.25", procName, 1);
1974 if ((n3a = (
NUMAA **)LEPT_CALLOC(nim,
sizeof(
NUMAA *))) == NULL)
1975 return ERROR_INT(
"calloc fail for n3a", procName, 1);
1978 for (i = 0; i < nim; i++) {
1982 index = (debug) ? i : 0;
1984 &naa, &w, &h, index);
2002 (l_float32 *)LEPT_CALLOC((
size_t)nim * nim,
sizeof(l_float32)))
2004 L_ERROR(
"calloc fail for scores\n", procName);
2008 for (i = 0, classid = 0; i < nim; i++) {
2009 scores[nim * i + i] = 1.0;
2014 if (n3a[i] == NULL) {
2020 for (j = i + 1; j < nim; j++) {
2030 scores[nim * i + j] = score;
2031 scores[nim * j + i] = score;
2033 if (score > simthresh) {
2036 "Setting %d similar to %d, in class %d; score %5.3f\n",
2037 j, i, classid, score);
2052 l_uint32 *line, *data;
2056 wpl = pixGetWpl(pix2);
2057 for (i = 0; i < nim; i++) {
2058 line = data + i * wpl;
2059 for (j = 0; j < nim; j++) {
2061 L_MIN(255, 4.0 * 255 * scores[nim * i + j]));
2064 fact = L_MAX(2, 1000 / nim);
2066 lept_stderr(
"Writing to /tmp/lept/comp/scorearray.png\n");
2068 pixWrite(
"/tmp/lept/comp/scorearray.png", pix3, IFF_PNG);
2085 for (i = 0; i < nim; i++)
2162 l_int32 w1, h1, w2, h2, w1c, h1c, w2c, h2c, debugindex;
2163 l_float32 wratio, hratio;
2168 PROCNAME(
"pixComparePhotoRegionsByHisto");
2171 return ERROR_INT(
"&score not defined", procName, 1);
2174 return ERROR_INT(
"pix1 and pix2 not both defined", procName, 1);
2175 if (minratio < 0.5 || minratio > 1.0)
2176 return ERROR_INT(
"minratio not in [0.5 ... 1.0]", procName, 1);
2178 return ERROR_INT(
"subsampling factor must be >= 1", procName, 1);
2179 if (n < 1 || n > 7) {
2180 L_WARNING(
"n = %d is invalid; setting to 4\n", procName, n);
2199 wratio = (w1 < w2) ? (l_float32)w1 / (l_float32)w2 :
2200 (l_float32)w2 / (l_float32)w1;
2201 hratio = (h1 < h2) ? (l_float32)h1 / (l_float32)h2 :
2202 (l_float32)h2 / (l_float32)h1;
2203 if (wratio < minratio || hratio < minratio)
2213 if (!naa1)
return 0;
2220 if (!naa2)
return 0;
2281 PIX *pix1, *pix2, *pix3, *pixm;
2284 PROCNAME(
"pixGenPhotoHistos");
2286 if (pnaa) *pnaa = NULL;
2290 return ERROR_INT(
"&naa not defined", procName, 1);
2292 return ERROR_INT(
"&w and &h not both defined", procName, 1);
2293 if (!pixs || pixGetDepth(pixs) == 1)
2294 return ERROR_INT(
"pixs not defined or 1 bpp", procName, 1);
2296 return ERROR_INT(
"subsampling factor must be >= 1", procName, 1);
2297 if (thresh <= 0.0) thresh = 1.3;
2298 if (n < 1 || n > 7) {
2299 L_WARNING(
"n = %d is invalid; setting to 4\n", procName, n);
2304 if (debugindex > 0) {
2326 if (debugindex > 0) {
2327 PIX *pix4, *pix5, *pix6, *pix7, *pix8;
2349 *pw = pixGetWidth(pix3);
2350 *ph = pixGetHeight(pix3);
2354 snprintf(buf,
sizeof(buf),
"/tmp/lept/comp/tiledhistos.%d.pdf",
2387 l_int32 xs, ys, delx, dely, icx, icy, ws, hs, wd, hd;
2390 PROCNAME(
"pixPadToCenterCentroid");
2393 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
2395 return (
PIX *)ERROR_PTR(
"invalid sampling factor", procName, NULL);
2399 icx = (l_int32)(cx + 0.5);
2400 icy = (l_int32)(cy + 0.5);
2402 delx = ws - 2 * icx;
2403 dely = hs - 2 * icy;
2404 xs = L_MAX(0, delx);
2405 ys = L_MAX(0, dely);
2406 wd = 2 * L_MAX(icx, ws - icx);
2407 hd = 2 * L_MAX(icy, hs - icy);
2410 pixCopyResolution(pixd, pixs);
2441 l_int32 i, j, w, h, wpl, val;
2442 l_float32 sumx, sumy, sumv;
2443 l_uint32 *data, *line;
2446 PROCNAME(
"pixCentroid8");
2448 if (pcx) *pcx = 0.0;
2449 if (pcy) *pcy = 0.0;
2450 if (!pixs || pixGetDepth(pixs) != 8)
2451 return ERROR_INT(
"pixs undefined or not 8 bpp", procName, 1);
2453 return ERROR_INT(
"subsampling factor must be >= 1", procName, 1);
2455 return ERROR_INT(
"&cx and &cy not both defined", procName, 1);
2460 wpl = pixGetWpl(pix1);
2461 sumx = sumy = sumv = 0.0;
2462 for (i = 0; i < h; i++) {
2463 line = data + i * wpl;
2464 for (j = 0; j < w; j++) {
2474 L_INFO(
"input image is white\n", procName);
2475 *pcx = (l_float32)(w) / 2;
2476 *pcy = (l_float32)(h) / 2;
2530 l_int32 i, w, h, nx, ny, ngrids, istext, isphoto;
2531 l_float32 maxval, sum1, sum2, ratio;
2533 NUMA *na1, *na2, *na3, *narv;
2536 PIXA *pixa1, *pixa2, *pixa3;
2538 PROCNAME(
"pixDecideIfPhotoImage");
2541 return ERROR_INT(
"&naa not defined", procName, 1);
2543 if (!pix || pixGetDepth(pix) != 8 || pixGetColormap(pix))
2544 return ERROR_INT(
"pix undefined or invalid", procName, 1);
2545 if (n < 1 || n > 7) {
2546 L_WARNING(
"n = %d is invalid; setting to 4\n", procName, n);
2549 if (thresh <= 0.0) thresh = 1.3;
2554 L_INFO(
"Image is text\n", procName);
2560 if (w == 0 || h == 0)
2561 return ERROR_INT(
"invalid pix dimension", procName, 1);
2567 bmf = (pixadebug) ?
bmfCreate(NULL, 6) : NULL;
2573 for (i = 0; i < ngrids; i++) {
2583 snprintf(buf,
sizeof(buf),
"/tmp/lept/compplot/plot.%d", i);
2619 ratio = sum1 / sum2;
2620 isphoto = (ratio > thresh) ? 1 : 0;
2624 L_INFO(
"ratio %f > %f; isphoto is true\n",
2625 procName, ratio, thresh);
2627 L_INFO(
"ratio %f < %f; isphoto is false\n",
2628 procName, ratio, thresh);
2674 l_int32 nx, ny, max;
2677 ratio = (l_float32)w / (l_float32)h;
2680 while (nx > 1 && ny > 1) {
2685 lept_stderr(
"nx = %d, ny = %d, ratio w/h = %4.2f\n",
2687 }
else if (ratio < 0.5) {
2691 lept_stderr(
"nx = %d, ny = %d, ratio w/h = %4.2f\n",
2695 lept_stderr(
"nx = %d, ny = %d, ratio w/h = %4.2f\n",
2699 ratio = (l_float32)(ny * w) / (l_float32)(nx * h);
2740 char buf1[128], buf2[128];
2742 l_float32 wratio, hratio, score, minscore, dist;
2744 NUMA *na1, *na2, *nadist, *nascore;
2746 PROCNAME(
"compareTilesByHisto");
2749 return ERROR_INT(
"&score not defined", procName, 1);
2752 return ERROR_INT(
"naa1 and naa2 not both defined", procName, 1);
2755 wratio = (w1 < w2) ? (l_float32)w1 / (l_float32)w2 :
2756 (l_float32)w2 / (l_float32)w1;
2757 hratio = (h1 < h2) ? (l_float32)h1 / (l_float32)h2 :
2758 (l_float32)h2 / (l_float32)h1;
2759 if (wratio < minratio || hratio < minratio) {
2761 L_INFO(
"Sizes differ: wratio = %f, hratio = %f\n",
2762 procName, wratio, hratio);
2767 L_INFO(
"naa1 and naa2 sizes are different\n", procName);
2784 bmf = (pixadebug) ?
bmfCreate(NULL, 6) : NULL;
2785 for (i = 0; i < n; i++) {
2796 score = L_MAX(0.0, 1.0 - 10.0 * (dist / 255.));
2799 minscore = L_MIN(minscore, score);
2801 snprintf(buf1,
sizeof(buf1),
"/tmp/lept/comptile/plot.%d", i);
2810 for (i = 0; i < n; i++) {
2812 snprintf(buf1,
sizeof(buf1),
"/tmp/lept/comptile/plot.%d.png", i);
2816 snprintf(buf2,
sizeof(buf2),
2817 "Image %d\ndist = %5.3f, score = %5.3f", i, dist, score);
2822 lept_stderr(
"Writing to /tmp/lept/comptile/comparegray.pdf\n");
2824 "/tmp/lept/comptile/comparegray.pdf");
2919 l_int32 w1, h1, w2, h2;
2920 l_float32 wratio, hratio;
2922 PIX *pix3, *pix4, *pix5, *pix6, *pix7, *pix8;
2925 PROCNAME(
"pixCompareGrayByHisto");
2928 return ERROR_INT(
"&score not defined", procName, 1);
2931 return ERROR_INT(
"pix1 and pix2 not both defined", procName, 1);
2932 if (minratio < 0.5 || minratio > 1.0)
2933 return ERROR_INT(
"minratio not in [0.5 ... 1.0]", procName, 1);
2935 return ERROR_INT(
"invalid maxgray; should be >= 200", procName, 1);
2936 maxgray = L_MIN(255, maxgray);
2938 return ERROR_INT(
"subsampling factor must be >= 1", procName, 1);
2939 if (n < 1 || n > 7) {
2940 L_WARNING(
"n = %d is invalid; setting to 4\n", procName, n);
2956 wratio = (w1 < w2) ? (l_float32)w1 / (l_float32)w2 :
2957 (l_float32)w2 / (l_float32)w1;
2958 hratio = (h1 < h2) ? (l_float32)h1 / (l_float32)h2 :
2959 (l_float32)h2 / (l_float32)h1;
2960 if (wratio < minratio || hratio < minratio)
2981 PIX *pix9, *pix10, *pix11, *pix12, *pix13;
3044 l_int32 w, h, i, j, nx, ny, ngr;
3045 l_float32 score, minscore, maxval1, maxval2, dist;
3047 NUMA *na1, *na2, *na3, *na4, *na5, *na6, *na7;
3049 PIXA *pixa1, *pixa2;
3051 PROCNAME(
"pixCompareTilesByHisto");
3054 return ERROR_INT(
"&score not defined", procName, 1);
3057 return ERROR_INT(
"pix1 and pix2 not both defined", procName, 1);
3068 bmf = (pixadebug) ?
bmfCreate(NULL, 6) : NULL;
3070 for (i = 0; i < ngr; i++) {
3077 if (maxgray < 255) {
3078 for (j = maxgray + 1; j <= 255; j++) {
3090 gplotSimple2(na5, na6, GPLOT_PNG,
"/tmp/lept/comp/plot1",
"Histos");
3098 score = L_MAX(0.0, 1.0 - 8.0 * (dist / 255.));
3100 minscore = L_MIN(minscore, score);
3102 PIX *pix5, *pix6, *pix7, *pix8, *pix9, *pix10;
3104 l_int32 w, h, wscale;
3107 wscale = (w > h) ? 700 : 400;
3112 pix7 =
pixRead(
"/tmp/lept/comp/plot1.png");
3114 snprintf(buf,
sizeof(buf),
"%5.3f", score);
3136 "/tmp/lept/comp/comparegray.pdf");
3171 l_float32 cx1, cy1, cx2, cy2;
3172 l_int32 w1, h1, w2, h2, icx1, icy1, icx2, icy2;
3173 l_int32 xm, xm1, xm2, xp, xp1, xp2, ym, ym1, ym2, yp, yp1, yp2;
3176 PROCNAME(
"pixCropAlignedToCentroid");
3178 if (pbox1) *pbox1 = NULL;
3179 if (pbox2) *pbox2 = NULL;
3181 return ERROR_INT(
"pix1 and pix2 not both defined", procName, 1);
3183 return ERROR_INT(
"subsampling factor must be >= 1", procName, 1);
3184 if (!pbox1 || !pbox2)
3185 return ERROR_INT(
"&box1 and &box2 not both defined", procName, 1);
3196 icx1 = (l_int32)(cx1 + 0.5);
3197 icy1 = (l_int32)(cy1 + 0.5);
3198 icx2 = (l_int32)(cx2 + 0.5);
3199 icy2 = (l_int32)(cy2 + 0.5);
3200 xm = L_MIN(icx1, icx2);
3203 xp = L_MIN(w1 - icx1, w2 - icx2);
3206 ym = L_MIN(icy1, icy2);
3209 yp = L_MIN(h1 - icy1, h2 - icy2);
3212 *pbox1 =
boxCreate(xm1, ym1, xp1 - xm1, yp1 - ym1);
3213 *pbox2 =
boxCreate(xm2, ym2, xp2 - xm2, yp2 - ym2);
3246 l_int32 i, j, n, nn, ival;
3250 PROCNAME(
"l_compressGrayHistograms");
3253 return (l_uint8 *)ERROR_PTR(
"&size not defined", procName, NULL);
3256 return (l_uint8 *)ERROR_PTR(
"naa not defined", procName, NULL);
3258 for (i = 0; i < n; i++) {
3261 L_ERROR(
"%d numbers in numa[%d]\n", procName, nn, i);
3266 if ((bytea = (l_uint8 *)LEPT_CALLOC(8 + 256 * n,
sizeof(l_uint8))) == NULL)
3267 return (l_uint8 *)ERROR_PTR(
"bytea not made", procName, NULL);
3268 *psize = 8 + 256 * n;
3271 for (i = 0; i < n; i++) {
3275 for (j = 0; j < 256; j++) {
3277 bytea[8 + 256 * i + j] = ival;
3317 PROCNAME(
"l_uncompressGrayHistograms");
3322 return (
NUMAA *)ERROR_PTR(
"&w and &h not both defined", procName, NULL);
3324 return (
NUMAA *)ERROR_PTR(
"bytea not defined", procName, NULL);
3325 n = (size - 8) / 256;
3326 if ((size - 8) % 256 != 0)
3327 return (
NUMAA *)ERROR_PTR(
"bytea size is invalid", procName, NULL);
3332 for (i = 0; i < n; i++) {
3334 for (j = 0; j < 256; j++)
3386 l_int32 i, level, area1, area2, delx, dely;
3387 l_int32 etransx, etransy, maxshift, dbint;
3388 l_int32 *stab, *ctab;
3389 l_float32 cx1, cx2, cy1, cy2, score;
3390 PIX *pixb1, *pixb2, *pixt1, *pixt2, *pixt3, *pixt4;
3391 PIXA *pixa1, *pixa2, *pixadb;
3393 PROCNAME(
"pixCompareWithTranslation");
3395 if (pdelx) *pdelx = 0;
3396 if (pdely) *pdely = 0;
3397 if (pscore) *pscore = 0.0;
3398 if (!pdelx || !pdely)
3399 return ERROR_INT(
"&delx and &dely not defined", procName, 1);
3401 return ERROR_INT(
"&score not defined", procName, 1);
3403 return ERROR_INT(
"pix1 not defined", procName, 1);
3405 return ERROR_INT(
"pix2 not defined", procName, 1);
3424 for (i = 0; i < 3; i++) {
3437 for (level = 3; level >= 0; level--) {
3453 dbint = (debugflag) ? level + 1 : 0;
3455 maxshift, stab, &delx, &dely, &score, dbint);
3457 lept_stderr(
"Level %d: delx = %d, dely = %d, score = %7.4f\n",
3458 level, delx, dely, score);
3471 "/tmp/lept/comp/compare.pdf");
3473 0,
"Correlation scores at levels 1 through 5",
3474 "/tmp/lept/comp/correl.pdf");
3544 l_int32 shiftx, shifty, delx, dely;
3546 l_float32 maxscore, score;
3550 PROCNAME(
"pixBestCorrelation");
3552 if (pdelx) *pdelx = 0;
3553 if (pdely) *pdely = 0;
3554 if (pscore) *pscore = 0.0;
3555 if (!pix1 || pixGetDepth(pix1) != 1)
3556 return ERROR_INT(
"pix1 not defined or not 1 bpp", procName, 1);
3557 if (!pix2 || pixGetDepth(pix2) != 1)
3558 return ERROR_INT(
"pix2 not defined or not 1 bpp", procName, 1);
3559 if (!area1 || !area2)
3560 return ERROR_INT(
"areas must be > 0", procName, 1);
3563 fpix =
fpixCreate(2 * maxshift + 1, 2 * maxshift + 1);
3574 for (shifty = -maxshift; shifty <= maxshift; shifty++) {
3575 for (shiftx = -maxshift; shiftx <= maxshift; shiftx++) {
3576 pixCorrelationScoreShifted(pix1, pix2, area1, area2,
3578 etransy + shifty, tab, &score);
3579 if (debugflag > 0) {
3580 fpixSetPixel(fpix, maxshift + shiftx, maxshift + shifty,
3585 if (score > maxscore) {
3587 delx = etransx + shiftx;
3588 dely = etransy + shifty;
3593 if (debugflag > 0) {
3598 snprintf(buf,
sizeof(buf),
"/tmp/lept/comp/correl_%d.png",
3600 pixWrite(buf, pix4, IFF_PNG);
3606 if (pdelx) *pdelx = delx;
3607 if (pdely) *pdely = dely;
3608 if (pscore) *pscore = maxscore;
3609 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()
void boxDestroy(BOX **pbox)
boxDestroy()
l_ok boxGetGeometry(BOX *box, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
boxGetGeometry()
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()