22 #pragma warning(disable:4244) // Conversion warnings 26 #include "config_auto.h" 36 #include "allheaders.h" 68 if (pixGetWidth(pix) < kMinImageFindSize ||
69 pixGetHeight(pix) < kMinImageFindSize)
70 return pixCreate(pixGetWidth(pix), pixGetHeight(pix), 1);
73 Pix *pixr = pixReduceRankBinaryCascade(pix, 1, 0, 0, 0);
75 pixa_debug->
AddPix(pixr,
"CascadeReduced");
82 if (pixGetWidth(pixr) < kMinImageFindSize ||
83 pixGetHeight(pixr) < kMinImageFindSize) {
85 return pixCreate(pixGetWidth(pix), pixGetHeight(pix), 1);
88 Pix *pixht2 = pixGenHalftoneMask(pixr, NULL, &ht_found,
91 if (!ht_found && pixht2 != NULL)
94 return pixCreate(pixGetWidth(pix), pixGetHeight(pix), 1);
97 Pix *pixht = pixExpandReplicate(pixht2, 2);
99 pixa_debug->
AddPix(pixht,
"HalftoneReplicated");
103 Pix *pixt = pixSeedfillBinary(NULL, pixht, pix, 8);
104 pixOr(pixht, pixht, pixt);
108 Pix* pixfinemask = pixReduceRankBinaryCascade(pixht, 1, 1, 3, 3);
109 pixDilateBrick(pixfinemask, pixfinemask, 5, 5);
111 pixa_debug->
AddPix(pixfinemask,
"FineMask");
112 Pix* pixreduced = pixReduceRankBinaryCascade(pixht, 1, 1, 1, 1);
113 Pix* pixreduced2 = pixReduceRankBinaryCascade(pixreduced, 3, 3, 3, 0);
114 pixDestroy(&pixreduced);
115 pixDilateBrick(pixreduced2, pixreduced2, 5, 5);
116 Pix* pixcoarsemask = pixExpandReplicate(pixreduced2, 8);
117 pixDestroy(&pixreduced2);
119 pixa_debug->
AddPix(pixcoarsemask,
"CoarseMask");
121 pixAnd(pixcoarsemask, pixcoarsemask, pixfinemask);
122 pixDestroy(&pixfinemask);
124 pixDilateBrick(pixcoarsemask, pixcoarsemask, 3, 3);
125 Pix* pixmask = pixExpandReplicate(pixcoarsemask, 16);
126 pixDestroy(&pixcoarsemask);
128 pixa_debug->
AddPix(pixmask,
"MaskDilated");
130 pixAnd(pixht, pixht, pixmask);
131 pixDestroy(&pixmask);
133 pixa_debug->
AddPix(pixht,
"FinalMask");
135 Pix* result = pixCreate(pixGetWidth(pix), pixGetHeight(pix), 1);
136 pixOr(result, result, pixht);
149 Boxa** boxa, Pixa** pixa) {
154 pixa_debug->
AddPix(pix,
"Conncompimage");
156 *boxa = pixConnComp(pix, pixa, 8);
161 if (*boxa !=
nullptr && *pixa !=
nullptr) npixes = pixaGetCount(*pixa);
162 for (
int i = 0; i < npixes; ++i) {
163 int x_start, x_end, y_start, y_end;
164 Pix* img_pix = pixaGetPix(*pixa, i, L_CLONE);
166 pixa_debug->
AddPix(img_pix,
"A component");
168 kMaxRectangularFraction,
169 kMaxRectangularGradient,
170 &x_start, &y_start, &x_end, &y_end)) {
171 Pix* simple_pix = pixCreate(x_end - x_start, y_end - y_start, 1);
172 pixSetAll(simple_pix);
173 pixDestroy(&img_pix);
175 pixaReplacePix(*pixa, i, simple_pix, NULL);
176 img_pix = pixaGetPix(*pixa, i, L_CLONE);
178 l_int32 x, y, width, height;
179 boxaGetBoxGeometry(*boxa, i, &x, &y, &width, &height);
180 Box* simple_box = boxCreate(x + x_start, y + y_start,
181 x_end - x_start, y_end - y_start);
182 boxaReplaceBox(*boxa, i, simple_box);
184 pixDestroy(&img_pix);
195 static bool HScanForEdge(
uinT32* data,
int wpl,
int x_start,
int x_end,
196 int min_count,
int mid_width,
int max_count,
197 int y_end,
int y_step,
int* y_start) {
199 for (
int y = *y_start; y != y_end; y += y_step) {
202 uinT32* line = data + wpl * y;
203 for (
int x = x_start; x < x_end; ++x) {
204 if (GET_DATA_BIT(line, x))
207 if (mid_rows == 0 && pix_count < min_count)
211 if (pix_count > max_count)
214 if (mid_rows > mid_width)
227 static bool VScanForEdge(
uinT32* data,
int wpl,
int y_start,
int y_end,
228 int min_count,
int mid_width,
int max_count,
229 int x_end,
int x_step,
int* x_start) {
231 for (
int x = *x_start; x != x_end; x += x_step) {
233 uinT32* line = data + y_start * wpl;
234 for (
int y = y_start; y < y_end; ++y, line += wpl) {
235 if (GET_DATA_BIT(line, x))
238 if (mid_cols == 0 && pix_count < min_count)
242 if (pix_count > max_count)
245 if (mid_cols > mid_width)
261 double min_fraction,
double max_fraction,
262 double max_skew_gradient,
263 int* x_start,
int* y_start,
264 int* x_end,
int* y_end) {
267 *x_end = pixGetWidth(pix);
269 *y_end = pixGetHeight(pix);
271 uinT32* data = pixGetData(pix);
272 int wpl = pixGetWpl(pix);
273 bool any_cut =
false;
274 bool left_done =
false;
275 bool right_done =
false;
276 bool top_done =
false;
277 bool bottom_done =
false;
281 int width = *x_end - *x_start;
282 int min_count =
static_cast<int>(width * min_fraction);
283 int max_count =
static_cast<int>(width * max_fraction);
284 int edge_width =
static_cast<int>(width * max_skew_gradient);
285 if (HScanForEdge(data, wpl, *x_start, *x_end, min_count, edge_width,
286 max_count, *y_end, 1, y_start) && !top_done) {
291 if (HScanForEdge(data, wpl, *x_start, *x_end, min_count, edge_width,
292 max_count, *y_start, -1, y_end) && !bottom_done) {
299 int height = *y_end - *y_start;
300 min_count =
static_cast<int>(height * min_fraction);
301 max_count =
static_cast<int>(height * max_fraction);
302 edge_width =
static_cast<int>(height * max_skew_gradient);
303 if (VScanForEdge(data, wpl, *y_start, *y_end, min_count, edge_width,
304 max_count, *x_end, 1, x_start) && !left_done) {
309 if (VScanForEdge(data, wpl, *y_start, *y_end, min_count, edge_width,
310 max_count, *x_start, -1, x_end) && !right_done) {
319 return left_done && right_done && top_done && bottom_done;
327 int* x_end,
int* y_end) {
328 Box* input_box = boxCreate(*x_start, *y_start, *x_end - *x_start,
330 Box* output_box = NULL;
331 pixClipBoxToForeground(pix, input_box, NULL, &output_box);
332 bool result = output_box != NULL;
334 l_int32 x, y, width, height;
335 boxGetGeometry(output_box, &x, &y, &width, &height);
340 boxDestroy(&output_box);
342 boxDestroy(&input_box);
351 const uinT8* point) {
355 line_vector[i] =
static_cast<int>(line2[i]) - static_cast<int>(line1[i]);
356 point_vector[i] =
static_cast<int>(point[i]) - static_cast<int>(line1[i]);
358 line_vector[L_ALPHA_CHANNEL] = 0;
361 cross[COLOR_RED] = line_vector[COLOR_GREEN] * point_vector[COLOR_BLUE]
362 - line_vector[COLOR_BLUE] * point_vector[COLOR_GREEN];
363 cross[COLOR_GREEN] = line_vector[COLOR_BLUE] * point_vector[COLOR_RED]
364 - line_vector[COLOR_RED] * point_vector[COLOR_BLUE];
365 cross[COLOR_BLUE] = line_vector[COLOR_RED] * point_vector[COLOR_GREEN]
366 - line_vector[COLOR_GREEN] * point_vector[COLOR_RED];
367 cross[L_ALPHA_CHANNEL] = 0;
369 double cross_sq = 0.0;
370 double line_sq = 0.0;
372 cross_sq +=
static_cast<double>(cross[j]) * cross[j];
373 line_sq +=
static_cast<double>(line_vector[j]) * line_vector[j];
375 if (line_sq == 0.0) {
378 return cross_sq / line_sq;
385 composeRGBPixel(r, g, b, &result);
393 else if (pixel >= 255.0)
395 return static_cast<uinT8>(pixel);
409 Pix* color_map1, Pix* color_map2,
412 ASSERT_HOST(pix != NULL && pixGetDepth(pix) == 32);
415 int width = pixGetWidth(pix);
416 int height = pixGetHeight(pix);
417 int left_pad =
MAX(rect.
left() - 2 * factor, 0) / factor;
418 int top_pad = (rect.
top() + 2 * factor + (factor - 1)) / factor;
419 top_pad =
MIN(height, top_pad);
420 int right_pad = (rect.
right() + 2 * factor + (factor - 1)) / factor;
421 right_pad =
MIN(width, right_pad);
422 int bottom_pad =
MAX(rect.
bottom() - 2 * factor, 0) / factor;
423 int width_pad = right_pad - left_pad;
424 int height_pad = top_pad - bottom_pad;
425 if (width_pad < 1 || height_pad < 1 || width_pad + height_pad < 4)
428 Box* scaled_box = boxCreate(left_pad, height - top_pad,
429 width_pad, height_pad);
430 Pix* scaled = pixClipRectangle(pix, scaled_box, NULL);
433 STATS red_stats(0, 256);
434 STATS green_stats(0, 256);
435 STATS blue_stats(0, 256);
436 uinT32* data = pixGetData(scaled);
438 for (
int y = 0; y < height_pad; ++y) {
439 for (
int x = 0; x < width_pad; ++x, ++data) {
440 int r = GET_DATA_BYTE(data, COLOR_RED);
441 int g = GET_DATA_BYTE(data, COLOR_GREEN);
442 int b = GET_DATA_BYTE(data, COLOR_BLUE);
444 green_stats.
add(g, 1);
445 blue_stats.
add(b, 1);
452 int best_l8 =
static_cast<int>(red_stats.
ile(0.125f));
453 int best_u8 =
static_cast<int>(ceil(red_stats.
ile(0.875f)));
454 int best_i8r = best_u8 - best_l8;
455 int x_color = COLOR_RED;
456 int y1_color = COLOR_GREEN;
457 int y2_color = COLOR_BLUE;
458 int l8 =
static_cast<int>(green_stats.
ile(0.125f));
459 int u8 =
static_cast<int>(ceil(green_stats.
ile(0.875f)));
460 if (u8 - l8 > best_i8r) {
464 x_color = COLOR_GREEN;
465 y1_color = COLOR_RED;
467 l8 =
static_cast<int>(blue_stats.
ile(0.125f));
468 u8 =
static_cast<int>(ceil(blue_stats.
ile(0.875f)));
469 if (u8 - l8 > best_i8r) {
473 x_color = COLOR_BLUE;
474 y1_color = COLOR_GREEN;
475 y2_color = COLOR_RED;
477 if (best_i8r >= kMinColorDifference) {
480 uinT32* data = pixGetData(scaled);
481 for (
int im_y = 0; im_y < height_pad; ++im_y) {
482 for (
int im_x = 0; im_x < width_pad; ++im_x, ++data) {
483 int x = GET_DATA_BYTE(data, x_color);
484 int y1 = GET_DATA_BYTE(data, y1_color);
485 int y2 = GET_DATA_BYTE(data, y2_color);
490 double m1 = line1.
m();
491 double c1 = line1.
c(m1);
492 double m2 = line2.
m();
493 double c2 = line2.
c(m2);
494 double rms = line1.
rms(m1, c1) + line2.
rms(m2, c2);
498 color1[y1_color] =
ClipToByte(m1 * best_l8 + c1 + 0.5);
499 color1[y2_color] =
ClipToByte(m2 * best_l8 + c2 + 0.5);
502 color2[y1_color] =
ClipToByte(m1 * best_u8 + c1 + 0.5);
503 color2[y2_color] =
ClipToByte(m2 * best_u8 + c2 + 0.5);
510 color1[L_ALPHA_CHANNEL] = 0;
511 memcpy(color2, color1, 4);
513 if (color_map1 != NULL) {
514 pixSetInRectArbitrary(color_map1, scaled_box,
517 color1[COLOR_BLUE]));
518 pixSetInRectArbitrary(color_map2, scaled_box,
521 color2[COLOR_BLUE]));
522 pixSetInRectArbitrary(rms_map, scaled_box, color1[L_ALPHA_CHANNEL]);
525 boxDestroy(&scaled_box);
573 TBOX search_box(box1);
576 if (box1.
x_gap(box2) <= 0)
581 if (box1.
y_gap(box2) <= 0)
592 const FCOORD& rotation, Pix* pix) {
598 TBOX rotated_im_box(im_box);
599 rotated_im_box.
rotate(rotation);
600 Pix* rect_pix = pixCreate(box.
width(), box.
height(), 1);
601 pixRasterop(rect_pix, 0, 0, box.
width(), box.
height(),
602 PIX_SRC, pix, box.
left() - rotated_im_box.
left(),
603 rotated_im_box.
top() - box.
top());
605 pixCountPixels(rect_pix, &result, NULL);
606 pixDestroy(&rect_pix);
614 static void AttemptToShrinkBox(
const FCOORD& rotation,
const FCOORD& rerotation,
615 const TBOX& im_box, Pix* pix,
TBOX* slice) {
616 TBOX rotated_box(*slice);
617 rotated_box.
rotate(rerotation);
618 TBOX rotated_im_box(im_box);
619 rotated_im_box.
rotate(rerotation);
620 int left = rotated_box.
left() - rotated_im_box.
left();
621 int right = rotated_box.
right() - rotated_im_box.
left();
622 int top = rotated_im_box.
top() - rotated_box.
top();
623 int bottom = rotated_im_box.
top() - rotated_box.
bottom();
625 top = rotated_im_box.
top() - top;
626 bottom = rotated_im_box.
top() - bottom;
627 left += rotated_im_box.
left();
628 right += rotated_im_box.
left();
630 rotated_box.
rotate(rotation);
659 static void CutChunkFromParts(
const TBOX& box,
const TBOX& im_box,
661 Pix* pix, ColPartition_LIST* part_list) {
663 ColPartition_IT part_it(part_list);
673 if (box.
top() < part_box.
top()) {
674 TBOX slice(part_box);
678 AttemptToShrinkBox(rotation, rerotation, im_box, pix, &slice);
679 part_it.add_before_stay_put(
686 TBOX slice(part_box);
688 if (box.
top() < part_box.
top())
694 AttemptToShrinkBox(rotation, rerotation, im_box, pix, &slice);
695 part_it.add_before_stay_put(
702 TBOX slice(part_box);
704 if (box.
top() < part_box.
top())
710 AttemptToShrinkBox(rotation, rerotation, im_box, pix, &slice);
711 part_it.add_before_stay_put(
718 TBOX slice(part_box);
722 AttemptToShrinkBox(rotation, rerotation, im_box, pix, &slice);
723 part_it.add_before_stay_put(
729 delete part_it.extract();
732 }
while (!part_it.at_first());
742 static void DivideImageIntoParts(
const TBOX& im_box,
const FCOORD& rotation,
743 const FCOORD& rerotation, Pix* pix,
745 ColPartition_LIST* part_list) {
750 ColPartition_IT part_it(part_list);
751 part_it.add_after_then_move(pix_part);
759 for (part_it.move_to_first(); !part_it.empty(); part_it.forward()) {
770 if (black_area * 2 < part_box.
area() || !im_box.
contains(part_box)) {
775 part_box.
set_top(part_box.
top() + padding / 2);
777 CutChunkFromParts(part_box, im_box, rotation, rerotation,
784 if (part_list->empty()) {
792 static int ExpandImageLeft(
const TBOX& box,
int left_limit,
801 if (part_box.y_gap(box) < 0) {
802 if (part_box.right() > left_limit && part_box.right() < box.
left())
803 left_limit = part_box.
right();
815 if (part_box.y_gap(box) < 0) {
816 if (part_box.right() > left_limit && part_box.right() < box.
left()) {
817 left_limit = part_box.
right();
828 static int ExpandImageRight(
const TBOX& box,
int right_limit,
837 if (part_box.y_gap(box) < 0) {
838 if (part_box.left() < right_limit && part_box.left() > box.
right())
839 right_limit = part_box.
left();
851 if (part_box.y_gap(box) < 0) {
852 if (part_box.left() < right_limit && part_box.left() > box.
right())
853 right_limit = part_box.
left();
863 static int ExpandImageBottom(
const TBOX& box,
int bottom_limit,
872 if (part_box.x_gap(box) < 0) {
873 if (part_box.top() > bottom_limit && part_box.top() < box.
bottom())
874 bottom_limit = part_box.
top();
886 if (part_box.x_gap(box) < 0) {
887 if (part_box.top() > bottom_limit && part_box.top() < box.
bottom())
888 bottom_limit = part_box.
top();
898 static int ExpandImageTop(
const TBOX& box,
int top_limit,
907 if (part_box.x_gap(box) < 0) {
908 if (part_box.bottom() < top_limit && part_box.bottom() > box.
top())
909 top_limit = part_box.
bottom();
921 if (part_box.x_gap(box) < 0) {
922 if (part_box.bottom() < top_limit && part_box.bottom() > box.
top())
923 top_limit = part_box.
bottom();
936 const TBOX& limit_box,
938 *expanded_box = im_box;
941 expanded_box->
set_left(ExpandImageLeft(im_box, limit_box.
left(),
945 expanded_box->
set_right(ExpandImageRight(im_box, limit_box.
right(),
949 expanded_box->
set_top(ExpandImageTop(im_box, limit_box.
top(), part_grid));
958 return expanded_box->
area() - im_box.
area();
967 memset(dunnit, 0,
sizeof(dunnit));
970 TBOX text_box(*im_box);
971 for (
int iteration = 0; iteration <
BND_COUNT; ++iteration) {
976 for (
int dir = 0; dir <
BND_COUNT; ++dir) {
980 int area_delta = ExpandImageDir(bnd, text_box, limit_box, part_grid,
981 &expanded_boxes[bnd]);
982 if (best_delta < 0 || area_delta < best_delta) {
983 best_delta = area_delta;
989 dunnit[best_dir] =
true;
990 text_box = expanded_boxes[best_dir];
1026 static bool ExpandImageIntoParts(
const TBOX& max_image_box,
1033 tprintf(
"Searching for merge with image part:");
1034 im_part_box.
print();
1036 max_image_box.
print();
1044 tprintf(
"Considering merge with part:");
1049 tprintf(
"Not within text box\n");
1064 DeletePartition(part);
1067 int x_dist =
MAX(0, box.
x_gap(im_part_box));
1068 int y_dist =
MAX(0, box.
y_gap(im_part_box));
1069 int dist = x_dist * x_dist + y_dist * y_dist;
1070 if (dist > box.
area() || dist > im_part_box.
area())
1072 if (best_part == NULL || dist < best_dist) {
1079 if (best_part != NULL) {
1083 tprintf(
"Merging image part:");
1084 im_part_box.
print();
1092 DeletePartition(image_part);
1094 DeletePartition(best_part);
1103 static int IntersectArea(
const TBOX& box, ColPartition_LIST* part_list) {
1104 int intersect_area = 0;
1105 ColPartition_IT part_it(part_list);
1107 for (part_it.mark_cycle_pt(); !part_it.cycled_list();
1108 part_it.forward()) {
1111 intersect_area += intersect.
area();
1113 return intersect_area;
1121 static bool TestWeakIntersectedPart(
const TBOX& im_box,
1122 ColPartition_LIST* part_list,
1128 int area = part_box.
area();
1129 int intersect_area = IntersectArea(part_box, part_list);
1130 if (area < 2 * intersect_area) {
1143 static void EliminateWeakParts(
const TBOX& im_box,
1145 ColPartition_LIST* big_parts,
1146 ColPartition_LIST* part_list) {
1151 if (TestWeakIntersectedPart(im_box, part_list, part)) {
1155 DeletePartition(part);
1165 ColPartition_IT big_it(big_parts);
1166 for (big_it.mark_cycle_pt(); !big_it.cycled_list(); big_it.forward()) {
1167 part = big_it.data();
1168 if (TestWeakIntersectedPart(im_box, part_list, part)) {
1170 DeletePartition(big_it.extract());
1181 TBOX padded_box(*box);
1182 padded_box.
pad(kNoisePadding, kNoisePadding);
1185 bool any_text_in_padded_rect =
false;
1190 any_text_in_padded_rect =
true;
1197 if (!any_text_in_padded_rect)
1206 static void MarkAndDeleteImageParts(
const FCOORD& rerotate,
1208 ColPartition_LIST* image_parts,
1210 if (image_pix == NULL)
1212 int imageheight = pixGetHeight(image_pix);
1213 ColPartition_IT part_it(image_parts);
1214 for (; !part_it.empty(); part_it.forward()) {
1218 if (!ScanForOverlappingText(part_grid, &part_box) ||
1222 part_box.
rotate(rerotate);
1223 int left = part_box.
left();
1224 int top = part_box.
top();
1225 pixRasterop(image_pix, left, imageheight - top,
1226 part_box.
width(), part_box.
height(), PIX_SET, NULL, 0, 0);
1228 DeletePartition(part);
1243 ColPartition_LIST parts_list;
1244 ColPartition_IT part_it(&parts_list);
1251 part_it.add_after_then_move(part);
1256 MarkAndDeleteImageParts(rerotation, part_grid, &parts_list, image_mask);
1263 if (part_grid != NULL)
return;
1272 if (part_box.
width() < kMinImageFindSize ||
1276 DeletePartition(part);
1296 ColPartition_LIST* big_parts) {
1297 int imageheight = pixGetHeight(image_pix);
1303 if (boxa !=
nullptr && pixa !=
nullptr) nboxes = boxaGetCount(boxa);
1304 for (
int i = 0; i < nboxes; ++i) {
1305 l_int32 x, y, width, height;
1306 boxaGetBoxGeometry(boxa, i, &x, &y, &width, &height);
1307 Pix* pix = pixaGetPix(pixa, i, L_CLONE);
1308 TBOX im_box(x, imageheight -y - height, x + width, imageheight - y);
1312 ColPartition_LIST part_list;
1313 DivideImageIntoParts(im_box, rotation, rerotation, pix,
1314 &rectsearch, &part_list);
1316 pixa_debug->
AddPix(pix,
"ImageComponent");
1317 tprintf(
"Component has %d parts\n", part_list.length());
1320 if (!part_list.empty()) {
1321 ColPartition_IT part_it(&part_list);
1322 if (part_list.singleton()) {
1327 TBOX text_box(im_box);
1328 MaximalImageBoundingBox(part_grid, &text_box);
1329 while (ExpandImageIntoParts(text_box, &rectsearch, part_grid, &part));
1330 part_it.set_to_list(&part_list);
1331 part_it.add_after_then_move(part);
1334 EliminateWeakParts(im_box, part_grid, big_parts, &part_list);
1336 for (part_it.move_to_first(); !part_it.empty(); part_it.forward()) {
1339 part_grid->
InsertBBox(
true,
true, image_part);
1340 if (!part_it.at_last()) {
1350 DeleteSmallImages(part_grid);
static void ComputeRectangleColors(const TBOX &rect, Pix *pix, int factor, Pix *color_map1, Pix *color_map2, Pix *rms_map, uinT8 *color1, uinT8 *color2)
TBOX intersection(const TBOX &box) const
int textord_tabfind_show_images
bool overlap(const TBOX &box) const
void DisplayBoxes(ScrollView *window)
const double kMaxRectangularFraction
void add(double x, double y)
const int kMinColorDifference
ScrollView * MakeWindow(int x, int y, const char *window_name)
const ICOORD & bleft() const
inT16 x() const
access function
static int CountPixelsInRotatedBox(TBOX box, const TBOX &im_box, const FCOORD &rotation, Pix *pix)
const double kRMSFitScaling
void set_flow(BlobTextFlowType f)
void set_to_given_coords(int x_min, int y_min, int x_max, int y_max)
const int kMinImageFindSize
static ColPartition * FakePartition(const TBOX &box, PolyBlockType block_type, BlobRegionType blob_type, BlobTextFlowType flow)
static double ColorDistanceFromLine(const uinT8 *line1, const uinT8 *line2, const uinT8 *point)
static Pix * FindImages(Pix *pix, DebugPixa *pixa_debug)
void RepositionIterator()
static void FindImagePartitions(Pix *image_pix, const FCOORD &rotation, const FCOORD &rerotation, TO_BLOCK *block, TabFind *tab_grid, DebugPixa *pixa_debug, ColPartitionGrid *part_grid, ColPartition_LIST *big_parts)
void SetUniqueMode(bool mode)
LIST search(LIST list, void *key, int_compare is_equal)
void StartVerticalSearch(int xmin, int xmax, int y)
int y_gap(const TBOX &box) const
static uinT8 ClipToByte(double pixel)
void InsertBBox(bool h_spread, bool v_spread, BBC *bbox)
const TBOX & bounding_box() const
inT16 y() const
access_function
const ICOORD & tright() const
#define INT_VAR(name, val, comment)
double rms(double m, double c) const
void StartSideSearch(int x, int ymin, int ymax)
void pad(int xpad, int ypad)
bool contains(const FCOORD pt) const
static void ConnCompAndRectangularize(Pix *pix, DebugPixa *pixa_debug, Boxa **boxa, Pixa **pixa)
const double kMinRectangularFraction
void add(inT32 value, inT32 count)
BBC * NextVerticalSearch(bool top_to_bottom)
static bool BoundsWithinRect(Pix *pix, int *x_start, int *y_start, int *x_end, int *y_end)
static bool pixNearlyRectangular(Pix *pix, double min_fraction, double max_fraction, double max_skew_gradient, int *x_start, int *y_start, int *x_end, int *y_end)
BBC * NextSideSearch(bool right_to_left)
void AddPartner(bool upper, ColPartition *partner)
static void TransferImagePartsToImageMask(const FCOORD &rerotation, ColPartitionGrid *part_grid, Pix *image_mask)
void RemoveBBox(BBC *bbox)
double ile(double frac) const
void AddPix(const Pix *pix, const char *caption)
void StartRectSearch(const TBOX &rect)
const double kMaxRectangularGradient
static uinT32 ComposeRGB(uinT32 r, uinT32 g, uinT32 b)
static bool BlankImageInBetween(const TBOX &box1, const TBOX &box2, const TBOX &im_box, const FCOORD &rotation, Pix *pix)
void rotate(const FCOORD &vec)
BlobTextFlowType flow() const
BlobRegionType blob_type() const
int x_gap(const TBOX &box) const
void set_blob_type(BlobRegionType t)