Attempts to put noise/diacritic outlines into the blobs that they overlap. Input: a set of noisy outlines that probably belong to the real_word. Output: word_wanted indicates which outlines are to be assigned to a blob, target_blobs indicates which to assign to, and overlapped_any_blob is true for all outlines that overlapped a blob.
| 980 | // target_blobs indicates which to assign to, and overlapped_any_blob is |
| 981 | // true for all outlines that overlapped a blob. |
| 982 | void Tesseract::AssignDiacriticsToOverlappingBlobs( |
| 983 | const GenericVector<C_OUTLINE*>& outlines, int pass, WERD* real_word, |
| 984 | PAGE_RES_IT* pr_it, GenericVector<bool>* word_wanted, |
| 985 | GenericVector<bool>* overlapped_any_blob, |
| 986 | GenericVector<C_BLOB*>* target_blobs) { |
| 987 | GenericVector<bool> blob_wanted; |
| 988 | word_wanted->init_to_size(outlines.size(), false); |
| 989 | overlapped_any_blob->init_to_size(outlines.size(), false); |
| 990 | target_blobs->init_to_size(outlines.size(), NULL); |
| 991 | // For each real blob, find the outlines that seriously overlap it. |
| 992 | // A single blob could be several merged characters, so there can be quite |
| 993 | // a few outlines overlapping, and the full engine needs to be used to chop |
| 994 | // and join to get a sensible result. |
| 995 | C_BLOB_IT blob_it(real_word->cblob_list()); |
| 996 | for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) { |
| 997 | C_BLOB* blob = blob_it.data(); |
| 998 | TBOX blob_box = blob->bounding_box(); |
| 999 | blob_wanted.init_to_size(outlines.size(), false); |
| 1000 | int num_blob_outlines = 0; |
| 1001 | for (int i = 0; i < outlines.size(); ++i) { |
| 1002 | if (blob_box.major_x_overlap(outlines[i]->bounding_box()) && |
| 1003 | !(*word_wanted)[i]) { |
| 1004 | blob_wanted[i] = true; |
| 1005 | (*overlapped_any_blob)[i] = true; |
| 1006 | ++num_blob_outlines; |
| 1007 | } |
| 1008 | } |
| 1009 | if (debug_noise_removal) { |
| 1010 | tprintf("%d noise outlines overlap blob at:", num_blob_outlines); |
| 1011 | blob_box.print(); |
| 1012 | } |
| 1013 | // If any outlines overlap the blob, and not too many, classify the blob |
| 1014 | // (using the full engine, languages and all), and choose the maximal |
| 1015 | // combination of outlines that doesn't hurt the end-result classification |
| 1016 | // by too much. Mark them as wanted. |
| 1017 | if (0 < num_blob_outlines && num_blob_outlines < noise_maxperblob) { |
| 1018 | if (SelectGoodDiacriticOutlines(pass, noise_cert_basechar, pr_it, blob, |
| 1019 | outlines, num_blob_outlines, |
| 1020 | &blob_wanted)) { |
| 1021 | for (int i = 0; i < blob_wanted.size(); ++i) { |
| 1022 | if (blob_wanted[i]) { |
| 1023 | // Claim the outline and record where it is going. |
| 1024 | (*word_wanted)[i] = true; |
| 1025 | (*target_blobs)[i] = blob; |
| 1026 | } |
| 1027 | } |
| 1028 | } |
| 1029 | } |
| 1030 | } |
| 1031 | } |
| 1032 | |
| 1033 | // Attempts to assign non-overlapping outlines to their nearest blobs or |
| 1034 | // make new blobs out of them. |
nothing calls this directly
no test coverage detected