83 #include <config_auto.h> 86 #include "allheaders.h" 110 l_int32 x1, y1, w1, h1, x2, y2, w2, h2, valid1, valid2;
112 PROCNAME(
"boxContains");
115 return ERROR_INT(
"&result not defined", procName, 1);
118 return ERROR_INT(
"boxes not both defined", procName, 1);
121 if (!valid1 || !valid2)
122 return ERROR_INT(
"boxes not both valid", procName, 1);
126 if (x1 <= x2 && y1 <= y2 && (x1 + w1 >= x2 + w2) && (y1 + h1 >= y2 + h2))
145 l_int32 l1, l2, r1, r2, t1, t2, b1, b2, w1, h1, w2, h2, valid1, valid2;
147 PROCNAME(
"boxIntersects");
150 return ERROR_INT(
"&result not defined", procName, 1);
153 return ERROR_INT(
"boxes not both defined", procName, 1);
156 if (!valid1 || !valid2)
157 return ERROR_INT(
"boxes not both valid", procName, 1);
165 if (b2 < t1 || b1 < t2 || r1 < l2 || r2 < l1)
191 l_int32 i, n, val, valid;
195 PROCNAME(
"boxaContainedInBox");
198 return (
BOXA *)ERROR_PTR(
"boxas not defined", procName, NULL);
200 return (
BOXA *)ERROR_PTR(
"box not defined", procName, NULL);
203 if (n == 0 || !valid)
207 for (i = 0; i < n; i++) {
238 l_int32 i, n, val, valid;
241 PROCNAME(
"boxaContainedInBoxCount");
244 return ERROR_INT(
"&count not defined", procName, 1);
247 return ERROR_INT(
"boxa not defined", procName, 1);
249 return ERROR_INT(
"box not defined", procName, 1);
252 if (n == 0 || !valid)
255 for (i = 0; i < n; i++) {
280 l_int32 i, j, n1, n2, cont, result;
283 PROCNAME(
"boxaContainedInBoxa");
286 return ERROR_INT(
"&contained not defined", procName, 1);
288 if (!boxa1 || !boxa2)
289 return ERROR_INT(
"boxa1 and boxa2 not both defined", procName, 1);
293 for (i = 0; i < n2; i++) {
297 for (j = 0; j < n1; j++) {
334 l_int32 i, n, val, valid;
338 PROCNAME(
"boxaIntersectsBox");
341 return (
BOXA *)ERROR_PTR(
"boxas not defined", procName, NULL);
343 return (
BOXA *)ERROR_PTR(
"box not defined", procName, NULL);
346 if (n == 0 || !valid)
350 for (i = 0; i < n; i++) {
376 l_int32 i, n, val, valid;
379 PROCNAME(
"boxaIntersectsBoxCount");
382 return ERROR_INT(
"&count not defined", procName, 1);
385 return ERROR_INT(
"boxa not defined", procName, 1);
387 return ERROR_INT(
"box not defined", procName, 1);
390 if (n == 0 || !valid)
393 for (i = 0; i < n; i++) {
426 PROCNAME(
"boxaClipToBox");
429 return (
BOXA *)ERROR_PTR(
"boxas not defined", procName, NULL);
431 return (
BOXA *)ERROR_PTR(
"box not defined", procName, NULL);
434 if (n == 0 || !valid)
438 for (i = 0; i < n; i++) {
481 l_int32 i, j, w, h, n1, n2, overlap, niters;
482 BOX *box1, *box2, *box3;
486 PROCNAME(
"boxaCombineOverlaps");
489 return (
BOXA *)ERROR_PTR(
"boxas not defined", procName, NULL);
506 for (i = 0; i < n1; i++) {
509 for (j = i + 1; j < n1; j++) {
540 L_INFO(
"number of iterations: %d\n", procName, niters);
578 l_int32 i, j, w, h, w2, h2, n1, n2, n1i, n2i, niters;
579 l_int32 overlap, bigger, area1, area2;
580 BOX *box1, *box2, *box3;
581 BOXA *boxa1, *boxa2, *boxac1, *boxac2;
584 PROCNAME(
"boxaCombineOverlapsInPair");
586 if (pboxad1) *pboxad1 = NULL;
587 if (pboxad2) *pboxad2 = NULL;
588 if (!boxas1 || !boxas2)
589 return ERROR_INT(
"boxas1 and boxas2 not both defined", procName, 1);
590 if (!pboxad1 || !pboxad2)
591 return ERROR_INT(
"&boxad1 and &boxad2 not both defined", procName, 1);
603 if (area1 >= area2) {
631 for (i = 0; i < n1; i++) {
634 for (j = 0; j < n2; j++) {
639 if (overlap && (bigger == 1)) {
650 for (i = 0; i < n2; i++) {
653 for (j = 0; j < n1; j++) {
658 if (overlap && (bigger == 1)) {
677 if (n1 == n1i && n2 == n2i)
break;
690 L_INFO(
"number of iterations: %d\n", procName, niters);
713 l_int32 l1, l2, r1, r2, t1, t2, b1, b2, w1, h1, w2, h2, ld, td, rd, bd;
714 l_int32 valid1, valid2;
716 PROCNAME(
"boxOverlapRegion");
719 return (
BOX *)ERROR_PTR(
"boxes not both defined", procName, NULL);
722 if (!valid1 || !valid2) {
723 L_WARNING(
"at least one box is invalid\n", procName);
733 if (b2 < t1 || b1 < t2 || r1 < l2 || r2 < l1)
740 return boxCreate(ld, td, rd - ld + 1, bd - td + 1);
763 l_int32 l1, l2, r1, r2, t1, t2, b1, b2, w1, h1, w2, h2, ld, td, rd, bd;
764 l_int32 valid1, valid2;
766 PROCNAME(
"boxBoundingRegion");
769 return (
BOX *)ERROR_PTR(
"boxes not both defined", procName, NULL);
772 if (!valid1 && !valid2) {
773 L_WARNING(
"both boxes are invalid\n", procName);
776 if (valid1 && !valid2)
778 if (!valid1 && valid2)
791 return boxCreate(ld, td, rd - ld + 1, bd - td + 1);
814 l_int32 w2, h2, w, h, valid1, valid2;
817 PROCNAME(
"boxOverlapFraction");
820 return ERROR_INT(
"&fract not defined", procName, 1);
823 return ERROR_INT(
"boxes not both defined", procName, 1);
826 if (!valid1 || !valid2) {
827 L_WARNING(
"boxes not both valid\n", procName);
836 *pfract = (l_float32)(w * h) / (l_float32)(w2 * h2);
854 l_int32 w, h, valid1, valid2;
857 PROCNAME(
"boxOverlapArea");
860 return ERROR_INT(
"&area not defined", procName, 1);
863 return ERROR_INT(
"boxes not both defined", procName, 1);
866 if (!valid1 || !valid2)
867 return ERROR_INT(
"boxes not both valid", procName, 1);
917 l_float32 min_overlap,
921 l_int32 i, j, n, w, h, area1, area2, val;
922 l_int32 overlap_area;
923 l_float32 overlap_ratio, area_ratio;
924 BOX *box1, *box2, *box3;
928 PROCNAME(
"boxaHandleOverlaps");
930 if (pnamap) *pnamap = NULL;
932 return (
BOXA *)ERROR_PTR(
"boxas not defined", procName, NULL);
934 return (
BOXA *)ERROR_PTR(
"invalid op", procName, NULL);
940 L_WARNING(
"range is 0\n", procName);
946 for (i = 0; i < n; i++) {
955 for (j = i + 1; j < i + 1 + range && j < n; j++) {
959 if (overlap_area > 0) {
964 }
else if (area1 >= area2) {
965 overlap_ratio = (l_float32)overlap_area / (l_float32)area2;
966 area_ratio = (l_float32)area2 / (l_float32)area1;
967 if (overlap_ratio >= min_overlap &&
968 area_ratio <= max_ratio) {
972 overlap_ratio = (l_float32)overlap_area / (l_float32)area1;
973 area_ratio = (l_float32)area1 / (l_float32)area2;
974 if (overlap_ratio >= min_overlap &&
975 area_ratio <= max_ratio) {
988 for (i = 0; i < n; i++) {
1003 for (i = 0; i < n; i++) {
1049 l_int32 l1, t1, w1, h1, r1, b1, l2, t2, w2, h2, r2, b2, valid1, valid2;
1051 PROCNAME(
"boxOverlapDistance");
1053 if (!ph_ovl && !pv_ovl)
1054 return ERROR_INT(
"nothing to do", procName, 1);
1055 if (ph_ovl) *ph_ovl = 0;
1056 if (pv_ovl) *pv_ovl = 0;
1058 return ERROR_INT(
"boxes not both defined", procName, 1);
1061 if (!valid1 || !valid2)
1062 return ERROR_INT(
"boxes not both valid", procName, 1);
1122 l_int32 h_ovl, v_ovl, valid1, valid2;
1124 PROCNAME(
"boxSeparationDistance");
1126 if (ph_sep) *ph_sep = 0;
1127 if (pv_sep) *pv_sep = 0;
1128 if (!ph_sep || !pv_sep)
1129 return ERROR_INT(
"&h_sep and &v_sep not both defined", procName, 1);
1131 return ERROR_INT(
"boxes not both defined", procName, 1);
1134 if (!valid1 || !valid2)
1135 return ERROR_INT(
"boxes not both valid", procName, 1);
1139 *ph_sep = -h_ovl + 1;
1141 *pv_sep = -v_ovl + 1;
1167 l_int32 w1, h1, w2, h2, size1, size2, valid1, valid2;
1169 PROCNAME(
"boxCompareSize");
1172 return ERROR_INT(
"&rel not defined", procName, 1);
1175 return ERROR_INT(
"boxes not both defined", procName, 1);
1178 if (!valid1 || !valid2)
1179 return ERROR_INT(
"boxes not both valid", procName, 1);
1183 return ERROR_INT(
"invalid compare type", procName, 1);
1188 *prel = (w1 > w2) ? 1 : ((w1 == w2) ? 0 : -1);
1190 *prel = (h1 > h2) ? 1 : ((h1 == h2) ? 0 : -1);
1192 size1 = L_MAX(w1, h1);
1193 size2 = L_MAX(w2, h2);
1194 *prel = (size1 > size2) ? 1 : ((size1 == size2) ? 0 : -1);
1198 *prel = (size1 > size2) ? 1 : ((size1 == size2) ? 0 : -1);
1202 *prel = (size1 > size2) ? 1 : ((size1 == size2) ? 0 : -1);
1222 l_int32 bx, by, bw, bh;
1224 PROCNAME(
"boxContainsPt");
1227 return ERROR_INT(
"&contains not defined", procName, 1);
1230 return ERROR_INT(
"&box not defined", procName, 1);
1232 if (x >= bx && x < bx + bw && y >= by && y < by + bh)
1256 l_int32 i, n, minindex;
1257 l_float32 delx, dely, dist, mindist, cx, cy;
1260 PROCNAME(
"boxaGetNearestToPt");
1263 return (
BOX *)ERROR_PTR(
"boxa not defined", procName, NULL);
1265 return (
BOX *)ERROR_PTR(
"n = 0", procName, NULL);
1267 mindist = 1000000000.;
1269 for (i = 0; i < n; i++) {
1273 delx = (l_float32)(cx - x);
1274 dely = (l_float32)(cy - y);
1275 dist = delx * delx + dely * dely;
1276 if (dist < mindist) {
1309 l_int32 i, n, minindex;
1310 l_float32 dist, mindist, cx, cy;
1313 PROCNAME(
"boxaGetNearestToLine");
1316 return (
BOX *)ERROR_PTR(
"boxa not defined", procName, NULL);
1318 return (
BOX *)ERROR_PTR(
"n = 0", procName, NULL);
1319 if (y >= 0 && x >= 0)
1320 return (
BOX *)ERROR_PTR(
"either x or y must be < 0", procName, NULL);
1322 return (
BOX *)ERROR_PTR(
"either x or y must be >= 0", procName, NULL);
1324 mindist = 1000000000.;
1326 for (i = 0; i < n; i++) {
1331 dist = L_ABS(cx - (l_float32)x);
1333 dist = L_ABS(cy - (l_float32)y);
1334 if (dist < mindist) {
1364 l_int32 dist_select,
1369 l_int32 i, n, index, dist;
1373 PROCNAME(
"boxaFindNearestBoxes");
1375 if (pnaaindex) *pnaaindex = NULL;
1376 if (pnaadist) *pnaadist = NULL;
1378 return ERROR_INT(
"&naaindex not defined", procName, 1);
1380 return ERROR_INT(
"&naadist not defined", procName, 1);
1382 return ERROR_INT(
"boxa not defined", procName, 1);
1389 for (i = 0; i < n; i++) {
1393 range, &index, &dist);
1397 range, &index, &dist);
1401 range, &index, &dist);
1405 range, &index, &dist);
1447 l_int32 dist_select,
1452 l_int32 j, jmin, jmax, n, mindist, dist, index;
1453 l_int32 x, y, w, h, bx, by, bw, bh;
1455 PROCNAME(
"boxaGetNearestByDirection");
1457 if (pindex) *pindex = -1;
1458 if (pdist) *pdist = 100000;
1460 return ERROR_INT(
"&index not defined", procName, 1);
1462 return ERROR_INT(
"&dist not defined", procName, 1);
1464 return ERROR_INT(
"boxa not defined", procName, 1);
1467 return ERROR_INT(
"invalid dir", procName, 1);
1469 return ERROR_INT(
"invalid dist_select", procName, 1);
1471 if (i < 0 || i >= n)
1472 return ERROR_INT(
"invalid box index", procName, 1);
1474 jmin = (range <= 0) ? 0 : L_MAX(0, i - range);
1475 jmax = (range <= 0) ? n - 1 : L_MIN(n -1, i + range);
1480 for (j = jmin; j <= jmax; j++) {
1481 if (j == i)
continue;
1489 if (dist < mindist) {
1496 for (j = jmin; j <= jmax; j++) {
1497 if (j == i)
continue;
1505 if (dist < mindist) {
1542 ovlp = c2 + s2 - 1 - c1;
1544 ovlp = c1 + s1 - 1 - c2;
1545 return (ovlp < 0) ? 0 : 1;
1568 dist = c1 - (c2 + s2 - 1);
1570 dist = c2 - (c1 + s1 - 1);
1589 PROCNAME(
"boxGetCenter");
1594 return ERROR_INT(
"&cx, &cy not both defined", procName, 1);
1596 return ERROR_INT(
"box not defined", procName, 1);
1598 if (w == 0 || h == 0)
return 1;
1599 *pcx = (l_float32)(x + 0.5 * w);
1600 *pcy = (l_float32)(y + 0.5 * h);
1635 l_int32 bx, by, bw, bh, xp, yp, xt, yt, i, n;
1639 PROCNAME(
"boxIntersectByLine");
1646 if (!px1 || !py1 || !px2 || !py2)
1647 return ERROR_INT(
"&x1, &y1, &x2, &y2 not all defined", procName, 1);
1649 return ERROR_INT(
"&n not defined", procName, 1);
1651 return ERROR_INT(
"box not defined", procName, 1);
1653 if (bw == 0 || bh == 0)
return 1;
1656 if (y >= by && y < by + bh) {
1664 if (slope > 1000000.0) {
1665 if (x >= bx && x < bx + bw) {
1675 invslope = 1.0 / slope;
1676 xp = (l_int32)(x + invslope * (y - by));
1677 if (xp >= bx && xp < bx + bw)
1679 xp = (l_int32)(x + invslope * (y - by - bh + 1));
1680 if (xp >= bx && xp < bx + bw)
1684 yp = (l_int32)(y + slope * (x - bx));
1685 if (yp >= by && yp < by + bh)
1687 yp = (l_int32)(y + slope * (x - bx - bw + 1));
1688 if (yp >= by && yp < by + bh)
1697 for (i = 1; i < n; i++) {
1699 if ((*px1 != xt) || (*py1 != yt)) {
1734 PROCNAME(
"boxClipToRectangle");
1737 return (
BOX *)ERROR_PTR(
"box not defined", procName, NULL);
1738 if (box->
x >= wi || box->
y >= hi ||
1739 box->
x + box->
w <= 0 || box->
y + box->
h <= 0)
1740 return (
BOX *)ERROR_PTR(
"box outside rectangle", procName, NULL);
1751 if (boxd->
x + boxd->
w > wi)
1752 boxd->
w = wi - boxd->
x;
1753 if (boxd->
y + boxd->
h > hi)
1754 boxd->
h = hi - boxd->
y;
1798 PROCNAME(
"boxClipToRectangleParams");
1800 if (pxstart) *pxstart = 0;
1801 if (pystart) *pystart = 0;
1802 if (pxend) *pxend = w;
1803 if (pyend) *pyend = h;
1806 if (!pxstart || !pystart || !pxend || !pyend)
1807 return ERROR_INT(
"invalid ptr input", procName, 1);
1811 return ERROR_INT(
"box outside image", procName, 1);
1817 if (bw == 0 || bh == 0)
1818 return ERROR_INT(
"invalid clipping box", procName, 1);
1819 *pxend = *pxstart + bw;
1820 *pyend = *pystart + bh;
1854 PROCNAME(
"boxRelocateOneSide");
1857 return (
BOX *)ERROR_PTR(
"boxs not defined", procName, NULL);
1862 if (w == 0 || h == 0)
1903 PROCNAME(
"boxaAdjustSides");
1906 return (
BOXA *)ERROR_PTR(
"boxas not defined", procName, NULL);
1910 for (i = 0; i < n; i++) {
1912 box2 =
boxAdjustSides(NULL, box1, delleft, delright, deltop, delbot);
1952 PROCNAME(
"boxaAdjustBoxSides");
1955 return ERROR_INT(
"boxa not defined", procName, 1);
1958 return ERROR_INT(
"invalid index", procName, 1);
1998 l_int32 x, y, w, h, xl, xr, yt, yb, wnew, hnew;
2000 PROCNAME(
"boxAdjustSides");
2003 return (
BOX *)ERROR_PTR(
"boxs not defined", procName, NULL);
2006 xl = L_MAX(0, x + delleft);
2007 yt = L_MAX(0, y + deltop);
2008 xr = x + w + delright;
2009 yb = y + h + delbot;
2013 if (wnew < 1 || hnew < 1)
2014 return (
BOX *)ERROR_PTR(
"boxd has 0 area", procName, NULL);
2052 PROCNAME(
"boxaSetSide");
2055 return (
BOXA *)ERROR_PTR(
"boxas not defined", procName, NULL);
2056 if (boxad && (boxas != boxad))
2057 return (
BOXA *)ERROR_PTR(
"not in-place", procName, NULL);
2060 return (
BOXA *)ERROR_PTR(
"invalid side", procName, NULL);
2062 return (
BOXA *)ERROR_PTR(
"val < 0", procName, NULL);
2067 for (i = 0; i < n; i++) {
2098 l_int32 x, y, w, h, diff;
2100 PROCNAME(
"boxSetSide");
2103 return ERROR_INT(
"box not defined", procName, 1);
2106 return ERROR_INT(
"invalid side", procName, 1);
2108 return ERROR_INT(
"val < 0", procName, 1);
2113 if (L_ABS(diff) >= thresh)
2116 diff = x + w -1 - val;
2117 if (L_ABS(diff) >= thresh)
2121 if (L_ABS(diff) >= thresh)
2124 diff = y + h - 1 - val;
2125 if (L_ABS(diff) >= thresh)
2161 l_int32 x, y, w, h, n, i, diff;
2164 PROCNAME(
"boxaAdjustWidthToTarget");
2167 return (
BOXA *)ERROR_PTR(
"boxas not defined", procName, NULL);
2168 if (boxad && (boxas != boxad))
2169 return (
BOXA *)ERROR_PTR(
"not in-place", procName, NULL);
2172 return (
BOXA *)ERROR_PTR(
"invalid sides", procName, NULL);
2174 return (
BOXA *)ERROR_PTR(
"target < 1", procName, NULL);
2179 for (i = 0; i < n; i++) {
2185 if (L_ABS(diff) >= thresh)
2188 if (L_ABS(diff) >= thresh)
2191 if (L_ABS(diff) >= thresh)
2229 l_int32 x, y, w, h, n, i, diff;
2232 PROCNAME(
"boxaAdjustHeightToTarget");
2235 return (
BOXA *)ERROR_PTR(
"boxas not defined", procName, NULL);
2236 if (boxad && (boxas != boxad))
2237 return (
BOXA *)ERROR_PTR(
"not in-place", procName, NULL);
2240 return (
BOXA *)ERROR_PTR(
"invalid sides", procName, NULL);
2242 return (
BOXA *)ERROR_PTR(
"target < 1", procName, NULL);
2247 for (i = 0; i < n; i++) {
2253 if (L_ABS(diff) >= thresh)
2256 if (L_ABS(diff) >= thresh)
2259 if (L_ABS(diff) >= thresh)
2282 PROCNAME(
"boxEqual");
2285 return ERROR_INT(
"&same not defined", procName, 1);
2288 return ERROR_INT(
"boxes not both defined", procName, 1);
2289 if (box1->
x == box2->
x && box1->
y == box2->
y &&
2290 box1->
w == box2->
w && box1->
h == box2->
h)
2331 l_int32 i, j, n, jstart, jend, found, samebox;
2332 l_int32 *countarray;
2336 PROCNAME(
"boxaEqual");
2338 if (pnaindex) *pnaindex = NULL;
2340 return ERROR_INT(
"&same not defined", procName, 1);
2342 if (!boxa1 || !boxa2)
2343 return ERROR_INT(
"boxa1 and boxa2 not both defined", procName, 1);
2348 if ((countarray = (l_int32 *)LEPT_CALLOC(n,
sizeof(l_int32))) == NULL)
2349 return ERROR_INT(
"calloc fail for countarray", procName, 1);
2352 for (i = 0; i < n; i++) {
2354 jstart = L_MAX(0, i - maxdist);
2355 jend = L_MIN(n-1, i + maxdist);
2357 for (j = jstart; j <= jend; j++) {
2360 if (samebox && countarray[j] == 0) {
2372 LEPT_FREE(countarray);
2382 LEPT_FREE(countarray);
2412 l_int32 l1, l2, r1, r2, t1, t2, b1, b2, valid1, valid2;
2414 PROCNAME(
"boxSimilar");
2417 return ERROR_INT(
"&similar not defined", procName, 1);
2420 return ERROR_INT(
"boxes not both defined", procName, 1);
2423 if (!valid1 || !valid2)
2424 return ERROR_INT(
"boxes not both valid", procName, 1);
2428 if (L_ABS(l1 - l2) > leftdiff)
2430 if (L_ABS(r1 - r2) > rightdiff)
2432 if (L_ABS(t1 - t2) > topdiff)
2434 if (L_ABS(b1 - b2) > botdiff)
2473 l_int32 i, n1, n2, match, mismatch;
2476 PROCNAME(
"boxaSimilar");
2478 if (psimilar) *psimilar = 0;
2479 if (pnasim) *pnasim = NULL;
2480 if (!boxa1 || !boxa2)
2481 return ERROR_INT(
"boxa1 and boxa2 not both defined", procName, 1);
2483 return ERROR_INT(
"&similar not defined", procName, 1);
2487 L_ERROR(
"boxa counts differ: %d vs %d\n", procName, n1, n2);
2493 for (i = 0; i < n1; i++) {
2496 boxSimilar(box1, box2, leftdiff, rightdiff, topdiff, botdiff,
2504 if (!debug && pnasim == NULL)
2507 L_INFO(
"box %d not similar\n", procName, i);
2511 if (!mismatch) *psimilar = 1;
2545 PROCNAME(
"boxaJoin");
2548 return ERROR_INT(
"boxad not defined", procName, 1);
2554 if (iend < 0 || iend >= n)
2557 return ERROR_INT(
"istart > iend; nothing to add", procName, 1);
2559 for (i = istart; i <= iend; i++) {
2594 PROCNAME(
"boxaaJoin");
2597 return ERROR_INT(
"baad not defined", procName, 1);
2604 if (iend < 0 || iend >= n)
2607 return ERROR_INT(
"istart > iend; nothing to add", procName, 1);
2609 for (i = istart; i <= iend; i++) {
2644 PROCNAME(
"boxaSplitEvenOdd");
2646 if (pboxae) *pboxae = NULL;
2647 if (pboxao) *pboxao = NULL;
2648 if (!pboxae || !pboxao)
2649 return ERROR_INT(
"&boxae and &boxao not both defined", procName, 1);
2651 return ERROR_INT(
"boxa not defined", procName, 1);
2656 if (fillflag == 0) {
2658 for (i = 0; i < n; i++) {
2666 for (i = 0; i < n; i++) {
2704 l_int32 i, n, ne, no;
2708 PROCNAME(
"boxaMergeEvenOdd");
2710 if (!boxae || !boxao)
2711 return (
BOXA *)ERROR_PTR(
"boxae and boxao not defined", procName, NULL);
2714 if (ne < no || ne > no + 1)
2715 return (
BOXA *)ERROR_PTR(
"boxa sizes invalid", procName, NULL);
2718 if (fillflag == 0) {
2720 for (i = 0; i < n; i++) {
2728 for (i = 0; i < ne; i++) {
BOXA * boxaIntersectsBox(BOXA *boxas, BOX *box)
boxaIntersectsBox()
BOX * boxaGetNearestToPt(BOXA *boxa, l_int32 x, l_int32 y)
boxaGetNearestToPt()
l_ok boxaEqual(BOXA *boxa1, BOXA *boxa2, l_int32 maxdist, NUMA **pnaindex, l_int32 *psame)
boxaEqual()
BOX * boxaGetValidBox(BOXA *boxa, l_int32 index, l_int32 accessflag)
boxaGetValidBox()
l_ok boxaJoin(BOXA *boxad, BOXA *boxas, l_int32 istart, l_int32 iend)
boxaJoin()
l_ok boxaCombineOverlapsInPair(BOXA *boxas1, BOXA *boxas2, BOXA **pboxad1, BOXA **pboxad2, PIXA *pixadb)
boxaCombineOverlapsInPair()
BOXA * boxaMergeEvenOdd(BOXA *boxae, BOXA *boxao, l_int32 fillflag)
boxaMergeEvenOdd()
l_ok ptaAddPt(PTA *pta, l_float32 x, l_float32 y)
ptaAddPt()
l_ok numaAddNumber(NUMA *na, l_float32 val)
numaAddNumber()
l_ok boxContainsPt(BOX *box, l_float32 x, l_float32 y, l_int32 *pcontains)
boxContainsPt()
l_int32 boxaaGetCount(BOXAA *baa)
boxaaGetCount()
l_ok boxaContainedInBoxCount(BOXA *boxa, BOX *box, l_int32 *pcount)
boxaContainedInBoxCount()
static l_int32 boxGetDistanceInXorY(l_int32 c1, l_int32 s1, l_int32 c2, l_int32 s2)
boxGetDistanceInXorY()
PTA * ptaCreate(l_int32 n)
ptaCreate()
l_ok boxGetSideLocations(BOX *box, l_int32 *pl, l_int32 *pr, l_int32 *pt, l_int32 *pb)
boxGetSideLocations()
l_ok boxaSplitEvenOdd(BOXA *boxa, l_int32 fillflag, BOXA **pboxae, BOXA **pboxao)
boxaSplitEvenOdd()
NUMA * numaMakeConstant(l_float32 val, l_int32 size)
numaMakeConstant()
BOXA * boxaContainedInBox(BOXA *boxas, BOX *box)
boxaContainedInBox()
l_ok boxaReplaceBox(BOXA *boxa, l_int32 index, BOX *box)
boxaReplaceBox()
BOX * boxClipToRectangle(BOX *box, l_int32 wi, l_int32 hi)
boxClipToRectangle()
PIX * pixCreate(l_int32 width, l_int32 height, l_int32 depth)
pixCreate()
l_ok pixSetAll(PIX *pix)
pixSetAll()
l_ok boxGetCenter(BOX *box, l_float32 *pcx, l_float32 *pcy)
boxGetCenter()
BOXA * boxaCopy(BOXA *boxa, l_int32 copyflag)
boxaCopy()
NUMA * numaCreate(l_int32 n)
numaCreate()
l_int32 ptaGetCount(PTA *pta)
ptaGetCount()
void boxaDestroy(BOXA **pboxa)
boxaDestroy()
BOXA * boxaAdjustHeightToTarget(BOXA *boxad, BOXA *boxas, l_int32 sides, l_int32 target, l_int32 thresh)
boxaAdjustHeightToTarget()
BOXA * boxaHandleOverlaps(BOXA *boxas, l_int32 op, l_int32 range, l_float32 min_overlap, l_float32 max_ratio, NUMA **pnamap)
boxaHandleOverlaps()
NUMAA * numaaCreate(l_int32 n)
numaaCreate()
BOX * boxBoundingRegion(BOX *box1, BOX *box2)
boxBoundingRegion()
l_ok numaSetValue(NUMA *na, l_int32 index, l_float32 val)
numaSetValue()
BOXA * boxaClipToBox(BOXA *boxas, BOX *box)
boxaClipToBox()
static l_int32 boxHasOverlapInXorY(l_int32 c1, l_int32 s1, l_int32 c2, l_int32 s2)
boxHasOverlapInXorY()
l_ok boxSeparationDistance(BOX *box1, BOX *box2, l_int32 *ph_sep, l_int32 *pv_sep)
boxSeparationDistance()
l_ok boxaaJoin(BOXAA *baad, BOXAA *baas, l_int32 istart, l_int32 iend)
boxaaJoin()
l_ok boxaaAddBoxa(BOXAA *baa, BOXA *ba, l_int32 copyflag)
boxaaAddBoxa()
l_ok boxOverlapArea(BOX *box1, BOX *box2, l_int32 *parea)
boxOverlapArea()
l_ok numaGetIValue(NUMA *na, l_int32 index, l_int32 *pival)
numaGetIValue()
l_ok pixaAddPix(PIXA *pixa, PIX *pix, l_int32 copyflag)
pixaAddPix()
l_ok boxaGetBoxGeometry(BOXA *boxa, l_int32 index, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
boxaGetBoxGeometry()
BOXA * boxaSaveValid(BOXA *boxas, l_int32 copyflag)
boxaSaveValid()
l_ok boxaFindNearestBoxes(BOXA *boxa, l_int32 dist_select, l_int32 range, NUMAA **pnaaindex, NUMAA **pnaadist)
boxaFindNearestBoxes()
l_ok boxaGetArea(BOXA *boxa, l_int32 *parea)
boxaGetArea()
l_ok boxSimilar(BOX *box1, BOX *box2, l_int32 leftdiff, l_int32 rightdiff, l_int32 topdiff, l_int32 botdiff, l_int32 *psimilar)
boxSimilar()
l_ok boxaAddBox(BOXA *boxa, BOX *box, l_int32 copyflag)
boxaAddBox()
l_ok boxContains(BOX *box1, BOX *box2, l_int32 *presult)
boxContains()
BOX * boxAdjustSides(BOX *boxd, BOX *boxs, l_int32 delleft, l_int32 delright, l_int32 deltop, l_int32 delbot)
boxAdjustSides()
l_ok boxSetSide(BOX *boxs, l_int32 side, l_int32 val, l_int32 thresh)
boxSetSide()
l_ok boxOverlapFraction(BOX *box1, BOX *box2, l_float32 *pfract)
boxOverlapFraction()
BOXA * boxaSetSide(BOXA *boxad, BOXA *boxas, l_int32 side, l_int32 val, l_int32 thresh)
boxaSetSide()
BOX * boxOverlapRegion(BOX *box1, BOX *box2)
boxOverlapRegion()
void pixDestroy(PIX **ppix)
pixDestroy()
BOX * boxaGetBox(BOXA *boxa, l_int32 index, l_int32 accessflag)
boxaGetBox()
l_ok boxOverlapDistance(BOX *box1, BOX *box2, l_int32 *ph_ovl, l_int32 *pv_ovl)
boxOverlapDistance()
l_ok boxaIntersectsBoxCount(BOXA *boxa, BOX *box, l_int32 *pcount)
boxaIntersectsBoxCount()
l_ok boxCompareSize(BOX *box1, BOX *box2, l_int32 type, l_int32 *prel)
boxCompareSize()
l_ok boxaGetExtent(BOXA *boxa, l_int32 *pw, l_int32 *ph, BOX **pbox)
boxaGetExtent()
void numaDestroy(NUMA **pna)
numaDestroy()
BOX * boxRelocateOneSide(BOX *boxd, BOX *boxs, l_int32 loc, l_int32 sideflag)
boxRelocateOneSide()
BOXA * boxaAdjustSides(BOXA *boxas, l_int32 delleft, l_int32 delright, l_int32 deltop, l_int32 delbot)
boxaAdjustSides()
l_ok boxClipToRectangleParams(BOX *box, l_int32 w, l_int32 h, l_int32 *pxstart, l_int32 *pystart, l_int32 *pxend, l_int32 *pyend, l_int32 *pbw, l_int32 *pbh)
boxClipToRectangleParams()
l_ok pixRenderBoxaArb(PIX *pix, BOXA *boxa, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval)
pixRenderBoxaArb()
BOX * boxaGetNearestToLine(BOXA *boxa, l_int32 x, l_int32 y)
boxaGetNearestToLine()
BOXA * boxaAdjustWidthToTarget(BOXA *boxad, BOXA *boxas, l_int32 sides, l_int32 target, l_int32 thresh)
boxaAdjustWidthToTarget()
l_ok boxaContainedInBoxa(BOXA *boxa1, BOXA *boxa2, l_int32 *pcontained)
boxaContainedInBoxa()
l_ok boxIntersectByLine(BOX *box, l_int32 x, l_int32 y, l_float32 slope, l_int32 *px1, l_int32 *py1, l_int32 *px2, l_int32 *py2, l_int32 *pn)
boxIntersectByLine()
BOXA * boxaCombineOverlaps(BOXA *boxas, PIXA *pixadb)
boxaCombineOverlaps()
l_ok boxaSimilar(BOXA *boxa1, BOXA *boxa2, l_int32 leftdiff, l_int32 rightdiff, l_int32 topdiff, l_int32 botdiff, l_int32 debug, l_int32 *psimilar, NUMA **pnasim)
boxaSimilar()
l_ok boxaAdjustBoxSides(BOXA *boxa, l_int32 index, l_int32 delleft, l_int32 delright, l_int32 deltop, l_int32 delbot)
boxaAdjustBoxSides()
BOX * boxCopy(BOX *box)
boxCopy()
void ptaDestroy(PTA **ppta)
ptaDestroy()
l_ok boxEqual(BOX *box1, BOX *box2, l_int32 *psame)
boxEqual()
l_ok boxaGetNearestByDirection(BOXA *boxa, l_int32 i, l_int32 dir, l_int32 dist_select, l_int32 range, l_int32 *pindex, l_int32 *pdist)
boxaGetNearestByDirection()
BOXA * boxaCreate(l_int32 n)
boxaCreate()
l_ok numaReplaceNumber(NUMA *na, l_int32 index, l_float32 val)
numaReplaceNumber()
void boxDestroy(BOX **pbox)
boxDestroy()
l_ok boxIntersects(BOX *box1, BOX *box2, l_int32 *presult)
boxIntersects()
l_int32 boxaGetCount(BOXA *boxa)
boxaGetCount()
l_ok ptaGetIPt(PTA *pta, l_int32 index, l_int32 *px, l_int32 *py)
ptaGetIPt()
l_ok boxSetGeometry(BOX *box, l_int32 x, l_int32 y, l_int32 w, l_int32 h)
boxSetGeometry()
l_ok boxIsValid(BOX *box, l_int32 *pvalid)
boxIsValid()
l_ok boxGetGeometry(BOX *box, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
boxGetGeometry()
BOX * boxCreate(l_int32 x, l_int32 y, l_int32 w, l_int32 h)
boxCreate()
l_ok numaaAddNuma(NUMAA *naa, NUMA *na, l_int32 copyflag)
numaaAddNuma()
BOXA * boxaaGetBoxa(BOXAA *baa, l_int32 index, l_int32 accessflag)
boxaaGetBoxa()