20 #include "config_auto.h" 31 static BOOL_VAR(textord_tabfind_show_color_fit,
false,
"Show stroke widths");
82 ColPartition* neighbour;
129 bool any_done =
false;
131 bool merge_done =
false;
141 if (!box_cb->
Run(part, &box))
144 ColPartition_CLIST merge_candidates;
145 FindMergeCandidates(part, box, debug, &merge_candidates);
147 int overlap_increase;
151 if (neighbour !=
nullptr && overlap_increase <= 0) {
153 tprintf(
"Merging:hoverlap=%d, voverlap=%d, OLI=%d\n",
162 part->
Absorb(neighbour,
nullptr);
166 }
else if (neighbour !=
nullptr) {
168 tprintf(
"Overlapped when merged with increase %d: ", overlap_increase);
172 tprintf(
"No candidate neighbour returned\n");
174 }
while (merge_done);
187 if (candidate == part)
194 tprintf(
"Examining merge candidate:");
200 if (h_dist >= std::max(part_box.
width(), c_box.
width()) / 2) {
202 tprintf(
"Too far away: h_dist = %d\n", h_dist);
208 if (v_dist >= std::max(part_box.
height(), c_box.
height()) / 2) {
210 tprintf(
"Too far away: v_dist = %d\n", v_dist);
219 tprintf(
"Candidate fails overlap and diacritic tests!\n");
231 static int IncreaseInOverlap(
const ColPartition* merge1,
234 ColPartition_CLIST* parts) {
235 ASSERT_HOST(merge1 !=
nullptr && merge2 !=
nullptr);
237 ColPartition_C_IT it(parts);
240 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
242 if (part == merge1 || part == merge2)
248 ok_overlap,
false)) {
249 total_area += overlap_area;
252 if (overlap_area > 0)
253 total_area -= overlap_area;
255 overlap_area = intersection_box.
area();
256 if (overlap_area > 0) {
257 total_area -= overlap_area;
260 overlap_area = intersection_box.
area();
261 if (overlap_area > 0)
262 total_area += overlap_area;
290 static bool TestCompatibleCandidates(
const ColPartition& part,
bool debug,
291 ColPartition_CLIST* candidates) {
292 ColPartition_C_IT it(candidates);
293 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
296 ColPartition_C_IT it2(it);
297 for (it2.mark_cycle_pt(); !it2.cycled_list(); it2.forward()) {
299 if (candidate2 != candidate &&
300 !OKMergeCandidate(candidate, candidate2,
false)) {
302 tprintf(
"NC overlap failed:Candidate:");
304 tprintf(
"fails to be a good merge with:");
319 int total_overlap = 0;
325 ColPartition_CLIST neighbors;
328 ColPartition_C_IT n_it(&neighbors);
329 bool any_part_overlap =
false;
330 for (n_it.mark_cycle_pt(); !n_it.cycled_list(); n_it.forward()) {
331 const TBOX& n_box = n_it.data()->bounding_box();
333 if (overlap > 0 && overlap_grid !=
nullptr) {
334 if (*overlap_grid ==
nullptr) {
337 (*overlap_grid)->InsertBBox(
true,
true, n_it.data()->ShallowCopy());
338 if (!any_part_overlap) {
339 (*overlap_grid)->InsertBBox(
true,
true, part->
ShallowCopy());
342 any_part_overlap =
true;
343 total_overlap += overlap;
346 return total_overlap;
354 ColPartition_CLIST* parts) {
359 if (part != not_this)
360 parts->add_sorted(SortByBoxLeft<ColPartition>,
true, part);
406 const ColPartition* part, ColPartition_CLIST* candidates,
bool debug,
408 int* overlap_increase) {
409 if (overlap_increase !=
nullptr)
410 *overlap_increase = 0;
411 if (candidates->empty())
414 static_cast<int>(kTinyEnoughTextlineOverlapFraction *
gridsize() + 0.5);
420 ColPartition_C_IT it(candidates);
423 TBOX full_box(part_box);
424 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
429 ColPartition_CLIST neighbours;
434 tprintf(
"Finding best merge candidate from %d, %d neighbours for box:",
435 candidates->length(), neighbours.length());
443 ColPartition_CLIST non_candidate_neighbours;
444 non_candidate_neighbours.set_subtract(SortByBoxLeft<ColPartition>,
true,
445 &neighbours, candidates);
446 int worst_nc_increase = 0;
447 int best_increase = INT32_MAX;
449 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
451 if (confirm_cb !=
nullptr && !confirm_cb->
Run(part, candidate)) {
453 tprintf(
"Candidate not confirmed:");
458 int increase = IncreaseInOverlap(part, candidate, ok_overlap, &neighbours);
460 if (best_candidate ==
nullptr || increase < best_increase) {
461 best_candidate = candidate;
462 best_increase = increase;
465 tprintf(
"New best merge candidate has increase %d, area %d, over box:",
466 increase, best_area);
470 }
else if (increase == best_increase) {
472 if (area < best_area) {
474 best_candidate = candidate;
477 increase = IncreaseInOverlap(part, candidate, ok_overlap,
478 &non_candidate_neighbours);
479 if (increase > worst_nc_increase)
480 worst_nc_increase = increase;
482 if (best_increase > 0) {
489 if (worst_nc_increase < best_increase &&
490 TestCompatibleCandidates(*part, debug, candidates)) {
491 best_increase = worst_nc_increase;
494 if (overlap_increase !=
nullptr)
495 *overlap_increase = best_increase;
496 return best_candidate;
502 ColPartition_LIST* part_list) {
515 ColPartition_LIST* big_parts) {
517 static_cast<int>(kTinyEnoughTextlineOverlapFraction *
gridsize() + 0.5);
528 int unresolved_overlaps = 0;
532 if (neighbour == part)
546 if (!shrunken.
overlap(neighbour_box) &&
548 kBigPartSizeRatio * shrunken.
height()) {
551 RemoveBadBox(excluded, part, big_parts);
556 }
else if (box.
contains(neighbour_box)) {
557 ++unresolved_overlaps;
565 kBigPartSizeRatio * shrunken.
height()) {
568 RemoveBadBox(excluded, neighbour, big_parts);
577 if (neighbour_overlap_count <= part_overlap_count ||
581 if (split_blob !=
nullptr) {
590 if (split_blob !=
nullptr) {
597 if (right_part !=
nullptr) {
604 if (unresolved_overlaps > 2 && part->
IsSingleton()) {
607 ColPartition_IT big_it(big_parts);
609 big_it.add_to_end(part);
632 bool any_changed =
false;
638 if (SmoothRegionType(nontext_map, im_box, rotation, debug, part))
647 ColPartition_LIST parts;
648 ColPartition_IT part_it(&parts);
654 part_it.add_after_then_move(part);
661 for (part_it.move_to_first(); !part_it.empty(); part_it.forward()) {
662 part = part_it.extract();
675 TO_BLOCK_LIST* to_blocks) {
676 TO_BLOCK_IT to_block_it(to_blocks);
677 BLOCK_IT block_it(blocks);
679 ColPartition_LIST parts;
680 ColPartition_IT part_it(&parts);
686 part_it.add_after_then_move(part);
699 if (row ==
nullptr) {
707 auto* to_block =
new TO_BLOCK(block);
708 TO_ROW_IT row_it(to_block->get_rows());
709 row_it.add_after_then_move(row);
713 to_block->line_size =
static_cast<float>(median_width);
714 to_block->line_spacing =
static_cast<float>(box.
width());
715 to_block->max_blob_size =
static_cast<float>(box.
width() + 1);
717 to_block->line_size =
static_cast<float>(median_height);
718 to_block->line_spacing =
static_cast<float>(box.
height());
719 to_block->max_blob_size =
static_cast<float>(box.
height() + 1);
721 if (to_block->line_size == 0) to_block->line_size = 1;
722 block_it.add_to_end(block);
723 to_block_it.add_to_end(to_block);
736 ColPartition_LIST parts;
737 ColPartition_IT part_it(&parts);
743 part_it.add_after_then_move(part);
751 for (part_it.move_to_first(); !part_it.empty(); part_it.forward()) {
752 part = part_it.extract();
768 if (left_line !=
nullptr && !left_line->
IsLeftTab())
770 if (left_line !=
nullptr && left_line->
IsLeftTab())
773 if (right_line !=
nullptr && !right_line->
IsRightTab())
775 if (right_line !=
nullptr && right_line->
IsRightTab())
784 auto* part_lists =
new ColPartition_LIST[
gridheight()];
791 bool any_parts_found =
false;
799 ColPartition_IT part_it(&part_lists[grid_y]);
800 part_it.add_to_end(part);
801 any_parts_found =
true;
804 if (any_parts_found) {
805 for (
int grid_y = 0; grid_y <
gridheight(); ++grid_y) {
807 if (!part_lists[grid_y].empty()) {
813 delete [] part_lists;
814 return any_parts_found;
838 if (single_column_part ==
nullptr) {
842 single_column_part->
CopyLeftTab(*single_column_part,
false);
843 single_column_part->
CopyRightTab(*single_column_part,
false);
853 if (single_column_part !=
nullptr) {
877 BLOBNBOX_IT im_blob_it(im_blobs);
878 ColPartition_LIST dead_parts;
879 ColPartition_IT dead_part_it(&dead_parts);
887 bool any_blobs_moved =
false;
889 BLOBNBOX_C_IT blob_it(part->
boxes());
890 for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
892 im_blob_it.add_after_then_move(blob);
896 BLOBNBOX_C_IT blob_it(part->
boxes());
897 for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
905 any_blobs_moved =
true;
914 BLOBNBOX_C_IT blob_it(part->
boxes());
916 dead_part_it.add_to_end(part);
918 for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
922 delete blob->
cblob();
926 }
else if (any_blobs_moved) {
941 ColPartition_LIST saved_parts;
942 ColPartition_IT part_it(&saved_parts);
948 part_it.add_to_end(part);
951 Init(gridsize, bleft, tright);
953 for (part_it.move_to_first(); !part_it.empty(); part_it.forward()) {
954 part = part_it.extract();
974 ? best_columns[gsearch.
GridY()]
976 FindPartitionMargins(columns, part);
979 tprintf(
"Computed margins for part:");
991 ColPartition_LIST* parts) {
992 ColPartition_IT part_it(parts);
993 for (part_it.mark_cycle_pt(); !part_it.cycled_list(); part_it.forward()) {
996 if (best_columns !=
nullptr) {
1001 columns = best_columns[grid_y];
1003 FindPartitionMargins(columns, part);
1009 ColPartition_LIST dead_parts;
1010 ColPartition_IT dead_it(&dead_parts);
1016 dead_it.add_to_end(part);
1075 for (
int upper = 0; upper < 2; ++upper) {
1079 for (partner_it.mark_cycle_pt(); !partner_it.cycled_list();
1080 partner_it.forward()) {
1086 if (!partner_it.cycled_list())
continue;
1088 for (partner_it.mark_cycle_pt(); !partner_it.cycled_list();
1089 partner_it.forward()) {
1094 tprintf(
"Finding figure captions for image part:");
1096 tprintf(
"Considering partner:");
1097 partner_box.
print();
1099 if (partner_box.
left() >= part_box.
left() &&
1101 int dist = partner_box.
y_gap(part_box);
1102 if (best_caption ==
nullptr || dist < best_dist) {
1104 best_caption = partner;
1110 if (best_caption !=
nullptr) {
1112 tprintf(
"Best caption candidate:");
1113 best_caption->bounding_box().print();
1119 int biggest_gap = 0;
1120 int smallest_gap = INT16_MAX;
1121 int total_height = 0;
1122 int mean_height = 0;
1125 for (
ColPartition* partner = best_caption; partner !=
nullptr &&
1127 partner = next_partner) {
1128 if (!partner->IsTextType()) {
1129 end_partner = partner;
1135 if (next_partner !=
nullptr) {
1138 if (gap > biggest_gap) {
1140 end_partner = next_partner;
1141 mean_height = total_height / line_count;
1142 }
else if (gap < smallest_gap) {
1147 if (biggest_gap > mean_height * kMinCaptionGapHeightRatio &&
1148 biggest_gap > smallest_gap * kMinCaptionGapRatio)
1153 tprintf(
"Line count=%d, biggest gap %d, smallest%d, mean height %d\n",
1154 line_count, biggest_gap, smallest_gap, mean_height);
1155 if (end_partner !=
nullptr) {
1160 if (next_partner ==
nullptr && line_count <= kMaxCaptionLines)
1161 end_partner =
nullptr;
1162 if (line_count <= kMaxCaptionLines) {
1164 for (
ColPartition* partner = best_caption; partner !=
nullptr &&
1165 partner != end_partner;
1166 partner = next_partner) {
1168 partner->SetBlobTypes();
1170 tprintf(
"Set caption type for partition:");
1171 partner->bounding_box().print();
1208 int height = top - bottom;
1209 int mid_y = (bottom + top) / 2;
1215 int best_dist = INT32_MAX;
1217 if (neighbour == part || neighbour->
type() ==
PT_NOISE)
1221 int neighbour_y = (neighbour_bottom + neighbour_top) / 2;
1222 if (upper != (neighbour_y > mid_y))
1227 if (best_neighbour ==
nullptr)
1228 best_neighbour = neighbour;
1231 int dist = upper ? neighbour_bottom - top : bottom - neighbour_top;
1232 if (dist <= kMaxPartitionSpacing * height) {
1233 if (dist < best_dist) {
1235 best_neighbour = neighbour;
1241 if (best_neighbour !=
nullptr)
1254 int width = right >= left ? right - left : -1;
1255 int mid_x = (left + right) / 2;
1261 int best_dist = INT32_MAX;
1262 while ((neighbour = hsearch.
NextSideSearch(to_the_left)) !=
nullptr) {
1263 if (neighbour == part || neighbour->
type() ==
PT_NOISE)
1267 int neighbour_x = (neighbour_left + neighbour_right) / 2;
1268 if (to_the_left != (neighbour_x < mid_x))
1274 int dist = to_the_left ? left - neighbour_right : neighbour_left - right;
1275 if (dist <= kMaxPartitionSpacing * width) {
1276 if (dist < best_dist || best_neighbour ==
nullptr) {
1278 best_neighbour = neighbour;
1286 if (best_neighbour !=
nullptr)
1287 part->
AddPartner(to_the_left, best_neighbour);
1303 get_desperate,
this);
1316 void ColPartitionGrid::FindMergeCandidates(
const ColPartition* part,
1317 const TBOX& search_box,
bool debug,
1318 ColPartition_CLIST* candidates) {
1320 static_cast<int>(kTinyEnoughTextlineOverlapFraction *
gridsize() + 0.5);
1328 if (!OKMergeCandidate(part, candidate, debug))
1345 TBOX merged_box(part_box);
1346 merged_box += c_box;
1352 if (neighbour == part || neighbour == candidate)
1354 if (neighbour->
OKMergeOverlap(*part, *candidate, ok_overlap,
false))
1361 !OKMergeCandidate(part, neighbour,
false) &&
1362 !OKMergeCandidate(candidate, neighbour,
false))
1365 if (neighbour !=
nullptr) {
1367 tprintf(
"Combined box overlaps another that is not OK despite" 1368 " allowance of %d:", ok_overlap);
1371 OKMergeCandidate(part, neighbour,
true);
1373 OKMergeCandidate(candidate, neighbour,
true);
1385 candidates->add_sorted(SortByBoxLeft<ColPartition>,
true, candidate);
1400 bool ColPartitionGrid::SmoothRegionType(Pix* nontext_map,
1402 const FCOORD& rerotation,
1407 tprintf(
"Smooothing part at:");
1411 int best_dist = INT32_MAX;
1412 int max_dist = std::min(part_box.
width(), part_box.
height());
1413 max_dist = std::max(max_dist * kMaxNeighbourDistFactor,
gridsize() * 2);
1415 bool any_image =
false;
1416 bool all_image =
true;
1421 rerotation, debug, *part,
1424 tprintf(
"Result in dir %d = %d at dist %d\n", dir, type, dist);
1435 if (best_dist > max_dist)
1442 if (best_type ==
BRT_TEXT && !any_image) {
1452 if (new_type != part->
blob_type() || new_flow != part->
flow()) {
1470 const TBOX& part_box,
1474 *search_box = part_box;
1477 int padding = std::min(part_box.
height(), part_box.
width());
1478 padding = std::max(padding, min_padding);
1480 search_box->
pad(padding, padding);
1483 switch (direction) {
1486 *dist_scaling =
ICOORD(2, 1);
1490 *dist_scaling =
ICOORD(1, 2);
1494 *dist_scaling =
ICOORD(2, 1);
1498 *dist_scaling =
ICOORD(1, 2);
1526 const TBOX& im_box,
const FCOORD& rerotation,
1527 bool debug,
const ColPartition& part,
int* best_distance) {
1532 ComputeSearchBoxAndScaling(direction, part_box,
gridsize(),
1533 &search_box, &dist_scaling);
1538 AccumulatePartDistances(part, dist_scaling, search_box,
1539 nontext_map, im_box, rerotation, debug, dists);
1544 memset(counts, 0,
sizeof(counts[0]) *
NPT_COUNT);
1546 int image_bias = image_region ? kSmoothDecisionMargin / 2 : 0;
1552 min_dist = INT32_MAX;
1554 if (counts[i] < dists[i].size() && dists[i][counts[i]] < min_dist)
1555 min_dist = dists[i][counts[i]];
1559 while (counts[i] < dists[i].size() && dists[i][counts[i]] <= min_dist)
1562 *best_distance = min_dist;
1564 tprintf(
"Totals: htext=%d+%d, vtext=%d+%d, image=%d+%d, at dist=%d\n",
1567 counts[
NPT_IMAGE], image_bias, min_dist);
1575 if (image_count > 0 &&
1576 image_bias - htext_score >= kSmoothDecisionMargin &&
1577 image_bias - vtext_score >= kSmoothDecisionMargin) {
1596 }
while (min_dist < INT32_MAX);
1607 void ColPartitionGrid::AccumulatePartDistances(
const ColPartition& base_part,
1608 const ICOORD& dist_scaling,
1609 const TBOX& search_box,
1612 const FCOORD& rerotation,
1625 neighbour == &base_part)
1635 int x_gap = std::max(part_box.
x_gap(nbox), 0);
1636 int y_gap = std::max(part_box.
y_gap(nbox), 0);
1637 int n_dist = x_gap * dist_scaling.
x() + y_gap* dist_scaling.
y();
1639 tprintf(
"Part has x-gap=%d, y=%d, dist=%d at:",
1640 x_gap, y_gap, n_dist);
1662 if (debug)
tprintf(
"Weak %d\n", n_boxes);
1665 if (debug)
tprintf(
"Image %d\n", n_boxes);
1667 if (count_vector !=
nullptr) {
1668 for (
int i = 0; i < n_boxes; ++i)
1687 int y = part->
MidY();
1689 int left_margin =
bleft().
x();
1690 int right_margin =
tright().
x();
1691 if (columns !=
nullptr) {
1693 if (column !=
nullptr)
1694 left_margin = column->
LeftAtY(y);
1696 if (column !=
nullptr)
1697 right_margin = column->
RightAtY(y);
1702 left_margin = FindMargin(box.
left() + box.
height(),
true, left_margin,
1706 right_margin = FindMargin(box.
right() - box.
height(),
false, right_margin,
1714 int ColPartitionGrid::FindMargin(
int x,
bool right_to_left,
int x_limit,
1715 int y_bottom,
int y_top,
1717 int height = y_top - y_bottom;
1723 while ((part = side_search.
NextSideSearch(right_to_left)) !=
nullptr) {
1725 if (part == not_this)
1730 int min_overlap = std::min(height, static_cast<int>(box.
height()));
1731 min_overlap =
static_cast<int>(min_overlap * kMarginOverlapFraction + 0.5);
1732 int y_overlap = std::min(y_top, static_cast<int>(box.
top())) - std::max(y_bottom, static_cast<int>(box.
bottom()));
1733 if (y_overlap < min_overlap)
1736 int x_edge = right_to_left ? box.
right() : box.
left();
1737 if ((x_edge < x) != right_to_left)
1740 if ((x_edge < x_limit) == right_to_left)
void CopyRightTab(const ColPartition &src, bool take_box)
void ReTypeBlobs(BLOBNBOX_LIST *im_blobs)
bool IsVerticalType() const
const ICOORD & bleft() const
int median_height() const
void StartSideSearch(int x, int ymin, int ymax)
void DeleteNonLeaderParts()
void GridFindMargins(ColPartitionSet **best_columns)
void StartRadSearch(int x, int y, int max_radius)
void SetTabStops(TabFind *tabgrid)
ColPartition_CLIST * upper_partners()
void StartRectSearch(const TBOX &rect)
void ExtractPartitionsAsBlocks(BLOCK_LIST *blocks, TO_BLOCK_LIST *to_blocks)
const double kMaxPartitionSpacing
void DeleteUnownedNoise()
void set_type(PolyBlockType t)
void RecomputeBounds(int gridsize, const ICOORD &bleft, const ICOORD &tright, const ICOORD &vertical)
bool ReleaseNonLeaderBoxes()
ColPartition * SplitAtBlob(BLOBNBOX *split_blob)
BBC * NextSideSearch(bool right_to_left)
void SplitOverlappingPartitions(ColPartition_LIST *big_parts)
bool ConfirmNoTabViolation(const ColPartition &other) const
void SetLeftTab(const TabVector *tab_vector)
TabVector * LeftTabForBox(const TBOX &box, bool crossing, bool extended)
const ICOORD & tright() const
ColPartitionGrid()=default
const int kColumnWidthFactor
bool IsUnMergeableType() const
int ComputeTotalOverlap(ColPartitionGrid **overlap_grid)
TBOX bounding_union(const TBOX &box) const
void set_block_owned(bool owned)
void FindVPartitionPartners(bool to_the_left, ColPartition *part)
void FindPartitionPartners()
int HCoreOverlap(const ColPartition &other) const
const TBOX & bounding_box() const
bool contains(const FCOORD pt) const
int16_t y() const
access_function
TBOX intersection(const TBOX &box) const
BlobRegionType blob_type() const
BlobTextFlowType flow() const
const int kSmoothDecisionMargin
void AddPartner(bool upper, ColPartition *partner)
void rotate_large(const FCOORD &vec)
const double kBigPartSizeRatio
void FindOverlappingPartitions(const TBOX &box, const ColPartition *not_this, ColPartition_CLIST *parts)
static bool IsLineType(BlobRegionType type)
const ICOORD & botleft() const
const double kMarginOverlapFraction
void set_right_margin(int margin)
const int kMaxCaptionLines
void DeleteUnknownParts(TO_BLOCK *block)
int median_bottom() const
int x_gap(const TBOX &box) const
void set_vertical(const ICOORD &v)
const double kTinyEnoughTextlineOverlapFraction
void SetUniqueMode(bool mode)
bool OKDiacriticMerge(const ColPartition &candidate, bool debug) const
PolyBlockType type() const
bool MergePart(TessResultCallback2< bool, ColPartition *, TBOX * > *box_cb, TessResultCallback2< bool, const ColPartition *, const ColPartition * > *confirm_cb, ColPartition *part)
TBOX BoundsWithoutBox(BLOBNBOX *box)
const TBOX & bounding_box() const
void RepositionIterator()
void HandleClick(int x, int y) override
static bool BlankImageInBetween(const TBOX &box1, const TBOX &box2, const TBOX &im_box, const FCOORD &rotation, Pix *pix)
bool OKMergeOverlap(const ColPartition &merge1, const ColPartition &merge2, int ok_box_overlap, bool debug)
const ICOORD & topright() const
bool TypesMatch(const ColPartition &other) const
BBC * NextVerticalSearch(bool top_to_bottom)
void set_owner(tesseract::ColPartition *new_owner)
ColPartition * ShallowCopy() const
void SetRightTab(const TabVector *tab_vector)
int16_t x() const
access function
DLLSYM void tprintf(const char *format,...)
static ColPartition * MakeBigPartition(BLOBNBOX *box, ColPartition_LIST *big_part_list)
bool overlap(const TBOX &box) const
ColPartition_CLIST * lower_partners()
int VCoreOverlap(const ColPartition &other) const
int direction(EDGEPT *point)
ColPartition * BestMergeCandidate(const ColPartition *part, ColPartition_CLIST *candidates, bool debug, TessResultCallback2< bool, const ColPartition *, const ColPartition * > *confirm_cb, int *overlap_increase)
PDBLK pdblk
Page Description Block.
void FindFigureCaptions()
void GridCoords(int x, int y, int *grid_x, int *grid_y) const
int y_gap(const TBOX &box) const
bool HOverlaps(const ColPartition &other) const
bool VSignificantCoreOverlap(const ColPartition &other) const
ColPartitionSet * MakeSingleColumnSet(WidthCallback *cb)
void set_flow(BlobTextFlowType f)
void RefinePartners(PolyBlockType type, bool get_desperate, ColPartitionGrid *grid)
BlobRegionType region_type() const
static bool IsTextType(BlobRegionType type)
void StartVerticalSearch(int xmin, int xmax, int y)
void Init(int gridsize, const ICOORD &bleft, const ICOORD &tright)
BlobTextFlowType flow() const
void InsertBBox(bool h_spread, bool v_spread, ColPartition *bbox)
void set_region_type(BlobRegionType new_type)
ColPartition * SingletonPartner(bool upper)
void Merges(TessResultCallback2< bool, ColPartition *, TBOX * > *box_cb, TessResultCallback2< bool, const ColPartition *, const ColPartition * > *confirm_cb)
void ListFindMargins(ColPartitionSet **best_columns, ColPartition_LIST *parts)
void set_flow(BlobTextFlowType value)
void RemoveBBox(ColPartition *bbox)
void RemoveBox(BLOBNBOX *box)
ColPartition * ColumnContaining(int x, int y)
static int CountPixelsInRotatedBox(TBOX box, const TBOX &im_box, const FCOORD &rotation, Pix *pix)
#define BOOL_VAR(name, val, comment)
BLOBNBOX * OverlapSplitBlob(const TBOX &box)
void CopyLeftTab(const ColPartition &src, bool take_box)
void set_poly_block(POLY_BLOCK *blk)
set the poly block
bool WithinSameMargins(const ColPartition &other) const
bool GridSmoothNeighbours(BlobTextFlowType source_type, Pix *nontext_map, const TBOX &im_box, const FCOORD &rerotation)
void SetColumnGoodness(WidthCallback *cb)
TabVector * RightTabForBox(const TBOX &box, bool crossing, bool extended)
const double kMinCaptionGapRatio
void Deskew(const FCOORD &deskew)
void RefinePartitionPartners(bool get_desperate)
int CountOverlappingBoxes(const TBOX &box)
void set_left_margin(int margin)
static bool WithinTestRegion(int detail_level, int x, int y)
void Absorb(ColPartition *other, WidthCallback *cb)
void pad(int xpad, int ypad)
WidthCallback * WidthCB()
const double kMinCaptionGapHeightRatio
int RightAtY(int y) const
void set_blob_type(BlobRegionType t)
bool MakeColPartSets(PartSetVector *part_sets)
bool VOverlaps(const ColPartition &other) const
const int kMaxNeighbourDistFactor