103 #include <config_auto.h>
107 #include "allheaders.h"
111 #define M_PI 3.14159265358979323846
133 return (
PTA *)ERROR_PTR(
"ptas not defined", __func__, NULL);
135 return (
PTA *)ERROR_PTR(
"subfactor < 1", __func__, NULL);
139 for (i = 0; i < n; i++) {
140 if (i % subfactor != 0)
continue;
174 return ERROR_INT(
"ptad not defined", __func__, 1);
181 if (iend < 0 || iend >= n)
184 return ERROR_INT(
"istart > iend; no pts", __func__, 1);
186 for (i = istart; i <= iend; i++) {
189 L_ERROR(
"failed to add pt at i = %d\n", __func__, i);
223 return ERROR_INT(
"ptaad not defined", __func__, 1);
230 if (iend < 0 || iend >= n)
233 return ERROR_INT(
"istart > iend; no pts", __func__, 1);
235 for (i = istart; i <= iend; i++) {
255 l_int32 n, i, ix, iy;
260 return (
PTA *)ERROR_PTR(
"ptas not defined", __func__, NULL);
264 return (
PTA *)ERROR_PTR(
"ptad not made", __func__, NULL);
265 for (i = n - 1; i >= 0; i--) {
293 return (
PTA *)ERROR_PTR(
"ptas not defined", __func__, NULL);
297 return (
PTA *)ERROR_PTR(
"ptad not made", __func__, NULL);
298 for (i = 0; i < n; i++) {
328 l_int32 n, i, x, y, j, index, state;
329 l_int32 x1, y1, x2, y2;
333 return (
PTA *)ERROR_PTR(
"ptas not defined", __func__, NULL);
340 if (x1 != x2 || y1 != y2)
341 return (
PTA *)ERROR_PTR(
"start and end pts not same", __func__, NULL);
343 for (i = 0; i < n; i++) {
345 if (x == xs && y == ys) {
350 if (state == L_NOT_FOUND)
351 return (
PTA *)ERROR_PTR(
"start pt not in ptas", __func__, NULL);
354 return (
PTA *)ERROR_PTR(
"ptad not made", __func__, NULL);
355 for (j = 0; j < n - 1; j++) {
359 index = (i + j + 1) % n;
387 return (
PTA *)ERROR_PTR(
"ptas not defined", __func__, NULL);
389 L_WARNING(
"ptas is empty\n", __func__);
392 first = L_MAX(0, first);
393 if (last < 0) last = n - 1;
395 return (
PTA *)ERROR_PTR(
"invalid first", __func__, NULL);
397 L_WARNING(
"last = %d is beyond max index = %d; adjusting\n",
398 __func__, last, n - 1);
402 return (
PTA *)ERROR_PTR(
"first > last", __func__, NULL);
404 npt = last - first + 1;
406 for (i = first; i <= last; i++) {
433 l_int32 n, i, x, y, minx, maxx, miny, maxy;
436 return (
BOX *)ERROR_PTR(
"pta not defined", __func__, NULL);
443 for (i = 0; i < n; i++) {
445 if (x < minx) minx = x;
446 if (x > maxx) maxx = x;
447 if (y < miny) miny = y;
448 if (y > maxy) maxy = y;
451 return boxCreate(minx, miny, maxx - minx + 1, maxy - miny + 1);
480 l_float32 x, y, minx, maxx, miny, maxy;
482 if (!pminx && !pmaxx && !pminy && !pmaxy)
483 return ERROR_INT(
"no output requested", __func__, 1);
484 if (pminx) *pminx = 0;
485 if (pmaxx) *pmaxx = 0;
486 if (pminy) *pminy = 0;
487 if (pmaxy) *pmaxy = 0;
489 return ERROR_INT(
"pta not defined", __func__, 1);
491 return ERROR_INT(
"no points in pta", __func__, 1);
498 for (i = 1; i < n; i++) {
500 if (x < minx) minx = x;
501 if (x > maxx) maxx = x;
502 if (y < miny) miny = y;
503 if (y > maxy) maxy = y;
505 if (pminx) *pminx = minx;
506 if (pmaxx) *pmaxx = maxx;
507 if (pminy) *pminy = miny;
508 if (pmaxy) *pmaxy = maxy;
525 l_int32 n, i, contains;
529 return (
PTA *)ERROR_PTR(
"ptas not defined", __func__, NULL);
531 return (
PTA *)ERROR_PTR(
"box not defined", __func__, NULL);
535 for (i = 0; i < n; i++) {
561 l_int32 i, j, x, y, w, h, wpl, mindim, found;
562 l_uint32 *data, *line;
566 return (
PTA *)ERROR_PTR(
"pixs not defined", __func__, NULL);
567 if (pixGetDepth(pixs) != 1)
568 return (
PTA *)ERROR_PTR(
"pixs not 1 bpp", __func__, NULL);
570 w = pixGetWidth(pixs);
571 h = pixGetHeight(pixs);
572 mindim = L_MIN(w, h);
574 wpl = pixGetWpl(pixs);
577 return (
PTA *)ERROR_PTR(
"pta not made", __func__, NULL);
579 for (found = FALSE, i = 0; i < mindim; i++) {
580 for (j = 0; j <= i; j++) {
582 line = data + y * wpl;
593 for (found = FALSE, i = 0; i < mindim; i++) {
594 for (j = 0; j <= i; j++) {
596 line = data + y * wpl;
608 for (found = FALSE, i = 0; i < mindim; i++) {
609 for (j = 0; j <= i; j++) {
611 line = data + y * wpl;
622 for (found = FALSE, i = 0; i < mindim; i++) {
623 for (j = 0; j <= i; j++) {
625 line = data + y * wpl;
653 l_int32 i, n, ix, iy;
656 return ERROR_INT(
"pta not defined", __func__, 0);
659 for (i = 0; i < n; i++) {
661 if (x == ix && y == iy)
679 l_int32 i, j, n1, n2, x1, y1, x2, y2;
682 return ERROR_INT(
"pta1 not defined", __func__, 0);
684 return ERROR_INT(
"pta2 not defined", __func__, 0);
688 for (i = 0; i < n1; i++) {
690 for (j = 0; j < n2; j++) {
692 if (x1 == x2 && y1 == y2)
725 return (
PTA *)ERROR_PTR(
"ptas not defined", __func__, NULL);
728 for (i = 0; i < n; i++) {
730 x = (l_int32)(scalex * (x + shiftx) + 0.5);
731 y = (l_int32)(scaley * (y + shifty) + 0.5);
759 l_float32 sum, x1, y1, x2, y2, xp1, yp1, xp2, yp2;
762 return ERROR_INT(
"&inside not defined", __func__, 1);
765 return ERROR_INT(
"pta not defined", __func__, 1);
771 for (i = 0; i < n; i++) {
773 ptaGetPt(pta, (i + 1) % n, &xp2, &yp2);
781 if (L_ABS(sum) > M_PI)
810 ang = atan2(y2, x2) - atan2(y1, x1);
811 if (ang > M_PI) ang -= 2.0 * M_PI;
812 if (ang < -M_PI) ang += 2.0 * M_PI;
842 l_float32 x0, y0, x1, y1, x2, y2;
846 return ERROR_INT(
"&isconvex not defined", __func__, 1);
849 return ERROR_INT(
"pta not defined", __func__, 1);
851 return ERROR_INT(
"pta has < 3 pts", __func__, 1);
853 for (i = 0; i < n; i++) {
855 ptaGetPt(pta, (i + 1) % n, &x1, &y1);
856 ptaGetPt(pta, (i + 2) % n, &x2, &y2);
863 cprod = (x2 - x0) * (y1 - y0) - (x1 - x0) * (y2 - y0);
894 l_float32 x, y, xmin, ymin, xmax, ymax;
896 if (pxmin) *pxmin = -1.0;
897 if (pymin) *pymin = -1.0;
898 if (pxmax) *pxmax = -1.0;
899 if (pymax) *pymax = -1.0;
901 return ERROR_INT(
"pta not defined", __func__, 1);
902 if (!pxmin && !pxmax && !pymin && !pymax)
903 return ERROR_INT(
"no output requested", __func__, 1);
905 L_WARNING(
"pta is empty\n", __func__);
909 xmin = ymin = 1.0e20;
910 xmax = ymax = -1.0e20;
911 for (i = 0; i < n; i++) {
913 if (x < xmin) xmin = x;
914 if (y < ymin) ymin = y;
915 if (x > xmax) xmax = x;
916 if (y > ymax) ymax = y;
918 if (pxmin) *pxmin = xmin;
919 if (pymin) *pymin = ymin;
920 if (pxmax) *pxmax = xmax;
921 if (pymax) *pymax = ymax;
949 return (
PTA *)ERROR_PTR(
"ptas not defined", __func__, NULL);
951 L_WARNING(
"ptas is empty\n", __func__);
956 return (
PTA *)ERROR_PTR(
"invalid type", __func__, NULL);
959 return (
PTA *)ERROR_PTR(
"invalid relation", __func__, NULL);
963 for (i = 0; i < n; i++) {
1012 return (
PTA *)ERROR_PTR(
"ptas not defined", __func__, NULL);
1013 if (!pixm || pixGetDepth(pixm) != 1)
1014 return (
PTA *)ERROR_PTR(
"pixm undefined or not 1 bpp", __func__, NULL);
1016 L_INFO(
"ptas is empty\n", __func__);
1022 for (i = 0; i < n; i++) {
1075 l_float32 a, b, factor, sx, sy, sxx, sxy, val;
1080 if (pnafit) *pnafit = NULL;
1081 if (!pa && !pb && !pnafit)
1082 return ERROR_INT(
"no output requested", __func__, 1);
1084 return ERROR_INT(
"pta not defined", __func__, 1);
1086 return ERROR_INT(
"less than 2 pts found", __func__, 1);
1090 sx = sy = sxx = sxy = 0.;
1092 for (i = 0; i < n; i++) {
1095 sxx += xa[i] * xa[i];
1096 sxy += xa[i] * ya[i];
1098 factor = n * sxx - sx * sx;
1100 return ERROR_INT(
"no solution found", __func__, 1);
1101 factor = 1. / factor;
1103 a = factor * ((l_float32)n * sxy - sx * sy);
1104 b = factor * (sxx * sy - sx * sxy);
1106 for (i = 0; i < n; i++) {
1107 sxx += xa[i] * xa[i];
1108 sxy += xa[i] * ya[i];
1111 return ERROR_INT(
"no solution found", __func__, 1);
1115 for (i = 0; i < n; i++)
1118 b = sy / (l_float32)n;
1123 for (i = 0; i < n; i++) {
1124 val = a * xa[i] + b;
1175 l_float32 x, y, sx, sy, sx2, sx3, sx4, sxy, sx2y;
1183 if (pnafit) *pnafit = NULL;
1184 if (!pa && !pb && !pc && !pnafit)
1185 return ERROR_INT(
"no output requested", __func__, 1);
1187 return ERROR_INT(
"pta not defined", __func__, 1);
1189 return ERROR_INT(
"less than 3 pts found", __func__, 1);
1193 sx = sy = sx2 = sx3 = sx4 = sxy = sx2y = 0.;
1194 for (i = 0; i < n; i++) {
1201 sx4 += x * x * x * x;
1206 for (i = 0; i < 3; i++)
1207 f[i] = (l_float32 *)LEPT_CALLOC(3,
sizeof(l_float32));
1223 for (i = 0; i < 3; i++)
1226 return ERROR_INT(
"quadratic solution failed", __func__, 1);
1233 for (i = 0; i < n; i++) {
1235 y = g[0] * x * x + g[1] * x + g[2];
1287 l_float32 x, y, sx, sy, sx2, sx3, sx4, sx5, sx6, sxy, sx2y, sx3y;
1296 if (pnafit) *pnafit = NULL;
1297 if (!pa && !pb && !pc && !pd && !pnafit)
1298 return ERROR_INT(
"no output requested", __func__, 1);
1300 return ERROR_INT(
"pta not defined", __func__, 1);
1302 return ERROR_INT(
"less than 4 pts found", __func__, 1);
1306 sx = sy = sx2 = sx3 = sx4 = sx5 = sx6 = sxy = sx2y = sx3y = 0.;
1307 for (i = 0; i < n; i++) {
1314 sx4 += x * x * x * x;
1315 sx5 += x * x * x * x * x;
1316 sx6 += x * x * x * x * x * x;
1319 sx3y += x * x * x * y;
1322 for (i = 0; i < 4; i++)
1323 f[i] = (l_float32 *)LEPT_CALLOC(4,
sizeof(l_float32));
1347 for (i = 0; i < 4; i++)
1350 return ERROR_INT(
"cubic solution failed", __func__, 1);
1358 for (i = 0; i < n; i++) {
1360 y = g[0] * x * x * x + g[1] * x * x + g[2] * x + g[3];
1416 l_float32 x, y, sx, sy, sx2, sx3, sx4, sx5, sx6, sx7, sx8;
1417 l_float32 sxy, sx2y, sx3y, sx4y;
1427 if (pnafit) *pnafit = NULL;
1428 if (!pa && !pb && !pc && !pd && !pe && !pnafit)
1429 return ERROR_INT(
"no output requested", __func__, 1);
1431 return ERROR_INT(
"pta not defined", __func__, 1);
1433 return ERROR_INT(
"less than 5 pts found", __func__, 1);
1437 sx = sy = sx2 = sx3 = sx4 = sx5 = sx6 = sx7 = sx8 = 0;
1438 sxy = sx2y = sx3y = sx4y = 0.;
1439 for (i = 0; i < n; i++) {
1446 sx4 += x * x * x * x;
1447 sx5 += x * x * x * x * x;
1448 sx6 += x * x * x * x * x * x;
1449 sx7 += x * x * x * x * x * x * x;
1450 sx8 += x * x * x * x * x * x * x * x;
1453 sx3y += x * x * x * y;
1454 sx4y += x * x * x * x * y;
1457 for (i = 0; i < 5; i++)
1458 f[i] = (l_float32 *)LEPT_CALLOC(5,
sizeof(l_float32));
1492 for (i = 0; i < 5; i++)
1495 return ERROR_INT(
"quartic solution failed", __func__, 1);
1504 for (i = 0; i < n; i++) {
1506 y = g[0] * x * x * x * x + g[1] * x * x * x + g[2] * x * x
1550 l_float32 x, y, yf, val, mederr;
1551 NUMA *nafit, *naerror;
1554 if (pptad) *pptad = NULL;
1557 if (pmederr) *pmederr = 0.0;
1558 if (pnafit) *pnafit = NULL;
1559 if (!pptad && !pa && !pb && !pnafit)
1560 return ERROR_INT(
"no output requested", __func__, 1);
1562 return ERROR_INT(
"pta not defined", __func__, 1);
1564 return ERROR_INT(
"factor must be > 0.0", __func__, 1);
1566 return ERROR_INT(
"less than 2 pts found", __func__, 1);
1569 return ERROR_INT(
"error in linear LSF", __func__, 1);
1573 for (i = 0; i < n; i++) {
1579 if (pmederr) *pmederr = mederr;
1584 for (i = 0; i < n; i++) {
1587 if (val <= factor * mederr)
1636 l_float32 x, y, yf, val, mederr;
1637 NUMA *nafit, *naerror;
1640 if (pptad) *pptad = NULL;
1644 if (pmederr) *pmederr = 0.0;
1645 if (pnafit) *pnafit = NULL;
1646 if (!pptad && !pa && !pb && !pc && !pnafit)
1647 return ERROR_INT(
"no output requested", __func__, 1);
1649 return ERROR_INT(
"factor must be > 0.0", __func__, 1);
1651 return ERROR_INT(
"pta not defined", __func__, 1);
1653 return ERROR_INT(
"less than 3 pts found", __func__, 1);
1656 return ERROR_INT(
"error in quadratic LSF", __func__, 1);
1660 for (i = 0; i < n; i++) {
1666 if (pmederr) *pmederr = mederr;
1671 for (i = 0; i < n; i++) {
1674 if (val <= factor * mederr)
1681 return ERROR_INT(
"less than 3 pts found", __func__, 1);
1710 return ERROR_INT(
"&y not defined", __func__, 1);
1733 return ERROR_INT(
"&y not defined", __func__, 1);
1735 *py = a * x * x + b * x + c;
1757 return ERROR_INT(
"&y not defined", __func__, 1);
1759 *py = a * x * x * x + b * x * x + c * x + d;
1784 return ERROR_INT(
"&y not defined", __func__, 1);
1787 *py = a * x2 * x2 + b * x2 * x + c * x2 + d * x + e;
1818 char *rtitle, *gtitle, *btitle;
1819 static l_int32 count = 0;
1820 l_int32 i, x, y, d, w, h, npts, rval, gval, bval;
1822 NUMA *na, *nar, *nag, *nab;
1828 return ERROR_INT(
"pixs not defined", __func__, 1);
1830 return ERROR_INT(
"pta not defined", __func__, 1);
1831 if (outformat != GPLOT_PNG && outformat != GPLOT_PS &&
1832 outformat != GPLOT_EPS && outformat != GPLOT_LATEX) {
1833 L_WARNING(
"outformat invalid; using GPLOT_PNG\n", __func__);
1834 outformat = GPLOT_PNG;
1838 d = pixGetDepth(pixt);
1839 w = pixGetWidth(pixt);
1840 h = pixGetHeight(pixt);
1846 for (i = 0; i < npts; i++) {
1848 if (x < 0 || x >= w)
1850 if (y < 0 || y >= h)
1861 snprintf(buffer,
sizeof(buffer),
"/tmp/lept/plot/%03d", count++);
1864 snprintf(buffer,
sizeof(buffer),
"/tmp/lept/plot/%03d", count++);
1867 snprintf(buffer,
sizeof(buffer),
"/tmp/lept/plot/%03d", count++);
1878 for (i = 0; i < npts; i++) {
1880 if (x < 0 || x >= w)
1882 if (y < 0 || y >= h)
1888 snprintf(buffer,
sizeof(buffer),
"/tmp/lept/plot/%03d", count++);
1914 l_int32 i, j, w, h, wpl, xstart, xend, ystart, yend, bw, bh;
1915 l_uint32 *data, *line;
1918 if (!pixs || (pixGetDepth(pixs) != 1))
1919 return (
PTA *)ERROR_PTR(
"pixs undefined or not 1 bpp", __func__, NULL);
1923 wpl = pixGetWpl(pixs);
1924 xstart = ystart = 0;
1929 xend = xstart + bw - 1;
1930 yend = ystart + bh - 1;
1934 return (
PTA *)ERROR_PTR(
"pta not made", __func__, NULL);
1935 for (i = ystart; i <= yend; i++) {
1936 line = data + i * wpl;
1937 for (j = xstart; j <= xend; j++) {
1970 return (
PIX *)ERROR_PTR(
"pta not defined", __func__, NULL);
1973 return (
PIX *)ERROR_PTR(
"pix not made", __func__, NULL);
1975 for (i = 0; i < n; i++) {
1977 if (x < 0 || x >= w || y < 0 || y >= h)
2007 if (!pixs || (pixGetDepth(pixs) != 1))
2008 return (
PTA *)ERROR_PTR(
"pixs undefined or not 1 bpp", __func__, NULL);
2009 if (type != L_BOUNDARY_FG && type != L_BOUNDARY_BG)
2010 return (
PTA *)ERROR_PTR(
"invalid type", __func__, NULL);
2012 if (type == L_BOUNDARY_FG)
2016 pixXor(pixt, pixt, pixs);
2050 l_int32 connectivity,
2054 l_int32 i, n, w, h, x, y, bw, bh, left, right, top, bot;
2061 if (pboxa) *pboxa = NULL;
2062 if (ppixa) *ppixa = NULL;
2063 if (!pixs || (pixGetDepth(pixs) != 1))
2064 return (
PTAA *)ERROR_PTR(
"pixs undefined or not 1 bpp", __func__, NULL);
2065 if (type != L_BOUNDARY_FG && type != L_BOUNDARY_BG)
2066 return (
PTAA *)ERROR_PTR(
"invalid type", __func__, NULL);
2067 if (connectivity != 4 && connectivity != 8)
2068 return (
PTAA *)ERROR_PTR(
"connectivity not 4 or 8", __func__, NULL);
2074 for (i = 0; i < n; i++) {
2077 left = right = top = bot = 0;
2078 if (type == L_BOUNDARY_BG) {
2079 if (x > 0) left = 1;
2081 if (x + bw < w) right = 1;
2082 if (y + bh < h) bot = 1;
2088 pta2 =
ptaTransform(pta1, x - left, y - top, 1.0, 1.0);
2132 l_int32 wpl, index, i, j, w, h;
2134 l_uint32 *data, *line;
2138 if (pncc) *pncc = 0;
2139 if (!pixs || (pixGetDepth(pixs) != 32))
2140 return (
PTAA *)ERROR_PTR(
"pixs undef or not 32 bpp", __func__, NULL);
2145 if (pncc) *pncc = maxval;
2155 wpl = pixGetWpl(pixs);
2156 for (i = 0; i < h; i++) {
2157 line = data + wpl * i;
2158 for (j = 0; j < w; j++) {
2193 return (
PTA *)ERROR_PTR(
"pixs not defined", __func__, NULL);
2195 if (x < 0 || x >= w || y < 0 || y >= h)
2196 return (
PTA *)ERROR_PTR(
"(x,y) not in pixs", __func__, NULL);
2197 if (conn != 4 && conn != 8)
2198 return (
PTA *)ERROR_PTR(
"conn not 4 or 8", __func__, NULL);
2241 l_float32 startx, delx, val;
2245 return (
PTA *)ERROR_PTR(
"na not defined", __func__, NULL);
2250 for (i = 0; i < n; i++) {
2252 ptaAddPt(pta, startx + i * delx, val);
2269 l_int32 i, n, nx, ny;
2270 l_float32 valx, valy;
2274 return (
PTA *)ERROR_PTR(
"nax and nay not both defined", __func__, NULL);
2280 L_WARNING(
"nx = %d does not equal ny = %d\n", __func__, nx, ny);
2282 for (i = 0; i < n; i++) {
2305 l_float32 valx, valy;
2307 if (pnax) *pnax = NULL;
2308 if (pnay) *pnay = NULL;
2310 return ERROR_INT(
"&nax and &nay not both defined", __func__, 1);
2312 return ERROR_INT(
"pta not defined", __func__, 1);
2317 for (i = 0; i < n; i++) {
2353 l_int32 i, n, w, h, x, y;
2354 l_uint32 rpixel, gpixel, bpixel;
2357 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, pixd);
2359 return (
PIX *)ERROR_PTR(
"pta not defined", __func__, pixd);
2360 if (pixd && (pixd != pixs || pixGetDepth(pixd) != 32))
2361 return (
PIX *)ERROR_PTR(
"invalid pixd", __func__, pixd);
2371 for (i = 0; i < n; i++) {
2373 if (x < 0 || x >= w || y < 0 || y >= h)
2426 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, pixd);
2428 return (
PIX *)ERROR_PTR(
"ptaa not defined", __func__, pixd);
2429 if (pixd && (pixd != pixs || pixGetDepth(pixd) != 32))
2430 return (
PIX *)ERROR_PTR(
"invalid pixd", __func__, pixd);
2432 return (
PIX *)ERROR_PTR(
"pixp not defined", __func__, pixd);
2440 for (i = 0; i < n; i++) {
2486 l_int32 i, n, w, h, x, y;
2490 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, pixd);
2492 return (
PIX *)ERROR_PTR(
"pta not defined", __func__, pixd);
2493 if (pixd && (pixd != pixs || pixGetDepth(pixd) != 32))
2494 return (
PIX *)ERROR_PTR(
"invalid pixd", __func__, pixd);
2496 return (
PIX *)ERROR_PTR(
"pixp not defined", __func__, pixd);
2504 for (i = 0; i < n; i++) {
2506 if (x < 0 || x >= w || y < 0 || y >= h)
2545 l_int32 i, j, n, np, x, y, xp, yp, xf, yf;
2549 return (
PTA *)ERROR_PTR(
"ptas not defined", __func__, NULL);
2551 return (
PTA *)ERROR_PTR(
"no pattern is defined", __func__, NULL);
2553 L_WARNING(
"pixp and ptap defined; using ptap\n", __func__);
2562 for (i = 0; i < n; i++) {
2564 for (j = 0; j < np; j++) {
2568 if (xf >= 0 && xf < w && yf >= 0 && yf < h)
2590 l_int32 i, j, w, h, npta, npt, x, y, rv, gv, bv;
2592 NUMA *na1, *na2, *na3;
2597 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
2599 return (
PIX *)ERROR_PTR(
"ptaa not defined", __func__, NULL);
2602 return (
PIX *)ERROR_PTR(
"no pta", __func__, NULL);
2605 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
2609 if ((pixela = (l_uint32 *)LEPT_CALLOC(npta,
sizeof(l_uint32))) == NULL) {
2611 return (
PIX *)ERROR_PTR(
"calloc fail for pixela", __func__, NULL);
2616 for (i = 0; i < npta; i++) {
2626 for (i = 0; i < npta; i++) {
2629 for (j = 0; j < npt; j++) {
2631 if (x < 0 || x >= w || y < 0 || y >= h)
l_int32 gaussjordan(l_float32 **a, l_float32 *b, l_int32 n)
gaussjordan()
#define GET_DATA_BYTE(pdata, n)
#define GET_DATA_BIT(pdata, n)
l_ok boxGetGeometry(const BOX *box, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
boxGetGeometry()
l_ok boxaGetBoxGeometry(BOXA *boxa, l_int32 index, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
boxaGetBoxGeometry()
void boxaDestroy(BOXA **pboxa)
boxaDestroy()
l_int32 boxaGetCount(const BOXA *boxa)
boxaGetCount()
BOX * boxCreate(l_int32 x, l_int32 y, l_int32 w, l_int32 h)
boxCreate()
l_ok boxContainsPt(BOX *box, l_float32 x, l_float32 y, l_int32 *pcontains)
boxContainsPt()
void pixcmapDestroy(PIXCMAP **pcmap)
pixcmapDestroy()
PIXCMAP * pixcmapCreateRandom(l_int32 depth, l_int32 hasblack, l_int32 haswhite)
pixcmapCreateRandom()
l_ok pixcmapGetColor32(PIXCMAP *cmap, l_int32 index, l_uint32 *pval32)
pixcmapGetColor32()
BOXA * pixConnComp(PIX *pixs, PIXA **ppixa, l_int32 connectivity)
pixConnComp()
l_ok gplotSimple1(NUMA *na, l_int32 outformat, const char *outroot, const char *title)
gplotSimple1()
PIX * pixMorphSequence(PIX *pixs, const char *sequence, l_int32 dispsep)
pixMorphSequence()
l_ok numaAddNumber(NUMA *na, l_float32 val)
numaAddNumber()
l_ok numaGetFValue(NUMA *na, l_int32 index, l_float32 *pval)
numaGetFValue()
NUMA * numaCreate(l_int32 n)
numaCreate()
void numaDestroy(NUMA **pna)
numaDestroy()
l_int32 numaGetCount(NUMA *na)
numaGetCount()
l_ok numaGetIValue(NUMA *na, l_int32 index, l_int32 *pival)
numaGetIValue()
l_ok numaGetParameters(NUMA *na, l_float32 *pstartx, l_float32 *pdelx)
numaGetParameters()
NUMA * numaPseudorandomSequence(l_int32 size, l_int32 seed)
numaPseudorandomSequence()
l_ok numaGetMedian(NUMA *na, l_float32 *pval)
numaGetMedian()
l_uint32 * pixGetData(PIX *pix)
pixGetData()
void pixDestroy(PIX **ppix)
pixDestroy()
l_ok pixGetDimensions(const PIX *pix, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixGetDimensions()
PIX * pixCreate(l_int32 width, l_int32 height, l_int32 depth)
pixCreate()
PIX * pixClone(PIX *pixs)
pixClone()
l_ok pixSetPixel(PIX *pix, l_int32 x, l_int32 y, l_uint32 val)
pixSetPixel()
l_ok pixGetPixel(PIX *pix, l_int32 x, l_int32 y, l_uint32 *pval)
pixGetPixel()
PIX * pixAddBorderGeneral(PIX *pixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot, l_uint32 val)
pixAddBorderGeneral()
l_ok composeRGBPixel(l_int32 rval, l_int32 gval, l_int32 bval, l_uint32 *ppixel)
composeRGBPixel()
PIX * pixXor(PIX *pixd, PIX *pixs1, PIX *pixs2)
pixXor()
l_ok pixGetMaxValueInRect(PIX *pixs, BOX *box, l_uint32 *pmaxval, l_int32 *pxmax, l_int32 *pymax)
pixGetMaxValueInRect()
@ REMOVE_CMAP_BASED_ON_SRC
void pixaDestroy(PIXA **ppixa)
pixaDestroy()
PIX * pixaGetPix(PIXA *pixa, l_int32 index, l_int32 accesstype)
pixaGetPix()
PIX * pixRemoveColormap(PIX *pixs, l_int32 type)
pixRemoveColormap()
PIX * pixConvertTo32(PIX *pixs)
pixConvertTo32()
PTAA * ptaaCreate(l_int32 n)
ptaaCreate()
l_ok ptaaAddPt(PTAA *ptaa, l_int32 ipta, l_float32 x, l_float32 y)
ptaaAddPt()
PTA * ptaaGetPta(PTAA *ptaa, l_int32 index, l_int32 accessflag)
ptaaGetPta()
l_ok ptaGetIPt(PTA *pta, l_int32 index, l_int32 *px, l_int32 *py)
ptaGetIPt()
l_ok ptaaAddPta(PTAA *ptaa, PTA *pta, l_int32 copyflag)
ptaaAddPta()
PTA * ptaClone(PTA *pta)
ptaClone()
l_int32 ptaaGetCount(PTAA *ptaa)
ptaaGetCount()
l_ok ptaaInitFull(PTAA *ptaa, PTA *pta)
ptaaInitFull()
l_ok ptaAddPt(PTA *pta, l_float32 x, l_float32 y)
ptaAddPt()
l_ok ptaGetPt(PTA *pta, l_int32 index, l_float32 *px, l_float32 *py)
ptaGetPt()
l_int32 ptaGetCount(PTA *pta)
ptaGetCount()
PTA * ptaCreate(l_int32 n)
ptaCreate()
void ptaDestroy(PTA **ppta)
ptaDestroy()
PTA * ptaCopy(PTA *pta)
ptaCopy()
l_ok applyLinearFit(l_float32 a, l_float32 b, l_float32 x, l_float32 *py)
applyLinearFit()
PTA * ptaGetBoundaryPixels(PIX *pixs, l_int32 type)
ptaGetBoundaryPixels()
l_int32 ptaContainsPt(PTA *pta, l_int32 x, l_int32 y)
ptaContainsPt()
PTA * ptaSubsample(PTA *ptas, l_int32 subfactor)
ptaSubsample()
l_ok pixPlotAlongPta(PIX *pixs, PTA *pta, l_int32 outformat, const char *title)
pixPlotAlongPta()
BOX * ptaGetBoundingRegion(PTA *pta)
ptaGetBoundingRegion()
PTA * ptaGetPixelsFromPix(PIX *pixs, BOX *box)
ptaGetPixelsFromPix()
l_ok ptaGetQuarticLSF(PTA *pta, l_float32 *pa, l_float32 *pb, l_float32 *pc, l_float32 *pd, l_float32 *pe, NUMA **pnafit)
ptaGetQuarticLSF()
PTA * ptaCyclicPerm(PTA *ptas, l_int32 xs, l_int32 ys)
ptaCyclicPerm()
PIX * pixDisplayPtaPattern(PIX *pixd, PIX *pixs, PTA *pta, PIX *pixp, l_int32 cx, l_int32 cy, l_uint32 color)
pixDisplayPtaPattern()
PTA * numaConvertToPta1(NUMA *na)
numaConvertToPta1()
l_ok applyQuadraticFit(l_float32 a, l_float32 b, l_float32 c, l_float32 x, l_float32 *py)
applyQuadraticFit()
l_int32 ptaPtInsidePolygon(PTA *pta, l_float32 x, l_float32 y, l_int32 *pinside)
ptaPtInsidePolygon()
PTA * ptaGetInsideBox(PTA *ptas, BOX *box)
ptaGetInsideBox()
l_int32 ptaTestIntersection(PTA *pta1, PTA *pta2)
ptaTestIntersection()
PTA * ptaTranspose(PTA *ptas)
ptaTranspose()
PTA * ptaGetNeighborPixLocs(PIX *pixs, l_int32 x, l_int32 y, l_int32 conn)
ptaGetNeighborPixLocs()
PIX * pixDisplayPtaa(PIX *pixs, PTAA *ptaa)
pixDisplayPtaa()
PTA * ptaSelectRange(PTA *ptas, l_int32 first, l_int32 last)
ptaSelectRange()
l_ok ptaGetMinMax(PTA *pta, l_float32 *pxmin, l_float32 *pymin, l_float32 *pxmax, l_float32 *pymax)
ptaGetMinMax()
l_ok ptaGetCubicLSF(PTA *pta, l_float32 *pa, l_float32 *pb, l_float32 *pc, l_float32 *pd, NUMA **pnafit)
ptaGetCubicLSF()
l_ok applyQuarticFit(l_float32 a, l_float32 b, l_float32 c, l_float32 d, l_float32 e, l_float32 x, l_float32 *py)
applyQuarticFit()
PTAA * ptaaIndexLabeledPixels(PIX *pixs, l_int32 *pncc)
ptaaIndexLabeledPixels()
l_ok ptaConvertToNuma(PTA *pta, NUMA **pnax, NUMA **pnay)
ptaConvertToNuma()
l_float32 l_angleBetweenVectors(l_float32 x1, l_float32 y1, l_float32 x2, l_float32 y2)
l_angleBetweenVectors()
l_ok ptaGetQuadraticLSF(PTA *pta, l_float32 *pa, l_float32 *pb, l_float32 *pc, NUMA **pnafit)
ptaGetQuadraticLSF()
l_ok ptaaJoin(PTAA *ptaad, PTAA *ptaas, l_int32 istart, l_int32 iend)
ptaaJoin()
l_ok ptaGetLinearLSF(PTA *pta, l_float32 *pa, l_float32 *pb, NUMA **pnafit)
ptaGetLinearLSF()
l_ok ptaNoisyLinearLSF(PTA *pta, l_float32 factor, PTA **pptad, l_float32 *pa, l_float32 *pb, l_float32 *pmederr, NUMA **pnafit)
ptaNoisyLinearLSF()
PTA * ptaSelectByValue(PTA *ptas, l_float32 xth, l_float32 yth, l_int32 type, l_int32 relation)
ptaSelectByValue()
l_ok ptaJoin(PTA *ptad, PTA *ptas, l_int32 istart, l_int32 iend)
ptaJoin()
PIX * pixDisplayPtaaPattern(PIX *pixd, PIX *pixs, PTAA *ptaa, PIX *pixp, l_int32 cx, l_int32 cy)
pixDisplayPtaaPattern()
l_ok ptaGetRange(PTA *pta, l_float32 *pminx, l_float32 *pmaxx, l_float32 *pminy, l_float32 *pmaxy)
ptaGetRange()
PTAA * ptaaGetBoundaryPixels(PIX *pixs, l_int32 type, l_int32 connectivity, BOXA **pboxa, PIXA **ppixa)
ptaaGetBoundaryPixels()
PTA * ptaReplicatePattern(PTA *ptas, PIX *pixp, PTA *ptap, l_int32 cx, l_int32 cy, l_int32 w, l_int32 h)
ptaReplicatePattern()
PIX * pixGenerateFromPta(PTA *pta, l_int32 w, l_int32 h)
pixGenerateFromPta()
PTA * ptaCropToMask(PTA *ptas, PIX *pixm)
ptaCropToMask()
PTA * pixFindCornerPixels(PIX *pixs)
pixFindCornerPixels()
PTA * ptaReverse(PTA *ptas, l_int32 type)
ptaReverse()
l_int32 ptaPolygonIsConvex(PTA *pta, l_int32 *pisconvex)
ptaPolygonIsConvex()
l_ok ptaNoisyQuadraticLSF(PTA *pta, l_float32 factor, PTA **pptad, l_float32 *pa, l_float32 *pb, l_float32 *pc, l_float32 *pmederr, NUMA **pnafit)
ptaNoisyQuadraticLSF()
PTA * numaConvertToPta2(NUMA *nax, NUMA *nay)
numaConvertToPta2()
PIX * pixDisplayPta(PIX *pixd, PIX *pixs, PTA *pta)
pixDisplayPta()
PTA * ptaTransform(PTA *ptas, l_int32 shiftx, l_int32 shifty, l_float32 scalex, l_float32 scaley)
ptaTransform()
l_ok applyCubicFit(l_float32 a, l_float32 b, l_float32 c, l_float32 d, l_float32 x, l_float32 *py)
applyCubicFit()
l_int32 lept_mkdir(const char *subdir)
lept_mkdir()
char * stringJoin(const char *src1, const char *src2)
stringJoin()