106 #include "allheaders.h" 109 static const l_float32 TINY = 0.00001;
112 l_int32 factor, l_int32 nx, l_int32 ny,
113 l_float32 *pscore,
PIXA *pixadebug);
181 l_int32 w1, h1, d1, w2, h2, d2, wpl1, wpl2;
182 l_int32 spp1, spp2, i, j, color, mismatch, opaque;
183 l_int32 fullwords, linebits, endbits;
184 l_uint32 endmask, wordmask;
185 l_uint32 *data1, *data2, *line1, *line2;
186 PIX *pixs1, *pixs2, *pixt1, *pixt2, *pixalpha;
189 PROCNAME(
"pixEqualWithAlpha");
192 return ERROR_INT(
"psame not defined", procName, 1);
195 return ERROR_INT(
"pix1 and pix2 not both defined", procName, 1);
198 if (w1 != w2 || h1 != h2) {
199 L_INFO(
"pix sizes differ\n", procName);
210 spp1 = pixGetSpp(pix1);
211 spp2 = pixGetSpp(pix2);
213 if (use_alpha && d1 == 32 && d2 == 32) {
214 mismatch = ((spp1 == 4 && spp2 != 4) || (spp1 != 4 && spp2 == 4));
216 pixalpha = (spp1 == 4) ? pix1 : pix2;
219 L_INFO(
"just one pix has a non-opaque alpha layer\n", procName);
225 cmap1 = pixGetColormap(pix1);
226 cmap2 = pixGetColormap(pix2);
227 if (!cmap1 && !cmap2 && (d1 != d2) && (d1 == 32 || d2 == 32)) {
228 L_INFO(
"no colormaps, pix depths unequal, and one of them is RGB\n",
233 if (cmap1 && cmap2 && (d1 == d2))
238 if (cmap1 && !cmap2) {
240 if (color && d2 <= 8)
250 }
else if (!cmap1 && cmap2) {
252 if (color && d1 <= 8)
262 }
else if (cmap1 && cmap2) {
271 d1 = pixGetDepth(pixs1);
272 d2 = pixGetDepth(pixs2);
274 if (d1 == 16 || d2 == 16) {
275 L_INFO(
"one pix is 16 bpp\n", procName);
282 if (!pixt1 || !pixt2) {
283 L_INFO(
"failure to convert to 8 bpp\n", procName);
298 d1 = pixGetDepth(pixt1);
299 d2 = pixGetDepth(pixt2);
300 wpl1 = pixGetWpl(pixt1);
301 wpl2 = pixGetWpl(pixt2);
306 if (use_alpha && !mismatch)
307 wordmask = (spp1 == 3) ? 0xffffff00 : 0xffffffff;
309 wordmask = 0xffffff00;
310 for (i = 0; i < h1; i++) {
311 line1 = data1 + wpl1 * i;
312 line2 = data2 + wpl2 * i;
313 for (j = 0; j < wpl1; j++) {
314 if ((*line1 ^ *line2) & wordmask) {
325 fullwords = linebits / 32;
326 endbits = linebits & 31;
327 endmask = (endbits == 0) ? 0 : (0xffffffff << (32 - endbits));
328 for (i = 0; i < h1; i++) {
329 line1 = data1 + wpl1 * i;
330 line2 = data2 + wpl2 * i;
331 for (j = 0; j < fullwords; j++) {
332 if (*line1 ^ *line2) {
341 if ((*line1 ^ *line2) & endmask) {
382 l_int32 d, w, h, wpl1, wpl2, i, j, linebits, fullwords, endbits;
383 l_int32 rval1, rval2, gval1, gval2, bval1, bval2, samecmaps;
384 l_uint32 endmask, val1, val2;
385 l_uint32 *data1, *data2, *line1, *line2;
388 PROCNAME(
"pixEqualWithCmap");
391 return ERROR_INT(
"&same not defined", procName, 1);
394 return ERROR_INT(
"pix1 not defined", procName, 1);
396 return ERROR_INT(
"pix2 not defined", procName, 1);
400 cmap1 = pixGetColormap(pix1);
401 cmap2 = pixGetColormap(pix2);
402 if (!cmap1 || !cmap2) {
403 L_INFO(
"both images don't have colormap\n", procName);
407 if (d != 1 && d != 2 && d != 4 && d != 8) {
408 L_INFO(
"pix depth not in {1, 2, 4, 8}\n", procName);
413 if (samecmaps == TRUE) {
415 wpl1 = pixGetWpl(pix1);
416 wpl2 = pixGetWpl(pix2);
419 fullwords = linebits / 32;
420 endbits = linebits & 31;
421 endmask = (endbits == 0) ? 0 : (0xffffffff << (32 - endbits));
422 for (i = 0; i < h; i++) {
423 line1 = data1 + wpl1 * i;
424 line2 = data2 + wpl2 * i;
425 for (j = 0; j < fullwords; j++) {
432 if ((*line1 ^ *line2) & endmask)
441 for (i = 0; i < h; i++) {
442 for (j = 0; j < w; j++) {
447 if (rval1 != rval2 || gval1 != gval2 || bval1 != bval2)
479 l_int32 n1, n2, i, rval1, rval2, gval1, gval2, bval1, bval2, aval1, aval2;
481 PROCNAME(
"cmapEqual");
484 return ERROR_INT(
"&same not defined", procName, 1);
487 return ERROR_INT(
"cmap1 not defined", procName, 1);
489 return ERROR_INT(
"cmap2 not defined", procName, 1);
490 if (ncomps != 3 && ncomps != 4)
491 return ERROR_INT(
"ncomps not 3 or 4", procName, 1);
496 L_INFO(
"colormap sizes are different\n", procName);
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;
539 PROCNAME(
"pixUsesCmapColor");
542 return ERROR_INT(
"&color not defined", procName, 1);
545 return ERROR_INT(
"pixs not defined", procName, 1);
547 if ((cmap = pixGetColormap(pixs)) == NULL)
557 for (i = 0; i < n; i++) {
560 if ((rval != gval || rval != bval) && numpix) {
602 l_int32 count1, count2, countn;
606 PROCNAME(
"pixCorrelationBinary");
609 return ERROR_INT(
"&pval not defined", procName, 1);
612 return ERROR_INT(
"pix1 not defined", procName, 1);
614 return ERROR_INT(
"pix2 not defined", procName, 1);
619 if (count1 == 0 || count2 == 0) {
623 pixn =
pixAnd(NULL, pix1, pix2);
625 *pval = (l_float32)countn * (l_float32)countn /
626 ((l_float32)count1 * (l_float32)count2);
659 l_int32 w1, h1, d1, w2, h2, d2, minw, minh;
663 PROCNAME(
"pixDisplayDiffBinary");
666 return (
PIX *)ERROR_PTR(
"pix1, pix2 not both defined", procName, NULL);
669 if (d1 != 1 || d2 != 1)
670 return (
PIX *)ERROR_PTR(
"pix1 and pix2 not 1 bpp", procName, NULL);
671 minw = L_MIN(w1, w2);
672 minh = L_MIN(h1, h2);
682 pixt =
pixAnd(NULL, pix1, pix2);
721 PROCNAME(
"pixCompareBinary");
723 if (ppixdiff) *ppixdiff = NULL;
725 return ERROR_INT(
"&pfract not defined", procName, 1);
727 if (!pix1 || pixGetDepth(pix1) != 1)
728 return ERROR_INT(
"pix1 not defined or not 1 bpp", procName, 1);
729 if (!pix2 || pixGetDepth(pix2) != 1)
730 return ERROR_INT(
"pix2 not defined or not 1 bpp", procName, 1);
731 if (comptype != L_COMPARE_XOR && comptype != L_COMPARE_SUBTRACT)
732 return ERROR_INT(
"invalid comptype", procName, 1);
734 if (comptype == L_COMPARE_XOR)
735 pixt =
pixXor(NULL, pix1, pix2);
740 *pfract = (l_float32)(count) / (l_float32)(w * h);
800 PROCNAME(
"pixCompareGrayOrRGB");
802 if (ppixdiff) *ppixdiff = NULL;
804 return ERROR_INT(
"pix1 not defined", procName, 1);
806 return ERROR_INT(
"pix2 not defined", procName, 1);
807 if (pixGetDepth(pix1) < 8 && !pixGetColormap(pix1))
808 return ERROR_INT(
"pix1 depth < 8 bpp and not cmapped", procName, 1);
809 if (pixGetDepth(pix2) < 8 && !pixGetColormap(pix2))
810 return ERROR_INT(
"pix2 depth < 8 bpp and not cmapped", procName, 1);
811 if (comptype != L_COMPARE_SUBTRACT && comptype != L_COMPARE_ABS_DIFF)
812 return ERROR_INT(
"invalid comptype", procName, 1);
813 if (plottype < 0 || plottype >= NUM_GPLOT_OUTPUTS)
814 return ERROR_INT(
"invalid plottype", procName, 1);
818 d = pixGetDepth(pixt1);
819 if (d != pixGetDepth(pixt2)) {
822 return ERROR_INT(
"intrinsic depths are not equal", procName, 1);
825 if (d == 8 || d == 16)
827 pdiff, prmsdiff, ppixdiff);
829 retval =
pixCompareRGB(pixt1, pixt2, comptype, plottype, psame,
830 pdiff, prmsdiff, ppixdiff);
869 static l_int32 index = 0;
870 l_int32 d1, d2, same, first, last;
875 PROCNAME(
"pixCompareGray");
877 if (psame) *psame = 0;
878 if (pdiff) *pdiff = 0.0;
879 if (prmsdiff) *prmsdiff = 0.0;
880 if (ppixdiff) *ppixdiff = NULL;
882 return ERROR_INT(
"pix1 not defined", procName, 1);
884 return ERROR_INT(
"pix2 not defined", procName, 1);
885 d1 = pixGetDepth(pix1);
886 d2 = pixGetDepth(pix2);
887 if ((d1 != d2) || (d1 != 8 && d1 != 16))
888 return ERROR_INT(
"depths unequal or not 8 or 16 bpp", procName, 1);
889 if (pixGetColormap(pix1) || pixGetColormap(pix2))
890 return ERROR_INT(
"pix1 and/or pix2 are colormapped", procName, 1);
891 if (comptype != L_COMPARE_SUBTRACT && comptype != L_COMPARE_ABS_DIFF)
892 return ERROR_INT(
"invalid comptype", procName, 1);
893 if (plottype < 0 || plottype >= NUM_GPLOT_OUTPUTS)
894 return ERROR_INT(
"invalid plottype", procName, 1);
898 if (comptype == L_COMPARE_SUBTRACT)
905 L_INFO(
"Images are pixel-wise identical\n", procName);
906 if (psame) *psame = same;
912 if (plottype && !same) {
913 L_INFO(
"Images differ: output plots will be generated\n", procName);
917 snprintf(buf,
sizeof(buf),
"/tmp/lept/comp/compare_gray%d", index);
919 "Pixel Difference Histogram",
"diff val",
924 snprintf(buf,
sizeof(buf),
"/tmp/lept/comp/compare_gray%d.png",
926 l_fileDisplay(buf, 100, 100, 1.0);
932 *ppixdiff =
pixCopy(NULL, pixt);
935 if (comptype == L_COMPARE_SUBTRACT) {
978 static l_int32 index = 0;
979 l_int32 rsame, gsame, bsame, same, first, rlast, glast, blast, last;
980 l_float32 rdiff, gdiff, bdiff;
982 NUMA *nar, *nag, *nab, *narc, *nagc, *nabc;
983 PIX *pixr1, *pixr2, *pixg1, *pixg2, *pixb1, *pixb2;
984 PIX *pixr, *pixg, *pixb;
986 PROCNAME(
"pixCompareRGB");
988 if (psame) *psame = 0;
989 if (pdiff) *pdiff = 0.0;
990 if (prmsdiff) *prmsdiff = 0.0;
991 if (ppixdiff) *ppixdiff = NULL;
992 if (!pix1 || pixGetDepth(pix1) != 32)
993 return ERROR_INT(
"pix1 not defined or not 32 bpp", procName, 1);
994 if (!pix2 || pixGetDepth(pix2) != 32)
995 return ERROR_INT(
"pix2 not defined or not ew bpp", procName, 1);
996 if (comptype != L_COMPARE_SUBTRACT && comptype != L_COMPARE_ABS_DIFF)
997 return ERROR_INT(
"invalid comptype", procName, 1);
998 if (plottype < 0 || plottype >= NUM_GPLOT_OUTPUTS)
999 return ERROR_INT(
"invalid plottype", procName, 1);
1009 if (comptype == L_COMPARE_SUBTRACT) {
1022 same = rsame && gsame && bsame;
1024 L_INFO(
"Images are pixel-wise identical\n", procName);
1025 if (psame) *psame = same;
1031 *pdiff = (rdiff + gdiff + bdiff) / 3.0;
1035 if (plottype && !same) {
1036 L_INFO(
"Images differ: output plots will be generated\n", procName);
1043 last = L_MAX(rlast, glast);
1044 last = L_MAX(last, blast);
1048 snprintf(buf,
sizeof(buf),
"/tmp/lept/comp/compare_rgb%d", index);
1050 "Pixel Difference Histogram",
"diff val",
1051 "number of pixels");
1057 snprintf(buf,
sizeof(buf),
"/tmp/lept/comp/compare_rgb%d.png",
1059 l_fileDisplay(buf, 100, 100, 1.0);
1072 if (comptype == L_COMPARE_SUBTRACT) {
1083 *prmsdiff = (rdiff + gdiff + bdiff) / 3.0;
1131 l_int32 d1, d2, w, h;
1132 PIX *pixt, *pixr, *pixg, *pixb;
1133 PIX *pixrdiff, *pixgdiff, *pixbdiff;
1136 PROCNAME(
"pixCompareTiled");
1139 return ERROR_INT(
"&pixdiff not defined", procName, 1);
1142 return ERROR_INT(
"pix1 not defined", procName, 1);
1144 return ERROR_INT(
"pix2 not defined", procName, 1);
1145 d1 = pixGetDepth(pix1);
1146 d2 = pixGetDepth(pix2);
1148 return ERROR_INT(
"depths not equal", procName, 1);
1149 if (d1 != 8 && d1 != 32)
1150 return ERROR_INT(
"pix1 not 8 or 32 bpp", procName, 1);
1151 if (d2 != 8 && d2 != 32)
1152 return ERROR_INT(
"pix2 not 8 or 32 bpp", procName, 1);
1153 if (sx < 2 || sy < 2)
1154 return ERROR_INT(
"sx and sy not both > 1", procName, 1);
1156 return ERROR_INT(
"invalid type", procName, 1);
1223 l_float32 *array1, *array2;
1224 NUMA *nah, *nan, *nad;
1226 PROCNAME(
"pixCompareRankDifference");
1229 return (
NUMA *)ERROR_PTR(
"pix1 not defined", procName, NULL);
1231 return (
NUMA *)ERROR_PTR(
"pix2 not defined", procName, NULL);
1234 return (
NUMA *)ERROR_PTR(
"na not made", procName, NULL);
1245 for (i = 1; i < 256; i++)
1246 array2[i] = array2[i - 1] - array1[i - 1];
1312 l_float32 fractdiff, avediff;
1314 PROCNAME(
"pixTestForSimilarity");
1317 return ERROR_INT(
"&similar not defined", procName, 1);
1320 return ERROR_INT(
"pix1 not defined", procName, 1);
1322 return ERROR_INT(
"pix2 not defined", procName, 1);
1324 return ERROR_INT(
"pix sizes not equal", procName, 1);
1326 return ERROR_INT(
"mindiff must be > 0", procName, 1);
1329 &fractdiff, &avediff, details))
1330 return ERROR_INT(
"diff stats not found", procName, 1);
1332 if (maxave <= 0.0) maxave = 256.0;
1333 if (fractdiff <= maxfract && avediff <= maxave)
1386 l_float32 *pfractdiff,
1387 l_float32 *pavediff,
1390 l_int32 i, first, last, diff;
1391 l_float32 fract, ave;
1393 NUMA *nah, *nan, *nac;
1395 PROCNAME(
"pixGetDifferenceStats");
1397 if (pfractdiff) *pfractdiff = 0.0;
1398 if (pavediff) *pavediff = 0.0;
1400 return ERROR_INT(
"&fractdiff not defined", procName, 1);
1402 return ERROR_INT(
"&avediff not defined", procName, 1);
1404 return ERROR_INT(
"pix1 not defined", procName, 1);
1406 return ERROR_INT(
"pix2 not defined", procName, 1);
1408 return ERROR_INT(
"mindiff must be > 0", procName, 1);
1411 return ERROR_INT(
"na not made", procName, 1);
1415 return ERROR_INT(
"nan not made", procName, 1);
1424 "Difference histogram");
1425 l_fileDisplay(
"/tmp/lept/comp/histo.png", 500, 0, 1.0);
1426 fprintf(stderr,
"\nNonzero values in normalized histogram:");
1429 fprintf(stderr,
" Mindiff fractdiff avediff\n");
1430 fprintf(stderr,
" -----------------------------------\n");
1431 for (diff = 1; diff < L_MIN(2 * mindiff, last); diff++) {
1434 for (i = diff; i <= last; i++) {
1436 ave += (l_float32)i * array[i];
1438 ave = (fract == 0.0) ? 0.0 : ave / fract;
1440 fprintf(stderr,
"%5d %7.4f %7.4f\n",
1443 fprintf(stderr,
" -----------------------------------\n");
1448 for (i = mindiff; i < 256; i++) {
1450 ave += (l_float32)i * array[i];
1452 ave = (fract == 0.0) ? 0.0 : ave / fract;
1455 *pfractdiff = fract;
1488 l_int32 w1, h1, d1, w2, h2, d2, w, h, wpl1, wpl2;
1489 l_int32 i, j, val, val1, val2;
1490 l_int32 rval1, rval2, gval1, gval2, bval1, bval2;
1491 l_int32 rdiff, gdiff, bdiff, maxdiff;
1492 l_uint32 *data1, *data2, *line1, *line2;
1497 PROCNAME(
"pixGetDifferenceHistogram");
1500 return (
NUMA *)ERROR_PTR(
"pix1 not defined", procName, NULL);
1502 return (
NUMA *)ERROR_PTR(
"pix2 not defined", procName, NULL);
1503 d1 = pixGetDepth(pix1);
1504 d2 = pixGetDepth(pix2);
1505 if (d1 == 16 || d2 == 16)
1506 return (
NUMA *)ERROR_PTR(
"d == 16 not supported", procName, NULL);
1507 if (d1 < 8 && !pixGetColormap(pix1))
1508 return (
NUMA *)ERROR_PTR(
"pix1 depth < 8 bpp and not cmapped",
1510 if (d2 < 8 && !pixGetColormap(pix2))
1511 return (
NUMA *)ERROR_PTR(
"pix2 depth < 8 bpp and not cmapped",
1520 return (
NUMA *)ERROR_PTR(
"pix depths not equal", procName, NULL);
1522 if (factor < 1) factor = 1;
1531 wpl1 = pixGetWpl(pixt1);
1532 wpl2 = pixGetWpl(pixt2);
1534 for (i = 0; i < h; i += factor) {
1535 line1 = data1 + i * wpl1;
1536 line2 = data2 + i * wpl2;
1537 for (j = 0; j < w; j += factor) {
1540 val = L_ABS(val1 - val2);
1545 for (i = 0; i < h; i += factor) {
1546 line1 = data1 + i * wpl1;
1547 line2 = data2 + i * wpl2;
1548 for (j = 0; j < w; j += factor) {
1551 rdiff = L_ABS(rval1 - rval2);
1552 gdiff = L_ABS(gval1 - gval2);
1553 bdiff = L_ABS(bval1 - bval2);
1554 maxdiff = L_MAX(rdiff, gdiff);
1555 maxdiff = L_MAX(maxdiff, bdiff);
1624 l_int32 d1, d2, w, h, count;
1625 PIX *pix1, *pix2, *pix3, *pix4, *pix5, *pix6, *pix7, *pix8, *pix9;
1628 PROCNAME(
"pixGetPerceptualDiff");
1630 if (ppixdiff1) *ppixdiff1 = NULL;
1631 if (ppixdiff2) *ppixdiff2 = NULL;
1633 return ERROR_INT(
"&fract not defined", procName, 1);
1635 if ((dilation & 1) == 0)
1636 return ERROR_INT(
"dilation must be odd", procName, 1);
1638 return ERROR_INT(
"pixs1 not defined", procName, 1);
1640 return ERROR_INT(
"pixs2 not defined", procName, 1);
1641 d1 = pixGetDepth(pixs1);
1642 d2 = pixGetDepth(pixs2);
1643 if (!pixGetColormap(pixs1) && d1 < 8)
1644 return ERROR_INT(
"pixs1 not cmapped or >=8 bpp", procName, 1);
1645 if (!pixGetColormap(pixs2) && d2 < 8)
1646 return ERROR_INT(
"pixs2 not cmapped or >=8 bpp", procName, 1);
1658 if (pixGetColormap(pix1)) {
1660 d1 = pixGetDepth(pix3);
1664 if (pixGetColormap(pix2)) {
1666 d2 = pixGetDepth(pix4);
1675 return ERROR_INT(
"pix3 and pix4 depths not equal", procName, 1);
1688 pixCompareGray(pix4, pix5, L_COMPARE_SUBTRACT, 0, NULL, NULL, NULL,
1691 pixCompareGray(pix3, pix6, L_COMPARE_SUBTRACT, 0, NULL, NULL, NULL,
1693 pix9 =
pixMinOrMax(NULL, pix7, pix8, L_CHOOSE_MAX);
1698 *pfract = (l_float32)count / (l_float32)(w * h);
1712 pix5 =
pixColorMorph(pix3, L_MORPH_DILATE, dilation, dilation);
1713 pixCompareRGB(pix4, pix5, L_COMPARE_SUBTRACT, 0, NULL, NULL, NULL,
1715 pix6 =
pixColorMorph(pix4, L_MORPH_DILATE, dilation, dilation);
1716 pixCompareRGB(pix3, pix6, L_COMPARE_SUBTRACT, 0, NULL, NULL, NULL,
1718 pix9 =
pixMinOrMax(NULL, pix7, pix8, L_CHOOSE_MAX);
1724 *pfract = (l_float32)count / (l_float32)(w * h);
1783 l_int32 same, i, j, w, h, d, wpl1, wpl2, v1, v2, r1, g1, b1, r2, g2, b2;
1784 l_uint32 *data1, *data2, *line1, *line2;
1787 PROCNAME(
"pixGetPSNR");
1790 return ERROR_INT(
"&psnr not defined", procName, 1);
1793 return ERROR_INT(
"empty input pix", procName, 1);
1795 return ERROR_INT(
"pix sizes unequal", procName, 1);
1796 if (pixGetColormap(pix1))
1797 return ERROR_INT(
"pix1 has colormap", procName, 1);
1798 if (pixGetColormap(pix2))
1799 return ERROR_INT(
"pix2 has colormap", procName, 1);
1801 if (d != 8 && d != 32)
1802 return ERROR_INT(
"pix not 8 or 32 bpp", procName, 1);
1804 return ERROR_INT(
"invalid sampling factor", procName, 1);
1814 wpl1 = pixGetWpl(pix1);
1815 wpl2 = pixGetWpl(pix2);
1818 for (i = 0; i < h; i += factor) {
1819 line1 = data1 + i * wpl1;
1820 line2 = data2 + i * wpl2;
1821 for (j = 0; j < w; j += factor) {
1824 mse += (l_float32)(v1 - v2) * (v1 - v2);
1828 for (i = 0; i < h; i += factor) {
1829 line1 = data1 + i * wpl1;
1830 line2 = data2 + i * wpl2;
1831 for (j = 0; j < w; j += factor) {
1834 mse += ((l_float32)(r1 - r2) * (r1 - r2) +
1835 (g1 - g2) * (g1 - g2) +
1836 (b1 - b2) * (b1 - b2)) / 3.0;
1840 mse = mse / ((l_float32)(w) * h);
1842 *ppsnr = -4.3429448 * log(mse / (255 * 255));
1894 l_float32 textthresh,
1898 l_float32 simthresh,
1900 l_float32 **pscores,
1904 l_int32 i, j, n, w, h, w1, h1, w2, h2, ival, index;
1907 NUMA *nai, *naw, *nah;
1912 PROCNAME(
"pixaComparePhotoRegionsByHisto");
1914 if (pscores) *pscores = NULL;
1915 if (ppixd) *ppixd = NULL;
1917 return ERROR_INT(
"&na not defined", procName, 1);
1920 return ERROR_INT(
"pixa not defined", procName, 1);
1921 if (minratio < 0.0 || minratio > 1.0)
1922 return ERROR_INT(
"minratio not in [0.0 ... 1.0]", procName, 1);
1923 if (textthresh <= 0.0) textthresh = 1.3;
1925 return ERROR_INT(
"subsampling factor must be >= 1", procName, 1);
1926 if (nx < 1 || ny < 1)
1927 return ERROR_INT(
"nx and ny must both be > 0", procName, 1);
1928 if (simthresh <= 0.0) simthresh = 0.25;
1929 if (simthresh > 1.0)
1930 return ERROR_INT(
"simthresh invalid; should be near 0.25", procName, 1);
1934 if ((n3a = (
NUMAA **)LEPT_CALLOC(n,
sizeof(
NUMAA *))) == NULL)
1935 return ERROR_INT(
"calloc fail for n3a", procName, 1);
1938 for (i = 0; i < n; i++) {
1943 &naa, &w, &h, FALSE);
1948 fprintf(stderr,
"Image %s is photo\n", text);
1950 fprintf(stderr,
"Image %s is NOT photo\n", text);
1960 if ((scores = (l_float32 *)LEPT_CALLOC(n * n,
sizeof(l_float32))) == NULL) {
1961 L_ERROR(
"calloc fail for scores\n", procName);
1965 for (i = 0, index = 0; i < n; i++) {
1966 scores[n * i + i] = 1.0;
1971 if (n3a[i] == NULL) {
1977 for (j = i + 1; j < n; j++) {
1987 scores[n * i + j] = score;
1988 scores[n * j + i] = score;
1990 if (score > simthresh) {
1992 fprintf(stderr,
"Setting %d similar to %d, in class %d\n",
2008 l_uint32 *line, *data;
2012 wpl = pixGetWpl(pix2);
2013 for (i = 0; i < n; i++) {
2014 line = data + i * wpl;
2015 for (j = 0; j < n; j++) {
2017 L_MIN(255, 4.0 * 255 * scores[n * i + j]));
2020 fact = L_MAX(2, 1000 / n);
2022 fprintf(stderr,
"Writing to /tmp/lept/comp/scorearray.png\n");
2024 pixWrite(
"/tmp/lept/comp/scorearray.png", pix3, IFF_PNG);
2041 for (i = 0; i < n; i++)
2111 l_int32 w1, h1, w2, h2, w1c, h1c, w2c, h2c;
2112 l_float32 wratio, hratio;
2117 PROCNAME(
"pixComparePhotoRegionsByHisto");
2120 return ERROR_INT(
"&score not defined", procName, 1);
2123 return ERROR_INT(
"pix1 and pix2 not both defined", procName, 1);
2124 if (minratio < 0.5 || minratio > 1.0)
2125 return ERROR_INT(
"minratio not in [0.5 ... 1.0]", procName, 1);
2127 return ERROR_INT(
"subsampling factor must be >= 1", procName, 1);
2128 if (nx < 1 || ny < 1)
2129 return ERROR_INT(
"nx and ny must both be > 0", procName, 1);
2143 wratio = (w1 < w2) ? (l_float32)w1 / (l_float32)w2 :
2144 (l_float32)w2 / (l_float32)w1;
2145 hratio = (h1 < h2) ? (l_float32)h1 / (l_float32)h2 :
2146 (l_float32)h2 / (l_float32)h1;
2147 if (wratio < minratio || hratio < minratio)
2156 &naa1, &w1c, &h1c, debugflag);
2158 if (!naa1)
return 0;
2164 &naa2, &w2c, &h2c, debugflag);
2166 if (!naa2)
return 0;
2219 PIX *pix1, *pix2, *pix3, *pixm;
2222 PROCNAME(
"pixGenPhotoHistos");
2224 if (pnaa) *pnaa = NULL;
2228 return ERROR_INT(
"&naa not defined", procName, 1);
2230 return ERROR_INT(
"&w and &h not both defined", procName, 1);
2231 if (!pixs || pixGetDepth(pixs) == 1)
2232 return ERROR_INT(
"pixs not defined or 1 bpp", procName, 1);
2234 return ERROR_INT(
"subsampling factor must be >= 1", procName, 1);
2235 if (nx < 1 || ny < 1)
2236 return ERROR_INT(
"nx and ny must both be > 0", procName, 1);
2237 if (thresh <= 0.0) thresh = 1.3;
2263 PIX *pix4, *pix5, *pix6, *pix7, *pix8;
2285 *pw = pixGetWidth(pix3);
2286 *ph = pixGetHeight(pix3);
2290 fprintf(stderr,
"Writing to /tmp/lept/comp/tiledhistos.pdf\n");
2292 "/tmp/lept/comp/tiledhistos.pdf");
2322 l_int32 xs, ys, delx, dely, icx, icy, ws, hs, wd, hd;
2325 PROCNAME(
"pixPadToCenterCentroid");
2328 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
2330 return (
PIX *)ERROR_PTR(
"invalid sampling factor", procName, NULL);
2334 icx = (l_int32)(cx + 0.5);
2335 icy = (l_int32)(cy + 0.5);
2337 delx = ws - 2 * icx;
2338 dely = hs - 2 * icy;
2339 xs = L_MAX(0, delx);
2340 ys = L_MAX(0, dely);
2341 wd = 2 * L_MAX(icx, ws - icx);
2342 hd = 2 * L_MAX(icy, hs - icy);
2345 pixCopyResolution(pixd, pixs);
2376 l_int32 i, j, w, h, wpl, val;
2377 l_float32 sumx, sumy, sumv;
2378 l_uint32 *data, *line;
2381 PROCNAME(
"pixCentroid8");
2383 if (pcx) *pcx = 0.0;
2384 if (pcy) *pcy = 0.0;
2385 if (!pixs || pixGetDepth(pixs) != 8)
2386 return ERROR_INT(
"pixs undefined or not 8 bpp", procName, 1);
2388 return ERROR_INT(
"subsampling factor must be >= 1", procName, 1);
2390 return ERROR_INT(
"&cx and &cy not both defined", procName, 1);
2395 wpl = pixGetWpl(pix1);
2396 sumx = sumy = sumv = 0.0;
2397 for (i = 0; i < h; i++) {
2398 line = data + i * wpl;
2399 for (j = 0; j < w; j++) {
2409 L_INFO(
"input image is white\n", procName);
2410 *pcx = (l_float32)(w) / 2;
2411 *pcy = (l_float32)(h) / 2;
2458 l_int32 i, n, istext, isphoto;
2459 l_float32 maxval, sum1, sum2, ratio;
2461 NUMA *na1, *na2, *na3, *narv;
2466 PROCNAME(
"pixDecideIfPhotoImage");
2469 return ERROR_INT(
"&naa not defined", procName, 1);
2471 if (!pix || pixGetDepth(pix) != 8 || pixGetColormap(pix))
2472 return ERROR_INT(
"pix undefined or invalid", procName, 1);
2473 if (thresh <= 0.0) thresh = 1.3;
2478 L_INFO(
"Image is text\n", procName);
2485 bmf = (pixadebug) ?
bmfCreate(NULL, 6) : NULL;
2487 for (i = 0; i < n; i++) {
2497 snprintf(buf,
sizeof(buf),
"/tmp/lept/comp/plot.%d", i);
2527 ratio = sum1 / sum2;
2528 isphoto = (ratio > thresh) ? 1 : 0;
2531 L_INFO(
"ratio %f > %f; isphoto is true\n",
2532 procName, ratio, thresh);
2534 L_INFO(
"ratio %f < %f; isphoto is false\n",
2535 procName, ratio, thresh);
2582 char buf1[128], buf2[128];
2584 l_float32 wratio, hratio, score, minscore, dist;
2586 NUMA *na1, *na2, *nadist, *nascore;
2588 PROCNAME(
"compareTilesByHisto");
2591 return ERROR_INT(
"&score not defined", procName, 1);
2594 return ERROR_INT(
"naa1 and naa2 not both defined", procName, 1);
2599 return ERROR_INT(
"naa1 and naa2 are different size", procName, 1);
2606 wratio = (w1 < w2) ? (l_float32)w1 / (l_float32)w2 :
2607 (l_float32)w2 / (l_float32)w1;
2608 hratio = (h1 < h2) ? (l_float32)h1 / (l_float32)h2 :
2609 (l_float32)h2 / (l_float32)h1;
2610 if (wratio < minratio || hratio < minratio) {
2612 L_INFO(
"Sizes differ: wratio = %f, hratio = %f\n",
2613 procName, wratio, hratio);
2624 bmf = (pixadebug) ?
bmfCreate(NULL, 6) : NULL;
2625 for (i = 0; i < n; i++) {
2636 score = L_MAX(0.0, 1.0 - 10.0 * (dist / 255.));
2639 minscore = L_MIN(minscore, score);
2641 snprintf(buf1,
sizeof(buf1),
"/tmp/lept/comptile/plot.%d", i);
2650 for (i = 0; i < n; i++) {
2652 snprintf(buf1,
sizeof(buf1),
"/tmp/lept/comptile/plot.%d.png", i);
2656 snprintf(buf2,
sizeof(buf2),
2657 "Image %d\ndist = %5.3f, score = %5.3f", i, dist, score);
2662 fprintf(stderr,
"Writing to /tmp/lept/comptile/comparegray.pdf\n");
2664 "/tmp/lept/comptile/comparegray.pdf");
2665 numaWrite(
"/tmp/lept/comptile/scores.na", nascore);
2666 numaWrite(
"/tmp/lept/comptile/dists.na", nadist);
2752 l_int32 w1, h1, w2, h2;
2753 l_float32 wratio, hratio;
2755 PIX *pix3, *pix4, *pix5, *pix6, *pix7, *pix8;
2758 PROCNAME(
"pixCompareGrayByHisto");
2761 return ERROR_INT(
"&score not defined", procName, 1);
2764 return ERROR_INT(
"pix1 and pix2 not both defined", procName, 1);
2765 if (minratio < 0.5 || minratio > 1.0)
2766 return ERROR_INT(
"minratio not in [0.5 ... 1.0]", procName, 1);
2768 return ERROR_INT(
"invalid maxgray; should be >= 200", procName, 1);
2769 maxgray = L_MIN(255, maxgray);
2771 return ERROR_INT(
"subsampling factor must be >= 1", procName, 1);
2772 if (nx < 1 || ny < 1)
2773 return ERROR_INT(
"nx and ny must both be > 0", procName, 1);
2787 wratio = (w1 < w2) ? (l_float32)w1 / (l_float32)w2 :
2788 (l_float32)w2 / (l_float32)w1;
2789 hratio = (h1 < h2) ? (l_float32)h1 / (l_float32)h2 :
2790 (l_float32)h2 / (l_float32)h1;
2791 if (wratio < minratio || hratio < minratio)
2812 PIX *pix9, *pix10, *pix11, *pix12, *pix13;
2877 l_float32 score, minscore, maxval1, maxval2, dist;
2879 NUMA *na1, *na2, *na3, *na4, *na5, *na6, *na7;
2881 PIXA *pixa1, *pixa2;
2883 PROCNAME(
"pixCompareTilesByHisto");
2886 return ERROR_INT(
"&score not defined", procName, 1);
2889 return ERROR_INT(
"pix1 and pix2 not both defined", procName, 1);
2896 bmf = (pixadebug) ?
bmfCreate(NULL, 6) : NULL;
2898 for (i = 0; i < n; i++) {
2905 if (maxgray < 255) {
2906 for (j = maxgray + 1; j <= 255; j++) {
2918 gplotSimple2(na5, na6, GPLOT_PNG,
"/tmp/lept/comp/plot1",
"Histos");
2926 score = L_MAX(0.0, 1.0 - 8.0 * (dist / 255.));
2928 minscore = L_MIN(minscore, score);
2930 PIX *pix5, *pix6, *pix7, *pix8, *pix9, *pix10;
2932 l_int32 w, h, wscale;
2935 wscale = (w > h) ? 700 : 400;
2940 pix7 =
pixRead(
"/tmp/lept/comp/plot1.png");
2942 snprintf(buf,
sizeof(buf),
"%5.3f", score);
2964 "/tmp/lept/comp/comparegray.pdf");
2965 numaWrite(
"/tmp/lept/comp/tilescores.na", na7);
2999 l_float32 cx1, cy1, cx2, cy2;
3000 l_int32 w1, h1, w2, h2, icx1, icy1, icx2, icy2;
3001 l_int32 xm, xm1, xm2, xp, xp1, xp2, ym, ym1, ym2, yp, yp1, yp2;
3004 PROCNAME(
"pixCropAlignedToCentroid");
3006 if (pbox1) *pbox1 = NULL;
3007 if (pbox2) *pbox2 = NULL;
3009 return ERROR_INT(
"pix1 and pix2 not both defined", procName, 1);
3011 return ERROR_INT(
"subsampling factor must be >= 1", procName, 1);
3012 if (!pbox1 || !pbox2)
3013 return ERROR_INT(
"&box1 and &box2 not both defined", procName, 1);
3024 icx1 = (l_int32)(cx1 + 0.5);
3025 icy1 = (l_int32)(cy1 + 0.5);
3026 icx2 = (l_int32)(cx2 + 0.5);
3027 icy2 = (l_int32)(cy2 + 0.5);
3028 xm = L_MIN(icx1, icx2);
3031 xp = L_MIN(w1 - icx1, w2 - icx2);
3034 ym = L_MIN(icy1, icy2);
3037 yp = L_MIN(h1 - icy1, h2 - icy2);
3040 *pbox1 =
boxCreate(xm1, ym1, xp1 - xm1, yp1 - ym1);
3041 *pbox2 =
boxCreate(xm2, ym2, xp2 - xm2, yp2 - ym2);
3074 l_int32 i, j, n, nn, ival;
3078 PROCNAME(
"l_compressGrayHistograms");
3081 return (l_uint8 *)ERROR_PTR(
"&size not defined", procName, NULL);
3084 return (l_uint8 *)ERROR_PTR(
"naa not defined", procName, NULL);
3086 for (i = 0; i < n; i++) {
3089 L_ERROR(
"%d numbers in numa[%d]\n", procName, nn, i);
3094 if ((bytea = (l_uint8 *)LEPT_CALLOC(8 + 256 * n,
sizeof(l_uint8))) == NULL)
3095 return (l_uint8 *)ERROR_PTR(
"bytea not made", procName, NULL);
3096 *psize = 8 + 256 * n;
3099 for (i = 0; i < n; i++) {
3103 for (j = 0; j < 256; j++) {
3105 bytea[8 + 256 * i + j] = ival;
3145 PROCNAME(
"l_uncompressGrayHistograms");
3150 return (
NUMAA *)ERROR_PTR(
"&w and &h not both defined", procName, NULL);
3152 return (
NUMAA *)ERROR_PTR(
"bytea not defined", procName, NULL);
3153 n = (size - 8) / 256;
3154 if ((size - 8) % 256 != 0)
3155 return (
NUMAA *)ERROR_PTR(
"bytea size is invalid", procName, NULL);
3160 for (i = 0; i < n; i++) {
3162 for (j = 0; j < 256; j++)
3214 l_int32 i, level, area1, area2, delx, dely;
3215 l_int32 etransx, etransy, maxshift, dbint;
3216 l_int32 *stab, *ctab;
3217 l_float32 cx1, cx2, cy1, cy2, score;
3218 PIX *pixb1, *pixb2, *pixt1, *pixt2, *pixt3, *pixt4;
3219 PIXA *pixa1, *pixa2, *pixadb;
3221 PROCNAME(
"pixCompareWithTranslation");
3223 if (pdelx) *pdelx = 0;
3224 if (pdely) *pdely = 0;
3225 if (pscore) *pscore = 0.0;
3226 if (!pdelx || !pdely)
3227 return ERROR_INT(
"&delx and &dely not defined", procName, 1);
3229 return ERROR_INT(
"&score not defined", procName, 1);
3231 return ERROR_INT(
"pix1 not defined", procName, 1);
3233 return ERROR_INT(
"pix2 not defined", procName, 1);
3252 for (i = 0; i < 3; i++) {
3265 for (level = 3; level >= 0; level--) {
3281 dbint = (debugflag) ? level + 1 : 0;
3283 maxshift, stab, &delx, &dely, &score, dbint);
3285 fprintf(stderr,
"Level %d: delx = %d, dely = %d, score = %7.4f\n",
3286 level, delx, dely, score);
3299 "/tmp/lept/comp/compare.pdf");
3301 0,
"Correlation scores at levels 1 through 5",
3302 "/tmp/lept/comp/correl.pdf");
3372 l_int32 shiftx, shifty, delx, dely;
3374 l_float32 maxscore, score;
3378 PROCNAME(
"pixBestCorrelation");
3380 if (pdelx) *pdelx = 0;
3381 if (pdely) *pdely = 0;
3382 if (pscore) *pscore = 0.0;
3383 if (!pix1 || pixGetDepth(pix1) != 1)
3384 return ERROR_INT(
"pix1 not defined or not 1 bpp", procName, 1);
3385 if (!pix2 || pixGetDepth(pix2) != 1)
3386 return ERROR_INT(
"pix2 not defined or not 1 bpp", procName, 1);
3387 if (!area1 || !area2)
3388 return ERROR_INT(
"areas must be > 0", procName, 1);
3391 fpix =
fpixCreate(2 * maxshift + 1, 2 * maxshift + 1);
3402 for (shifty = -maxshift; shifty <= maxshift; shifty++) {
3403 for (shiftx = -maxshift; shiftx <= maxshift; shiftx++) {
3404 pixCorrelationScoreShifted(pix1, pix2, area1, area2,
3406 etransy + shifty, tab, &score);
3407 if (debugflag > 0) {
3408 fpixSetPixel(fpix, maxshift + shiftx, maxshift + shifty,
3413 if (score > maxscore) {
3415 delx = etransx + shiftx;
3416 dely = etransy + shifty;
3421 if (debugflag > 0) {
3426 snprintf(buf,
sizeof(buf),
"/tmp/lept/comp/correl_%d.png",
3428 pixWrite(buf, pix4, IFF_PNG);
3434 if (pdelx) *pdelx = delx;
3435 if (pdely) *pdely = dely;
3436 if (pscore) *pscore = maxscore;
3437 if (!tab8) LEPT_FREE(tab);
void gplotDestroy(GPLOT **pgplot)
gplotDestroy()
l_int32 pixDecideIfPhotoImage(PIX *pix, l_int32 factor, l_int32 nx, l_int32 ny, l_float32 thresh, NUMAA **pnaa, PIXA *pixadebug)
pixDecideIfPhotoImage()
l_int32 pixCompareRGB(PIX *pix1, PIX *pix2, l_int32 comptype, l_int32 plottype, l_int32 *psame, l_float32 *pdiff, l_float32 *prmsdiff, PIX **ppixdiff)
pixCompareRGB()
l_int32 numaGetNonzeroRange(NUMA *na, l_float32 eps, l_int32 *pfirst, l_int32 *plast)
numaGetNonzeroRange()
NUMA * pixGetGrayHistogram(PIX *pixs, l_int32 factor)
pixGetGrayHistogram()
void bmfDestroy(L_BMF **pbmf)
bmfDestroy()
PIX * pixConvertTo1(PIX *pixs, l_int32 threshold)
pixConvertTo1()
l_int32 gplotAddPlot(GPLOT *gplot, NUMA *nax, NUMA *nay, l_int32 plotstyle, const char *plottitle)
gplotAddPlot()
l_int32 gplotSimple1(NUMA *na, l_int32 outformat, const char *outroot, const char *title)
gplotSimple1()
PIX * pixRemoveColormap(PIX *pixs, l_int32 type)
pixRemoveColormap()
l_int32 numaSetCount(NUMA *na, l_int32 newcount)
numaSetCount()
l_int32 pixSetMaskedGeneral(PIX *pixd, PIX *pixm, l_uint32 val, l_int32 x, l_int32 y)
pixSetMaskedGeneral()
l_int32 pixGenPhotoHistos(PIX *pixs, BOX *box, l_int32 factor, l_float32 thresh, l_int32 nx, l_int32 ny, NUMAA **pnaa, l_int32 *pw, l_int32 *ph, l_int32 debugflag)
pixGenPhotoHistos()
l_int32 lept_mkdir(const char *subdir)
lept_mkdir()
l_int32 pixaccAdd(PIXACC *pixacc, PIX *pix)
pixaccAdd()
l_int32 numaAddNumber(NUMA *na, l_float32 val)
numaAddNumber()
PIX * pixDilateGray(PIX *pixs, l_int32 hsize, l_int32 vsize)
pixDilateGray()
PIX * pixConvertTo32(PIX *pixs)
pixConvertTo32()
l_int32 numaGetSumOnInterval(NUMA *na, l_int32 first, l_int32 last, l_float32 *psum)
numaGetSumOnInterval()
l_int32 lept_roundftoi(l_float32 fval)
lept_roundftoi()
l_int32 * makePixelCentroidTab8(void)
makePixelCentroidTab8()
l_int32 pixCentroid8(PIX *pixs, l_int32 factor, l_float32 *pcx, l_float32 *pcy)
pixCentroid8()
PIX * pixConvertLossless(PIX *pixs, l_int32 d)
pixConvertLossless()
l_int32 grayInterHistogramStats(NUMAA *naa, l_int32 wc, NUMA **pnam, NUMA **pnams, NUMA **pnav, NUMA **pnarv)
grayInterHistogramStats()
PIXA * pixaReadFiles(const char *dirname, const char *substr)
pixaReadFiles()
l_int32 pixCropAlignedToCentroid(PIX *pix1, PIX *pix2, l_int32 factor, BOX **pbox1, BOX **pbox2)
pixCropAlignedToCentroid()
l_uint8 * l_compressGrayHistograms(NUMAA *naa, l_int32 w, l_int32 h, size_t *psize)
l_compressGrayHistograms()
l_int32 pixGetPixel(PIX *pix, l_int32 x, l_int32 y, l_uint32 *pval)
pixGetPixel()
PIXA * pixaCreate(l_int32 n)
pixaCreate()
l_int32 pixZero(PIX *pix, l_int32 *pempty)
pixZero()
GPLOT * gplotCreate(const char *rootname, l_int32 outformat, const char *title, const char *xlabel, const char *ylabel)
gplotCreate()
l_int32 numaGetMax(NUMA *na, l_float32 *pmaxval, l_int32 *pimaxloc)
numaGetMax()
PIX * pixConvertTo8(PIX *pixs, l_int32 cmapflag)
pixConvertTo8()
l_int32 pixCompareGrayByHisto(PIX *pix1, PIX *pix2, BOX *box1, BOX *box2, l_float32 minratio, l_int32 maxgray, l_int32 factor, l_int32 nx, l_int32 ny, l_float32 *pscore, l_int32 debugflag)
pixCompareGrayByHisto()
NUMA * numaMakeConstant(l_float32 val, l_int32 size)
numaMakeConstant()
l_int32 numaGetFValue(NUMA *na, l_int32 index, l_float32 *pval)
numaGetFValue()
l_int32 numaEarthMoverDistance(NUMA *na1, NUMA *na2, l_float32 *pdist)
numaEarthMoverDistance()
PIX * pixGetAverageTiled(PIX *pixs, l_int32 sx, l_int32 sy, l_int32 type)
pixGetAverageTiled()
l_int32 pixaccMultConst(PIXACC *pixacc, l_float32 factor)
pixaccMultConst()
PIX * pixCreate(l_int32 width, l_int32 height, l_int32 depth)
pixCreate()
l_int32 pixAlphaIsOpaque(PIX *pix, l_int32 *popaque)
pixAlphaIsOpaque()
PIXA * pixaSplitPix(PIX *pixs, l_int32 nx, l_int32 ny, l_int32 borderwidth, l_uint32 bordercolor)
pixaSplitPix()
PIX * pixInvert(PIX *pixd, PIX *pixs)
pixInvert()
NUMA * numaCreate(l_int32 n)
numaCreate()
l_uint32 * pixGetData(PIX *pix)
pixGetData()
l_int32 pixcmapGetColor(PIXCMAP *cmap, l_int32 index, l_int32 *prval, l_int32 *pgval, l_int32 *pbval)
pixcmapGetColor()
PIX * pixThresholdToBinary(PIX *pixs, l_int32 thresh)
pixThresholdToBinary()
NUMA * numaClipToInterval(NUMA *nas, l_int32 first, l_int32 last)
numaClipToInterval()
l_int32 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()
PIX * pixPadToCenterCentroid(PIX *pixs, l_int32 factor)
pixPadToCenterCentroid()
NUMAA * numaaCreate(l_int32 n)
numaaCreate()
PIX * pixClipRectangle(PIX *pixs, BOX *box, BOX **pboxc)
pixClipRectangle()
l_int32 gplotMakeOutput(GPLOT *gplot)
gplotMakeOutput()
PIX * pixDisplayDiffBinary(PIX *pix1, PIX *pix2)
pixDisplayDiffBinary()
l_int32 pixCompareWithTranslation(PIX *pix1, PIX *pix2, l_int32 thresh, l_int32 *pdelx, l_int32 *pdely, l_float32 *pscore, l_int32 debugflag)
pixCompareWithTranslation()
void numaaDestroy(NUMAA **pnaa)
numaaDestroy()
PIX * pixGetRGBComponent(PIX *pixs, l_int32 comp)
pixGetRGBComponent()
l_int32 pixRenderBoxArb(PIX *pix, BOX *box, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval)
pixRenderBoxArb()
l_int32 numaaAddNuma(NUMAA *naa, NUMA *na, l_int32 copyflag)
numaaAddNuma()
PIXCMAP * pixcmapCreate(l_int32 depth)
pixcmapCreate()
l_int32 pixcmapGetRGBA(PIXCMAP *cmap, l_int32 index, l_int32 *prval, l_int32 *pgval, l_int32 *pbval, l_int32 *paval)
pixcmapGetRGBA()
PIX * fpixDisplayMaxDynamicRange(FPIX *fpixs)
fpixDisplayMaxDynamicRange()
l_int32 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()
void pixaccDestroy(PIXACC **ppixacc)
pixaccDestroy()
NUMA * numaaGetNuma(NUMAA *naa, l_int32 index, l_int32 accessflag)
numaaGetNuma()
PIX * pixSubtractGray(PIX *pixd, PIX *pixs1, PIX *pixs2)
pixSubtractGray()
l_int32 pixEqualWithAlpha(PIX *pix1, PIX *pix2, l_int32 use_alpha, l_int32 *psame)
pixEqualWithAlpha()
static const l_int32 L_INSERT
PIX * pixaDisplayTiledByIndex(PIXA *pixa, NUMA *na, l_int32 width, l_int32 spacing, l_int32 border, l_int32 fontsize, l_uint32 textcolor)
pixaDisplayTiledByIndex()
l_int32 pixcmapAddColor(PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval)
pixcmapAddColor()
PIX * pixXor(PIX *pixd, PIX *pixs1, PIX *pixs2)
pixXor()
l_int32 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_int32 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()
PIX * pixAbsDifference(PIX *pixs1, PIX *pixs2)
pixAbsDifference()
l_int32 pixaAddPix(PIXA *pixa, PIX *pix, l_int32 copyflag)
pixaAddPix()
l_int32 pixEqualWithCmap(PIX *pix1, PIX *pix2, l_int32 *psame)
pixEqualWithCmap()
l_int32 pixCompareGrayOrRGB(PIX *pix1, PIX *pix2, l_int32 comptype, l_int32 plottype, l_int32 *psame, l_float32 *pdiff, l_float32 *prmsdiff, PIX **ppixdiff)
pixCompareGrayOrRGB()
PIX * pixAnd(PIX *pixd, PIX *pixs1, PIX *pixs2)
pixAnd()
PIX * pixaDisplayTiledInRows(PIXA *pixa, l_int32 outdepth, l_int32 maxwidth, l_float32 scalefactor, l_int32 background, l_int32 spacing, l_int32 border)
pixaDisplayTiledInRows()
l_int32 pixCompareTiled(PIX *pix1, PIX *pix2, l_int32 sx, l_int32 sy, l_int32 type, PIX **ppixdiff)
pixCompareTiled()
l_int32 * makePixelSumTab8(void)
makePixelSumTab8()
#define SET_DATA_BYTE(pdata, n, val)
l_int32 pixSetColormap(PIX *pix, PIXCMAP *colormap)
pixSetColormap()
l_int32 cmapEqual(PIXCMAP *cmap1, PIXCMAP *cmap2, l_int32 ncomps, l_int32 *psame)
cmapEqual()
l_int32 boxGetGeometry(BOX *box, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
boxGetGeometry()
PIX * pixConvertRGBToGrayMinMax(PIX *pixs, l_int32 type)
pixConvertRGBToGrayMinMax()
static l_int32 pixCompareTilesByHisto(PIX *pix1, PIX *pix2, l_int32 maxgray, l_int32 factor, l_int32 nx, l_int32 ny, l_float32 *pscore, PIXA *pixadebug)
pixCompareTilesByHisto()
NUMA * pixCompareRankDifference(PIX *pix1, PIX *pix2, l_int32 factor)
pixCompareRankDifference()
l_int32 pixSizesEqual(PIX *pix1, PIX *pix2)
pixSizesEqual()
#define GET_DATA_BYTE(pdata, n)
PIX * pixCreateRGBImage(PIX *pixr, PIX *pixg, PIX *pixb)
pixCreateRGBImage()
PIX * pixClone(PIX *pixs)
pixClone()
PIX * pixSubtract(PIX *pixd, PIX *pixs1, PIX *pixs2)
pixSubtract()
l_int32 pixCompareBinary(PIX *pix1, PIX *pix2, l_int32 comptype, l_float32 *pfract, PIX **ppixdiff)
pixCompareBinary()
PIX * pixScaleToSize(PIX *pixs, l_int32 wd, l_int32 hd)
pixScaleToSize()
l_int32 pixCentroid(PIX *pix, l_int32 *centtab, l_int32 *sumtab, l_float32 *pxave, l_float32 *pyave)
pixCentroid()
l_int32 pixaConvertToPdf(PIXA *pixa, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, const char *title, const char *fileout)
pixaConvertToPdf()
void pixDestroy(PIX **ppix)
pixDestroy()
l_int32 pixaComparePhotoRegionsByHisto(PIXA *pixa, l_float32 minratio, l_float32 textthresh, l_int32 factor, l_int32 nx, l_int32 ny, l_float32 simthresh, NUMA **pnai, l_float32 **pscores, PIX **ppixd)
pixaComparePhotoRegionsByHisto()
PIX * pixScaleByIntSampling(PIX *pixs, l_int32 factor)
pixScaleByIntSampling()
l_int32 pixUsesCmapColor(PIX *pixs, l_int32 *pcolor)
pixUsesCmapColor()
l_int32 pixGetPerceptualDiff(PIX *pixs1, PIX *pixs2, l_int32 sampling, l_int32 dilation, l_int32 mindiff, l_float32 *pfract, PIX **ppixdiff1, PIX **ppixdiff2)
pixGetPerceptualDiff()
PIX * pixaccFinal(PIXACC *pixacc, l_int32 outdepth)
pixaccFinal()
l_int32 pixPaintThroughMask(PIX *pixd, PIX *pixm, l_int32 x, l_int32 y, l_uint32 val)
pixPaintThroughMask()
l_int32 pixDecideIfText(PIX *pixs, BOX *box, l_int32 *pistext, PIXA *pixadb)
pixDecideIfText()
void numaDestroy(NUMA **pna)
numaDestroy()
l_int32 pixSetResolution(PIX *pix, l_int32 xres, l_int32 yres)
pixSetResolution()
PIX * pixReduceRankBinary2(PIX *pixs, l_int32 level, l_uint8 *intab)
pixReduceRankBinary2()
NUMA * numaTransform(NUMA *nas, l_float32 shift, l_float32 scale)
numaTransform()
PIX * pixRead(const char *filename)
pixRead()
NUMA * pixGetDifferenceHistogram(PIX *pix1, PIX *pix2, l_int32 factor)
pixGetDifferenceHistogram()
char * pixGetText(PIX *pix)
pixGetText()
l_int32 pixaJoin(PIXA *pixad, PIXA *pixas, l_int32 istart, l_int32 iend)
pixaJoin()
NUMA * numaWindowedMean(NUMA *nas, l_int32 wc)
numaWindowedMean()
l_int32 l_getDataFourBytes(void *line, l_int32 n)
l_getDataFourBytes()
PIX * pixExpandReplicate(PIX *pixs, l_int32 factor)
pixExpandReplicate()
l_int32 pixEqual(PIX *pix1, PIX *pix2, l_int32 *psame)
pixEqual()
FPIX * fpixCreate(l_int32 width, l_int32 height)
fpixCreate()
l_float32 * numaGetFArray(NUMA *na, l_int32 copyflag)
numaGetFArray()
l_int32 numaWrite(const char *filename, NUMA *na)
numaWrite()
l_int32 numaaGetCount(NUMAA *naa)
numaaGetCount()
PIXACC * pixaccCreate(l_int32 w, l_int32 h, l_int32 negflag)
pixaccCreate()
PIX * pixaGetPix(PIXA *pixa, l_int32 index, l_int32 accesstype)
pixaGetPix()
l_int32 numaaGetNumaCount(NUMAA *naa, l_int32 index)
numaaGetNumaCount()
l_int32 pixcmapGetCount(PIXCMAP *cmap)
pixcmapGetCount()
l_int32 pixGetPSNR(PIX *pix1, PIX *pix2, l_int32 factor, l_float32 *ppsnr)
pixGetPSNR()
void l_setDataFourBytes(void *line, l_int32 n, l_int32 val)
l_setDataFourBytes()
l_int32 numaSetValue(NUMA *na, l_int32 index, l_float32 val)
numaSetValue()
l_int32 pixComparePhotoRegionsByHisto(PIX *pix1, PIX *pix2, BOX *box1, BOX *box2, l_float32 minratio, l_int32 factor, l_int32 nx, l_int32 ny, l_float32 *pscore, l_int32 debugflag)
pixComparePhotoRegionsByHisto()
l_int32 pixGetDifferenceStats(PIX *pix1, PIX *pix2, l_int32 factor, l_int32 mindiff, l_float32 *pfractdiff, l_float32 *pavediff, l_int32 details)
pixGetDifferenceStats()
NUMAA * l_uncompressGrayHistograms(l_uint8 *bytea, size_t size, l_int32 *pw, l_int32 *ph)
l_uncompressGrayHistograms()
PIX * pixCopy(PIX *pixd, PIX *pixs)
pixCopy()
void boxDestroy(BOX **pbox)
boxDestroy()
l_int32 gplotSimple2(NUMA *na1, NUMA *na2, l_int32 outformat, const char *outroot, const char *title)
gplotSimple2()
NUMA * numaNormalizeHistogram(NUMA *nas, l_float32 tsum)
numaNormalizeHistogram()
PIX * pixAddTextlines(PIX *pixs, L_BMF *bmf, const char *textstr, l_uint32 val, l_int32 location)
pixAddTextlines()
l_int32 numaGetIValue(NUMA *na, l_int32 index, l_int32 *pival)
numaGetIValue()
PIX * pixMinOrMax(PIX *pixd, PIX *pixs1, PIX *pixs2, l_int32 type)
pixMinOrMax()
l_int32 pixSetAll(PIX *pix)
pixSetAll()
l_int32 fpixSetPixel(FPIX *fpix, l_int32 x, l_int32 y, l_float32 val)
fpixSetPixel()
l_int32 pixGetDimensions(PIX *pix, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixGetDimensions()
l_int32 lept_rmdir(const char *subdir)
lept_rmdir()
l_int32 pixCorrelationBinary(PIX *pix1, PIX *pix2, l_float32 *pval)
pixCorrelationBinary()
void fpixDestroy(FPIX **pfpix)
fpixDestroy()
l_int32 pixCountPixels(PIX *pixs, l_int32 *pcount, l_int32 *tab8)
pixCountPixels()
l_int32 pixRasteropIP(PIX *pixd, l_int32 hshift, l_int32 vshift, l_int32 incolor)
pixRasteropIP()
void pixaDestroy(PIXA **ppixa)
pixaDestroy()
void extractRGBValues(l_uint32 pixel, l_int32 *prval, l_int32 *pgval, l_int32 *pbval)
extractRGBValues()
BOX * boxCreate(l_int32 x, l_int32 y, l_int32 w, l_int32 h)
boxCreate()
l_uint8 * makeSubsampleTab2x(void)
Permutation table for 2x rank binary reduction.
l_int32 pixaGetCount(PIXA *pixa)
pixaGetCount()
l_int32 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_int32 pixCompareGray(PIX *pix1, PIX *pix2, l_int32 comptype, l_int32 plottype, l_int32 *psame, l_float32 *pdiff, l_float32 *prmsdiff, PIX **ppixdiff)
pixCompareGray()
l_int32 pixGetAverageMasked(PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor, l_int32 type, l_float32 *pval)
pixGetAverageMasked()
PIX * pixColorMorph(PIX *pixs, l_int32 type, l_int32 hsize, l_int32 vsize)
pixColorMorph()
l_int32 numaWriteStream(FILE *fp, NUMA *na)
numaWriteStream()
l_int32 pixcmapHasColor(PIXCMAP *cmap, l_int32 *pcolor)
pixcmapHasColor()
L_BMF * bmfCreate(const char *dir, l_int32 fontsize)
bmfCreate()