44 STATS xht_stats (0, 128);
54 max_right = -INT16_MAX;
60 for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
64 xht_stats.add ((int16_t) floor (row->
xheight + 0.5), 1);
66 start_of_row = blob_it.data ()->bounding_box ().left ();
67 end_of_row = blob_it.data_relative (-1)->bounding_box ().right ();
68 if (min_left > start_of_row)
69 min_left = start_of_row;
70 if (max_right < end_of_row)
71 max_right = end_of_row;
74 if ((total_rows < 3) || (min_left >= max_right)) {
78 min_left = max_right = 0;
81 bucket_size = (int16_t) floor (xht_stats.median () + 0.5) / 2;
82 map_max = (max_right - min_left) / bucket_size;
83 map =
new int16_t[map_max + 1];
84 for (i = 0; i <= map_max; i++)
87 for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
91 blob_it.mark_cycle_pt ();
93 prev_blob_box = blob_box;
96 gap_width = blob_box.
left () - min_left;
99 max_quantum = (blob_box.
left () - min_left) / bucket_size;
100 if (max_quantum > map_max) max_quantum = map_max;
101 for (i = 0; i <= max_quantum; i++)
105 while (!blob_it.cycled_list ()) {
107 gap_width = blob_box.
left () - prev_blob_box.
right ();
111 (prev_blob_box.
right () - min_left) / bucket_size;
112 max_quantum = (blob_box.
left () - min_left) / bucket_size;
113 if (max_quantum > map_max) max_quantum = map_max;
114 for (i = min_quantum; i <= max_quantum; i++)
117 prev_blob_box = blob_box;
121 gap_width = max_right - prev_blob_box.
right ();
125 (prev_blob_box.
right () - min_left) / bucket_size;
126 if (min_quantum < 0) min_quantum = 0;
127 for (i = min_quantum; i <= map_max; i++)
133 for (i = 0; i <= map_max; i++) {
134 if (map[i] > total_rows / 2) {
137 (map[i + 1] <= total_rows / 2)) ||
139 (map[i - 1] <= total_rows / 2)) ||
142 (map[i - 1] <= total_rows / 2) &&
143 (map[i + 1] <= total_rows / 2)))) {
bool gapmap_no_isolated_quanta
TBOX box_next(BLOBNBOX_IT *it)
DLLSYM void tprintf(const char *format,...)
BLOBNBOX_LIST * blob_list()