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));
1895 l_float32 textthresh,
1899 l_float32 simthresh,
1901 l_float32 **pscores,
1906 l_int32 i, j, n, w, h, w1, h1, w2, h2, ival, index, classid;
1909 NUMA *nai, *naw, *nah;
1914 PROCNAME(
"pixaComparePhotoRegionsByHisto");
1916 if (pscores) *pscores = NULL;
1917 if (ppixd) *ppixd = NULL;
1919 return ERROR_INT(
"&na not defined", procName, 1);
1922 return ERROR_INT(
"pixa not defined", procName, 1);
1923 if (minratio < 0.0 || minratio > 1.0)
1924 return ERROR_INT(
"minratio not in [0.0 ... 1.0]", procName, 1);
1925 if (textthresh <= 0.0) textthresh = 1.3;
1927 return ERROR_INT(
"subsampling factor must be >= 1", procName, 1);
1928 if (nx < 1 || ny < 1)
1929 return ERROR_INT(
"nx and ny must both be > 0", procName, 1);
1930 if (simthresh <= 0.0) simthresh = 0.25;
1931 if (simthresh > 1.0)
1932 return ERROR_INT(
"simthresh invalid; should be near 0.25", procName, 1);
1936 if ((n3a = (
NUMAA **)LEPT_CALLOC(n,
sizeof(
NUMAA *))) == NULL)
1937 return ERROR_INT(
"calloc fail for n3a", procName, 1);
1940 for (i = 0; i < n; i++) {
1944 index = (debug) ? i : 0;
1946 &naa, &w, &h, index);
1951 fprintf(stderr,
"Image %s is photo\n", text);
1953 fprintf(stderr,
"Image %s is NOT photo\n", text);
1963 if ((scores = (l_float32 *)LEPT_CALLOC((
size_t)n * n,
sizeof(l_float32)))
1965 L_ERROR(
"calloc fail for scores\n", procName);
1969 for (i = 0, classid = 0; i < n; i++) {
1970 scores[n * i + i] = 1.0;
1975 if (n3a[i] == NULL) {
1981 for (j = i + 1; j < n; j++) {
1991 scores[n * i + j] = score;
1992 scores[n * j + i] = score;
1994 if (score > simthresh) {
1997 "Setting %d similar to %d, in class %d; score %5.3f\n",
1998 j, i, classid, score);
2013 l_uint32 *line, *data;
2017 wpl = pixGetWpl(pix2);
2018 for (i = 0; i < n; i++) {
2019 line = data + i * wpl;
2020 for (j = 0; j < n; j++) {
2022 L_MIN(255, 4.0 * 255 * scores[n * i + j]));
2025 fact = L_MAX(2, 1000 / n);
2027 fprintf(stderr,
"Writing to /tmp/lept/comp/scorearray.png\n");
2029 pixWrite(
"/tmp/lept/comp/scorearray.png", pix3, IFF_PNG);
2046 for (i = 0; i < n; i++)
2116 l_int32 w1, h1, w2, h2, w1c, h1c, w2c, h2c, debugindex;
2117 l_float32 wratio, hratio;
2122 PROCNAME(
"pixComparePhotoRegionsByHisto");
2125 return ERROR_INT(
"&score not defined", procName, 1);
2128 return ERROR_INT(
"pix1 and pix2 not both defined", procName, 1);
2129 if (minratio < 0.5 || minratio > 1.0)
2130 return ERROR_INT(
"minratio not in [0.5 ... 1.0]", procName, 1);
2132 return ERROR_INT(
"subsampling factor must be >= 1", procName, 1);
2133 if (nx < 1 || ny < 1)
2134 return ERROR_INT(
"nx and ny must both be > 0", procName, 1);
2151 wratio = (w1 < w2) ? (l_float32)w1 / (l_float32)w2 :
2152 (l_float32)w2 / (l_float32)w1;
2153 hratio = (h1 < h2) ? (l_float32)h1 / (l_float32)h2 :
2154 (l_float32)h2 / (l_float32)h1;
2155 if (wratio < minratio || hratio < minratio)
2164 &naa1, &w1c, &h1c, debugindex);
2166 if (!naa1)
return 0;
2172 &naa2, &w2c, &h2c, debugindex);
2174 if (!naa2)
return 0;
2228 PIX *pix1, *pix2, *pix3, *pixm;
2231 PROCNAME(
"pixGenPhotoHistos");
2233 if (pnaa) *pnaa = NULL;
2237 return ERROR_INT(
"&naa not defined", procName, 1);
2239 return ERROR_INT(
"&w and &h not both defined", procName, 1);
2240 if (!pixs || pixGetDepth(pixs) == 1)
2241 return ERROR_INT(
"pixs not defined or 1 bpp", procName, 1);
2243 return ERROR_INT(
"subsampling factor must be >= 1", procName, 1);
2244 if (nx < 1 || ny < 1)
2245 return ERROR_INT(
"nx and ny must both be > 0", procName, 1);
2246 if (thresh <= 0.0) thresh = 1.3;
2249 if (debugindex > 0) {
2271 if (debugindex > 0) {
2272 PIX *pix4, *pix5, *pix6, *pix7, *pix8;
2294 *pw = pixGetWidth(pix3);
2295 *ph = pixGetHeight(pix3);
2299 snprintf(buf,
sizeof(buf),
"/tmp/lept/comp/tiledhistos.%d.pdf",
2301 fprintf(stderr,
"Writing to %s\n", buf);
2332 l_int32 xs, ys, delx, dely, icx, icy, ws, hs, wd, hd;
2335 PROCNAME(
"pixPadToCenterCentroid");
2338 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
2340 return (
PIX *)ERROR_PTR(
"invalid sampling factor", procName, NULL);
2344 icx = (l_int32)(cx + 0.5);
2345 icy = (l_int32)(cy + 0.5);
2347 delx = ws - 2 * icx;
2348 dely = hs - 2 * icy;
2349 xs = L_MAX(0, delx);
2350 ys = L_MAX(0, dely);
2351 wd = 2 * L_MAX(icx, ws - icx);
2352 hd = 2 * L_MAX(icy, hs - icy);
2355 pixCopyResolution(pixd, pixs);
2386 l_int32 i, j, w, h, wpl, val;
2387 l_float32 sumx, sumy, sumv;
2388 l_uint32 *data, *line;
2391 PROCNAME(
"pixCentroid8");
2393 if (pcx) *pcx = 0.0;
2394 if (pcy) *pcy = 0.0;
2395 if (!pixs || pixGetDepth(pixs) != 8)
2396 return ERROR_INT(
"pixs undefined or not 8 bpp", procName, 1);
2398 return ERROR_INT(
"subsampling factor must be >= 1", procName, 1);
2400 return ERROR_INT(
"&cx and &cy not both defined", procName, 1);
2405 wpl = pixGetWpl(pix1);
2406 sumx = sumy = sumv = 0.0;
2407 for (i = 0; i < h; i++) {
2408 line = data + i * wpl;
2409 for (j = 0; j < w; j++) {
2419 L_INFO(
"input image is white\n", procName);
2420 *pcx = (l_float32)(w) / 2;
2421 *pcy = (l_float32)(h) / 2;
2468 l_int32 i, n, istext, isphoto;
2469 l_float32 maxval, sum1, sum2, ratio;
2471 NUMA *na1, *na2, *na3, *narv;
2474 PIXA *pixa, *pixa2, *pixa3;
2476 PROCNAME(
"pixDecideIfPhotoImage");
2479 return ERROR_INT(
"&naa not defined", procName, 1);
2481 if (!pix || pixGetDepth(pix) != 8 || pixGetColormap(pix))
2482 return ERROR_INT(
"pix undefined or invalid", procName, 1);
2483 if (thresh <= 0.0) thresh = 1.3;
2488 L_INFO(
"Image is text\n", procName);
2495 bmf = (pixadebug) ?
bmfCreate(NULL, 6) : NULL;
2501 for (i = 0; i < n; i++) {
2511 snprintf(buf,
sizeof(buf),
"/tmp/lept/compplot/plot.%d", i);
2546 ratio = sum1 / sum2;
2547 isphoto = (ratio > thresh) ? 1 : 0;
2550 L_INFO(
"ratio %f > %f; isphoto is true\n",
2551 procName, ratio, thresh);
2553 L_INFO(
"ratio %f < %f; isphoto is false\n",
2554 procName, ratio, thresh);
2601 char buf1[128], buf2[128];
2603 l_float32 wratio, hratio, score, minscore, dist;
2605 NUMA *na1, *na2, *nadist, *nascore;
2607 PROCNAME(
"compareTilesByHisto");
2610 return ERROR_INT(
"&score not defined", procName, 1);
2613 return ERROR_INT(
"naa1 and naa2 not both defined", procName, 1);
2618 return ERROR_INT(
"naa1 and naa2 are different size", procName, 1);
2625 wratio = (w1 < w2) ? (l_float32)w1 / (l_float32)w2 :
2626 (l_float32)w2 / (l_float32)w1;
2627 hratio = (h1 < h2) ? (l_float32)h1 / (l_float32)h2 :
2628 (l_float32)h2 / (l_float32)h1;
2629 if (wratio < minratio || hratio < minratio) {
2631 L_INFO(
"Sizes differ: wratio = %f, hratio = %f\n",
2632 procName, wratio, hratio);
2643 bmf = (pixadebug) ?
bmfCreate(NULL, 6) : NULL;
2644 for (i = 0; i < n; i++) {
2655 score = L_MAX(0.0, 1.0 - 10.0 * (dist / 255.));
2658 minscore = L_MIN(minscore, score);
2660 snprintf(buf1,
sizeof(buf1),
"/tmp/lept/comptile/plot.%d", i);
2669 for (i = 0; i < n; i++) {
2671 snprintf(buf1,
sizeof(buf1),
"/tmp/lept/comptile/plot.%d.png", i);
2675 snprintf(buf2,
sizeof(buf2),
2676 "Image %d\ndist = %5.3f, score = %5.3f", i, dist, score);
2681 fprintf(stderr,
"Writing to /tmp/lept/comptile/comparegray.pdf\n");
2683 "/tmp/lept/comptile/comparegray.pdf");
2771 l_int32 w1, h1, w2, h2;
2772 l_float32 wratio, hratio;
2774 PIX *pix3, *pix4, *pix5, *pix6, *pix7, *pix8;
2777 PROCNAME(
"pixCompareGrayByHisto");
2780 return ERROR_INT(
"&score not defined", procName, 1);
2783 return ERROR_INT(
"pix1 and pix2 not both defined", procName, 1);
2784 if (minratio < 0.5 || minratio > 1.0)
2785 return ERROR_INT(
"minratio not in [0.5 ... 1.0]", procName, 1);
2787 return ERROR_INT(
"invalid maxgray; should be >= 200", procName, 1);
2788 maxgray = L_MIN(255, maxgray);
2790 return ERROR_INT(
"subsampling factor must be >= 1", procName, 1);
2791 if (nx < 1 || ny < 1)
2792 return ERROR_INT(
"nx and ny must both be > 0", procName, 1);
2806 wratio = (w1 < w2) ? (l_float32)w1 / (l_float32)w2 :
2807 (l_float32)w2 / (l_float32)w1;
2808 hratio = (h1 < h2) ? (l_float32)h1 / (l_float32)h2 :
2809 (l_float32)h2 / (l_float32)h1;
2810 if (wratio < minratio || hratio < minratio)
2831 PIX *pix9, *pix10, *pix11, *pix12, *pix13;
2896 l_float32 score, minscore, maxval1, maxval2, dist;
2898 NUMA *na1, *na2, *na3, *na4, *na5, *na6, *na7;
2900 PIXA *pixa1, *pixa2;
2902 PROCNAME(
"pixCompareTilesByHisto");
2905 return ERROR_INT(
"&score not defined", procName, 1);
2908 return ERROR_INT(
"pix1 and pix2 not both defined", procName, 1);
2915 bmf = (pixadebug) ?
bmfCreate(NULL, 6) : NULL;
2917 for (i = 0; i < n; i++) {
2924 if (maxgray < 255) {
2925 for (j = maxgray + 1; j <= 255; j++) {
2937 gplotSimple2(na5, na6, GPLOT_PNG,
"/tmp/lept/comp/plot1",
"Histos");
2945 score = L_MAX(0.0, 1.0 - 8.0 * (dist / 255.));
2947 minscore = L_MIN(minscore, score);
2949 PIX *pix5, *pix6, *pix7, *pix8, *pix9, *pix10;
2951 l_int32 w, h, wscale;
2954 wscale = (w > h) ? 700 : 400;
2959 pix7 =
pixRead(
"/tmp/lept/comp/plot1.png");
2961 snprintf(buf,
sizeof(buf),
"%5.3f", score);
2983 "/tmp/lept/comp/comparegray.pdf");
3018 l_float32 cx1, cy1, cx2, cy2;
3019 l_int32 w1, h1, w2, h2, icx1, icy1, icx2, icy2;
3020 l_int32 xm, xm1, xm2, xp, xp1, xp2, ym, ym1, ym2, yp, yp1, yp2;
3023 PROCNAME(
"pixCropAlignedToCentroid");
3025 if (pbox1) *pbox1 = NULL;
3026 if (pbox2) *pbox2 = NULL;
3028 return ERROR_INT(
"pix1 and pix2 not both defined", procName, 1);
3030 return ERROR_INT(
"subsampling factor must be >= 1", procName, 1);
3031 if (!pbox1 || !pbox2)
3032 return ERROR_INT(
"&box1 and &box2 not both defined", procName, 1);
3043 icx1 = (l_int32)(cx1 + 0.5);
3044 icy1 = (l_int32)(cy1 + 0.5);
3045 icx2 = (l_int32)(cx2 + 0.5);
3046 icy2 = (l_int32)(cy2 + 0.5);
3047 xm = L_MIN(icx1, icx2);
3050 xp = L_MIN(w1 - icx1, w2 - icx2);
3053 ym = L_MIN(icy1, icy2);
3056 yp = L_MIN(h1 - icy1, h2 - icy2);
3059 *pbox1 =
boxCreate(xm1, ym1, xp1 - xm1, yp1 - ym1);
3060 *pbox2 =
boxCreate(xm2, ym2, xp2 - xm2, yp2 - ym2);
3093 l_int32 i, j, n, nn, ival;
3097 PROCNAME(
"l_compressGrayHistograms");
3100 return (l_uint8 *)ERROR_PTR(
"&size not defined", procName, NULL);
3103 return (l_uint8 *)ERROR_PTR(
"naa not defined", procName, NULL);
3105 for (i = 0; i < n; i++) {
3108 L_ERROR(
"%d numbers in numa[%d]\n", procName, nn, i);
3113 if ((bytea = (l_uint8 *)LEPT_CALLOC(8 + 256 * n,
sizeof(l_uint8))) == NULL)
3114 return (l_uint8 *)ERROR_PTR(
"bytea not made", procName, NULL);
3115 *psize = 8 + 256 * n;
3118 for (i = 0; i < n; i++) {
3122 for (j = 0; j < 256; j++) {
3124 bytea[8 + 256 * i + j] = ival;
3164 PROCNAME(
"l_uncompressGrayHistograms");
3169 return (
NUMAA *)ERROR_PTR(
"&w and &h not both defined", procName, NULL);
3171 return (
NUMAA *)ERROR_PTR(
"bytea not defined", procName, NULL);
3172 n = (size - 8) / 256;
3173 if ((size - 8) % 256 != 0)
3174 return (
NUMAA *)ERROR_PTR(
"bytea size is invalid", procName, NULL);
3179 for (i = 0; i < n; i++) {
3181 for (j = 0; j < 256; j++)
3233 l_int32 i, level, area1, area2, delx, dely;
3234 l_int32 etransx, etransy, maxshift, dbint;
3235 l_int32 *stab, *ctab;
3236 l_float32 cx1, cx2, cy1, cy2, score;
3237 PIX *pixb1, *pixb2, *pixt1, *pixt2, *pixt3, *pixt4;
3238 PIXA *pixa1, *pixa2, *pixadb;
3240 PROCNAME(
"pixCompareWithTranslation");
3242 if (pdelx) *pdelx = 0;
3243 if (pdely) *pdely = 0;
3244 if (pscore) *pscore = 0.0;
3245 if (!pdelx || !pdely)
3246 return ERROR_INT(
"&delx and &dely not defined", procName, 1);
3248 return ERROR_INT(
"&score not defined", procName, 1);
3250 return ERROR_INT(
"pix1 not defined", procName, 1);
3252 return ERROR_INT(
"pix2 not defined", procName, 1);
3271 for (i = 0; i < 3; i++) {
3284 for (level = 3; level >= 0; level--) {
3300 dbint = (debugflag) ? level + 1 : 0;
3302 maxshift, stab, &delx, &dely, &score, dbint);
3304 fprintf(stderr,
"Level %d: delx = %d, dely = %d, score = %7.4f\n",
3305 level, delx, dely, score);
3318 "/tmp/lept/comp/compare.pdf");
3320 0,
"Correlation scores at levels 1 through 5",
3321 "/tmp/lept/comp/correl.pdf");
3391 l_int32 shiftx, shifty, delx, dely;
3393 l_float32 maxscore, score;
3397 PROCNAME(
"pixBestCorrelation");
3399 if (pdelx) *pdelx = 0;
3400 if (pdely) *pdely = 0;
3401 if (pscore) *pscore = 0.0;
3402 if (!pix1 || pixGetDepth(pix1) != 1)
3403 return ERROR_INT(
"pix1 not defined or not 1 bpp", procName, 1);
3404 if (!pix2 || pixGetDepth(pix2) != 1)
3405 return ERROR_INT(
"pix2 not defined or not 1 bpp", procName, 1);
3406 if (!area1 || !area2)
3407 return ERROR_INT(
"areas must be > 0", procName, 1);
3410 fpix =
fpixCreate(2 * maxshift + 1, 2 * maxshift + 1);
3421 for (shifty = -maxshift; shifty <= maxshift; shifty++) {
3422 for (shiftx = -maxshift; shiftx <= maxshift; shiftx++) {
3423 pixCorrelationScoreShifted(pix1, pix2, area1, area2,
3425 etransy + shifty, tab, &score);
3426 if (debugflag > 0) {
3427 fpixSetPixel(fpix, maxshift + shiftx, maxshift + shifty,
3432 if (score > maxscore) {
3434 delx = etransx + shiftx;
3435 dely = etransy + shifty;
3440 if (debugflag > 0) {
3445 snprintf(buf,
sizeof(buf),
"/tmp/lept/comp/correl_%d.png",
3447 pixWrite(buf, pix4, IFF_PNG);
3453 if (pdelx) *pdelx = delx;
3454 if (pdely) *pdely = dely;
3455 if (pscore) *pscore = maxscore;
3456 if (!tab8) LEPT_FREE(tab);
void gplotDestroy(GPLOT **pgplot)
gplotDestroy()
l_ok 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 * pixGetGrayHistogram(PIX *pixs, l_int32 factor)
pixGetGrayHistogram()
void bmfDestroy(L_BMF **pbmf)
bmfDestroy()
PIX * pixConvertTo1(PIX *pixs, l_int32 threshold)
pixConvertTo1()
l_ok numaGetFValue(NUMA *na, l_int32 index, l_float32 *pval)
numaGetFValue()
l_ok pixCorrelationBinary(PIX *pix1, PIX *pix2, l_float32 *pval)
pixCorrelationBinary()
PIX * pixRemoveColormap(PIX *pixs, l_int32 type)
pixRemoveColormap()
l_int32 lept_mkdir(const char *subdir)
lept_mkdir()
l_ok 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 debugindex)
pixGenPhotoHistos()
l_ok gplotAddPlot(GPLOT *gplot, NUMA *nax, NUMA *nay, l_int32 plotstyle, const char *plottitle)
gplotAddPlot()
l_ok pixCentroid(PIX *pix, l_int32 *centtab, l_int32 *sumtab, l_float32 *pxave, l_float32 *pyave)
pixCentroid()
PIX * pixDilateGray(PIX *pixs, l_int32 hsize, l_int32 vsize)
pixDilateGray()
PIX * pixConvertTo32(PIX *pixs)
pixConvertTo32()
l_int32 lept_roundftoi(l_float32 fval)
lept_roundftoi()
l_int32 * makePixelCentroidTab8(void)
makePixelCentroidTab8()
PIX * pixConvertLossless(PIX *pixs, l_int32 d)
pixConvertLossless()
l_ok pixUsesCmapColor(PIX *pixs, l_int32 *pcolor)
pixUsesCmapColor()
PIXA * pixaReadFiles(const char *dirname, const char *substr)
pixaReadFiles()
l_uint8 * l_compressGrayHistograms(NUMAA *naa, l_int32 w, l_int32 h, size_t *psize)
l_compressGrayHistograms()
l_ok numaWriteDebug(const char *filename, NUMA *na)
numaWriteDebug()
l_ok numaAddNumber(NUMA *na, l_float32 val)
numaAddNumber()
PIXA * pixaCreate(l_int32 n)
pixaCreate()
l_ok gplotMakeOutput(GPLOT *gplot)
gplotMakeOutput()
GPLOT * gplotCreate(const char *rootname, l_int32 outformat, const char *title, const char *xlabel, const char *ylabel)
gplotCreate()
l_ok numaGetNonzeroRange(NUMA *na, l_float32 eps, l_int32 *pfirst, l_int32 *plast)
numaGetNonzeroRange()
l_ok pixRasteropIP(PIX *pixd, l_int32 hshift, l_int32 vshift, l_int32 incolor)
pixRasteropIP()
l_ok numaEarthMoverDistance(NUMA *na1, NUMA *na2, l_float32 *pdist)
numaEarthMoverDistance()
l_ok cmapEqual(PIXCMAP *cmap1, PIXCMAP *cmap2, l_int32 ncomps, l_int32 *psame)
cmapEqual()
l_ok pixDecideIfText(PIX *pixs, BOX *box, l_int32 *pistext, PIXA *pixadb)
pixDecideIfText()
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 * pixConvertTo8(PIX *pixs, l_int32 cmapflag)
pixConvertTo8()
NUMA * numaMakeConstant(l_float32 val, l_int32 size)
numaMakeConstant()
PIX * pixGetAverageTiled(PIX *pixs, l_int32 sx, l_int32 sy, l_int32 type)
pixGetAverageTiled()
PIX * pixCreate(l_int32 width, l_int32 height, l_int32 depth)
pixCreate()
l_ok pixSetMaskedGeneral(PIX *pixd, PIX *pixm, l_uint32 val, l_int32 x, l_int32 y)
pixSetMaskedGeneral()
PIXA * pixaSplitPix(PIX *pixs, l_int32 nx, l_int32 ny, l_int32 borderwidth, l_uint32 bordercolor)
pixaSplitPix()
l_ok pixSetAll(PIX *pix)
pixSetAll()
PIX * pixInvert(PIX *pixd, PIX *pixs)
pixInvert()
l_ok numaWriteStream(FILE *fp, NUMA *na)
numaWriteStream()
NUMA * numaCreate(l_int32 n)
numaCreate()
l_uint32 * pixGetData(PIX *pix)
pixGetData()
l_ok numaSetCount(NUMA *na, l_int32 newcount)
numaSetCount()
l_ok pixCompareBinary(PIX *pix1, PIX *pix2, l_int32 comptype, l_float32 *pfract, PIX **ppixdiff)
pixCompareBinary()
PIX * pixThresholdToBinary(PIX *pixs, l_int32 thresh)
pixThresholdToBinary()
NUMA * numaClipToInterval(NUMA *nas, l_int32 first, l_int32 last)
numaClipToInterval()
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_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()
NUMAA * numaaCreate(l_int32 n)
numaaCreate()
PIX * pixClipRectangle(PIX *pixs, BOX *box, BOX **pboxc)
pixClipRectangle()
PIX * pixaDisplayTiledInColumns(PIXA *pixas, l_int32 nx, l_float32 scalefactor, l_int32 spacing, l_int32 border)
pixaDisplayTiledInColumns()
l_ok pixaccMultConst(PIXACC *pixacc, l_float32 factor)
pixaccMultConst()
l_ok numaSetValue(NUMA *na, l_int32 index, l_float32 val)
numaSetValue()
l_ok pixSetColormap(PIX *pix, PIXCMAP *colormap)
pixSetColormap()
PIX * pixDisplayDiffBinary(PIX *pix1, PIX *pix2)
pixDisplayDiffBinary()
l_ok pixCentroid8(PIX *pixs, l_int32 factor, l_float32 *pcx, l_float32 *pcy)
pixCentroid8()
l_ok 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_ok fpixSetPixel(FPIX *fpix, l_int32 x, l_int32 y, l_float32 val)
fpixSetPixel()
l_ok pixPaintThroughMask(PIX *pixd, PIX *pixm, l_int32 x, l_int32 y, l_uint32 val)
pixPaintThroughMask()
PIXCMAP * pixcmapCreate(l_int32 depth)
pixcmapCreate()
PIX * fpixDisplayMaxDynamicRange(FPIX *fpixs)
fpixDisplayMaxDynamicRange()
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_ok numaGetIValue(NUMA *na, l_int32 index, l_int32 *pival)
numaGetIValue()
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 pixaAddPix(PIXA *pixa, PIX *pix, l_int32 copyflag)
pixaAddPix()
PIX * pixaDisplayTiledByIndex(PIXA *pixa, NUMA *na, l_int32 width, l_int32 spacing, l_int32 border, l_int32 fontsize, l_uint32 textcolor)
pixaDisplayTiledByIndex()
l_ok pixGetAverageMasked(PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor, l_int32 type, l_float32 *pval)
pixGetAverageMasked()
PIX * pixXor(PIX *pixd, PIX *pixs1, PIX *pixs2)
pixXor()
PIX * pixAbsDifference(PIX *pixs1, PIX *pixs2)
pixAbsDifference()
l_ok 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, l_int32 debug)
pixaComparePhotoRegionsByHisto()
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_ok pixcmapGetColor(PIXCMAP *cmap, l_int32 index, l_int32 *prval, l_int32 *pgval, l_int32 *pbval)
pixcmapGetColor()
l_ok 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_ok pixCountPixels(PIX *pixs, l_int32 *pcount, l_int32 *tab8)
pixCountPixels()
l_ok gplotSimple2(NUMA *na1, NUMA *na2, l_int32 outformat, const char *outroot, const char *title)
gplotSimple2()
l_int32 * makePixelSumTab8(void)
makePixelSumTab8()
l_ok pixEqualWithAlpha(PIX *pix1, PIX *pix2, l_int32 use_alpha, l_int32 *psame)
pixEqualWithAlpha()
#define SET_DATA_BYTE(pdata, n, val)
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()
#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()
PIX * pixScaleToSize(PIX *pixs, l_int32 wd, l_int32 hd)
pixScaleToSize()
void pixDestroy(PIX **ppix)
pixDestroy()
PIX * pixScaleByIntSampling(PIX *pixs, l_int32 factor)
pixScaleByIntSampling()
l_ok pixcmapHasColor(PIXCMAP *cmap, l_int32 *pcolor)
pixcmapHasColor()
l_ok pixCropAlignedToCentroid(PIX *pix1, PIX *pix2, l_int32 factor, BOX **pbox1, BOX **pbox2)
pixCropAlignedToCentroid()
PIX * pixaccFinal(PIXACC *pixacc, l_int32 outdepth)
pixaccFinal()
void numaDestroy(NUMA **pna)
numaDestroy()
l_ok pixGetPixel(PIX *pix, l_int32 x, l_int32 y, l_uint32 *pval)
pixGetPixel()
l_ok pixGetDimensions(const PIX *pix, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixGetDimensions()
PIX * pixReduceRankBinary2(PIX *pixs, l_int32 level, l_uint8 *intab)
pixReduceRankBinary2()
NUMA * numaTransform(NUMA *nas, l_float32 shift, l_float32 scale)
numaTransform()
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()
PIX * pixRead(const char *filename)
pixRead()
NUMA * pixGetDifferenceHistogram(PIX *pix1, PIX *pix2, l_int32 factor)
pixGetDifferenceHistogram()
char * pixGetText(PIX *pix)
pixGetText()
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()
FPIX * fpixCreate(l_int32 width, l_int32 height)
fpixCreate()
l_float32 * numaGetFArray(NUMA *na, l_int32 copyflag)
numaGetFArray()
l_ok pixCompareTiled(PIX *pix1, PIX *pix2, l_int32 sx, l_int32 sy, l_int32 type, PIX **ppixdiff)
pixCompareTiled()
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_int32 numaaGetCount(NUMAA *naa)
numaaGetCount()
PIXACC * pixaccCreate(l_int32 w, l_int32 h, l_int32 negflag)
pixaccCreate()
PIXA * pixaScale(PIXA *pixas, l_float32 scalex, l_float32 scaley)
pixaScale()
PIX * pixaGetPix(PIXA *pixa, l_int32 index, l_int32 accesstype)
pixaGetPix()
l_int32 numaaGetNumaCount(NUMAA *naa, l_int32 index)
numaaGetNumaCount()
l_ok pixRenderBoxArb(PIX *pix, BOX *box, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval)
pixRenderBoxArb()
l_int32 pixcmapGetCount(PIXCMAP *cmap)
pixcmapGetCount()
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()
void l_setDataFourBytes(void *line, l_int32 n, l_int32 val)
l_setDataFourBytes()
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 pixZero(PIX *pix, l_int32 *pempty)
pixZero()
NUMAA * l_uncompressGrayHistograms(l_uint8 *bytea, size_t size, l_int32 *pw, l_int32 *ph)
l_uncompressGrayHistograms()
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()
PIX * pixCopy(PIX *pixd, PIX *pixs)
pixCopy()
l_ok pixAlphaIsOpaque(PIX *pix, l_int32 *popaque)
pixAlphaIsOpaque()
void boxDestroy(BOX **pbox)
boxDestroy()
l_ok pixEqual(PIX *pix1, PIX *pix2, l_int32 *psame)
pixEqual()
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()
PIX * pixMinOrMax(PIX *pixd, PIX *pixs1, PIX *pixs2, l_int32 type)
pixMinOrMax()
l_ok pixSetResolution(PIX *pix, l_int32 xres, l_int32 yres)
pixSetResolution()
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 pixDecideIfPhotoImage(PIX *pix, l_int32 factor, l_int32 nx, l_int32 ny, l_float32 thresh, NUMAA **pnaa, PIXA *pixadebug)
pixDecideIfPhotoImage()
l_ok numaGetMax(NUMA *na, l_float32 *pmaxval, l_int32 *pimaxloc)
numaGetMax()
l_ok pixcmapGetRGBA(PIXCMAP *cmap, l_int32 index, l_int32 *prval, l_int32 *pgval, l_int32 *pbval, l_int32 *paval)
pixcmapGetRGBA()
l_ok pixaccAdd(PIXACC *pixacc, PIX *pix)
pixaccAdd()
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_int32 lept_rmdir(const char *subdir)
lept_rmdir()
l_int32 pixSizesEqual(const PIX *pix1, const PIX *pix2)
pixSizesEqual()
l_ok pixEqualWithCmap(PIX *pix1, PIX *pix2, l_int32 *psame)
pixEqualWithCmap()
l_ok pixcmapAddColor(PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval)
pixcmapAddColor()
void fpixDestroy(FPIX **pfpix)
fpixDestroy()
l_ok boxGetGeometry(BOX *box, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
boxGetGeometry()
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_ok grayInterHistogramStats(NUMAA *naa, l_int32 wc, NUMA **pnam, NUMA **pnams, NUMA **pnav, NUMA **pnarv)
grayInterHistogramStats()
l_uint8 * makeSubsampleTab2x(void)
Permutation table for 2x rank binary reduction.
l_int32 pixaGetCount(PIXA *pixa)
pixaGetCount()
l_ok numaGetSumOnInterval(NUMA *na, l_int32 first, l_int32 last, l_float32 *psum)
numaGetSumOnInterval()
l_ok gplotSimple1(NUMA *na, l_int32 outformat, const char *outroot, const char *title)
gplotSimple1()
l_ok numaaAddNuma(NUMAA *naa, NUMA *na, l_int32 copyflag)
numaaAddNuma()
PIX * pixColorMorph(PIX *pixs, l_int32 type, l_int32 hsize, l_int32 vsize)
pixColorMorph()
l_ok pixGetPSNR(PIX *pix1, PIX *pix2, l_int32 factor, l_float32 *ppsnr)
pixGetPSNR()
L_BMF * bmfCreate(const char *dir, l_int32 fontsize)
bmfCreate()