37
37
#include " blobbox.h"
38
38
#include " blread.h"
39
39
#include " colfind.h"
40
+ #include " debugpixa.h"
40
41
#include " equationdetect.h"
41
42
#include " imagefind.h"
42
43
#include " linefind.h"
@@ -176,28 +177,6 @@ int Tesseract::SegmentPage(const STRING* input_file, BLOCK_LIST* blocks,
176
177
return auto_page_seg_ret_val;
177
178
}
178
179
179
- // Helper writes a grey image to a file for use by scrollviewer.
180
- // Normally for speed we don't display the image in the layout debug windows.
181
- // If textord_debug_images is true, we draw the image as a background to some
182
- // of the debug windows. printable determines whether these
183
- // images are optimized for printing instead of screen display.
184
- static void WriteDebugBackgroundImage (bool printable, Pix* pix_binary) {
185
- Pix* grey_pix = pixCreate (pixGetWidth (pix_binary),
186
- pixGetHeight (pix_binary), 8 );
187
- // Printable images are light grey on white, but for screen display
188
- // they are black on dark grey so the other colors show up well.
189
- if (printable) {
190
- pixSetAll (grey_pix);
191
- pixSetMasked (grey_pix, pix_binary, 192 );
192
- } else {
193
- pixSetAllArbitrary (grey_pix, 64 );
194
- pixSetMasked (grey_pix, pix_binary, 0 );
195
- }
196
- AlignedBlob::IncrementDebugPix ();
197
- pixWrite (AlignedBlob::textord_debug_pix ().string (), grey_pix, IFF_PNG);
198
- pixDestroy (&grey_pix);
199
- }
200
-
201
180
/* *
202
181
* Auto page segmentation. Divide the page image into blocks of uniform
203
182
* text linespacing and images.
@@ -226,9 +205,6 @@ int Tesseract::AutoPageSeg(PageSegMode pageseg_mode, BLOCK_LIST* blocks,
226
205
TO_BLOCK_LIST* to_blocks,
227
206
BLOBNBOX_LIST* diacritic_blobs, Tesseract* osd_tess,
228
207
OSResults* osr) {
229
- if (textord_debug_images) {
230
- WriteDebugBackgroundImage (textord_debug_printable, pix_binary_);
231
- }
232
208
Pix* photomask_pix = NULL ;
233
209
Pix* musicmask_pix = NULL ;
234
210
// The blocks made by the ColumnFinder. Moved to blocks before return.
@@ -250,9 +226,10 @@ int Tesseract::AutoPageSeg(PageSegMode pageseg_mode, BLOCK_LIST* blocks,
250
226
if (equ_detect_) {
251
227
finder->SetEquationDetect (equ_detect_);
252
228
}
253
- result = finder->FindBlocks (
254
- pageseg_mode, scaled_color_, scaled_factor_, to_block, photomask_pix,
255
- pix_thresholds_, pix_grey_, &found_blocks, diacritic_blobs, to_blocks);
229
+ result = finder->FindBlocks (pageseg_mode, scaled_color_, scaled_factor_,
230
+ to_block, photomask_pix, pix_thresholds_,
231
+ pix_grey_, &pixa_debug_, &found_blocks,
232
+ diacritic_blobs, to_blocks);
256
233
if (result >= 0 )
257
234
finder->GetDeskewVectors (&deskew_, &reskew_);
258
235
delete finder;
@@ -265,11 +242,6 @@ int Tesseract::AutoPageSeg(PageSegMode pageseg_mode, BLOCK_LIST* blocks,
265
242
BLOCK_IT block_it (blocks);
266
243
// Move the found blocks to the input/output blocks.
267
244
block_it.add_list_after (&found_blocks);
268
-
269
- if (textord_debug_images) {
270
- // The debug image is no longer needed so delete it.
271
- unlink (AlignedBlob::textord_debug_pix ().string ());
272
- }
273
245
return result;
274
246
}
275
247
@@ -311,19 +283,21 @@ ColumnFinder* Tesseract::SetupPageSegAndDetectOrientation(
311
283
312
284
ASSERT_HOST (pix_binary_ != NULL );
313
285
if (tessedit_dump_pageseg_images) {
314
- pixWrite ( " tessinput.png " , pix_binary_, IFF_PNG );
286
+ pixa_debug_. AddPix ( pix_binary_, " PageSegInput " );
315
287
}
316
288
// Leptonica is used to find the rule/separator lines in the input.
317
289
LineFinder::FindAndRemoveLines (source_resolution_,
318
290
textord_tabfind_show_vlines, pix_binary_,
319
291
&vertical_x, &vertical_y, music_mask_pix,
320
292
&v_lines, &h_lines);
321
- if (tessedit_dump_pageseg_images)
322
- pixWrite (" tessnolines.png" , pix_binary_, IFF_PNG);
293
+ if (tessedit_dump_pageseg_images) {
294
+ pixa_debug_.AddPix (pix_binary_, " NoLines" );
295
+ }
323
296
// Leptonica is used to find a mask of the photo regions in the input.
324
- *photo_mask_pix = ImageFind::FindImages (pix_binary_);
325
- if (tessedit_dump_pageseg_images)
326
- pixWrite (" tessnoimages.png" , pix_binary_, IFF_PNG);
297
+ *photo_mask_pix = ImageFind::FindImages (pix_binary_, &pixa_debug_);
298
+ if (tessedit_dump_pageseg_images) {
299
+ pixa_debug_.AddPix (pix_binary_, " NoImages" );
300
+ }
327
301
if (!PSM_COL_FIND_ENABLED (pageseg_mode)) v_lines.clear ();
328
302
329
303
// The rest of the algorithm uses the usual connected components.
0 commit comments