133 bool any_done =
false;
135 bool merge_done =
false;
145 if (!box_cb->
Run(part, &box))
148 ColPartition_CLIST merge_candidates;
149 FindMergeCandidates(part, box, debug, &merge_candidates);
151 int overlap_increase;
155 if (neighbour != NULL && overlap_increase <= 0) {
157 tprintf(
"Merging:hoverlap=%d, voverlap=%d, OLI=%d\n",
166 part->
Absorb(neighbour, NULL);
170 }
else if (neighbour != NULL) {
172 tprintf(
"Overlapped when merged with increase %d: ", overlap_increase);
176 tprintf(
"No candidate neighbour returned\n");
178 }
while (merge_done);
191 if (candidate == part)
198 tprintf(
"Examining merge candidate:");
206 tprintf(
"Too far away: h_dist = %d\n", h_dist);
214 tprintf(
"Too far away: v_dist = %d\n", v_dist);
223 tprintf(
"Candidate fails overlap and diacritic tests!\n");
235 static int IncreaseInOverlap(
const ColPartition* merge1,
236 const ColPartition* merge2,
238 ColPartition_CLIST* parts) {
241 ColPartition_C_IT it(parts);
242 TBOX merged_box(merge1->bounding_box());
243 merged_box += merge2->bounding_box();
244 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
245 ColPartition* part = it.data();
246 if (part == merge1 || part == merge2)
248 TBOX part_box = part->bounding_box();
251 if (overlap_area > 0 && !part->OKMergeOverlap(*merge1, *merge2,
252 ok_overlap,
false)) {
253 total_area += overlap_area;
255 overlap_area = part_box.
intersection(merge1->bounding_box()).area();
256 if (overlap_area > 0)
257 total_area -= overlap_area;
259 overlap_area = intersection_box.
area();
260 if (overlap_area > 0) {
261 total_area -= overlap_area;
263 intersection_box &= merge1->bounding_box();
264 overlap_area = intersection_box.
area();
265 if (overlap_area > 0)
266 total_area += overlap_area;
294 static bool TestCompatibleCandidates(
const ColPartition& part,
bool debug,
295 ColPartition_CLIST* candidates) {
296 ColPartition_C_IT it(candidates);
297 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
298 ColPartition* candidate = it.data();
299 if (!candidate->OKDiacriticMerge(part,
false)) {
300 ColPartition_C_IT it2(it);
301 for (it2.mark_cycle_pt(); !it2.cycled_list(); it2.forward()) {
302 ColPartition* candidate2 = it2.data();
303 if (candidate2 != candidate &&
304 !OKMergeCandidate(candidate, candidate2,
false)) {
306 tprintf(
"NC overlap failed:Candidate:");
307 candidate2->bounding_box().print();
308 tprintf(
"fails to be a good merge with:");
309 candidate->bounding_box().print();
323 int total_overlap = 0;
329 ColPartition_CLIST neighbors;
332 ColPartition_C_IT n_it(&neighbors);
333 bool any_part_overlap =
false;
334 for (n_it.mark_cycle_pt(); !n_it.cycled_list(); n_it.forward()) {
335 const TBOX& n_box = n_it.data()->bounding_box();
337 if (overlap > 0 && overlap_grid != NULL) {
338 if (*overlap_grid == NULL) {
341 (*overlap_grid)->InsertBBox(
true,
true, n_it.data()->ShallowCopy());
342 if (!any_part_overlap) {
343 (*overlap_grid)->InsertBBox(
true,
true, part->
ShallowCopy());
346 any_part_overlap =
true;
347 total_overlap += overlap;
350 return total_overlap;
358 ColPartition_CLIST* parts) {
363 if (part != not_this)
364 parts->add_sorted(SortByBoxLeft<ColPartition>,
true, part);
410 const ColPartition* part, ColPartition_CLIST* candidates,
bool debug,
412 int* overlap_increase) {
413 if (overlap_increase != NULL)
414 *overlap_increase = 0;
415 if (candidates->empty())
424 ColPartition_C_IT it(candidates);
427 TBOX full_box(part_box);
428 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
433 ColPartition_CLIST neighbours;
438 tprintf(
"Finding best merge candidate from %d, %d neighbours for box:",
439 candidates->length(), neighbours.length());
447 ColPartition_CLIST non_candidate_neighbours;
448 non_candidate_neighbours.set_subtract(SortByBoxLeft<ColPartition>,
true,
449 &neighbours, candidates);
450 int worst_nc_increase = 0;
453 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
455 if (confirm_cb != NULL && !confirm_cb->
Run(part, candidate)) {
457 tprintf(
"Candidate not confirmed:");
462 int increase = IncreaseInOverlap(part, candidate, ok_overlap, &neighbours);
464 if (best_candidate == NULL || increase < best_increase) {
465 best_candidate = candidate;
466 best_increase = increase;
469 tprintf(
"New best merge candidate has increase %d, area %d, over box:",
470 increase, best_area);
474 }
else if (increase == best_increase) {
476 if (area < best_area) {
478 best_candidate = candidate;
481 increase = IncreaseInOverlap(part, candidate, ok_overlap,
482 &non_candidate_neighbours);
483 if (increase > worst_nc_increase)
484 worst_nc_increase = increase;
486 if (best_increase > 0) {
493 if (worst_nc_increase < best_increase &&
494 TestCompatibleCandidates(*part, debug, candidates)) {
495 best_increase = worst_nc_increase;
498 if (overlap_increase != NULL)
499 *overlap_increase = best_increase;
500 return best_candidate;
506 ColPartition_LIST* part_list) {
519 ColPartition_LIST* big_parts) {
532 int unresolved_overlaps = 0;
536 if (neighbour == part)
550 if (!shrunken.
overlap(neighbour_box) &&
555 RemoveBadBox(excluded, part, big_parts);
560 }
else if (box.
contains(neighbour_box)) {
561 ++unresolved_overlaps;
572 RemoveBadBox(excluded, neighbour, big_parts);
581 if (neighbour_overlap_count <= part_overlap_count ||
585 if (split_blob != NULL) {
594 if (split_blob != NULL) {
601 if (right_part != NULL) {
608 if (unresolved_overlaps > 2 && part->
IsSingleton()) {
611 ColPartition_IT big_it(big_parts);
613 big_it.add_to_end(part);
636 bool any_changed =
false;
642 if (SmoothRegionType(nontext_map, im_box, rotation, debug, part))
652 const FCOORD& rerotation) {
653 if (scaled_color == NULL)
655 Pix* color_map1 = NULL;
656 Pix* color_map2 = NULL;
659 int width = pixGetWidth(scaled_color);
660 int height = pixGetHeight(scaled_color);
661 color_map1 = pixCreate(width, height, 32);
662 color_map2 = pixCreate(width, height, 32);
663 rms_map = pixCreate(width, height, 8);
674 color_map1, color_map2, rms_map,
677 if (color_map1 != NULL) {
678 pixWrite(
"swcolorinput.png", scaled_color, IFF_PNG);
679 pixWrite(
"swcolor1.png", color_map1, IFF_PNG);
680 pixWrite(
"swcolor2.png", color_map2, IFF_PNG);
681 pixWrite(
"swrms.png", rms_map, IFF_PNG);
682 pixDestroy(&color_map1);
683 pixDestroy(&color_map2);
684 pixDestroy(&rms_map);
691 ColPartition_LIST parts;
692 ColPartition_IT part_it(&parts);
698 part_it.add_after_then_move(part);
705 for (part_it.move_to_first(); !part_it.empty(); part_it.forward()) {
706 part = part_it.extract();
719 TO_BLOCK_LIST* to_blocks) {
720 TO_BLOCK_IT to_block_it(to_blocks);
721 BLOCK_IT block_it(blocks);
723 ColPartition_LIST parts;
724 ColPartition_IT part_it(&parts);
730 part_it.add_after_then_move(part);
752 TO_ROW_IT row_it(to_block->
get_rows());
753 row_it.add_after_then_move(row);
757 to_block->
line_size =
static_cast<float>(median_width);
761 to_block->
line_size =
static_cast<float>(median_height);
765 block_it.add_to_end(block);
766 to_block_it.add_to_end(to_block);
779 ColPartition_LIST parts;
780 ColPartition_IT part_it(&parts);
786 part_it.add_after_then_move(part);
794 for (part_it.move_to_first(); !part_it.empty(); part_it.forward()) {
795 part = part_it.extract();
811 if (left_line != NULL && !left_line->
IsLeftTab())
813 if (left_line != NULL && left_line->
IsLeftTab())
816 if (right_line != NULL && !right_line->
IsRightTab())
818 if (right_line != NULL && right_line->
IsRightTab())
827 ColPartition_LIST* part_lists =
new ColPartition_LIST[
gridheight()];
834 bool any_parts_found =
false;
842 ColPartition_IT part_it(&part_lists[grid_y]);
843 part_it.add_to_end(part);
844 any_parts_found =
true;
847 if (any_parts_found) {
848 for (
int grid_y = 0; grid_y <
gridheight(); ++grid_y) {
850 if (!part_lists[grid_y].empty()) {
856 delete [] part_lists;
857 return any_parts_found;
881 if (single_column_part == NULL) {
885 single_column_part->
CopyLeftTab(*single_column_part,
false);
886 single_column_part->
CopyRightTab(*single_column_part,
false);
896 if (single_column_part != NULL) {
920 BLOBNBOX_IT im_blob_it(im_blobs);
921 ColPartition_LIST dead_parts;
922 ColPartition_IT dead_part_it(&dead_parts);
930 bool any_blobs_moved =
false;
932 BLOBNBOX_C_IT blob_it(part->
boxes());
933 for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
935 im_blob_it.add_after_then_move(blob);
939 BLOBNBOX_C_IT blob_it(part->
boxes());
940 for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
948 any_blobs_moved =
true;
957 BLOBNBOX_C_IT blob_it(part->
boxes());
959 dead_part_it.add_to_end(part);
961 for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
965 delete blob->
cblob();
969 }
else if (any_blobs_moved) {
984 ColPartition_LIST saved_parts;
985 ColPartition_IT part_it(&saved_parts);
991 part_it.add_to_end(part);
996 for (part_it.move_to_first(); !part_it.empty(); part_it.forward()) {
997 part = part_it.extract();
1017 ? best_columns[gsearch.
GridY()]
1019 FindPartitionMargins(columns, part);
1022 tprintf(
"Computed margins for part:");
1034 ColPartition_LIST* parts) {
1035 ColPartition_IT part_it(parts);
1036 for (part_it.mark_cycle_pt(); !part_it.cycled_list(); part_it.forward()) {
1039 if (best_columns != NULL) {
1044 columns = best_columns[grid_y];
1046 FindPartitionMargins(columns, part);
1052 ColPartition_LIST dead_parts;
1053 ColPartition_IT dead_it(&dead_parts);
1059 dead_it.add_to_end(part);
1118 for (
int upper = 0; upper < 2; ++upper) {
1122 for (partner_it.mark_cycle_pt(); !partner_it.cycled_list();
1123 partner_it.forward()) {
1129 if (!partner_it.cycled_list())
continue;
1131 for (partner_it.mark_cycle_pt(); !partner_it.cycled_list();
1132 partner_it.forward()) {
1137 tprintf(
"Finding figure captions for image part:");
1139 tprintf(
"Considering partner:");
1140 partner_box.
print();
1142 if (partner_box.
left() >= part_box.
left() &&
1144 int dist = partner_box.
y_gap(part_box);
1145 if (best_caption == NULL || dist < best_dist) {
1147 best_caption = partner;
1153 if (best_caption != NULL) {
1155 tprintf(
"Best caption candidate:");
1156 best_caption->bounding_box().print();
1162 int biggest_gap = 0;
1164 int total_height = 0;
1165 int mean_height = 0;
1168 for (
ColPartition* partner = best_caption; partner != NULL &&
1170 partner = next_partner) {
1171 if (!partner->IsTextType()) {
1172 end_partner = partner;
1178 if (next_partner != NULL) {
1181 if (gap > biggest_gap) {
1183 end_partner = next_partner;
1184 mean_height = total_height / line_count;
1185 }
else if (gap < smallest_gap) {
1196 tprintf(
"Line count=%d, biggest gap %d, smallest%d, mean height %d\n",
1197 line_count, biggest_gap, smallest_gap, mean_height);
1198 if (end_partner != NULL) {
1207 for (
ColPartition* partner = best_caption; partner != NULL &&
1208 partner != end_partner;
1209 partner = next_partner) {
1211 partner->SetBlobTypes();
1213 tprintf(
"Set caption type for partition:");
1214 partner->bounding_box().print();
1251 int height = top - bottom;
1252 int mid_y = (bottom + top) / 2;
1260 if (neighbour == part || neighbour->
type() ==
PT_NOISE)
1264 int neighbour_y = (neighbour_bottom + neighbour_top) / 2;
1265 if (upper != (neighbour_y > mid_y))
1270 if (best_neighbour == NULL)
1271 best_neighbour = neighbour;
1274 int dist = upper ? neighbour_bottom - top : bottom - neighbour_top;
1276 if (dist < best_dist) {
1278 best_neighbour = neighbour;
1284 if (best_neighbour != NULL)
1297 int width = right - left;
1298 int mid_x = (left + right) / 2;
1305 while ((neighbour = hsearch.
NextSideSearch(to_the_left)) != NULL) {
1306 if (neighbour == part || neighbour->
type() ==
PT_NOISE)
1310 int neighbour_x = (neighbour_left + neighbour_right) / 2;
1311 if (to_the_left != (neighbour_x < mid_x))
1317 int dist = to_the_left ? left - neighbour_right : neighbour_left - right;
1319 if (dist < best_dist || best_neighbour == NULL) {
1321 best_neighbour = neighbour;
1329 if (best_neighbour != NULL)
1330 part->
AddPartner(to_the_left, best_neighbour);
1346 get_desperate,
this);
1359 void ColPartitionGrid::FindMergeCandidates(
const ColPartition* part,
1360 const TBOX& search_box,
bool debug,
1361 ColPartition_CLIST* candidates) {
1367 rsearch.SetUniqueMode(
true);
1368 rsearch.StartRectSearch(search_box);
1370 while ((candidate = rsearch.NextRectSearch()) != NULL) {
1371 if (!OKMergeCandidate(part, candidate, debug))
1388 TBOX merged_box(part_box);
1389 merged_box += c_box;
1391 msearch.SetUniqueMode(
true);
1392 msearch.StartRectSearch(merged_box);
1394 while ((neighbour = msearch.NextRectSearch()) != NULL) {
1395 if (neighbour == part || neighbour == candidate)
1397 if (neighbour->
OKMergeOverlap(*part, *candidate, ok_overlap,
false))
1404 !OKMergeCandidate(part, neighbour,
false) &&
1405 !OKMergeCandidate(candidate, neighbour,
false))
1408 if (neighbour != NULL) {
1410 tprintf(
"Combined box overlaps another that is not OK despite" 1411 " allowance of %d:", ok_overlap);
1414 OKMergeCandidate(part, neighbour,
true);
1416 OKMergeCandidate(candidate, neighbour,
true);
1428 candidates->add_sorted(SortByBoxLeft<ColPartition>,
true, candidate);
1443 bool ColPartitionGrid::SmoothRegionType(Pix* nontext_map,
1445 const FCOORD& rerotation,
1447 ColPartition* part) {
1448 const TBOX& part_box = part->bounding_box();
1450 tprintf(
"Smooothing part at:");
1458 bool any_image =
false;
1459 bool all_image =
true;
1463 BlobRegionType type = SmoothInOneDirection(dir, nontext_map, im_box,
1464 rerotation, debug, *part,
1467 tprintf(
"Result in dir %d = %d at dist %d\n", dir, type, dist);
1478 if (best_dist > max_dist)
1485 if (best_type ==
BRT_TEXT && !any_image) {
1495 if (new_type != part->blob_type() || new_flow != part->flow()) {
1496 part->set_flow(new_flow);
1497 part->set_blob_type(new_type);
1498 part->SetBlobTypes();
1513 const TBOX& part_box,
1517 *search_box = part_box;
1521 padding =
MAX(padding, min_padding);
1523 search_box->
pad(padding, padding);
1529 *dist_scaling =
ICOORD(2, 1);
1533 *dist_scaling =
ICOORD(1, 2);
1537 *dist_scaling =
ICOORD(2, 1);
1541 *dist_scaling =
ICOORD(1, 2);
1569 const TBOX& im_box,
const FCOORD& rerotation,
1570 bool debug,
const ColPartition& part,
int* best_distance) {
1572 const TBOX& part_box = part.bounding_box();
1576 &search_box, &dist_scaling);
1581 AccumulatePartDistances(part, dist_scaling, search_box,
1582 nontext_map, im_box, rerotation, debug, dists);
1587 memset(counts, 0,
sizeof(counts[0]) *
NPT_COUNT);
1597 if (counts[i] < dists[i].size() && dists[i][counts[i]] < min_dist)
1598 min_dist = dists[i][counts[i]];
1602 while (counts[i] < dists[i].size() && dists[i][counts[i]] <= min_dist)
1605 *best_distance = min_dist;
1607 tprintf(
"Totals: htext=%d+%d, vtext=%d+%d, image=%d+%d, at dist=%d\n",
1610 counts[
NPT_IMAGE], image_bias, min_dist);
1618 if (image_count > 0 &&
1650 void ColPartitionGrid::AccumulatePartDistances(
const ColPartition& base_part,
1651 const ICOORD& dist_scaling,
1652 const TBOX& search_box,
1655 const FCOORD& rerotation,
1658 const TBOX& part_box = base_part.bounding_box();
1660 rsearch.SetUniqueMode(
true);
1661 rsearch.StartRectSearch(search_box);
1662 ColPartition* neighbour;
1665 while ((neighbour = rsearch.NextRectSearch()) != NULL) {
1666 if (neighbour->IsUnMergeableType() ||
1667 !base_part.ConfirmNoTabViolation(*neighbour) ||
1668 neighbour == &base_part)
1670 TBOX nbox = neighbour->bounding_box();
1678 int x_gap =
MAX(part_box.
x_gap(nbox), 0);
1679 int y_gap =
MAX(part_box.
y_gap(nbox), 0);
1680 int n_dist = x_gap * dist_scaling.
x() + y_gap* dist_scaling.
y();
1682 tprintf(
"Part has x-gap=%d, y=%d, dist=%d at:",
1683 x_gap, y_gap, n_dist);
1705 if (debug)
tprintf(
"Weak %d\n", n_boxes);
1708 if (debug)
tprintf(
"Image %d\n", n_boxes);
1710 if (count_vector != NULL) {
1711 for (
int i = 0; i < n_boxes; ++i)
1726 void ColPartitionGrid::FindPartitionMargins(ColPartitionSet* columns,
1727 ColPartition* part) {
1730 int y = part->MidY();
1732 int left_margin =
bleft().
x();
1733 int right_margin =
tright().
x();
1734 if (columns != NULL) {
1735 ColPartition* column = columns->ColumnContaining(box.
left(), y);
1737 left_margin = column->LeftAtY(y);
1738 column = columns->ColumnContaining(box.
right(), y);
1740 right_margin = column->RightAtY(y);
1745 left_margin = FindMargin(box.
left() + box.
height(),
true, left_margin,
1747 part->set_left_margin(left_margin);
1749 right_margin = FindMargin(box.
right() - box.
height(),
false, right_margin,
1751 part->set_right_margin(right_margin);
1757 int ColPartitionGrid::FindMargin(
int x,
bool right_to_left,
int x_limit,
1758 int y_bottom,
int y_top,
1759 const ColPartition* not_this) {
1760 int height = y_top - y_bottom;
1763 side_search.SetUniqueMode(
true);
1764 side_search.StartSideSearch(x, y_bottom, y_top);
1766 while ((part = side_search.NextSideSearch(right_to_left)) != NULL) {
1768 if (part == not_this)
1772 TBOX box = part->bounding_box();
1773 int min_overlap =
MIN(height, box.
height());
1776 if (y_overlap < min_overlap)
1779 int x_edge = right_to_left ? box.
right() : box.
left();
1780 if ((x_edge < x) != right_to_left)
1783 if ((x_edge < x_limit) == right_to_left)
void SetRightTab(const TabVector *tab_vector)
TBOX bounding_union(const TBOX &box) const
const TBOX & bounding_box() const
static bool IsTextType(BlobRegionType type)
void set_flow(BlobTextFlowType f)
TabVector * LeftTabForBox(const TBOX &box, bool crossing, bool extended)
bool VOverlaps(const ColPartition &other) const
const int kMaxCaptionLines
static bool IsLineType(BlobRegionType type)
bool textord_tabfind_show_color_fit
bool overlap(const TBOX &box) const
void CopyRightTab(const ColPartition &src, bool take_box)
void FindFigureCaptions()
const int kSmoothDecisionMargin
TBOX BoundsWithoutBox(BLOBNBOX *box)
bool IsVerticalType() const
const ICOORD & tright() const
const ICOORD & topright() const
bool ReleaseNonLeaderBoxes()
bool WithinSameMargins(const ColPartition &other) const
GridSearch< ColPartition, ColPartition_CLIST, ColPartition_C_IT > ColPartitionGridSearch
static bool BlankImageInBetween(const TBOX &box1, const TBOX &box2, const TBOX &im_box, const FCOORD &rotation, Pix *pix)
static bool WithinTestRegion(int detail_level, int x, int y)
static int CountPixelsInRotatedBox(TBOX box, const TBOX &im_box, const FCOORD &rotation, Pix *pix)
void RecomputeBounds(int gridsize, const ICOORD &bleft, const ICOORD &tright, const ICOORD &vertical)
void set_block_owned(bool owned)
PolyBlockType type() const
const int kMaxNeighbourDistFactor
void Merges(TessResultCallback2< bool, ColPartition *, TBOX *> *box_cb, TessResultCallback2< bool, const ColPartition *, const ColPartition *> *confirm_cb)
BBC * NextVerticalSearch(bool top_to_bottom)
void SetTabStops(TabFind *tabgrid)
void FindOverlappingPartitions(const TBOX &box, const ColPartition *not_this, ColPartition_CLIST *parts)
void SetUniqueMode(bool mode)
void GridFindMargins(ColPartitionSet **best_columns)
void DeleteNonLeaderParts()
void StartVerticalSearch(int xmin, int xmax, int y)
const double kMaxPartitionSpacing
BlobTextFlowType flow() const
TabVector * RightTabForBox(const TBOX &box, bool crossing, bool extended)
bool IsUnMergeableType() const
void set_flow(BlobTextFlowType value)
const int kColumnWidthFactor
void FindVPartitionPartners(bool to_the_left, ColPartition *part)
void SetColumnGoodness(WidthCallback *cb)
ColPartitionSet * MakeSingleColumnSet(WidthCallback *cb)
bool MakeColPartSets(PartSetVector *part_sets)
ColPartition * BestMergeCandidate(const ColPartition *part, ColPartition_CLIST *candidates, bool debug, TessResultCallback2< bool, const ColPartition *, const ColPartition *> *confirm_cb, int *overlap_increase)
void DeleteUnownedNoise()
void Absorb(ColPartition *other, WidthCallback *cb)
void HandleClick(int x, int y)
int y_gap(const TBOX &box) const
void DeleteUnknownParts(TO_BLOCK *block)
const double kBigPartSizeRatio
void set_poly_block(POLY_BLOCK *blk)
set the poly block
void RemoveBBox(ColPartition *bbox)
void StartSideSearch(int x, int ymin, int ymax)
bool contains(const FCOORD pt) const
void StartRadSearch(int x, int y, int max_radius)
const double kMarginOverlapFraction
inT16 x() const
access function
void ComputePartitionColors(Pix *scaled_color, int scaled_factor, const FCOORD &rerotation)
const double kMinCaptionGapRatio
BBC * NextSideSearch(bool right_to_left)
ColPartition * SingletonPartner(bool upper)
void CopyLeftTab(const ColPartition &src, bool take_box)
int HCoreOverlap(const ColPartition &other) const
void SetLeftTab(const TabVector *tab_vector)
void Deskew(const FCOORD &deskew)
bool VSignificantCoreOverlap(const ColPartition &other) const
void ListFindMargins(ColPartitionSet **best_columns, ColPartition_LIST *parts)
int median_bottom() const
int x_gap(const TBOX &box) const
int direction(EDGEPT *point)
void ReTypeBlobs(BLOBNBOX_LIST *im_blobs)
int VCoreOverlap(const ColPartition &other) const
static void ComputeRectangleColors(const TBOX &rect, Pix *pix, int factor, Pix *color_map1, Pix *color_map2, Pix *rms_map, uinT8 *color1, uinT8 *color2)
ColPartition * ShallowCopy() const
const double kMinCaptionGapHeightRatio
static ColPartition * MakeBigPartition(BLOBNBOX *box, ColPartition_LIST *big_part_list)
bool OKDiacriticMerge(const ColPartition &candidate, bool debug) const
void GridCoords(int x, int y, int *grid_x, int *grid_y) const
void SplitOverlappingPartitions(ColPartition_LIST *big_parts)
bool HOverlaps(const ColPartition &other) const
void rotate_large(const FCOORD &vec)
void RefinePartners(PolyBlockType type, bool get_desperate, ColPartitionGrid *grid)
void pad(int xpad, int ypad)
void InsertBBox(bool h_spread, bool v_spread, ColPartition *bbox)
ColPartition_CLIST * lower_partners()
const ICOORD & bleft() const
ColPartition_CLIST * upper_partners()
void AddPartner(bool upper, ColPartition *partner)
int ComputeTotalOverlap(ColPartitionGrid **overlap_grid)
void set_vertical(const ICOORD &v)
void RemoveBox(BLOBNBOX *box)
WidthCallback * WidthCB()
bool GridSmoothNeighbours(BlobTextFlowType source_type, Pix *nontext_map, const TBOX &im_box, const FCOORD &rerotation)
int CountOverlappingBoxes(const TBOX &box)
void set_region_type(BlobRegionType new_type)
BlobTextFlowType flow() const
TBOX intersection(const TBOX &box) const
ColPartition * SplitAtBlob(BLOBNBOX *split_blob)
void set_owner(tesseract::ColPartition *new_owner)
void RefinePartitionPartners(bool get_desperate)
bool TypesMatch(const ColPartition &other) const
void set_blob_type(BlobRegionType t)
const TBOX & bounding_box() const
void StartRectSearch(const TBOX &rect)
bool MergePart(TessResultCallback2< bool, ColPartition *, TBOX *> *box_cb, TessResultCallback2< bool, const ColPartition *, const ColPartition *> *confirm_cb, ColPartition *part)
BlobRegionType region_type() const
#define BOOL_VAR(name, val, comment)
BlobRegionType blob_type() const
void Init(int gridsize, const ICOORD &bleft, const ICOORD &tright)
void set_type(PolyBlockType t)
BLOBNBOX * OverlapSplitBlob(const TBOX &box)
void RepositionIterator()
void ExtractPartitionsAsBlocks(BLOCK_LIST *blocks, TO_BLOCK_LIST *to_blocks)
const ICOORD & botleft() const
virtual ~ColPartitionGrid()
const double kTinyEnoughTextlineOverlapFraction
bool OKMergeOverlap(const ColPartition &merge1, const ColPartition &merge2, int ok_box_overlap, bool debug)
void FindPartitionPartners()
inT16 y() const
access_function