28 #include "config_auto.h"
39 "Use the new outline complexity module");
41 "Max number of children inside a character outline");
43 "Max layers of nested children inside a character outline");
45 "turn on debugging for this module");
49 "Importance ratio for chucking outlines");
51 "Max holes allowed in blob");
53 "Remove boxy parents of char-like children");
55 "Min pixels for potential char in box");
57 "Max lensq/area for acceptable child outline");
59 "Min area fraction of child outline");
61 "Min area fraction of grandchild for box");
71 ICOORD tright): bl(bleft), tr(tright) {
75 buckets =
new C_OUTLINE_LIST[bxdim * bydim];
122 inT16 xindex, yindex;
125 inT32 grandchild_count;
126 C_OUTLINE_IT child_it;
134 grandchild_count = 0;
136 return max_count + depth;
138 for (yindex = ymin; yindex <= ymax; yindex++) {
139 for (xindex = xmin; xindex <= xmax; xindex++) {
140 child_it.set_to_list(&buckets[yindex * bxdim + xindex]);
141 if (child_it.empty())
143 for (child_it.mark_cycle_pt(); !child_it.cycled_list();
144 child_it.forward()) {
145 child = child_it.data();
146 if (child == outline || !(*child < *outline))
152 tprintf(
"Discard outline on child_count=%d > "
153 "max_children_per_outline=%d\n",
156 return max_count + child_count;
160 inT32 remaining_count = max_count - child_count - grandchild_count;
161 if (remaining_count > 0)
164 if (child_count + grandchild_count > max_count) {
166 tprintf(
"Disgard outline on child_count=%d + grandchild_count=%d "
168 child_count, grandchild_count, max_count);
169 return child_count + grandchild_count;
174 return child_count + grandchild_count;
191 inT16 xindex, yindex;
194 inT32 grandchild_count;
200 C_OUTLINE_IT child_it;
208 grandchild_count = 0;
212 for (yindex = ymin; yindex <= ymax; yindex++) {
213 for (xindex = xmin; xindex <= xmax; xindex++) {
214 child_it.set_to_list(&buckets[yindex * bxdim + xindex]);
215 if (child_it.empty())
217 for (child_it.mark_cycle_pt(); !child_it.cycled_list();
218 child_it.forward()) {
219 child = child_it.data();
220 if (child != outline && *child < *outline) {
222 if (child_count <= max_count) {
223 int max_grand =(max_count - child_count) /
231 if (child_count + grandchild_count > max_count) {
233 tprintf(
"Discarding parent with child count=%d, gc=%d\n",
234 child_count,grandchild_count);
235 return child_count + grandchild_count;
237 if (parent_area == 0) {
240 parent_area = -parent_area;
242 if (parent_area < max_parent_area)
250 child_area = -child_area;
252 if (parent_area - child_area < max_parent_area) {
256 if (grandchild_count > 0) {
258 tprintf(
"Discarding parent of area %d, child area=%d, max%g "
260 parent_area, child_area, max_parent_area,
262 return max_count + 1;
265 if (child_length * child_length >
268 tprintf(
"Discarding parent of area %d, child area=%d, max%g "
269 "with child length=%d\n",
270 parent_area, child_area, max_parent_area,
272 return max_count + 1;
277 tprintf(
"Discarding parent of area %d, child area=%d, max%g "
278 "with child rect=%d\n",
279 parent_area, child_area, max_parent_area,
281 return max_count + 1;
288 return child_count + grandchild_count;
306 inT16 xindex, yindex;
308 C_OUTLINE_IT child_it;
315 for (yindex = ymin; yindex <= ymax; yindex++) {
316 for (xindex = xmin; xindex <= xmax; xindex++) {
317 child_it.set_to_list(&buckets[yindex * bxdim + xindex]);
318 for (child_it.mark_cycle_pt(); !child_it.cycled_list();
319 child_it.forward()) {
320 if (*child_it.data() < *outline) {
321 it->add_after_then_move(child_it.extract());
337 C_OUTLINE_LIST outlines;
338 C_OUTLINE_IT out_it = &outlines;
363 C_OUTLINE_LIST *outlines) {
379 C_OUTLINE_LIST *outlines,
383 C_OUTLINE_IT out_it = outlines;
384 C_OUTLINE_IT bucket_it;
387 for (out_it.mark_cycle_pt(); !out_it.cycled_list(); out_it.forward()) {
388 outline = out_it.extract();
391 bucket_it.set_to_list((*buckets) (ol_box.
left(), ol_box.
bottom()));
392 bucket_it.add_to_end(outline);
408 C_OUTLINE_LIST outlines;
410 C_OUTLINE_IT out_it = &outlines;
411 C_OUTLINE_IT bucket_it = buckets->
start_scan();
412 C_OUTLINE_IT parent_it;
414 C_BLOB_IT good_blobs = block->
blob_list();
417 while (!bucket_it.empty()) {
418 out_it.set_to_list(&outlines);
420 parent_it = bucket_it;
423 }
while (!bucket_it.at_first() &&
424 !(*parent_it.data() < *bucket_it.data()));
425 }
while (!bucket_it.at_first());
428 out_it.add_after_then_move(parent_it.extract());
430 blob =
new C_BLOB(&outlines);
432 good_blobs.add_after_then_move(blob);
434 junk_blobs.add_after_then_move(blob);
436 bucket_it.set_to_list(buckets->
scan_next());
451 C_BLOB_IT *reject_it,
452 C_OUTLINE_IT *blob_it
457 outline = blob_it->data();