85 SplitStrategy split_strategy = split_for_pageseg ? pageseg_split_strategy_ :
94 tprintf(
"Splitting shiro-rekha ...\n");
95 tprintf(
"Split strategy = %s\n",
97 tprintf(
"Initial pageseg available = %s\n",
98 segmentation_block_list_ ?
"yes" :
"no");
101 pixDestroy(&splitted_image_);
102 splitted_image_ = pixCopy(NULL, orig_pix_);
106 pixDestroy(&debug_image_);
107 debug_image_ = pixConvertTo32(orig_pix_);
112 Pix* pix_for_ccs = pixClone(orig_pix_);
114 !segmentation_block_list_) {
116 tprintf(
"Performing a global close operation..\n");
120 pixDestroy(&pix_for_ccs);
121 pix_for_ccs = pixCopy(NULL, orig_pix_);
122 PerformClose(pix_for_ccs, global_xheight_);
125 Boxa* tmp_boxa = pixConnComp(pix_for_ccs, &ccs, 8);
126 boxaDestroy(&tmp_boxa);
127 pixDestroy(&pix_for_ccs);
132 Boxa* regions_to_clear = boxaCreate(0);
133 for (
int i = 0; i < pixaGetCount(ccs); ++i) {
134 Box* box = ccs->boxa->box[i];
135 Pix* word_pix = pixClipRectangle(orig_pix_, box, NULL);
137 int xheight = GetXheightForCC(box);
140 pixRenderBoxArb(debug_image_, box, 1, 255, 0, 0);
147 (box->w > xheight / 3 && box->h > xheight / 2)) {
148 SplitWordShiroRekha(split_strategy, word_pix, xheight,
149 box->x, box->y, regions_to_clear);
151 tprintf(
"CC dropped from splitting: %d,%d (%d, %d)\n",
152 box->x, box->y, box->w, box->h);
154 pixDestroy(&word_pix);
157 for (
int i = 0; i < boxaGetCount(regions_to_clear); ++i) {
158 Box* box = boxaGetBox(regions_to_clear, i, L_CLONE);
159 pixClearInRect(splitted_image_, box);
162 boxaDestroy(®ions_to_clear);
166 "ocr_split_debug.png");
static const int kUnspecifiedXheight
bool devanagari_split_debugimage
void DumpDebugImage(const char *filename) const
int devanagari_split_debuglevel