80 {
81 SplitStrategy split_strategy = split_for_pageseg ? pageseg_split_strategy_ : ocr_split_strategy_;
83 return false;
84 }
88 tprintf(
"Splitting shiro-rekha ...\n");
90 tprintf(
"Initial pageseg available = %s\n", segmentation_block_list_ ?
"yes" :
"no");
91 }
92
94 splitted_image_ = orig_pix_.
copy();
95
96
99 debug_image_ = pixConvertTo32(orig_pix_);
100 }
101
102
103
104 Image pix_for_ccs = orig_pix_.
clone();
105 if (perform_close_ && global_xheight_ !=
kUnspecifiedXheight && !segmentation_block_list_) {
107 tprintf(
"Performing a global close operation..\n");
108 }
109
110
111 pix_for_ccs.destroy();
112 pix_for_ccs = orig_pix_.
copy();
113 PerformClose(pix_for_ccs, global_xheight_);
114 }
115 Pixa *ccs;
116 Boxa *tmp_boxa = pixConnComp(pix_for_ccs, &ccs, 8);
117 boxaDestroy(&tmp_boxa);
118 pix_for_ccs.destroy();
119
120
121
122
123 Boxa *regions_to_clear = boxaCreate(0);
124 int num_ccs = 0;
125 if (ccs != nullptr) {
126 num_ccs = pixaGetCount(ccs);
127 }
128 for (
int i = 0;
i < num_ccs; ++
i) {
129 Box *box = pixaGetBox(ccs,
i, L_CLONE);
130 Image word_pix = pixClipRectangle(orig_pix_, box, nullptr);
132 int xheight = GetXheightForCC(box);
134 pixRenderBoxArb(debug_image_, box, 1, 255, 0, 0);
135 }
136
137
138
139
141 boxGetGeometry(box, &
x, &
y, &w, &h);
143 SplitWordShiroRekha(split_strategy, word_pix, xheight,
x,
y, regions_to_clear);
145 tprintf(
"CC dropped from splitting: %d,%d (%d, %d)\n",
x,
y, w, h);
146 }
147 word_pix.destroy();
148 boxDestroy(&box);
149 }
150
151 for (
int i = 0;
i < boxaGetCount(regions_to_clear); ++
i) {
152 Box *box = boxaGetBox(regions_to_clear,
i, L_CLONE);
153 pixClearInRect(splitted_image_, box);
154 boxDestroy(&box);
155 }
156 boxaDestroy(®ions_to_clear);
157 pixaDestroy(&ccs);
159 pixa_debug->AddPix(debug_image_, split_for_pageseg ? "pageseg_split" : "ocr_split");
160 }
161 return true;
162}