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;
82 if (stats->gap_sum == 0) stats->gap_sum = negative_gap_sum;
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,
86 stats->bad_shape ?
"bad_shape" :
"");
96 float left_gap = word_res->
GetBlobsGap(col - 1) / normalizing_height;
99 stats->bad_shape =
true;
102 tprintf(
"left_gap %g, left_seam %g %s\n", left_gap,
103 left_seam->
priority(), stats->bad_shape ?
"bad_shape" :
"");
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) {
111 stats->bad_shape =
true;
112 if (right_gap <
kMinGap) stats->bad_fixed_pitch_right_gap =
true;
115 tprintf(
"right_gap %g right_seam %g %s\n", right_gap,
116 right_seam->
priority(), stats->bad_shape ?
"bad_shape" :
"");
125 stats->full_wh_ratio = wh_ratio + right_gap;
126 if (parent_stats !=
nullptr) {
127 stats->full_wh_ratio_total =
128 (parent_stats->full_wh_ratio_total + stats->full_wh_ratio);
130 stats->full_wh_ratio_total / static_cast<float>(parent_path_length+1);
131 stats->full_wh_ratio_var =
132 parent_stats->full_wh_ratio_var + pow(mean-stats->full_wh_ratio, 2);
134 stats->full_wh_ratio_total = stats->full_wh_ratio;
137 tprintf(
"full_wh_ratio %g full_wh_ratio_total %g full_wh_ratio_var %g\n",
138 stats->full_wh_ratio, stats->full_wh_ratio_total,
139 stats->full_wh_ratio_var);
148 if (col == 0 && end_row && wh_ratio > max_char_wh_ratio) {
149 stats->shape_cost += 10;
151 stats->shape_cost += stats->full_wh_ratio_var;
152 if (debug)
tprintf(
"shape_cost %g\n", stats->shape_cost);