36 int parent_path_length,
38 float max_char_wh_ratio,
49 tprintf(
"AssociateUtils::ComputeStats() for col=%d, row=%d%s\n",
50 col, row, fixed_pitch ?
" (fixed pitch)" :
"");
55 if (fixed_pitch && blob_row !=
nullptr) {
66 tprintf(
"normalizing height = %g (scale %g xheight %g ascenders %g)\n",
71 float wh_ratio = word_res->
GetBlobsWidth(col, row) / normalizing_height;
72 if (wh_ratio > max_char_wh_ratio) stats->
bad_shape =
true;
77 int negative_gap_sum = 0;
78 for (
int c = col; c < row; ++c) {
80 (gap > 0) ? stats->
gap_sum += gap : negative_gap_sum += gap;
84 tprintf(
"wh_ratio=%g (max_char_wh_ratio=%g) gap_sum=%d %s\n",
85 wh_ratio, max_char_wh_ratio, stats->
gap_sum,
96 float left_gap = word_res->
GetBlobsGap(col - 1) / normalizing_height;
102 tprintf(
"left_gap %g, left_seam %g %s\n", left_gap,
106 float right_gap = 0.0f;
108 right_gap = word_res->
GetBlobsGap(row) / normalizing_height;
110 if (right_gap < kMinGap || right_seam->priority() > 0.0f) {
115 tprintf(
"right_gap %g right_seam %g %s\n", right_gap,
126 if (parent_stats !=
nullptr) {
137 tprintf(
"full_wh_ratio %g full_wh_ratio_total %g full_wh_ratio_var %g\n",
148 if (col == 0 && end_row && wh_ratio > max_char_wh_ratio) {
159 float max_char_wh_ratio) {
161 if (norm_width > max_char_wh_ratio) cost += norm_width;
163 cost += norm_width * norm_width;
165 if (norm_width+right_gap < 0.5f && !end_pos) {
166 cost += 1.0f - (norm_width + right_gap);