82 SplitStrategy split_strategy = split_for_pageseg ? pageseg_split_strategy_ : ocr_split_strategy_;
89 tprintf(
"Splitting shiro-rekha ...\n");
91 tprintf(
"Initial pageseg available = %s\n", segmentation_block_list_ ?
"yes" :
"no");
95 splitted_image_ = orig_pix_.
copy();
100 debug_image_ = pixConvertTo32(orig_pix_);
105 Image pix_for_ccs = orig_pix_.
clone();
106 if (perform_close_ && global_xheight_ !=
kUnspecifiedXheight && !segmentation_block_list_) {
108 tprintf(
"Performing a global close operation..\n");
112 pix_for_ccs.destroy();
113 pix_for_ccs = orig_pix_.
copy();
114 PerformClose(pix_for_ccs, global_xheight_);
117 Boxa *tmp_boxa = pixConnComp(pix_for_ccs, &ccs, 8);
118 boxaDestroy(&tmp_boxa);
119 pix_for_ccs.destroy();
124 Boxa *regions_to_clear = boxaCreate(0);
126 if (ccs !=
nullptr) {
127 num_ccs = pixaGetCount(ccs);
129 for (
int i = 0; i < num_ccs; ++i) {
130 Box *box = ccs->boxa->box[i];
131 Image word_pix = pixClipRectangle(orig_pix_, box,
nullptr);
133 int xheight = GetXheightForCC(box);
135 pixRenderBoxArb(debug_image_, box, 1, 255, 0, 0);
142 SplitWordShiroRekha(split_strategy, word_pix, xheight, box->x, box->y, regions_to_clear);
144 tprintf(
"CC dropped from splitting: %d,%d (%d, %d)\n", box->x, box->y, box->w, box->h);
149 for (
int i = 0; i < boxaGetCount(regions_to_clear); ++i) {
150 Box *box = boxaGetBox(regions_to_clear, i, L_CLONE);
151 pixClearInRect(splitted_image_, box);
154 boxaDestroy(®ions_to_clear);
157 pixa_debug->AddPix(debug_image_, split_for_pageseg ?
"pageseg_split" :
"ocr_split");