void Textord::filter_blobs(ICOORD page_tr, // top right TO_BLOCK_LIST* blocks, // output list bool testing_on) { // for plotting TO_BLOCK_IT block_it = blocks; // destination iterator TO_BLOCK *block; // created block #ifndef GRAPHICS_DISABLED if (to_win != nullptr) to_win->Clear(); #endif // GRAPHICS_DISABLED for (block_it.mark_cycle_pt(); !block_it.cycled_list(); block_it.forward()) { block = block_it.data(); block->line_size = filter_noise_blobs(&block->blobs, &block->noise_blobs, &block->small_blobs, &block->large_blobs); if (block->line_size == 0) block->line_size = 1; block->line_spacing = block->line_size * (tesseract::CCStruct::kDescenderFraction + tesseract::CCStruct::kXHeightFraction + 2 * tesseract::CCStruct::kAscenderFraction) / tesseract::CCStruct::kXHeightFraction; block->line_size *= textord_min_linesize; block->max_blob_size = block->line_size * textord_excess_blobsize; #ifndef GRAPHICS_DISABLED if (textord_show_blobs && testing_on) { if (to_win == nullptr) create_to_win(page_tr); block->plot_graded_blobs(to_win); } if (textord_show_boxes && testing_on) { if (to_win == nullptr) create_to_win(page_tr); plot_box_list(to_win, &block->noise_blobs, ScrollView::WHITE); plot_box_list(to_win, &block->small_blobs, ScrollView::WHITE); plot_box_list(to_win, &block->large_blobs, ScrollView::WHITE); plot_box_list(to_win, &block->blobs, ScrollView::WHITE); } #endif // GRAPHICS_DISABLED } }
void filter_blobs( //split into groups ICOORD page_tr, //top right TO_BLOCK_LIST *blocks, //output list BOOL8 testing_on //for plotting ) { TO_BLOCK_IT block_it = blocks; //destination iterator TO_BLOCK *block; //created block for (block_it.mark_cycle_pt (); !block_it.cycled_list (); block_it.forward ()) { block = block_it.data (); block->line_size = filter_noise_blobs (&block->blobs, &block->noise_blobs, &block->small_blobs, &block->large_blobs); block->line_spacing = block->line_size * (textord_merge_desc + textord_merge_x + textord_merge_asc + textord_merge_asc) / textord_merge_x; block->line_size *= textord_min_linesize; block->max_blob_size = block->line_size * textord_excess_blobsize; #ifndef GRAPHICS_DISABLED if (textord_show_blobs && testing_on) { if (to_win == NO_WINDOW) create_to_win(page_tr); plot_blob_list (to_win, &block->noise_blobs, CORAL, BLUE); plot_blob_list (to_win, &block->small_blobs, GOLDENROD, YELLOW); plot_blob_list (to_win, &block->large_blobs, DARK_GREEN, YELLOW); plot_blob_list (to_win, &block->blobs, WHITE, BROWN); } if (textord_show_boxes && testing_on) { if (to_win == NO_WINDOW) create_to_win(page_tr); plot_box_list (to_win, &block->noise_blobs, WHITE); plot_box_list (to_win, &block->small_blobs, WHITE); plot_box_list (to_win, &block->large_blobs, WHITE); plot_box_list (to_win, &block->blobs, WHITE); } #endif } }
void filter_blobs( //split into groups ICOORD page_tr, //top right TO_BLOCK_LIST *blocks, //output list BOOL8 testing_on //for plotting ) { TO_BLOCK_IT block_it = blocks; //destination iterator TO_BLOCK *block; //created block if (to_win != NULL) to_win->Clear(); for (block_it.mark_cycle_pt (); !block_it.cycled_list (); block_it.forward ()) { block = block_it.data (); block->line_size = filter_noise_blobs (&block->blobs, &block->noise_blobs, &block->small_blobs, &block->large_blobs); block->line_spacing = block->line_size * (textord_merge_desc + textord_merge_x + textord_merge_asc + textord_merge_asc) / textord_merge_x; block->line_size *= textord_min_linesize; block->max_blob_size = block->line_size * textord_excess_blobsize; #ifndef GRAPHICS_DISABLED if (textord_show_blobs && testing_on) { if (to_win == NULL) create_to_win(page_tr); block->plot_graded_blobs(to_win); } if (textord_show_boxes && testing_on) { if (to_win == NULL) create_to_win(page_tr); plot_box_list (to_win, &block->noise_blobs, ScrollView::WHITE); plot_box_list (to_win, &block->small_blobs, ScrollView::WHITE); plot_box_list (to_win, &block->large_blobs, ScrollView::WHITE); plot_box_list (to_win, &block->blobs, ScrollView::WHITE); } #endif } }
// Draws the (straight) baselines and final blobs colored according to // what was discarded as noise and what is associated with each row. void BaselineBlock::DrawFinalRows(const ICOORD& page_tr) { #ifndef GRAPHICS_DISABLED if (non_text_block_) return; double gradient = tan(skew_angle_); FCOORD rotation(1.0f, 0.0f); int left_edge = block_->block->bounding_box().left(); ScrollView* win = create_to_win(page_tr); ScrollView::Color colour = ScrollView::RED; TO_ROW_IT row_it = block_->get_rows(); for (row_it.mark_cycle_pt(); !row_it.cycled_list(); row_it.forward()) { plot_parallel_row(row_it.data(), gradient, left_edge, colour, rotation); colour = static_cast<ScrollView::Color>(colour + 1); if (colour > ScrollView::MAGENTA) colour = ScrollView::RED; } plot_blob_list(win, &block_->blobs, ScrollView::MAGENTA, ScrollView::WHITE); // Show discarded blobs. plot_blob_list(win, &block_->underlines, ScrollView::YELLOW, ScrollView::CORAL); if (block_->blobs.length() > 0) tprintf("%d blobs discarded as noise\n", block_->blobs.length()); draw_meanlines(block_, gradient, left_edge, ScrollView::WHITE, rotation); #endif }