93 #include "allheaders.h" 96 #define M_PI 3.14159265358979323846 118 PROCNAME(
"pixSubsample");
121 return (
PTA *)ERROR_PTR(
"ptas not defined", procName, NULL);
123 return (
PTA *)ERROR_PTR(
"subfactor < 1", procName, NULL);
127 for (i = 0; i < n; i++) {
128 if (i % subfactor != 0)
continue;
164 return ERROR_INT(
"ptad not defined", procName, 1);
171 if (iend < 0 || iend >= n)
174 return ERROR_INT(
"istart > iend; no pts", procName, 1);
176 for (i = istart; i <= iend; i++) {
210 PROCNAME(
"ptaaJoin");
213 return ERROR_INT(
"ptaad not defined", procName, 1);
220 if (iend < 0 || iend >= n)
223 return ERROR_INT(
"istart > iend; no pts", procName, 1);
225 for (i = istart; i <= iend; i++) {
245 l_int32 n, i, ix, iy;
249 PROCNAME(
"ptaReverse");
252 return (
PTA *)ERROR_PTR(
"ptas not defined", procName, NULL);
256 return (
PTA *)ERROR_PTR(
"ptad not made", procName, NULL);
257 for (i = n - 1; i >= 0; i--) {
284 PROCNAME(
"ptaTranspose");
287 return (
PTA *)ERROR_PTR(
"ptas not defined", procName, NULL);
291 return (
PTA *)ERROR_PTR(
"ptad not made", procName, NULL);
292 for (i = 0; i < n; i++) {
322 l_int32 n, i, x, y, j, index, state;
323 l_int32 x1, y1, x2, y2;
326 PROCNAME(
"ptaCyclicPerm");
329 return (
PTA *)ERROR_PTR(
"ptas not defined", procName, NULL);
336 if (x1 != x2 || y1 != y2)
337 return (
PTA *)ERROR_PTR(
"start and end pts not same", procName, NULL);
339 for (i = 0; i < n; i++) {
341 if (x == xs && y == ys) {
346 if (state == L_NOT_FOUND)
347 return (
PTA *)ERROR_PTR(
"start pt not in ptas", procName, NULL);
350 return (
PTA *)ERROR_PTR(
"ptad not made", procName, NULL);
351 for (j = 0; j < n - 1; j++) {
355 index = (i + j + 1) % n;
382 PROCNAME(
"ptaSelectRange");
385 return (
PTA *)ERROR_PTR(
"ptas not defined", procName, NULL);
387 L_WARNING(
"ptas is empty\n", procName);
390 first = L_MAX(0, first);
391 if (last <= 0) last = n - 1;
393 return (
PTA *)ERROR_PTR(
"invalid first", procName, NULL);
395 return (
PTA *)ERROR_PTR(
"first > last", procName, NULL);
397 npt = last - first + 1;
399 for (i = first; i <= last; i++) {
426 l_int32 n, i, x, y, minx, maxx, miny, maxy;
428 PROCNAME(
"ptaGetBoundingRegion");
431 return (
BOX *)ERROR_PTR(
"pta not defined", procName, NULL);
438 for (i = 0; i < n; i++) {
440 if (x < minx) minx = x;
441 if (x > maxx) maxx = x;
442 if (y < miny) miny = y;
443 if (y > maxy) maxy = y;
446 return boxCreate(minx, miny, maxx - minx + 1, maxy - miny + 1);
475 l_float32 x, y, minx, maxx, miny, maxy;
477 PROCNAME(
"ptaGetRange");
479 if (!pminx && !pmaxx && !pminy && !pmaxy)
480 return ERROR_INT(
"no output requested", procName, 1);
481 if (pminx) *pminx = 0;
482 if (pmaxx) *pmaxx = 0;
483 if (pminy) *pminy = 0;
484 if (pmaxy) *pmaxy = 0;
486 return ERROR_INT(
"pta not defined", procName, 1);
488 return ERROR_INT(
"no points in pta", procName, 1);
495 for (i = 1; i < n; i++) {
497 if (x < minx) minx = x;
498 if (x > maxx) maxx = x;
499 if (y < miny) miny = y;
500 if (y > maxy) maxy = y;
502 if (pminx) *pminx = minx;
503 if (pmaxx) *pmaxx = maxx;
504 if (pminy) *pminy = miny;
505 if (pmaxy) *pmaxy = maxy;
522 l_int32 n, i, contains;
525 PROCNAME(
"ptaGetInsideBox");
528 return (
PTA *)ERROR_PTR(
"ptas not defined", procName, NULL);
530 return (
PTA *)ERROR_PTR(
"box not defined", procName, NULL);
534 for (i = 0; i < n; i++) {
560 l_int32 i, j, x, y, w, h, wpl, mindim, found;
561 l_uint32 *data, *line;
564 PROCNAME(
"pixFindCornerPixels");
567 return (
PTA *)ERROR_PTR(
"pixs not defined", procName, NULL);
568 if (pixGetDepth(pixs) != 1)
569 return (
PTA *)ERROR_PTR(
"pixs not 1 bpp", procName, NULL);
571 w = pixGetWidth(pixs);
572 h = pixGetHeight(pixs);
573 mindim = L_MIN(w, h);
575 wpl = pixGetWpl(pixs);
578 return (
PTA *)ERROR_PTR(
"pta not made", procName, NULL);
580 for (found = FALSE, i = 0; i < mindim; i++) {
581 for (j = 0; j <= i; j++) {
583 line = data + y * wpl;
594 for (found = FALSE, i = 0; i < mindim; i++) {
595 for (j = 0; j <= i; j++) {
597 line = data + y * wpl;
609 for (found = FALSE, i = 0; i < mindim; i++) {
610 for (j = 0; j <= i; j++) {
612 line = data + y * wpl;
623 for (found = FALSE, i = 0; i < mindim; i++) {
624 for (j = 0; j <= i; j++) {
626 line = data + y * wpl;
654 l_int32 i, n, ix, iy;
656 PROCNAME(
"ptaContainsPt");
659 return ERROR_INT(
"pta not defined", procName, 0);
662 for (i = 0; i < n; i++) {
664 if (x == ix && y == iy)
682 l_int32 i, j, n1, n2, x1, y1, x2, y2;
684 PROCNAME(
"ptaTestIntersection");
687 return ERROR_INT(
"pta1 not defined", procName, 0);
689 return ERROR_INT(
"pta2 not defined", procName, 0);
693 for (i = 0; i < n1; i++) {
695 for (j = 0; j < n2; j++) {
697 if (x1 == x2 && y1 == y2)
729 PROCNAME(
"ptaTransform");
732 return (
PTA *)ERROR_PTR(
"ptas not defined", procName, NULL);
735 for (i = 0; i < n; i++) {
737 x = (l_int32)(scalex * (x + shiftx) + 0.5);
738 y = (l_int32)(scaley * (y + shifty) + 0.5);
766 l_float32 sum, x1, y1, x2, y2, xp1, yp1, xp2, yp2;
768 PROCNAME(
"ptaPtInsidePolygon");
771 return ERROR_INT(
"&inside not defined", procName, 1);
774 return ERROR_INT(
"pta not defined", procName, 1);
780 for (i = 0; i < n; i++) {
782 ptaGetPt(pta, (i + 1) % n, &xp2, &yp2);
790 if (L_ABS(sum) > M_PI)
819 ang = atan2(y2, x2) - atan2(y1, x1);
820 if (ang > M_PI) ang -= 2.0 * M_PI;
821 if (ang < -M_PI) ang += 2.0 * M_PI;
848 l_float32 x, y, xmin, ymin, xmax, ymax;
850 PROCNAME(
"ptaGetMinMax");
852 if (pxmin) *pxmin = -1.0;
853 if (pymin) *pymin = -1.0;
854 if (pxmax) *pxmax = -1.0;
855 if (pymax) *pymax = -1.0;
857 return ERROR_INT(
"pta not defined", procName, 1);
858 if (!pxmin && !pxmax && !pymin && !pymax)
859 return ERROR_INT(
"no output requested", procName, 1);
861 L_WARNING(
"pta is empty\n", procName);
865 xmin = ymin = 1.0e20;
866 xmax = ymax = -1.0e20;
867 for (i = 0; i < n; i++) {
869 if (x < xmin) xmin = x;
870 if (y < ymin) ymin = y;
871 if (x > xmax) xmax = x;
872 if (y > ymax) ymax = y;
874 if (pxmin) *pxmin = xmin;
875 if (pymin) *pymin = ymin;
876 if (pxmax) *pxmax = xmax;
877 if (pymax) *pymax = ymax;
904 PROCNAME(
"ptaSelectByValue");
907 return (
PTA *)ERROR_PTR(
"ptas not defined", procName, NULL);
909 L_WARNING(
"ptas is empty\n", procName);
914 return (
PTA *)ERROR_PTR(
"invalid type", procName, NULL);
917 return (
PTA *)ERROR_PTR(
"invalid relation", procName, NULL);
921 for (i = 0; i < n; i++) {
969 PROCNAME(
"ptaCropToMask");
972 return (
PTA *)ERROR_PTR(
"ptas not defined", procName, NULL);
973 if (!pixm || pixGetDepth(pixm) != 1)
974 return (
PTA *)ERROR_PTR(
"pixm undefined or not 1 bpp", procName, NULL);
976 L_INFO(
"ptas is empty\n", procName);
982 for (i = 0; i < n; i++) {
1035 l_float32 a, b, factor, sx, sy, sxx, sxy, val;
1038 PROCNAME(
"ptaGetLinearLSF");
1042 if (pnafit) *pnafit = NULL;
1043 if (!pa && !pb && !pnafit)
1044 return ERROR_INT(
"no output requested", procName, 1);
1046 return ERROR_INT(
"pta not defined", procName, 1);
1048 return ERROR_INT(
"less than 2 pts found", procName, 1);
1052 sx = sy = sxx = sxy = 0.;
1054 for (i = 0; i < n; i++) {
1057 sxx += xa[i] * xa[i];
1058 sxy += xa[i] * ya[i];
1060 factor = n * sxx - sx * sx;
1062 return ERROR_INT(
"no solution found", procName, 1);
1063 factor = 1. / factor;
1065 a = factor * ((l_float32)n * sxy - sx * sy);
1066 b = factor * (sxx * sy - sx * sxy);
1068 for (i = 0; i < n; i++) {
1069 sxx += xa[i] * xa[i];
1070 sxy += xa[i] * ya[i];
1073 return ERROR_INT(
"no solution found", procName, 1);
1077 for (i = 0; i < n; i++)
1080 b = sy / (l_float32)n;
1085 for (i = 0; i < n; i++) {
1086 val = a * xa[i] + b;
1137 l_float32 x, y, sx, sy, sx2, sx3, sx4, sxy, sx2y;
1142 PROCNAME(
"ptaGetQuadraticLSF");
1147 if (pnafit) *pnafit = NULL;
1148 if (!pa && !pb && !pc && !pnafit)
1149 return ERROR_INT(
"no output requested", procName, 1);
1151 return ERROR_INT(
"pta not defined", procName, 1);
1153 return ERROR_INT(
"less than 3 pts found", procName, 1);
1157 sx = sy = sx2 = sx3 = sx4 = sxy = sx2y = 0.;
1158 for (i = 0; i < n; i++) {
1165 sx4 += x * x * x * x;
1170 for (i = 0; i < 3; i++)
1171 f[i] = (l_float32 *)LEPT_CALLOC(3,
sizeof(l_float32));
1187 for (i = 0; i < 3; i++)
1190 return ERROR_INT(
"quadratic solution failed", procName, 1);
1197 for (i = 0; i < n; i++) {
1199 y = g[0] * x * x + g[1] * x + g[2];
1251 l_float32 x, y, sx, sy, sx2, sx3, sx4, sx5, sx6, sxy, sx2y, sx3y;
1256 PROCNAME(
"ptaGetCubicLSF");
1262 if (pnafit) *pnafit = NULL;
1263 if (!pa && !pb && !pc && !pd && !pnafit)
1264 return ERROR_INT(
"no output requested", procName, 1);
1266 return ERROR_INT(
"pta not defined", procName, 1);
1268 return ERROR_INT(
"less than 4 pts found", procName, 1);
1272 sx = sy = sx2 = sx3 = sx4 = sx5 = sx6 = sxy = sx2y = sx3y = 0.;
1273 for (i = 0; i < n; i++) {
1280 sx4 += x * x * x * x;
1281 sx5 += x * x * x * x * x;
1282 sx6 += x * x * x * x * x * x;
1285 sx3y += x * x * x * y;
1288 for (i = 0; i < 4; i++)
1289 f[i] = (l_float32 *)LEPT_CALLOC(4,
sizeof(l_float32));
1313 for (i = 0; i < 4; i++)
1316 return ERROR_INT(
"cubic solution failed", procName, 1);
1324 for (i = 0; i < n; i++) {
1326 y = g[0] * x * x * x + g[1] * x * x + g[2] * x + g[3];
1382 l_float32 x, y, sx, sy, sx2, sx3, sx4, sx5, sx6, sx7, sx8;
1383 l_float32 sxy, sx2y, sx3y, sx4y;
1388 PROCNAME(
"ptaGetQuarticLSF");
1395 if (pnafit) *pnafit = NULL;
1396 if (!pa && !pb && !pc && !pd && !pe && !pnafit)
1397 return ERROR_INT(
"no output requested", procName, 1);
1399 return ERROR_INT(
"pta not defined", procName, 1);
1401 return ERROR_INT(
"less than 5 pts found", procName, 1);
1405 sx = sy = sx2 = sx3 = sx4 = sx5 = sx6 = sx7 = sx8 = 0;
1406 sxy = sx2y = sx3y = sx4y = 0.;
1407 for (i = 0; i < n; i++) {
1414 sx4 += x * x * x * x;
1415 sx5 += x * x * x * x * x;
1416 sx6 += x * x * x * x * x * x;
1417 sx7 += x * x * x * x * x * x * x;
1418 sx8 += x * x * x * x * x * x * x * x;
1421 sx3y += x * x * x * y;
1422 sx4y += x * x * x * x * y;
1425 for (i = 0; i < 5; i++)
1426 f[i] = (l_float32 *)LEPT_CALLOC(5,
sizeof(l_float32));
1460 for (i = 0; i < 5; i++)
1463 return ERROR_INT(
"quartic solution failed", procName, 1);
1472 for (i = 0; i < n; i++) {
1474 y = g[0] * x * x * x * x + g[1] * x * x * x + g[2] * x * x
1518 l_float32 x, y, yf, val, mederr;
1519 NUMA *nafit, *naerror;
1522 PROCNAME(
"ptaNoisyLinearLSF");
1524 if (pptad) *pptad = NULL;
1527 if (pmederr) *pmederr = 0.0;
1528 if (pnafit) *pnafit = NULL;
1529 if (!pptad && !pa && !pb && !pnafit)
1530 return ERROR_INT(
"no output requested", procName, 1);
1532 return ERROR_INT(
"pta not defined", procName, 1);
1534 return ERROR_INT(
"factor must be > 0.0", procName, 1);
1536 return ERROR_INT(
"less than 2 pts found", procName, 1);
1539 return ERROR_INT(
"error in linear LSF", procName, 1);
1543 for (i = 0; i < n; i++) {
1549 if (pmederr) *pmederr = mederr;
1554 for (i = 0; i < n; i++) {
1557 if (val <= factor * mederr)
1606 l_float32 x, y, yf, val, mederr;
1607 NUMA *nafit, *naerror;
1610 PROCNAME(
"ptaNoisyQuadraticLSF");
1612 if (pptad) *pptad = NULL;
1616 if (pmederr) *pmederr = 0.0;
1617 if (pnafit) *pnafit = NULL;
1618 if (!pptad && !pa && !pb && !pc && !pnafit)
1619 return ERROR_INT(
"no output requested", procName, 1);
1621 return ERROR_INT(
"factor must be > 0.0", procName, 1);
1623 return ERROR_INT(
"pta not defined", procName, 1);
1625 return ERROR_INT(
"less than 3 pts found", procName, 1);
1628 return ERROR_INT(
"error in quadratic LSF", procName, 1);
1632 for (i = 0; i < n; i++) {
1638 if (pmederr) *pmederr = mederr;
1643 for (i = 0; i < n; i++) {
1646 if (val <= factor * mederr)
1653 return ERROR_INT(
"less than 3 pts found", procName, 1);
1681 PROCNAME(
"applyLinearFit");
1684 return ERROR_INT(
"&y not defined", procName, 1);
1706 PROCNAME(
"applyQuadraticFit");
1709 return ERROR_INT(
"&y not defined", procName, 1);
1711 *py = a * x * x + b * x + c;
1732 PROCNAME(
"applyCubicFit");
1735 return ERROR_INT(
"&y not defined", procName, 1);
1737 *py = a * x * x * x + b * x * x + c * x + d;
1761 PROCNAME(
"applyQuarticFit");
1764 return ERROR_INT(
"&y not defined", procName, 1);
1767 *py = a * x2 * x2 + b * x2 * x + c * x2 + d * x + e;
1798 char *rtitle, *gtitle, *btitle;
1799 static l_int32 count = 0;
1800 l_int32 i, x, y, d, w, h, npts, rval, gval, bval;
1802 NUMA *na, *nar, *nag, *nab;
1805 PROCNAME(
"pixPlotAlongPta");
1810 return ERROR_INT(
"pixs not defined", procName, 1);
1812 return ERROR_INT(
"pta not defined", procName, 1);
1813 if (outformat != GPLOT_PNG && outformat != GPLOT_PS &&
1814 outformat != GPLOT_EPS && outformat != GPLOT_LATEX) {
1815 L_WARNING(
"outformat invalid; using GPLOT_PNG\n", procName);
1816 outformat = GPLOT_PNG;
1820 d = pixGetDepth(pixt);
1821 w = pixGetWidth(pixt);
1822 h = pixGetHeight(pixt);
1828 for (i = 0; i < npts; i++) {
1830 if (x < 0 || x >= w)
1832 if (y < 0 || y >= h)
1843 snprintf(buffer,
sizeof(buffer),
"/tmp/lept/plot/%03d", count++);
1846 snprintf(buffer,
sizeof(buffer),
"/tmp/lept/plot/%03d", count++);
1849 snprintf(buffer,
sizeof(buffer),
"/tmp/lept/plot/%03d", count++);
1860 for (i = 0; i < npts; i++) {
1862 if (x < 0 || x >= w)
1864 if (y < 0 || y >= h)
1870 snprintf(buffer,
sizeof(buffer),
"/tmp/lept/plot/%03d", count++);
1896 l_int32 i, j, w, h, wpl, xstart, xend, ystart, yend, bw, bh;
1897 l_uint32 *data, *line;
1900 PROCNAME(
"ptaGetPixelsFromPix");
1902 if (!pixs || (pixGetDepth(pixs) != 1))
1903 return (
PTA *)ERROR_PTR(
"pixs undefined or not 1 bpp", procName, NULL);
1907 wpl = pixGetWpl(pixs);
1908 xstart = ystart = 0;
1913 xend = xstart + bw - 1;
1914 yend = ystart + bh - 1;
1918 return (
PTA *)ERROR_PTR(
"pta not made", procName, NULL);
1919 for (i = ystart; i <= yend; i++) {
1920 line = data + i * wpl;
1921 for (j = xstart; j <= xend; j++) {
1953 PROCNAME(
"pixGenerateFromPta");
1956 return (
PIX *)ERROR_PTR(
"pta not defined", procName, NULL);
1959 return (
PIX *)ERROR_PTR(
"pix not made", procName, NULL);
1961 for (i = 0; i < n; i++) {
1963 if (x < 0 || x >= w || y < 0 || y >= h)
1993 PROCNAME(
"ptaGetBoundaryPixels");
1995 if (!pixs || (pixGetDepth(pixs) != 1))
1996 return (
PTA *)ERROR_PTR(
"pixs undefined or not 1 bpp", procName, NULL);
1997 if (type != L_BOUNDARY_FG && type != L_BOUNDARY_BG)
1998 return (
PTA *)ERROR_PTR(
"invalid type", procName, NULL);
2000 if (type == L_BOUNDARY_FG)
2004 pixXor(pixt, pixt, pixs);
2038 l_int32 connectivity,
2042 l_int32 i, n, w, h, x, y, bw, bh, left, right, top, bot;
2049 PROCNAME(
"ptaaGetBoundaryPixels");
2051 if (pboxa) *pboxa = NULL;
2052 if (ppixa) *ppixa = NULL;
2053 if (!pixs || (pixGetDepth(pixs) != 1))
2054 return (
PTAA *)ERROR_PTR(
"pixs undefined or not 1 bpp", procName, NULL);
2055 if (type != L_BOUNDARY_FG && type != L_BOUNDARY_BG)
2056 return (
PTAA *)ERROR_PTR(
"invalid type", procName, NULL);
2057 if (connectivity != 4 && connectivity != 8)
2058 return (
PTAA *)ERROR_PTR(
"connectivity not 4 or 8", procName, NULL);
2064 for (i = 0; i < n; i++) {
2067 left = right = top = bot = 0;
2068 if (type == L_BOUNDARY_BG) {
2069 if (x > 0) left = 1;
2071 if (x + bw < w) right = 1;
2072 if (y + bh < h) bot = 1;
2078 pta2 =
ptaTransform(pta1, x - left, y - top, 1.0, 1.0);
2122 l_int32 wpl, index, i, j, w, h;
2124 l_uint32 *data, *line;
2128 PROCNAME(
"ptaaIndexLabeledPixels");
2130 if (pncc) *pncc = 0;
2131 if (!pixs || (pixGetDepth(pixs) != 32))
2132 return (
PTAA *)ERROR_PTR(
"pixs undef or not 32 bpp", procName, NULL);
2137 if (pncc) *pncc = maxval;
2147 wpl = pixGetWpl(pixs);
2148 for (i = 0; i < h; i++) {
2149 line = data + wpl * i;
2150 for (j = 0; j < w; j++) {
2184 PROCNAME(
"ptaGetNeighborPixLocs");
2187 return (
PTA *)ERROR_PTR(
"pixs not defined", procName, NULL);
2189 if (x < 0 || x >= w || y < 0 || y >= h)
2190 return (
PTA *)ERROR_PTR(
"(x,y) not in pixs", procName, NULL);
2191 if (conn != 4 && conn != 8)
2192 return (
PTA *)ERROR_PTR(
"conn not 4 or 8", procName, NULL);
2235 l_float32 startx, delx, val;
2238 PROCNAME(
"numaConvertToPta1");
2241 return (
PTA *)ERROR_PTR(
"na not defined", procName, NULL);
2246 for (i = 0; i < n; i++) {
2248 ptaAddPt(pta, startx + i * delx, val);
2265 l_int32 i, n, nx, ny;
2266 l_float32 valx, valy;
2269 PROCNAME(
"numaConvertToPta2");
2272 return (
PTA *)ERROR_PTR(
"nax and nay not both defined", procName, NULL);
2278 L_WARNING(
"nx = %d does not equal ny = %d\n", procName, nx, ny);
2280 for (i = 0; i < n; i++) {
2303 l_float32 valx, valy;
2305 PROCNAME(
"ptaConvertToNuma");
2307 if (pnax) *pnax = NULL;
2308 if (pnay) *pnay = NULL;
2310 return ERROR_INT(
"&nax and &nay not both defined", procName, 1);
2312 return ERROR_INT(
"pta not defined", procName, 1);
2317 for (i = 0; i < n; i++) {
2353 l_int32 i, n, w, h, x, y;
2354 l_uint32 rpixel, gpixel, bpixel;
2356 PROCNAME(
"pixDisplayPta");
2359 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, pixd);
2361 return (
PIX *)ERROR_PTR(
"pta not defined", procName, pixd);
2362 if (pixd && (pixd != pixs || pixGetDepth(pixd) != 32))
2363 return (
PIX *)ERROR_PTR(
"invalid pixd", procName, pixd);
2373 for (i = 0; i < n; i++) {
2375 if (x < 0 || x >= w || y < 0 || y >= h)
2427 PROCNAME(
"pixDisplayPtaaPattern");
2430 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, pixd);
2432 return (
PIX *)ERROR_PTR(
"ptaa not defined", procName, pixd);
2433 if (pixd && (pixd != pixs || pixGetDepth(pixd) != 32))
2434 return (
PIX *)ERROR_PTR(
"invalid pixd", procName, pixd);
2436 return (
PIX *)ERROR_PTR(
"pixp not defined", procName, pixd);
2444 for (i = 0; i < n; i++) {
2490 l_int32 i, n, w, h, x, y;
2493 PROCNAME(
"pixDisplayPtaPattern");
2496 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, pixd);
2498 return (
PIX *)ERROR_PTR(
"pta not defined", procName, pixd);
2499 if (pixd && (pixd != pixs || pixGetDepth(pixd) != 32))
2500 return (
PIX *)ERROR_PTR(
"invalid pixd", procName, pixd);
2502 return (
PIX *)ERROR_PTR(
"pixp not defined", procName, pixd);
2510 for (i = 0; i < n; i++) {
2512 if (x < 0 || x >= w || y < 0 || y >= h)
2550 l_int32 i, j, n, np, x, y, xp, yp, xf, yf;
2553 PROCNAME(
"ptaReplicatePattern");
2556 return (
PTA *)ERROR_PTR(
"ptas not defined", procName, NULL);
2558 return (
PTA *)ERROR_PTR(
"no pattern is defined", procName, NULL);
2560 L_WARNING(
"pixp and ptap defined; using ptap\n", procName);
2569 for (i = 0; i < n; i++) {
2571 for (j = 0; j < np; j++) {
2575 if (xf >= 0 && xf < w && yf >= 0 && yf < h)
2597 l_int32 i, j, w, h, npta, npt, x, y, rv, gv, bv;
2599 NUMA *na1, *na2, *na3;
2603 PROCNAME(
"pixDisplayPtaa");
2606 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
2608 return (
PIX *)ERROR_PTR(
"ptaa not defined", procName, NULL);
2611 return (
PIX *)ERROR_PTR(
"no pta", procName, NULL);
2614 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
2618 if ((pixela = (l_uint32 *)LEPT_CALLOC(npta,
sizeof(l_uint32))) == NULL) {
2620 return (
PIX *)ERROR_PTR(
"calloc fail for pixela", procName, NULL);
2625 for (i = 0; i < npta; i++) {
2635 for (i = 0; i < npta; i++) {
2638 for (j = 0; j < npt; j++) {
2640 if (x < 0 || x >= w || y < 0 || y >= h)
l_int32 ptaaInitFull(PTAA *ptaa, PTA *pta)
ptaaInitFull()
l_int32 ptaGetQuadraticLSF(PTA *pta, l_float32 *pa, l_float32 *pb, l_float32 *pc, NUMA **pnafit)
ptaGetQuadraticLSF()
l_int32 gaussjordan(l_float32 **a, l_float32 *b, l_int32 n)
gaussjordan()
l_int32 ptaaAddPta(PTAA *ptaa, PTA *pta, l_int32 copyflag)
ptaaAddPta()
l_int32 applyQuarticFit(l_float32 a, l_float32 b, l_float32 c, l_float32 d, l_float32 e, l_float32 x, l_float32 *py)
applyQuarticFit()
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 lept_mkdir(const char *subdir)
lept_mkdir()
l_int32 numaAddNumber(NUMA *na, l_float32 val)
numaAddNumber()
l_int32 ptaGetCubicLSF(PTA *pta, l_float32 *pa, l_float32 *pb, l_float32 *pc, l_float32 *pd, NUMA **pnafit)
ptaGetCubicLSF()
PIX * pixConvertTo32(PIX *pixs)
pixConvertTo32()
PIX * pixGenerateFromPta(PTA *pta, l_int32 w, l_int32 h)
pixGenerateFromPta()
l_int32 ptaAddPt(PTA *pta, l_float32 x, l_float32 y)
ptaAddPt()
l_int32 pixGetPixel(PIX *pix, l_int32 x, l_int32 y, l_uint32 *pval)
pixGetPixel()
l_int32 ptaGetPt(PTA *pta, l_int32 index, l_float32 *px, l_float32 *py)
ptaGetPt()
l_int32 ptaGetLinearLSF(PTA *pta, l_float32 *pa, l_float32 *pb, NUMA **pnafit)
ptaGetLinearLSF()
PTA * ptaCreate(l_int32 n)
ptaCreate()
l_int32 ptaaJoin(PTAA *ptaad, PTAA *ptaas, l_int32 istart, l_int32 iend)
ptaaJoin()
PIX * pixDisplayPtaaPattern(PIX *pixd, PIX *pixs, PTAA *ptaa, PIX *pixp, l_int32 cx, l_int32 cy)
pixDisplayPtaaPattern()
l_int32 numaGetFValue(NUMA *na, l_int32 index, l_float32 *pval)
numaGetFValue()
l_int32 boxContainsPt(BOX *box, l_float32 x, l_float32 y, l_int32 *pcontains)
boxContainsPt()
PIX * pixCreate(l_int32 width, l_int32 height, l_int32 depth)
pixCreate()
void pixcmapDestroy(PIXCMAP **pcmap)
pixcmapDestroy()
NUMA * numaCreate(l_int32 n)
numaCreate()
l_int32 ptaGetCount(PTA *pta)
ptaGetCount()
void boxaDestroy(BOXA **pboxa)
boxaDestroy()
l_uint32 * pixGetData(PIX *pix)
pixGetData()
l_int32 ptaConvertToNuma(PTA *pta, NUMA **pnax, NUMA **pnay)
ptaConvertToNuma()
l_int32 boxaGetBoxGeometry(BOXA *boxa, l_int32 index, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
boxaGetBoxGeometry()
PTA * ptaGetBoundaryPixels(PIX *pixs, l_int32 type)
ptaGetBoundaryPixels()
l_int32 pixGetMaxValueInRect(PIX *pixs, BOX *box, l_uint32 *pmaxval, l_int32 *pxmax, l_int32 *pymax)
pixGetMaxValueInRect()
l_int32 numaGetParameters(NUMA *na, l_float32 *pstartx, l_float32 *pdelx)
numaGetParameters()
#define GET_DATA_BIT(pdata, n)
PTA * ptaCropToMask(PTA *ptas, PIX *pixm)
ptaCropToMask()
BOXA * pixConnComp(PIX *pixs, PIXA **ppixa, l_int32 connectivity)
pixConnComp()
PTA * ptaSubsample(PTA *ptas, l_int32 subfactor)
ptaSubsample()
NUMA * numaPseudorandomSequence(l_int32 size, l_int32 seed)
numaPseudorandomSequence()
l_int32 ptaPtInsidePolygon(PTA *pta, l_float32 x, l_float32 y, l_int32 *pinside)
ptaPtInsidePolygon()
PTA * ptaaGetPta(PTAA *ptaa, l_int32 index, l_int32 accessflag)
ptaaGetPta()
PTA * numaConvertToPta1(NUMA *na)
numaConvertToPta1()
static const l_int32 L_INSERT
PIX * pixXor(PIX *pixd, PIX *pixs1, PIX *pixs2)
pixXor()
PIX * pixDisplayPtaa(PIX *pixs, PTAA *ptaa)
pixDisplayPtaa()
l_int32 ptaNoisyLinearLSF(PTA *pta, l_float32 factor, PTA **pptad, l_float32 *pa, l_float32 *pb, l_float32 *pmederr, NUMA **pnafit)
ptaNoisyLinearLSF()
l_int32 ptaJoin(PTA *ptad, PTA *ptas, l_int32 istart, l_int32 iend)
ptaJoin()
l_int32 numaGetCount(NUMA *na)
numaGetCount()
PTA * ptaClone(PTA *pta)
ptaClone()
PIX * pixMorphSequence(PIX *pixs, const char *sequence, l_int32 dispsep)
pixMorphSequence()
PTA * ptaCyclicPerm(PTA *ptas, l_int32 xs, l_int32 ys)
ptaCyclicPerm()
PTA * ptaGetNeighborPixLocs(PIX *pixs, l_int32 x, l_int32 y, l_int32 conn)
ptaGetNeighborPixLocs()
PTA * ptaSelectByValue(PTA *ptas, l_float32 xth, l_float32 yth, l_int32 type, l_int32 relation)
ptaSelectByValue()
l_int32 ptaContainsPt(PTA *pta, l_int32 x, l_int32 y)
ptaContainsPt()
l_int32 boxGetGeometry(BOX *box, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
boxGetGeometry()
#define GET_DATA_BYTE(pdata, n)
PTAA * ptaaGetBoundaryPixels(PIX *pixs, l_int32 type, l_int32 connectivity, BOXA **pboxa, PIXA **ppixa)
ptaaGetBoundaryPixels()
PTA * ptaGetInsideBox(PTA *ptas, BOX *box)
ptaGetInsideBox()
l_float32 l_angleBetweenVectors(l_float32 x1, l_float32 y1, l_float32 x2, l_float32 y2)
l_angleBetweenVectors()
l_int32 applyQuadraticFit(l_float32 a, l_float32 b, l_float32 c, l_float32 x, l_float32 *py)
applyQuadraticFit()
PIX * pixClone(PIX *pixs)
pixClone()
void pixDestroy(PIX **ppix)
pixDestroy()
l_int32 pixcmapGetColor32(PIXCMAP *cmap, l_int32 index, l_uint32 *pval32)
pixcmapGetColor32()
l_int32 pixPlotAlongPta(PIX *pixs, PTA *pta, l_int32 outformat, const char *title)
pixPlotAlongPta()
l_int32 ptaGetQuarticLSF(PTA *pta, l_float32 *pa, l_float32 *pb, l_float32 *pc, l_float32 *pd, l_float32 *pe, NUMA **pnafit)
ptaGetQuarticLSF()
BOX * ptaGetBoundingRegion(PTA *pta)
ptaGetBoundingRegion()
PTA * ptaCopy(PTA *pta)
ptaCopy()
void numaDestroy(NUMA **pna)
numaDestroy()
PTA * pixFindCornerPixels(PIX *pixs)
pixFindCornerPixels()
l_int32 ptaGetMinMax(PTA *pta, l_float32 *pxmin, l_float32 *pymin, l_float32 *pxmax, l_float32 *pymax)
ptaGetMinMax()
l_int32 ptaGetIPt(PTA *pta, l_int32 index, l_int32 *px, l_int32 *py)
ptaGetIPt()
l_int32 ptaaGetCount(PTAA *ptaa)
ptaaGetCount()
l_int32 pixSetPixel(PIX *pix, l_int32 x, l_int32 y, l_uint32 val)
pixSetPixel()
PTA * ptaReplicatePattern(PTA *ptas, PIX *pixp, PTA *ptap, l_int32 cx, l_int32 cy, l_int32 w, l_int32 h)
ptaReplicatePattern()
PIX * pixaGetPix(PIXA *pixa, l_int32 index, l_int32 accesstype)
pixaGetPix()
l_int32 ptaTestIntersection(PTA *pta1, PTA *pta2)
ptaTestIntersection()
l_int32 composeRGBPixel(l_int32 rval, l_int32 gval, l_int32 bval, l_uint32 *ppixel)
composeRGBPixel()
l_int32 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()
char * stringJoin(const char *src1, const char *src2)
stringJoin()
void ptaDestroy(PTA **ppta)
ptaDestroy()
l_int32 applyCubicFit(l_float32 a, l_float32 b, l_float32 c, l_float32 d, l_float32 x, l_float32 *py)
applyCubicFit()
l_int32 ptaGetRange(PTA *pta, l_float32 *pminx, l_float32 *pmaxx, l_float32 *pminy, l_float32 *pmaxy)
ptaGetRange()
PTA * ptaSelectRange(PTA *ptas, l_int32 first, l_int32 last)
ptaSelectRange()
l_int32 applyLinearFit(l_float32 a, l_float32 b, l_float32 x, l_float32 *py)
applyLinearFit()
l_int32 numaGetMedian(NUMA *na, l_float32 *pval)
numaGetMedian()
PTAA * ptaaIndexLabeledPixels(PIX *pixs, l_int32 *pncc)
ptaaIndexLabeledPixels()
l_int32 boxaGetCount(BOXA *boxa)
boxaGetCount()
l_int32 numaGetIValue(NUMA *na, l_int32 index, l_int32 *pival)
numaGetIValue()
PTA * ptaTransform(PTA *ptas, l_int32 shiftx, l_int32 shifty, l_float32 scalex, l_float32 scaley)
ptaTransform()
PIX * pixDisplayPtaPattern(PIX *pixd, PIX *pixs, PTA *pta, PIX *pixp, l_int32 cx, l_int32 cy, l_uint32 color)
pixDisplayPtaPattern()
l_int32 pixGetDimensions(PIX *pix, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixGetDimensions()
PTA * ptaReverse(PTA *ptas, l_int32 type)
ptaReverse()
PTA * ptaGetPixelsFromPix(PIX *pixs, BOX *box)
ptaGetPixelsFromPix()
void pixaDestroy(PIXA **ppixa)
pixaDestroy()
BOX * boxCreate(l_int32 x, l_int32 y, l_int32 w, l_int32 h)
boxCreate()
PTAA * ptaaCreate(l_int32 n)
ptaaCreate()
PIX * pixAddBorderGeneral(PIX *pixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot, l_uint32 val)
pixAddBorderGeneral()
PTA * ptaTranspose(PTA *ptas)
ptaTranspose()
PIXCMAP * pixcmapCreateRandom(l_int32 depth, l_int32 hasblack, l_int32 haswhite)
pixcmapCreateRandom()
l_int32 ptaaAddPt(PTAA *ptaa, l_int32 ipta, l_float32 x, l_float32 y)
ptaaAddPt()