35 #include "scrollview.h" 88 enum BlobNeighbourDir {
97 enum BlobSpecialTextType {
107 inline BlobNeighbourDir DirOtherWay(BlobNeighbourDir dir) {
108 return static_cast<BlobNeighbourDir
>(dir ^ 2);
115 enum BlobTextFlowType {
130 inline bool DominatesInMerge(BlobTextFlowType type1, BlobTextFlowType type2) {
132 if (type1 == BTFT_LEADER)
return false;
133 if (type2 == BTFT_LEADER)
return true;
135 return type1 >= type2;
154 area =
static_cast<int>(srcblob->
area());
188 BLOBNBOX_IT *start_it,
189 BLOBNBOX_IT *blob_it,
195 int* v_min,
int* v_max)
const;
219 double fractional_tolerance,
220 double constant_tolerance)
const;
296 BlobTextFlowType
flow()
const {
420 return type == BRT_TEXT || type == BRT_VERT_TEXT;
424 return type == BRT_RECTIMAGE || type == BRT_POLYIMAGE;
428 return type == BRT_HLINE || type == BRT_VLINE;
441 BLOBNBOX_LIST* blobs);
443 #ifndef GRAPHICS_DISABLED 446 static void PlotBlobs(BLOBNBOX_LIST* list,
459 BlobTextFlowType flow_type);
496 &&
cblob()->perimeter()!=0)
512 for (
int n = 0; n < BND_COUNT; ++n) {
559 static const int kErrorWeight = 3;
578 return (y_min + y_max) / 2.0f;
581 return initial_y_min;
629 para_error = new_error;
631 (float) (blobs.length () - kErrorWeight * new_error);
632 y_origin = (float) (new_c / sqrt (1 + gradient * gradient));
641 void compute_vertical_projection();
645 return num_repeated_sets_ != -1;
648 num_repeated_sets_ = -1;
651 return num_repeated_sets_;
654 num_repeated_sets_ = num_sets;
724 BLOBNBOX_LIST* blobnbox_list[] = {&blobs, &underlines, &noise_blobs,
725 &small_blobs, &large_blobs,
nullptr};
726 for (BLOBNBOX_LIST** list = blobnbox_list; *list !=
nullptr; ++list) {
727 BLOBNBOX_IT it(*list);
728 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
729 it.data()->rotate(rotation);
733 ASSERT_HOST(block->pdblk.poly_block() !=
nullptr);
734 block->rotate(rotation);
736 STATS widths(0, block->pdblk.bounding_box().width());
737 STATS heights(0, block->pdblk.bounding_box().height());
738 BLOBNBOX_IT blob_it(&blobs);
739 for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
740 widths.add(blob_it.data()->bounding_box().width(), 1);
741 heights.add(blob_it.data()->bounding_box().height(), 1);
743 block->set_median_size(static_cast<int>(widths.median() + 0.5),
744 static_cast<int>(heights.median() + 0.5));
748 TO_ROW_IT row_it = &row_list;
751 for (row_it.mark_cycle_pt(); !row_it.cycled_list();
754 tprintf(
"Row range (%g,%g), para_c=%g, blobcount=%" PRId32
"\n",
764 void ReSetAndReFilterBlobs();
767 void DeleteUnownedNoise();
776 void ComputeEdgeOffsets(Pix* thresholds, Pix* grey);
778 #ifndef GRAPHICS_DISABLED 819 "Weighting for error in believability");
820 void find_cblob_limits(
827 void find_cblob_vlimits(
833 void find_cblob_hlimits(
846 TBOX box_next_pre_chopped(
849 void vertical_cblob_projection(
853 void vertical_coutline_projection(
857 #ifndef GRAPHICS_DISABLED 862 #endif // GRAPHICS_DISABLED void set_reduced_box(TBOX new_box)
Definition: blobbox.h:250
void plot(ScrollView *window, ScrollView::Color blob_colour, ScrollView::Color child_colour)
Definition: blobbox.cpp:486
void CleanNeighbours()
Definition: blobbox.cpp:215
void set_repeated_set(int set_id)
Definition: blobbox.h:266
static bool UnMergeableType(BlobRegionType type)
Definition: blobbox.h:431
void set_bounding_box(const TBOX &new_box)
Definition: blobbox.h:236
void set_region_type(BlobRegionType new_type)
Definition: blobbox.h:287
float fixed_pitch
Definition: blobbox.h:802
void set_num_repeated_sets(int num_sets)
Definition: blobbox.h:653
void set_owns_cblob(bool value)
Definition: blobbox.h:409
void translate_box(ICOORD v)
Definition: blobbox.h:175
BlobSpecialTextType special_text_type() const
Definition: blobbox.h:290
const TBOX & bounding_box() const
Definition: blobbox.h:231
void ReInit()
Definition: blobbox.h:482
void set_leader_on_right(bool flag)
Definition: blobbox.h:368
int16_t right_rule_
Definition: blobbox.h:531
bool joined_to_prev() const
Definition: blobbox.h:257
BLOBNBOX_LIST blobs
Definition: blobbox.h:785
float line_m() const
Definition: blobbox.h:583
float fp_space
Definition: blobbox.h:665
float line_spacing
Definition: blobbox.h:792
const TBOX & reduced_box() const
Definition: blobbox.h:247
float spacing
Definition: blobbox.h:669
void set_right_crossing_rule(int new_right)
Definition: blobbox.h:335
bool DeletableNoise() const
Definition: blobbox.h:204
BLOBNBOX * neighbours_[BND_COUNT]
Definition: blobbox.h:544
void set_right_tab_type(TabType new_type)
Definition: blobbox.h:281
int32_t min_space
Definition: blobbox.h:805
int32_t enclosed_area() const
Definition: blobbox.h:254
BlobTextFlowType flow() const
Definition: blobbox.h:296
float fp_nonsp
Definition: blobbox.h:666
float intercept() const
Definition: blobbox.h:601
bool IsDiacritic() const
Definition: blobbox.h:381
float mean_y() const
Definition: blobbox.h:577
float vert_stroke_width() const
Definition: blobbox.h:344
float xheight
Definition: blobbox.h:801
void print_rows()
Definition: blobbox.h:747
bool leader_on_right() const
Definition: blobbox.h:365
tesseract::ColPartition * owner() const
Definition: blobbox.h:353
static bool IsImageType(BlobRegionType type)
Definition: blobbox.h:423
void set_line_crossings(int value)
Definition: blobbox.h:396
float min_y() const
Definition: blobbox.h:574
float body_size
Definition: blobbox.h:674
BLOCK * block
Definition: blobbox.h:790
void NeighbourGaps(int gaps[BND_COUNT]) const
Definition: blobbox.cpp:182
float believability() const
Definition: blobbox.h:598
void reflect_box_in_y_axis()
Definition: blobbox.cpp:63
float parallel_c() const
Definition: blobbox.h:592
TabType left_tab_type_
Definition: blobbox.h:526
float parallel_error() const
Definition: blobbox.h:595
void set_line(float new_m, float new_c, float new_error)
Definition: blobbox.h:616
WERD_LIST rep_words
Definition: blobbox.h:681
BLOBNBOX_LIST small_blobs
Definition: blobbox.h:788
float para_c
Definition: blobbox.h:695
BlobRegionType region_type_
Definition: blobbox.h:528
int line_crossings_
Definition: blobbox.h:537
float initial_min_y() const
Definition: blobbox.h:580
TBOX bounding_box() const
Definition: stepblob.cpp:255
int32_t perimeter()
Definition: stepblob.cpp:294
QSPLINE baseline
Definition: blobbox.h:683
static bool IsTextType(BlobRegionType type)
Definition: blobbox.h:419
float y_origin
Definition: blobbox.h:697
float fp_space
Definition: blobbox.h:807
float pr_nonsp
Definition: blobbox.h:668
void move(const ICOORD vec)
Definition: rect.h:157
TO_ROW * key_row
Definition: blobbox.h:811
void compute_bounding_box()
Definition: blobbox.h:241
Definition: quspline.h:32
void merge(BLOBNBOX *nextblob)
Definition: blobbox.cpp:93
bool rep_chars_marked() const
Definition: blobbox.h:644
int16_t base_char_bottom_
Definition: blobbox.h:535
signed int area
Definition: blobbox.h:522
TO_ROW_LIST * get_rows()
Definition: blobbox.h:717
C_BLOB * cblob_ptr
Definition: blobbox.h:519
Definition: baseapi.cpp:94
int num_repeated_sets() const
Definition: blobbox.h:650
void set_left_tab_type(TabType new_type)
Definition: blobbox.h:275
float horz_stroke_width_
Definition: blobbox.h:539
BLOBNBOX_LIST underlines
Definition: blobbox.h:786
tesseract::ColPartition * owner_
Definition: blobbox.h:542
static void ComputeEdgeOffsets(Pix *thresholds, Pix *grey, BLOBNBOX_LIST *blobs)
Definition: blobbox.cpp:386
int32_t area()
Definition: stepblob.cpp:275
bool red_box_set() const
Definition: blobbox.h:260
int base_char_top() const
Definition: blobbox.h:384
int xheight_evidence
Definition: blobbox.h:671
float ascrise
Definition: blobbox.h:672
void set_left_crossing_rule(int new_left)
Definition: blobbox.h:329
TO_ROW_LIST row_list
Definition: blobbox.h:814
float area_stroke_width() const
Definition: blobbox.h:350
ICOORDELT_LIST char_cells
Definition: blobbox.h:682
float max_y() const
Definition: blobbox.h:571
int16_t bottom() const
Definition: rect.h:65
BlobTextFlowType flow_
Definition: blobbox.h:529
TO_BLOCK()
Definition: blobbox.h:708
void clear_rep_chars_marked()
Definition: blobbox.h:647
void chop(BLOBNBOX_IT *start_it, BLOBNBOX_IT *blob_it, FCOORD rotation, float xheight)
Definition: blobbox.cpp:121
int16_t projection_left
Definition: blobbox.h:661
TabType right_tab_type_
Definition: blobbox.h:527
static ScrollView::Color TextlineColor(BlobRegionType region_type, BlobTextFlowType flow_type)
Definition: blobbox.cpp:445
int32_t max_nonspace
Definition: blobbox.h:806
float initial_y_min
Definition: blobbox.h:692
float pr_space
Definition: blobbox.h:809
PITCH_TYPE pitch_decision
Definition: blobbox.h:663
void set_limits(float new_min, float new_max)
Definition: blobbox.h:635
BLOBNBOX_LIST * blob_list()
Definition: blobbox.h:612
bool leader_on_left_
Definition: blobbox.h:548
bool good_stroke_neighbours_[BND_COUNT]
Definition: blobbox.h:545
static bool IsLineType(BlobRegionType type)
Definition: blobbox.h:427
BLOBNBOX(C_BLOB *srcblob)
Definition: blobbox.h:150
int right_crossing_rule() const
Definition: blobbox.h:332
double_VAR_H(textord_tabvector_vertical_gap_fraction, 0.5, "Max fraction of mean blob width allowed for vertical gaps in vertical text")
bool owns_cblob_
Definition: blobbox.h:553
Definition: blobbox.h:144
bool vert_possible_
Definition: blobbox.h:547
Definition: ocrblock.h:30
void set_right_rule(int new_right)
Definition: blobbox.h:323
TabType right_tab_type() const
Definition: blobbox.h:278
void set_diacritic_box(const TBOX &diacritic_box)
Definition: blobbox.h:399
float fp_nonsp
Definition: blobbox.h:808
void set_parallel_line(float gradient, float new_c, float new_error)
Definition: blobbox.h:624
void set_leader_on_left(bool flag)
Definition: blobbox.h:362
int16_t y() const
access_function
Definition: points.h:57
ScrollView::Color BoxColor() const
Definition: blobbox.cpp:482
float line_c() const
Definition: blobbox.h:586
float area_stroke_width_
Definition: blobbox.h:541
BLOBNBOX * base_char_blob_
Definition: blobbox.h:538
void ConstructionInit()
Definition: blobbox.h:471
static void PlotBlobs(BLOBNBOX_LIST *list, ScrollView::Color body_colour, ScrollView::Color child_colour, ScrollView *win)
Definition: blobbox.cpp:420
void rotate(FCOORD rotation)
Definition: blobbox.cpp:56
bool used_dm_model
Definition: blobbox.h:660
float space_size
Definition: blobbox.h:680
float kern_size
Definition: blobbox.h:679
float pr_space
Definition: blobbox.h:667
BLOBNBOX * neighbour(BlobNeighbourDir n) const
Definition: blobbox.h:371
Definition: stepblob.h:37
TBOX BoundsWithinLimits(int left, int right)
Definition: blobbox.cpp:334
bool vert_possible() const
Definition: blobbox.h:302
bool good_stroke_neighbour(BlobNeighbourDir n) const
Definition: blobbox.h:374
unsigned joined
Definition: blobbox.h:523
int num_repeated_sets_
Definition: blobbox.h:699
BLOBNBOX_LIST noise_blobs
Definition: blobbox.h:787
bool UniquelyHorizontal() const
Definition: blobbox.h:414
unsigned reduced
Definition: blobbox.h:524
int line_crossings() const
Definition: blobbox.h:393
int right_rule() const
Definition: blobbox.h:320
void set_vert_stroke_width(float width)
Definition: blobbox.h:347
float credibility
Definition: blobbox.h:698
Definition: blobbox.h:556
int16_t projection_right
Definition: blobbox.h:662
bool all_caps
Definition: blobbox.h:659
Definition: statistc.h:33
integer coordinate
Definition: points.h:32
float m
Definition: blobbox.h:693
float kern_size
Definition: blobbox.h:803
int16_t top() const
Definition: rect.h:58
BLOBNBOX * base_char_blob() const
Definition: blobbox.h:403
bool MatchingStrokeWidth(const BLOBNBOX &other, double fractional_tolerance, double constant_tolerance) const
Definition: blobbox.cpp:306
bool leader_on_left() const
Definition: blobbox.h:359
int baseline_position() const
Definition: blobbox.h:390
int32_t space_threshold
Definition: blobbox.h:678
bool ConfirmNoTabViolation(const BLOBNBOX &other) const
Definition: blobbox.cpp:293
~BLOBNBOX()
Definition: blobbox.h:156
void rotate(const FCOORD &rotation)
Definition: blobbox.h:723
float descdrop
Definition: blobbox.h:673
static void PlotNoiseBlobs(BLOBNBOX_LIST *list, ScrollView::Color body_colour, ScrollView::Color child_colour, ScrollView *win)
Definition: blobbox.cpp:433
STATS projection
Definition: blobbox.h:684
int left_crossing_rule() const
Definition: blobbox.h:326
int16_t baseline_y_
Definition: blobbox.h:536
void EstimateBaselinePosition()
Definition: blobbox.cpp:358
int repeated_set_
Definition: blobbox.h:525
int NoisyNeighbours() const
Definition: blobbox.cpp:238
void set_base_char_blob(BLOBNBOX *blob)
Definition: blobbox.h:406
BLOBNBOX_LIST blobs
Definition: blobbox.h:689
float horz_stroke_width() const
Definition: blobbox.h:338
int base_char_bottom() const
Definition: blobbox.h:387
float vert_stroke_width_
Definition: blobbox.h:540
int16_t left_crossing_rule_
Definition: blobbox.h:532
float fixed_pitch
Definition: blobbox.h:664
float para_error
Definition: blobbox.h:696
void set_vert_possible(bool value)
Definition: blobbox.h:305
BLOBNBOX_LIST large_blobs
Definition: blobbox.h:789
float pr_nonsp
Definition: blobbox.h:810
float y_min
Definition: blobbox.h:690
PITCH_TYPE pitch_decision
Definition: blobbox.h:791
Definition: blobbox.h:705
int repeated_set() const
Definition: blobbox.h:263
void rotate_box(FCOORD rotation)
Definition: blobbox.cpp:72
int32_t max_nonspace
Definition: blobbox.h:677
void set_left_rule(int new_left)
Definition: blobbox.h:317
int32_t min_space
Definition: blobbox.h:676
int GoodTextBlob() const
Definition: blobbox.cpp:227
bool UniquelyVertical() const
Definition: blobbox.h:411
void really_merge(BLOBNBOX *other)
Definition: blobbox.cpp:104
void ClearNeighbours()
Definition: blobbox.h:511
void set_flow(BlobTextFlowType value)
Definition: blobbox.h:299
void set_horz_possible(bool value)
Definition: blobbox.h:311
void MinMaxGapsClipped(int *h_min, int *h_max, int *v_min, int *v_max) const
Definition: blobbox.cpp:201
bool horz_possible_
Definition: blobbox.h:546
float error
Definition: blobbox.h:694
void set_neighbour(BlobNeighbourDir n, BLOBNBOX *neighbour, bool good)
Definition: blobbox.h:377
bool DefiniteIndividualFlow()
Definition: blobbox.cpp:253
bool horz_possible() const
Definition: blobbox.h:308
int16_t base_char_top_
Definition: blobbox.h:534
bool leader_on_right_
Definition: blobbox.h:549
BlobSpecialTextType spt_type_
Definition: blobbox.h:543
C_BLOB * cblob() const
Definition: blobbox.h:269
static void DeleteNoiseBlobs(BLOBNBOX_LIST *blobs)
Definition: blobbox.cpp:373
float baseline_offset
Definition: blobbox.h:800
TO_ROW()
Definition: blobbox.h:561
TBOX box
Definition: blobbox.h:520
int left_rule() const
Definition: blobbox.h:314
TBOX red_box
Definition: blobbox.h:521
int16_t left_rule_
Definition: blobbox.h:530
bool merged
Definition: blobbox.h:658
float y_max
Definition: blobbox.h:691
Definition: colpartition.h:68
static BLOBNBOX * RealBlob(C_OUTLINE *outline)
Definition: blobbox.h:159
float max_blob_size
Definition: blobbox.h:799
float line_error() const
Definition: blobbox.h:589
TabType left_tab_type() const
Definition: blobbox.h:272
float line_size
Definition: blobbox.h:798
void set_horz_stroke_width(float width)
Definition: blobbox.h:341
BlobRegionType region_type() const
Definition: blobbox.h:284
float xheight
Definition: blobbox.h:670
void set_owner(tesseract::ColPartition *new_owner)
Definition: blobbox.h:356
void set_special_text_type(BlobSpecialTextType new_type)
Definition: blobbox.h:293
int16_t right_crossing_rule_
Definition: blobbox.h:533
float space_size
Definition: blobbox.h:804
BLOBNBOX()
Definition: blobbox.h:147