tesseract  4.0.0-1-g2a2b
TO_BLOCK Class Reference

#include <blobbox.h>

Inheritance diagram for TO_BLOCK:
ELIST_LINK

Public Member Functions

 TO_BLOCK ()
 
 TO_BLOCK (BLOCK *src_block)
 
 ~TO_BLOCK ()
 
void clear ()
 
TO_ROW_LIST * get_rows ()
 
void rotate (const FCOORD &rotation)
 
void print_rows ()
 
void ReSetAndReFilterBlobs ()
 
void DeleteUnownedNoise ()
 
void ComputeEdgeOffsets (Pix *thresholds, Pix *grey)
 
void plot_noise_blobs (ScrollView *to_win)
 
void plot_graded_blobs (ScrollView *to_win)
 
- Public Member Functions inherited from ELIST_LINK
 ELIST_LINK ()
 
 ELIST_LINK (const ELIST_LINK &)
 
void operator= (const ELIST_LINK &)
 

Public Attributes

BLOBNBOX_LIST blobs
 
BLOBNBOX_LIST underlines
 
BLOBNBOX_LIST noise_blobs
 
BLOBNBOX_LIST small_blobs
 
BLOBNBOX_LIST large_blobs
 
BLOCKblock
 
PITCH_TYPE pitch_decision
 
float line_spacing
 
float line_size
 
float max_blob_size
 
float baseline_offset
 
float xheight
 
float fixed_pitch
 
float kern_size
 
float space_size
 
int32_t min_space
 
int32_t max_nonspace
 
float fp_space
 
float fp_nonsp
 
float pr_space
 
float pr_nonsp
 
TO_ROWkey_row
 

Detailed Description

Definition at line 705 of file blobbox.h.

Constructor & Destructor Documentation

◆ TO_BLOCK() [1/2]

TO_BLOCK::TO_BLOCK ( )
inline

Definition at line 708 of file blobbox.h.

709  clear();
710  } //empty
PITCH_TYPE pitch_decision
Definition: blobbox.h:791
void clear()
Definition: blobbox.cpp:945

◆ TO_BLOCK() [2/2]

TO_BLOCK::TO_BLOCK ( BLOCK src_block)

Definition at line 923 of file blobbox.cpp.

925  {
926  clear();
927  block = src_block;
928 }
BLOCK * block
Definition: blobbox.h:790
void clear()
Definition: blobbox.cpp:945

◆ ~TO_BLOCK()

TO_BLOCK::~TO_BLOCK ( )

Definition at line 966 of file blobbox.cpp.

966  {
967  // Any residual BLOBNBOXes at this stage own their blobs, so delete them.
968  clear_blobnboxes(&blobs);
969  clear_blobnboxes(&underlines);
970  clear_blobnboxes(&noise_blobs);
971  clear_blobnboxes(&small_blobs);
972  clear_blobnboxes(&large_blobs);
973 }
BLOBNBOX_LIST blobs
Definition: blobbox.h:785
BLOBNBOX_LIST large_blobs
Definition: blobbox.h:789
BLOBNBOX_LIST underlines
Definition: blobbox.h:786
BLOBNBOX_LIST small_blobs
Definition: blobbox.h:788
BLOBNBOX_LIST noise_blobs
Definition: blobbox.h:787

Member Function Documentation

◆ clear()

void TO_BLOCK::clear ( )

Definition at line 945 of file blobbox.cpp.

945  {
946  block = nullptr;
948  line_spacing = 0.0;
949  line_size = 0.0;
950  max_blob_size = 0.0;
951  baseline_offset = 0.0;
952  xheight = 0.0;
953  fixed_pitch = 0.0;
954  kern_size = 0.0;
955  space_size = 0.0;
956  min_space = 0;
957  max_nonspace = 0;
958  fp_space = 0.0;
959  fp_nonsp = 0.0;
960  pr_space = 0.0;
961  pr_nonsp = 0.0;
962  key_row = nullptr;
963 }
float fp_space
Definition: blobbox.h:807
TO_ROW * key_row
Definition: blobbox.h:811
float fixed_pitch
Definition: blobbox.h:802
float kern_size
Definition: blobbox.h:803
float fp_nonsp
Definition: blobbox.h:808
int32_t max_nonspace
Definition: blobbox.h:806
float space_size
Definition: blobbox.h:804
float line_spacing
Definition: blobbox.h:792
float max_blob_size
Definition: blobbox.h:799
float baseline_offset
Definition: blobbox.h:800
PITCH_TYPE pitch_decision
Definition: blobbox.h:791
float xheight
Definition: blobbox.h:801
int32_t min_space
Definition: blobbox.h:805
float pr_nonsp
Definition: blobbox.h:810
BLOCK * block
Definition: blobbox.h:790
float pr_space
Definition: blobbox.h:809
float line_size
Definition: blobbox.h:798

◆ ComputeEdgeOffsets()

void TO_BLOCK::ComputeEdgeOffsets ( Pix *  thresholds,
Pix *  grey 
)

Definition at line 1056 of file blobbox.cpp.

1056  {
1057  BLOBNBOX::ComputeEdgeOffsets(thresholds, grey, &blobs);
1058  BLOBNBOX::ComputeEdgeOffsets(thresholds, grey, &small_blobs);
1059  BLOBNBOX::ComputeEdgeOffsets(thresholds, grey, &noise_blobs);
1060 }
static void ComputeEdgeOffsets(Pix *thresholds, Pix *grey, BLOBNBOX_LIST *blobs)
Definition: blobbox.cpp:386
BLOBNBOX_LIST blobs
Definition: blobbox.h:785
BLOBNBOX_LIST small_blobs
Definition: blobbox.h:788
BLOBNBOX_LIST noise_blobs
Definition: blobbox.h:787

◆ DeleteUnownedNoise()

void TO_BLOCK::DeleteUnownedNoise ( )

Definition at line 1038 of file blobbox.cpp.

1038  {
1047 }
void CleanNeighbours()
Definition: blobbox.cpp:215
BLOBNBOX_LIST blobs
Definition: blobbox.h:785
static void DeleteNoiseBlobs(BLOBNBOX_LIST *blobs)
Definition: blobbox.cpp:373
BLOBNBOX_LIST large_blobs
Definition: blobbox.h:789
BLOBNBOX_LIST small_blobs
Definition: blobbox.h:788
BLOBNBOX_LIST noise_blobs
Definition: blobbox.h:787

◆ get_rows()

TO_ROW_LIST* TO_BLOCK::get_rows ( )
inline

Definition at line 717 of file blobbox.h.

717  { //access function
718  return &row_list;
719  }

◆ plot_graded_blobs()

void TO_BLOCK::plot_graded_blobs ( ScrollView to_win)

Definition at line 1072 of file blobbox.cpp.

1072  {
1075  win);
1077  win);
1079 }
static void PlotBlobs(BLOBNBOX_LIST *list, ScrollView::Color body_colour, ScrollView::Color child_colour, ScrollView *win)
Definition: blobbox.cpp:420
BLOBNBOX_LIST blobs
Definition: blobbox.h:785
BLOBNBOX_LIST large_blobs
Definition: blobbox.h:789
BLOBNBOX_LIST small_blobs
Definition: blobbox.h:788
BLOBNBOX_LIST noise_blobs
Definition: blobbox.h:787

◆ plot_noise_blobs()

void TO_BLOCK::plot_noise_blobs ( ScrollView to_win)

Definition at line 1064 of file blobbox.cpp.

1064  {
1069 }
static void PlotNoiseBlobs(BLOBNBOX_LIST *list, ScrollView::Color body_colour, ScrollView::Color child_colour, ScrollView *win)
Definition: blobbox.cpp:433
BLOBNBOX_LIST blobs
Definition: blobbox.h:785
BLOBNBOX_LIST large_blobs
Definition: blobbox.h:789
BLOBNBOX_LIST small_blobs
Definition: blobbox.h:788
BLOBNBOX_LIST noise_blobs
Definition: blobbox.h:787

◆ print_rows()

void TO_BLOCK::print_rows ( )
inline

Definition at line 747 of file blobbox.h.

747  { //debug info
748  TO_ROW_IT row_it = &row_list;
749  TO_ROW *row;
750 
751  for (row_it.mark_cycle_pt(); !row_it.cycled_list();
752  row_it.forward()) {
753  row = row_it.data();
754  tprintf("Row range (%g,%g), para_c=%g, blobcount=%" PRId32 "\n",
755  row->min_y(), row->max_y(), row->parallel_c(),
756  row->blob_list()->length());
757  }
758  }
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37
float parallel_c() const
Definition: blobbox.h:592
float min_y() const
Definition: blobbox.h:574
BLOBNBOX_LIST * blob_list()
Definition: blobbox.h:612
float max_y() const
Definition: blobbox.h:571

◆ ReSetAndReFilterBlobs()

void TO_BLOCK::ReSetAndReFilterBlobs ( )

Definition at line 1012 of file blobbox.cpp.

1012  {
1013  int min_height = IntCastRounded(kMinMediumSizeRatio * line_size);
1014  int max_height = IntCastRounded(kMaxMediumSizeRatio * line_size);
1015  BLOBNBOX_LIST noise_list;
1016  BLOBNBOX_LIST small_list;
1017  BLOBNBOX_LIST medium_list;
1018  BLOBNBOX_LIST large_list;
1019  SizeFilterBlobs(min_height, max_height, &blobs,
1020  &noise_list, &small_list, &medium_list, &large_list);
1021  SizeFilterBlobs(min_height, max_height, &large_blobs,
1022  &noise_list, &small_list, &medium_list, &large_list);
1023  SizeFilterBlobs(min_height, max_height, &small_blobs,
1024  &noise_list, &small_list, &medium_list, &large_list);
1025  SizeFilterBlobs(min_height, max_height, &noise_blobs,
1026  &noise_list, &small_list, &medium_list, &large_list);
1027  BLOBNBOX_IT blob_it(&blobs);
1028  blob_it.add_list_after(&medium_list);
1029  blob_it.set_to_list(&large_blobs);
1030  blob_it.add_list_after(&large_list);
1031  blob_it.set_to_list(&small_blobs);
1032  blob_it.add_list_after(&small_list);
1033  blob_it.set_to_list(&noise_blobs);
1034  blob_it.add_list_after(&noise_list);
1035 }
const double kMinMediumSizeRatio
Definition: blobbox.cpp:51
int IntCastRounded(double x)
Definition: helpers.h:168
const double kMaxMediumSizeRatio
Definition: blobbox.cpp:53
BLOBNBOX_LIST blobs
Definition: blobbox.h:785
BLOBNBOX_LIST large_blobs
Definition: blobbox.h:789
BLOBNBOX_LIST small_blobs
Definition: blobbox.h:788
BLOBNBOX_LIST noise_blobs
Definition: blobbox.h:787
float line_size
Definition: blobbox.h:798

◆ rotate()

void TO_BLOCK::rotate ( const FCOORD rotation)
inline

Definition at line 723 of file blobbox.h.

723  {
724  BLOBNBOX_LIST* blobnbox_list[] = {&blobs, &underlines, &noise_blobs,
725  &small_blobs, &large_blobs, nullptr};
726  for (BLOBNBOX_LIST** list = blobnbox_list; *list != nullptr; ++list) {
727  BLOBNBOX_IT it(*list);
728  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
729  it.data()->rotate(rotation);
730  }
731  }
732  // Rotate the block
733  ASSERT_HOST(block->pdblk.poly_block() != nullptr);
734  block->rotate(rotation);
735  // Update the median size statistic from the blobs list.
736  STATS widths(0, block->pdblk.bounding_box().width());
737  STATS heights(0, block->pdblk.bounding_box().height());
738  BLOBNBOX_IT blob_it(&blobs);
739  for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
740  widths.add(blob_it.data()->bounding_box().width(), 1);
741  heights.add(blob_it.data()->bounding_box().height(), 1);
742  }
743  block->set_median_size(static_cast<int>(widths.median() + 0.5),
744  static_cast<int>(heights.median() + 0.5));
745  }
Definition: statistc.h:33
POLY_BLOCK * poly_block() const
Definition: pdblock.h:56
void set_median_size(int x, int y)
Definition: ocrblock.h:157
BLOCK * block
Definition: blobbox.h:790
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
Definition: pdblock.h:60
BLOBNBOX_LIST blobs
Definition: blobbox.h:785
BLOBNBOX_LIST large_blobs
Definition: blobbox.h:789
BLOBNBOX_LIST underlines
Definition: blobbox.h:786
PDBLK pdblk
Definition: ocrblock.h:192
BLOBNBOX_LIST small_blobs
Definition: blobbox.h:788
BLOBNBOX_LIST noise_blobs
Definition: blobbox.h:787
void rotate(const FCOORD &rotation)
Definition: ocrblock.cpp:82
#define ASSERT_HOST(x)
Definition: errcode.h:84

Member Data Documentation

◆ baseline_offset

float TO_BLOCK::baseline_offset

Definition at line 800 of file blobbox.h.

◆ blobs

BLOBNBOX_LIST TO_BLOCK::blobs

Definition at line 785 of file blobbox.h.

◆ block

BLOCK* TO_BLOCK::block

Definition at line 790 of file blobbox.h.

◆ fixed_pitch

float TO_BLOCK::fixed_pitch

Definition at line 802 of file blobbox.h.

◆ fp_nonsp

float TO_BLOCK::fp_nonsp

Definition at line 808 of file blobbox.h.

◆ fp_space

float TO_BLOCK::fp_space

Definition at line 807 of file blobbox.h.

◆ kern_size

float TO_BLOCK::kern_size

Definition at line 803 of file blobbox.h.

◆ key_row

TO_ROW* TO_BLOCK::key_row

Definition at line 811 of file blobbox.h.

◆ large_blobs

BLOBNBOX_LIST TO_BLOCK::large_blobs

Definition at line 789 of file blobbox.h.

◆ line_size

float TO_BLOCK::line_size

Definition at line 798 of file blobbox.h.

◆ line_spacing

float TO_BLOCK::line_spacing

Definition at line 792 of file blobbox.h.

◆ max_blob_size

float TO_BLOCK::max_blob_size

Definition at line 799 of file blobbox.h.

◆ max_nonspace

int32_t TO_BLOCK::max_nonspace

Definition at line 806 of file blobbox.h.

◆ min_space

int32_t TO_BLOCK::min_space

Definition at line 805 of file blobbox.h.

◆ noise_blobs

BLOBNBOX_LIST TO_BLOCK::noise_blobs

Definition at line 787 of file blobbox.h.

◆ pitch_decision

PITCH_TYPE TO_BLOCK::pitch_decision

Definition at line 791 of file blobbox.h.

◆ pr_nonsp

float TO_BLOCK::pr_nonsp

Definition at line 810 of file blobbox.h.

◆ pr_space

float TO_BLOCK::pr_space

Definition at line 809 of file blobbox.h.

◆ small_blobs

BLOBNBOX_LIST TO_BLOCK::small_blobs

Definition at line 788 of file blobbox.h.

◆ space_size

float TO_BLOCK::space_size

Definition at line 804 of file blobbox.h.

◆ underlines

BLOBNBOX_LIST TO_BLOCK::underlines

Definition at line 786 of file blobbox.h.

◆ xheight

float TO_BLOCK::xheight

Definition at line 801 of file blobbox.h.


The documentation for this class was generated from the following files: