tesseract  5.0.0
tesseract::TO_BLOCK Class Reference

#include <blobbox.h>

Inheritance diagram for tesseract::TO_BLOCK:
tesseract::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 (Image thresholds, Image grey)
 
void plot_noise_blobs (ScrollView *to_win)
 
void plot_graded_blobs (ScrollView *to_win)
 
- Public Member Functions inherited from tesseract::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 698 of file blobbox.h.

Constructor & Destructor Documentation

◆ TO_BLOCK() [1/2]

tesseract::TO_BLOCK::TO_BLOCK ( )
inline

Definition at line 700 of file blobbox.h.

701  clear();
702  } // empty
@ PITCH_DUNNO
Definition: blobbox.h:48
PITCH_TYPE pitch_decision
Definition: blobbox.h:782

◆ TO_BLOCK() [2/2]

tesseract::TO_BLOCK::TO_BLOCK ( BLOCK src_block)

Definition at line 923 of file blobbox.cpp.

925  {
926  clear();
927  block = src_block;
928 }

◆ ~TO_BLOCK()

tesseract::TO_BLOCK::~TO_BLOCK ( )

Definition at line 955 of file blobbox.cpp.

955  {
956  // Any residual BLOBNBOXes at this stage own their blobs, so delete them.
962 }
static void clear_blobnboxes(BLOBNBOX_LIST *boxes)
Definition: blobbox.h:158
BLOBNBOX_LIST underlines
Definition: blobbox.h:777
BLOBNBOX_LIST blobs
Definition: blobbox.h:776
BLOBNBOX_LIST small_blobs
Definition: blobbox.h:779
BLOBNBOX_LIST large_blobs
Definition: blobbox.h:780
BLOBNBOX_LIST noise_blobs
Definition: blobbox.h:778

Member Function Documentation

◆ clear()

void tesseract::TO_BLOCK::clear ( )

Definition at line 935 of file blobbox.cpp.

935  {
936  block = nullptr;
938  line_spacing = 0.0;
939  line_size = 0.0;
940  max_blob_size = 0.0;
941  baseline_offset = 0.0;
942  xheight = 0.0;
943  fixed_pitch = 0.0;
944  kern_size = 0.0;
945  space_size = 0.0;
946  min_space = 0;
947  max_nonspace = 0;
948  fp_space = 0.0;
949  fp_nonsp = 0.0;
950  pr_space = 0.0;
951  pr_nonsp = 0.0;
952  key_row = nullptr;
953 }
float baseline_offset
Definition: blobbox.h:791
TO_ROW * key_row
Definition: blobbox.h:802
int32_t min_space
Definition: blobbox.h:796
int32_t max_nonspace
Definition: blobbox.h:797

◆ ComputeEdgeOffsets()

void tesseract::TO_BLOCK::ComputeEdgeOffsets ( Image  thresholds,
Image  grey 
)

Definition at line 1042 of file blobbox.cpp.

1042  {
1043  BLOBNBOX::ComputeEdgeOffsets(thresholds, grey, &blobs);
1044  BLOBNBOX::ComputeEdgeOffsets(thresholds, grey, &small_blobs);
1045  BLOBNBOX::ComputeEdgeOffsets(thresholds, grey, &noise_blobs);
1046 }
static void ComputeEdgeOffsets(Image thresholds, Image grey, BLOBNBOX_LIST *blobs)
Definition: blobbox.cpp:390

◆ DeleteUnownedNoise()

void tesseract::TO_BLOCK::DeleteUnownedNoise ( )

◆ get_rows()

TO_ROW_LIST* tesseract::TO_BLOCK::get_rows ( )
inline

Definition at line 709 of file blobbox.h.

709  { // access function
710  return &row_list;
711  }

◆ plot_graded_blobs()

void tesseract::TO_BLOCK::plot_graded_blobs ( ScrollView to_win)

◆ plot_noise_blobs()

void tesseract::TO_BLOCK::plot_noise_blobs ( ScrollView to_win)

Definition at line 1050 of file blobbox.cpp.

1050  {
1055 }
static void PlotNoiseBlobs(BLOBNBOX_LIST *list, ScrollView::Color body_colour, ScrollView::Color child_colour, ScrollView *win)
Definition: blobbox.cpp:431

◆ print_rows()

void tesseract::TO_BLOCK::print_rows ( )
inline

Definition at line 739 of file blobbox.h.

739  { // debug info
740  TO_ROW_IT row_it = &row_list;
741  for (row_it.mark_cycle_pt(); !row_it.cycled_list(); row_it.forward()) {
742  auto row = row_it.data();
743  tprintf("Row range (%g,%g), para_c=%g, blobcount=%" PRId32 "\n",
744  static_cast<double>(row->min_y()),
745  static_cast<double>(row->max_y()),
746  static_cast<double>(row->parallel_c()),
747  row->blob_list()->length());
748  }
749  }
void tprintf(const char *format,...)
Definition: tprintf.cpp:41

◆ ReSetAndReFilterBlobs()

void tesseract::TO_BLOCK::ReSetAndReFilterBlobs ( )

Definition at line 998 of file blobbox.cpp.

998  {
999  int min_height = IntCastRounded(kMinMediumSizeRatio * line_size);
1000  int max_height = IntCastRounded(kMaxMediumSizeRatio * line_size);
1001  BLOBNBOX_LIST noise_list;
1002  BLOBNBOX_LIST small_list;
1003  BLOBNBOX_LIST medium_list;
1004  BLOBNBOX_LIST large_list;
1005  SizeFilterBlobs(min_height, max_height, &blobs, &noise_list, &small_list, &medium_list,
1006  &large_list);
1007  SizeFilterBlobs(min_height, max_height, &large_blobs, &noise_list, &small_list, &medium_list,
1008  &large_list);
1009  SizeFilterBlobs(min_height, max_height, &small_blobs, &noise_list, &small_list, &medium_list,
1010  &large_list);
1011  SizeFilterBlobs(min_height, max_height, &noise_blobs, &noise_list, &small_list, &medium_list,
1012  &large_list);
1013  BLOBNBOX_IT blob_it(&blobs);
1014  blob_it.add_list_after(&medium_list);
1015  blob_it.set_to_list(&large_blobs);
1016  blob_it.add_list_after(&large_list);
1017  blob_it.set_to_list(&small_blobs);
1018  blob_it.add_list_after(&small_list);
1019  blob_it.set_to_list(&noise_blobs);
1020  blob_it.add_list_after(&noise_list);
1021 }
int IntCastRounded(double x)
Definition: helpers.h:175
const double kMaxMediumSizeRatio
Definition: blobbox.cpp:52
const double kMinMediumSizeRatio
Definition: blobbox.cpp:50

◆ rotate()

void tesseract::TO_BLOCK::rotate ( const FCOORD rotation)
inline

Definition at line 715 of file blobbox.h.

715  {
716  BLOBNBOX_LIST *blobnbox_list[] = {&blobs, &underlines, &noise_blobs,
717  &small_blobs, &large_blobs, nullptr};
718  for (BLOBNBOX_LIST **list = blobnbox_list; *list != nullptr; ++list) {
719  BLOBNBOX_IT it(*list);
720  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
721  it.data()->rotate(rotation);
722  }
723  }
724  // Rotate the block
725  ASSERT_HOST(block->pdblk.poly_block() != nullptr);
726  block->rotate(rotation);
727  // Update the median size statistic from the blobs list.
728  STATS widths(0, block->pdblk.bounding_box().width());
729  STATS heights(0, block->pdblk.bounding_box().height());
730  BLOBNBOX_IT blob_it(&blobs);
731  for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
732  widths.add(blob_it.data()->bounding_box().width(), 1);
733  heights.add(blob_it.data()->bounding_box().height(), 1);
734  }
735  block->set_median_size(static_cast<int>(widths.median() + 0.5),
736  static_cast<int>(heights.median() + 0.5));
737  }
#define ASSERT_HOST(x)
Definition: errcode.h:59
void rotate(const FCOORD &rotation)
Definition: ocrblock.cpp:81
PDBLK pdblk
Page Description Block.
Definition: ocrblock.h:185
void set_median_size(int x, int y)
Definition: ocrblock.h:150
POLY_BLOCK * poly_block() const
Definition: pdblock.h:59
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
Definition: pdblock.h:67

Member Data Documentation

◆ baseline_offset

float tesseract::TO_BLOCK::baseline_offset

Definition at line 791 of file blobbox.h.

◆ blobs

BLOBNBOX_LIST tesseract::TO_BLOCK::blobs

Definition at line 776 of file blobbox.h.

◆ block

BLOCK* tesseract::TO_BLOCK::block

Definition at line 781 of file blobbox.h.

◆ fixed_pitch

float tesseract::TO_BLOCK::fixed_pitch

Definition at line 793 of file blobbox.h.

◆ fp_nonsp

float tesseract::TO_BLOCK::fp_nonsp

Definition at line 799 of file blobbox.h.

◆ fp_space

float tesseract::TO_BLOCK::fp_space

Definition at line 798 of file blobbox.h.

◆ kern_size

float tesseract::TO_BLOCK::kern_size

Definition at line 794 of file blobbox.h.

◆ key_row

TO_ROW* tesseract::TO_BLOCK::key_row

Definition at line 802 of file blobbox.h.

◆ large_blobs

BLOBNBOX_LIST tesseract::TO_BLOCK::large_blobs

Definition at line 780 of file blobbox.h.

◆ line_size

float tesseract::TO_BLOCK::line_size

Definition at line 789 of file blobbox.h.

◆ line_spacing

float tesseract::TO_BLOCK::line_spacing

Definition at line 783 of file blobbox.h.

◆ max_blob_size

float tesseract::TO_BLOCK::max_blob_size

Definition at line 790 of file blobbox.h.

◆ max_nonspace

int32_t tesseract::TO_BLOCK::max_nonspace

Definition at line 797 of file blobbox.h.

◆ min_space

int32_t tesseract::TO_BLOCK::min_space

Definition at line 796 of file blobbox.h.

◆ noise_blobs

BLOBNBOX_LIST tesseract::TO_BLOCK::noise_blobs

Definition at line 778 of file blobbox.h.

◆ pitch_decision

PITCH_TYPE tesseract::TO_BLOCK::pitch_decision

Definition at line 782 of file blobbox.h.

◆ pr_nonsp

float tesseract::TO_BLOCK::pr_nonsp

Definition at line 801 of file blobbox.h.

◆ pr_space

float tesseract::TO_BLOCK::pr_space

Definition at line 800 of file blobbox.h.

◆ small_blobs

BLOBNBOX_LIST tesseract::TO_BLOCK::small_blobs

Definition at line 779 of file blobbox.h.

◆ space_size

float tesseract::TO_BLOCK::space_size

Definition at line 795 of file blobbox.h.

◆ underlines

BLOBNBOX_LIST tesseract::TO_BLOCK::underlines

Definition at line 777 of file blobbox.h.

◆ xheight

float tesseract::TO_BLOCK::xheight

Definition at line 792 of file blobbox.h.


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