Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BLOBNBOX Class Reference

#include <blobbox.h>

Inheritance diagram for BLOBNBOX:
ELIST_LINK

Public Member Functions

 BLOBNBOX ()
 
 BLOBNBOX (C_BLOB *srcblob)
 
void rotate (FCOORD rotation)
 
void reflect_box_in_y_axis ()
 
void rotate_box (FCOORD rotation)
 
void translate_box (ICOORD v)
 
void merge (BLOBNBOX *nextblob)
 
void really_merge (BLOBNBOX *other)
 
void chop (BLOBNBOX_IT *start_it, BLOBNBOX_IT *blob_it, FCOORD rotation, float xheight)
 
void NeighbourGaps (int gaps[BND_COUNT]) const
 
void MinMaxGapsClipped (int *h_min, int *h_max, int *v_min, int *v_max) const
 
void CleanNeighbours ()
 
int GoodTextBlob () const
 
int NoisyNeighbours () const
 
bool DeletableNoise () const
 
bool DefiniteIndividualFlow ()
 
bool ConfirmNoTabViolation (const BLOBNBOX &other) const
 
bool MatchingStrokeWidth (const BLOBNBOX &other, double fractional_tolerance, double constant_tolerance) const
 
TBOX BoundsWithinLimits (int left, int right)
 
const TBOXbounding_box () const
 
void set_bounding_box (const TBOX &new_box)
 
void compute_bounding_box ()
 
const TBOXreduced_box () const
 
void set_reduced_box (TBOX new_box)
 
inT32 enclosed_area () const
 
bool joined_to_prev () const
 
bool red_box_set () const
 
int repeated_set () const
 
void set_repeated_set (int set_id)
 
C_BLOBcblob () const
 
TabType left_tab_type () const
 
void set_left_tab_type (TabType new_type)
 
TabType right_tab_type () const
 
void set_right_tab_type (TabType new_type)
 
BlobRegionType region_type () const
 
void set_region_type (BlobRegionType new_type)
 
BlobSpecialTextType special_text_type () const
 
void set_special_text_type (BlobSpecialTextType new_type)
 
BlobTextFlowType flow () const
 
void set_flow (BlobTextFlowType value)
 
bool vert_possible () const
 
void set_vert_possible (bool value)
 
bool horz_possible () const
 
void set_horz_possible (bool value)
 
int left_rule () const
 
void set_left_rule (int new_left)
 
int right_rule () const
 
void set_right_rule (int new_right)
 
int left_crossing_rule () const
 
void set_left_crossing_rule (int new_left)
 
int right_crossing_rule () const
 
void set_right_crossing_rule (int new_right)
 
float horz_stroke_width () const
 
void set_horz_stroke_width (float width)
 
float vert_stroke_width () const
 
void set_vert_stroke_width (float width)
 
float area_stroke_width () const
 
tesseract::ColPartitionowner () const
 
void set_owner (tesseract::ColPartition *new_owner)
 
bool leader_on_left () const
 
void set_leader_on_left (bool flag)
 
bool leader_on_right () const
 
void set_leader_on_right (bool flag)
 
BLOBNBOXneighbour (BlobNeighbourDir n) const
 
bool good_stroke_neighbour (BlobNeighbourDir n) const
 
void set_neighbour (BlobNeighbourDir n, BLOBNBOX *neighbour, bool good)
 
bool IsDiacritic () const
 
int base_char_top () const
 
int base_char_bottom () const
 
int line_crossings () const
 
void set_line_crossings (int value)
 
void set_diacritic_box (const TBOX &diacritic_box)
 
BLOBNBOXbase_char_blob () const
 
void set_base_char_blob (BLOBNBOX *blob)
 
bool UniquelyVertical () const
 
bool UniquelyHorizontal () const
 
ScrollView::Color BoxColor () const
 
void plot (ScrollView *window, ScrollView::Color blob_colour, ScrollView::Color child_colour)
 
void ConstructionInit ()
 
void ReInit ()
 
void ClearNeighbours ()
 
- Public Member Functions inherited from ELIST_LINK
 ELIST_LINK ()
 
 ELIST_LINK (const ELIST_LINK &)
 
void operator= (const ELIST_LINK &)
 

Static Public Member Functions

static BLOBNBOXRealBlob (C_OUTLINE *outline)
 
static bool IsTextType (BlobRegionType type)
 
static bool IsImageType (BlobRegionType type)
 
static bool IsLineType (BlobRegionType type)
 
static bool UnMergeableType (BlobRegionType type)
 
static void CleanNeighbours (BLOBNBOX_LIST *blobs)
 
static void DeleteNoiseBlobs (BLOBNBOX_LIST *blobs)
 
static void PlotBlobs (BLOBNBOX_LIST *list, ScrollView::Color body_colour, ScrollView::Color child_colour, ScrollView *win)
 
static void PlotNoiseBlobs (BLOBNBOX_LIST *list, ScrollView::Color body_colour, ScrollView::Color child_colour, ScrollView *win)
 
static ScrollView::Color TextlineColor (BlobRegionType region_type, BlobTextFlowType flow_type)
 

Detailed Description

Definition at line 128 of file blobbox.h.

Constructor & Destructor Documentation

BLOBNBOX::BLOBNBOX ( )
inline

Definition at line 131 of file blobbox.h.

131  {
133  }
void ConstructionInit()
Definition: blobbox.h:439
BLOBNBOX::BLOBNBOX ( C_BLOB srcblob)
inlineexplicit

Definition at line 134 of file blobbox.h.

134  {
135  box = srcblob->bounding_box();
137  cblob_ptr = srcblob;
138  area = static_cast<int>(srcblob->area());
139  }
void ConstructionInit()
Definition: blobbox.h:439
inT32 area()
Definition: stepblob.cpp:211
TBOX bounding_box()
Definition: stepblob.cpp:192

Member Function Documentation

float BLOBNBOX::area_stroke_width ( ) const
inline

Definition at line 326 of file blobbox.h.

326  {
327  return area_stroke_width_;
328  }
BLOBNBOX* BLOBNBOX::base_char_blob ( ) const
inline

Definition at line 376 of file blobbox.h.

376  {
377  return base_char_blob_;
378  }
int BLOBNBOX::base_char_bottom ( ) const
inline

Definition at line 363 of file blobbox.h.

363  {
364  return base_char_bottom_;
365  }
int BLOBNBOX::base_char_top ( ) const
inline

Definition at line 360 of file blobbox.h.

360  {
361  return base_char_top_;
362  }
const TBOX& BLOBNBOX::bounding_box ( ) const
inline

Definition at line 208 of file blobbox.h.

208  {
209  return box;
210  }
TBOX BLOBNBOX::BoundsWithinLimits ( int  left,
int  right 
)

Definition at line 323 of file blobbox.cpp.

323  {
324  FCOORD no_rotation(1.0f, 0.0f);
325  float top = box.top();
326  float bottom = box.bottom();
327  if (cblob_ptr != NULL) {
328  find_cblob_limits(cblob_ptr, static_cast<float>(left),
329  static_cast<float>(right), no_rotation,
330  bottom, top);
331  }
332 
333  if (top < bottom) {
334  top = box.top();
335  bottom = box.bottom();
336  }
337  FCOORD bot_left(left, bottom);
338  FCOORD top_right(right, top);
339  TBOX shrunken_box(bot_left);
340  TBOX shrunken_box2(top_right);
341  shrunken_box += shrunken_box2;
342  return shrunken_box;
343 }
#define NULL
Definition: host.h:144
Definition: rect.h:29
#define f(xc, yc)
Definition: imgscale.cpp:39
inT16 top() const
Definition: rect.h:53
Definition: points.h:189
void find_cblob_limits(C_BLOB *blob, float leftx, float rightx, FCOORD rotation, float &ymin, float &ymax)
Definition: blobbox.cpp:448
size_t top
Definition: tessarray.h:52
inT16 bottom() const
Definition: rect.h:60
ScrollView::Color BLOBNBOX::BoxColor ( ) const

Definition at line 430 of file blobbox.cpp.

430  {
431  return TextlineColor(region_type_, flow_);
432 }
static ScrollView::Color TextlineColor(BlobRegionType region_type, BlobTextFlowType flow_type)
Definition: blobbox.cpp:393
C_BLOB* BLOBNBOX::cblob ( ) const
inline

Definition at line 245 of file blobbox.h.

245  {
246  return cblob_ptr;
247  }
void BLOBNBOX::chop ( BLOBNBOX_IT *  start_it,
BLOBNBOX_IT *  blob_it,
FCOORD  rotation,
float  xheight 
)

Definition at line 111 of file blobbox.cpp.

116  {
117  inT16 blobcount; //no of blobs
118  BLOBNBOX *newblob; //fake blob
119  BLOBNBOX *blob; //current blob
120  inT16 blobindex; //number of chop
121  inT16 leftx; //left edge of blob
122  float blobwidth; //width of each
123  float rightx; //right edge to scan
124  float ymin, ymax; //limits of new blob
125  float test_ymin, test_ymax; //limits of part blob
126  ICOORD bl, tr; //corners of box
127  BLOBNBOX_IT blob_it; //blob iterator
128 
129  //get no of chops
130  blobcount = (inT16) floor (box.width () / xheight);
131  if (blobcount > 1 && cblob_ptr != NULL) {
132  //width of each
133  blobwidth = (float) (box.width () + 1) / blobcount;
134  for (blobindex = blobcount - 1, rightx = box.right ();
135  blobindex >= 0; blobindex--, rightx -= blobwidth) {
136  ymin = (float) MAX_INT32;
137  ymax = (float) -MAX_INT32;
138  blob_it = *start_it;
139  do {
140  blob = blob_it.data ();
141  find_cblob_vlimits(blob->cblob_ptr, rightx - blobwidth,
142  rightx,
143  /*rotation, */ test_ymin, test_ymax);
144  blob_it.forward ();
145  UpdateRange(test_ymin, test_ymax, &ymin, &ymax);
146  }
147  while (blob != end_it->data ());
148  if (ymin < ymax) {
149  leftx = (inT16) floor (rightx - blobwidth);
150  if (leftx < box.left ())
151  leftx = box.left (); //clip to real box
152  bl = ICOORD (leftx, (inT16) floor (ymin));
153  tr = ICOORD ((inT16) ceil (rightx), (inT16) ceil (ymax));
154  if (blobindex == 0)
155  box = TBOX (bl, tr); //change box
156  else {
157  newblob = new BLOBNBOX;
158  //box is all it has
159  newblob->box = TBOX (bl, tr);
160  //stay on current
161  newblob->base_char_top_ = tr.y();
162  newblob->base_char_bottom_ = bl.y();
163  end_it->add_after_stay_put (newblob);
164  }
165  }
166  }
167  }
168 }
void find_cblob_vlimits(C_BLOB *blob, float leftx, float rightx, float &ymin, float &ymax)
Definition: blobbox.cpp:488
#define NULL
Definition: host.h:144
inT16 left() const
Definition: rect.h:67
inT16 width() const
Definition: rect.h:104
Definition: rect.h:29
inT16 right() const
Definition: rect.h:74
inT16 y() const
access_function
Definition: points.h:56
#define MAX_INT32
Definition: host.h:120
short inT16
Definition: host.h:100
integer coordinate
Definition: points.h:30
BLOBNBOX()
Definition: blobbox.h:131
void UpdateRange(const T1 &x, T2 *lower_bound, T2 *upper_bound)
Definition: helpers.h:74
void BLOBNBOX::CleanNeighbours ( )

Definition at line 205 of file blobbox.cpp.

205  {
206  for (int dir = 0; dir < BND_COUNT; ++dir) {
207  BLOBNBOX* neighbour = neighbours_[dir];
208  if (neighbour != NULL && neighbour->DeletableNoise()) {
209  neighbours_[dir] = NULL;
210  good_stroke_neighbours_[dir] = false;
211  }
212  }
213 }
bool DeletableNoise() const
Definition: blobbox.h:185
#define NULL
Definition: host.h:144
BLOBNBOX * neighbour(BlobNeighbourDir n) const
Definition: blobbox.h:347
void BLOBNBOX::CleanNeighbours ( BLOBNBOX_LIST *  blobs)
static

Definition at line 346 of file blobbox.cpp.

346  {
347  BLOBNBOX_IT blob_it(blobs);
348  for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
349  blob_it.data()->CleanNeighbours();
350  }
351 }
void BLOBNBOX::ClearNeighbours ( )
inline

Definition at line 476 of file blobbox.h.

476  {
477  for (int n = 0; n < BND_COUNT; ++n) {
478  neighbours_[n] = NULL;
479  good_stroke_neighbours_[n] = false;
480  }
481  }
#define NULL
Definition: host.h:144
void BLOBNBOX::compute_bounding_box ( )
inline

Definition at line 218 of file blobbox.h.

218  {
219  box = cblob_ptr->bounding_box();
220  base_char_top_ = box.top();
221  base_char_bottom_ = box.bottom();
222  }
inT16 top() const
Definition: rect.h:53
TBOX bounding_box()
Definition: stepblob.cpp:192
inT16 bottom() const
Definition: rect.h:60
bool BLOBNBOX::ConfirmNoTabViolation ( const BLOBNBOX other) const

Definition at line 282 of file blobbox.cpp.

282  {
283  if (box.left() < other.box.left() && box.left() < other.left_rule_)
284  return false;
285  if (other.box.left() < box.left() && other.box.left() < left_rule_)
286  return false;
287  if (box.right() > other.box.right() && box.right() > other.right_rule_)
288  return false;
289  if (other.box.right() > box.right() && other.box.right() > right_rule_)
290  return false;
291  return true;
292 }
inT16 left() const
Definition: rect.h:67
inT16 right() const
Definition: rect.h:74
void BLOBNBOX::ConstructionInit ( )
inline

Definition at line 439 of file blobbox.h.

439  {
440  cblob_ptr = NULL;
441  area = 0;
442  area_stroke_width_ = 0.0f;
443  horz_stroke_width_ = 0.0f;
444  vert_stroke_width_ = 0.0f;
445  ReInit();
446  }
#define NULL
Definition: host.h:144
void ReInit()
Definition: blobbox.h:449
bool BLOBNBOX::DefiniteIndividualFlow ( )

Definition at line 243 of file blobbox.cpp.

243  {
244  int box_perimeter = 2 * (box.height() + box.width());
245  if (box.width() > box.height() * kDefiniteAspectRatio) {
246  // Attempt to distinguish a wide joined word from a dash.
247  // If it is a dash, then its perimeter is approximately
248  // 2 * (box width + stroke width), but more if the outline is noisy,
249  // so perimeter - 2*(box width + stroke width) should be close to zero.
250  // A complex shape such as a joined word should have a much larger value.
251  int perimeter = cblob()->perimeter();
252  if (vert_stroke_width() > 0)
253  perimeter -= 2 * vert_stroke_width();
254  else
255  perimeter -= 4 * cblob()->area() / perimeter;
256  perimeter -= 2 * box.width();
257  // Use a multiple of the box perimeter as a threshold.
258  if (perimeter > kComplexShapePerimeterRatio * box_perimeter) {
259  set_vert_possible(false);
260  set_horz_possible(true);
261  return true;
262  }
263  }
264  if (box.height() > box.width() * kDefiniteAspectRatio) {
265  // As above, but for a putative vertical word vs a I/1/l.
266  int perimeter = cblob()->perimeter();
267  if (horz_stroke_width() > 0)
268  perimeter -= 2 * horz_stroke_width();
269  else
270  perimeter -= 4 * cblob()->area() / perimeter;
271  perimeter -= 2 * box.height();
272  if (perimeter > kComplexShapePerimeterRatio * box_perimeter) {
273  set_vert_possible(true);
274  set_horz_possible(false);
275  return true;
276  }
277  }
278  return false;
279 }
C_BLOB * cblob() const
Definition: blobbox.h:245
inT16 width() const
Definition: rect.h:104
float vert_stroke_width() const
Definition: blobbox.h:320
const double kComplexShapePerimeterRatio
Definition: blobbox.cpp:39
inT32 area()
Definition: stepblob.cpp:211
inT32 perimeter()
Definition: stepblob.cpp:230
float horz_stroke_width() const
Definition: blobbox.h:314
const double kDefiniteAspectRatio
Definition: blobbox.cpp:37
void set_vert_possible(bool value)
Definition: blobbox.h:281
void set_horz_possible(bool value)
Definition: blobbox.h:287
inT16 height() const
Definition: rect.h:97
bool BLOBNBOX::DeletableNoise ( ) const
inline

Definition at line 185 of file blobbox.h.

185  {
186  return owner() == NULL && region_type() == BRT_NOISE;
187  }
BlobRegionType region_type() const
Definition: blobbox.h:260
#define NULL
Definition: host.h:144
tesseract::ColPartition * owner() const
Definition: blobbox.h:329
void BLOBNBOX::DeleteNoiseBlobs ( BLOBNBOX_LIST *  blobs)
static

Definition at line 354 of file blobbox.cpp.

354  {
355  BLOBNBOX_IT blob_it(blobs);
356  for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
357  BLOBNBOX* blob = blob_it.data();
358  if (blob->DeletableNoise()) {
359  delete blob->cblob();
360  delete blob_it.extract();
361  }
362  }
363 }
bool DeletableNoise() const
Definition: blobbox.h:185
C_BLOB * cblob() const
Definition: blobbox.h:245
inT32 BLOBNBOX::enclosed_area ( ) const
inline

Definition at line 230 of file blobbox.h.

230  {
231  return area;
232  }
BlobTextFlowType BLOBNBOX::flow ( ) const
inline

Definition at line 272 of file blobbox.h.

272  {
273  return flow_;
274  }
bool BLOBNBOX::good_stroke_neighbour ( BlobNeighbourDir  n) const
inline

Definition at line 350 of file blobbox.h.

350  {
351  return good_stroke_neighbours_[n];
352  }
int BLOBNBOX::GoodTextBlob ( ) const

Definition at line 217 of file blobbox.cpp.

217  {
218  int score = 0;
219  for (int dir = 0; dir < BND_COUNT; ++dir) {
220  BlobNeighbourDir bnd = static_cast<BlobNeighbourDir>(dir);
221  if (good_stroke_neighbour(bnd))
222  ++score;
223  }
224  return score;
225 }
BlobNeighbourDir
Definition: blobbox.h:72
bool good_stroke_neighbour(BlobNeighbourDir n) const
Definition: blobbox.h:350
bool BLOBNBOX::horz_possible ( ) const
inline

Definition at line 284 of file blobbox.h.

284  {
285  return horz_possible_;
286  }
float BLOBNBOX::horz_stroke_width ( ) const
inline

Definition at line 314 of file blobbox.h.

314  {
315  return horz_stroke_width_;
316  }
bool BLOBNBOX::IsDiacritic ( ) const
inline

Definition at line 357 of file blobbox.h.

357  {
358  return base_char_top_ != box.top() || base_char_bottom_ != box.bottom();
359  }
inT16 top() const
Definition: rect.h:53
inT16 bottom() const
Definition: rect.h:60
static bool BLOBNBOX::IsImageType ( BlobRegionType  type)
inlinestatic

Definition at line 395 of file blobbox.h.

395  {
396  return type == BRT_RECTIMAGE || type == BRT_POLYIMAGE;
397  }
static bool BLOBNBOX::IsLineType ( BlobRegionType  type)
inlinestatic

Definition at line 399 of file blobbox.h.

399  {
400  return type == BRT_HLINE || type == BRT_VLINE;
401  }
static bool BLOBNBOX::IsTextType ( BlobRegionType  type)
inlinestatic

Definition at line 391 of file blobbox.h.

391  {
392  return type == BRT_TEXT || type == BRT_VERT_TEXT;
393  }
bool BLOBNBOX::joined_to_prev ( ) const
inline

Definition at line 233 of file blobbox.h.

233  {
234  return joined != 0;
235  }
bool BLOBNBOX::leader_on_left ( ) const
inline

Definition at line 335 of file blobbox.h.

335  {
336  return leader_on_left_;
337  }
bool BLOBNBOX::leader_on_right ( ) const
inline

Definition at line 341 of file blobbox.h.

341  {
342  return leader_on_right_;
343  }
int BLOBNBOX::left_crossing_rule ( ) const
inline

Definition at line 302 of file blobbox.h.

302  {
303  return left_crossing_rule_;
304  }
int BLOBNBOX::left_rule ( ) const
inline

Definition at line 290 of file blobbox.h.

290  {
291  return left_rule_;
292  }
TabType BLOBNBOX::left_tab_type ( ) const
inline

Definition at line 248 of file blobbox.h.

248  {
249  return left_tab_type_;
250  }
int BLOBNBOX::line_crossings ( ) const
inline

Definition at line 366 of file blobbox.h.

366  {
367  return line_crossings_;
368  }
bool BLOBNBOX::MatchingStrokeWidth ( const BLOBNBOX other,
double  fractional_tolerance,
double  constant_tolerance 
) const

Definition at line 295 of file blobbox.cpp.

297  {
298  // The perimeter-based width is used as a backup in case there is
299  // no information in the blob.
300  double p_width = area_stroke_width();
301  double n_p_width = other.area_stroke_width();
302  float h_tolerance = horz_stroke_width_ * fractional_tolerance
303  + constant_tolerance;
304  float v_tolerance = vert_stroke_width_ * fractional_tolerance
305  + constant_tolerance;
306  double p_tolerance = p_width * fractional_tolerance
307  + constant_tolerance;
308  bool h_zero = horz_stroke_width_ == 0.0f || other.horz_stroke_width_ == 0.0f;
309  bool v_zero = vert_stroke_width_ == 0.0f || other.vert_stroke_width_ == 0.0f;
310  bool h_ok = !h_zero && NearlyEqual(horz_stroke_width_,
311  other.horz_stroke_width_, h_tolerance);
312  bool v_ok = !v_zero && NearlyEqual(vert_stroke_width_,
313  other.vert_stroke_width_, v_tolerance);
314  bool p_ok = h_zero && v_zero && NearlyEqual(p_width, n_p_width, p_tolerance);
315  // For a match, at least one of the horizontal and vertical widths
316  // must match, and the other one must either match or be zero.
317  // Only if both are zero will we look at the perimeter metric.
318  return p_ok || ((v_ok || h_ok) && (h_ok || h_zero) && (v_ok || v_zero));
319 }
float area_stroke_width() const
Definition: blobbox.h:326
bool NearlyEqual(T x, T y, T tolerance)
Definition: host.h:148
void BLOBNBOX::merge ( BLOBNBOX nextblob)

Definition at line 83 of file blobbox.cpp.

85  {
86  box += nextblob->box; //merge boxes
87  set_diacritic_box(box);
88  nextblob->joined = TRUE;
89 }
void set_diacritic_box(const TBOX &diacritic_box)
Definition: blobbox.h:372
#define TRUE
Definition: capi.h:27
void BLOBNBOX::MinMaxGapsClipped ( int *  h_min,
int *  h_max,
int *  v_min,
int *  v_max 
) const

Definition at line 191 of file blobbox.cpp.

192  {
193  int max_dimension = MAX(box.width(), box.height());
194  int gaps[BND_COUNT];
195  NeighbourGaps(gaps);
196  *h_min = MIN(gaps[BND_LEFT], gaps[BND_RIGHT]);
197  *h_max = MAX(gaps[BND_LEFT], gaps[BND_RIGHT]);
198  if (*h_max > max_dimension && *h_min < max_dimension) *h_max = *h_min;
199  *v_min = MIN(gaps[BND_ABOVE], gaps[BND_BELOW]);
200  *v_max = MAX(gaps[BND_ABOVE], gaps[BND_BELOW]);
201  if (*v_max > max_dimension && *v_min < max_dimension) *v_max = *v_min;
202 }
void NeighbourGaps(int gaps[BND_COUNT]) const
Definition: blobbox.cpp:172
inT16 width() const
Definition: rect.h:104
#define MIN(x, y)
Definition: ndminx.h:28
#define MAX(x, y)
Definition: ndminx.h:24
inT16 height() const
Definition: rect.h:97
BLOBNBOX* BLOBNBOX::neighbour ( BlobNeighbourDir  n) const
inline

Definition at line 347 of file blobbox.h.

347  {
348  return neighbours_[n];
349  }
void BLOBNBOX::NeighbourGaps ( int  gaps[BND_COUNT]) const

Definition at line 172 of file blobbox.cpp.

172  {
173  for (int dir = 0; dir < BND_COUNT; ++dir) {
174  gaps[dir] = MAX_INT16;
175  BLOBNBOX* neighbour = neighbours_[dir];
176  if (neighbour != NULL) {
177  TBOX n_box = neighbour->bounding_box();
178  if (dir == BND_LEFT || dir == BND_RIGHT) {
179  gaps[dir] = box.x_gap(n_box);
180  } else {
181  gaps[dir] = box.y_gap(n_box);
182  }
183  }
184  }
185 }
const TBOX & bounding_box() const
Definition: blobbox.h:208
#define NULL
Definition: host.h:144
Definition: rect.h:29
int y_gap(const TBOX &box) const
Definition: rect.h:218
int x_gap(const TBOX &box) const
Definition: rect.h:210
#define MAX_INT16
Definition: host.h:119
BLOBNBOX * neighbour(BlobNeighbourDir n) const
Definition: blobbox.h:347
int BLOBNBOX::NoisyNeighbours ( ) const

Definition at line 228 of file blobbox.cpp.

228  {
229  int count = 0;
230  for (int dir = 0; dir < BND_COUNT; ++dir) {
231  BlobNeighbourDir bnd = static_cast<BlobNeighbourDir>(dir);
232  BLOBNBOX* blob = neighbour(bnd);
233  if (blob != NULL && blob->region_type() == BRT_NOISE)
234  ++count;
235  }
236  return count;
237 }
BlobRegionType region_type() const
Definition: blobbox.h:260
#define NULL
Definition: host.h:144
BlobNeighbourDir
Definition: blobbox.h:72
BLOBNBOX * neighbour(BlobNeighbourDir n) const
Definition: blobbox.h:347
int count(LIST var_list)
Definition: oldlist.cpp:108
tesseract::ColPartition* BLOBNBOX::owner ( ) const
inline

Definition at line 329 of file blobbox.h.

329  {
330  return owner_;
331  }
void BLOBNBOX::plot ( ScrollView window,
ScrollView::Color  blob_colour,
ScrollView::Color  child_colour 
)

Definition at line 434 of file blobbox.cpp.

436  { // for holes
437  if (cblob_ptr != NULL)
438  cblob_ptr->plot(window, blob_colour, child_colour);
439 }
#define NULL
Definition: host.h:144
void plot(ScrollView *window, ScrollView::Color blob_colour, ScrollView::Color child_colour)
Definition: stepblob.cpp:376
void BLOBNBOX::PlotBlobs ( BLOBNBOX_LIST *  list,
ScrollView::Color  body_colour,
ScrollView::Color  child_colour,
ScrollView win 
)
static

Definition at line 368 of file blobbox.cpp.

371  {
372  BLOBNBOX_IT it(list);
373  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
374  it.data()->plot(win, body_colour, child_colour);
375  }
376 }
void BLOBNBOX::PlotNoiseBlobs ( BLOBNBOX_LIST *  list,
ScrollView::Color  body_colour,
ScrollView::Color  child_colour,
ScrollView win 
)
static

Definition at line 381 of file blobbox.cpp.

384  {
385  BLOBNBOX_IT it(list);
386  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
387  BLOBNBOX* blob = it.data();
388  if (blob->DeletableNoise())
389  blob->plot(win, body_colour, child_colour);
390  }
391 }
bool DeletableNoise() const
Definition: blobbox.h:185
void plot(ScrollView *window, ScrollView::Color blob_colour, ScrollView::Color child_colour)
Definition: blobbox.cpp:434
static BLOBNBOX* BLOBNBOX::RealBlob ( C_OUTLINE outline)
inlinestatic

Definition at line 140 of file blobbox.h.

140  {
141  C_BLOB* blob = new C_BLOB(outline);
142  return new BLOBNBOX(blob);
143  }
BLOBNBOX()
Definition: blobbox.h:131
void BLOBNBOX::really_merge ( BLOBNBOX other)

Definition at line 94 of file blobbox.cpp.

94  {
95  if (cblob_ptr != NULL && other->cblob_ptr != NULL) {
96  C_OUTLINE_IT ol_it(cblob_ptr->out_list());
97  ol_it.add_list_after(other->cblob_ptr->out_list());
98  }
100 }
void compute_bounding_box()
Definition: blobbox.h:218
C_OUTLINE_LIST * out_list()
Definition: stepblob.h:42
#define NULL
Definition: host.h:144
bool BLOBNBOX::red_box_set ( ) const
inline

Definition at line 236 of file blobbox.h.

236  {
237  return reduced != 0;
238  }
const TBOX& BLOBNBOX::reduced_box ( ) const
inline

Definition at line 223 of file blobbox.h.

223  {
224  return red_box;
225  }
void BLOBNBOX::reflect_box_in_y_axis ( )

Definition at line 53 of file blobbox.cpp.

53  {
54  int left = -box.right();
55  box.set_right(-box.left());
56  box.set_left(left);
57 }
void set_right(int x)
Definition: rect.h:77
inT16 left() const
Definition: rect.h:67
inT16 right() const
Definition: rect.h:74
void set_left(int x)
Definition: rect.h:70
BlobRegionType BLOBNBOX::region_type ( ) const
inline

Definition at line 260 of file blobbox.h.

260  {
261  return region_type_;
262  }
void BLOBNBOX::ReInit ( )
inline

Definition at line 449 of file blobbox.h.

449  {
450  joined = false;
451  reduced = false;
452  repeated_set_ = 0;
453  left_tab_type_ = TT_NONE;
454  right_tab_type_ = TT_NONE;
455  region_type_ = BRT_UNKNOWN;
456  flow_ = BTFT_NONE;
457  spt_type_ = BSTT_SKIP;
458  left_rule_ = 0;
459  right_rule_ = 0;
460  left_crossing_rule_ = 0;
461  right_crossing_rule_ = 0;
462  if (area_stroke_width_ == 0.0f && area > 0 && cblob() != NULL)
463  area_stroke_width_ = 2.0f * area / cblob()->perimeter();
464  owner_ = NULL;
465  base_char_top_ = box.top();
466  base_char_bottom_ = box.bottom();
467  line_crossings_ = 0;
468  base_char_blob_ = NULL;
469  horz_possible_ = false;
470  vert_possible_ = false;
471  leader_on_left_ = false;
472  leader_on_right_ = false;
473  ClearNeighbours();
474  }
C_BLOB * cblob() const
Definition: blobbox.h:245
#define NULL
Definition: host.h:144
#define f(xc, yc)
Definition: imgscale.cpp:39
inT16 top() const
Definition: rect.h:53
inT32 perimeter()
Definition: stepblob.cpp:230
void ClearNeighbours()
Definition: blobbox.h:476
inT16 bottom() const
Definition: rect.h:60
int BLOBNBOX::repeated_set ( ) const
inline

Definition at line 239 of file blobbox.h.

239  {
240  return repeated_set_;
241  }
int BLOBNBOX::right_crossing_rule ( ) const
inline

Definition at line 308 of file blobbox.h.

308  {
309  return right_crossing_rule_;
310  }
int BLOBNBOX::right_rule ( ) const
inline

Definition at line 296 of file blobbox.h.

296  {
297  return right_rule_;
298  }
TabType BLOBNBOX::right_tab_type ( ) const
inline

Definition at line 254 of file blobbox.h.

254  {
255  return right_tab_type_;
256  }
void BLOBNBOX::rotate ( FCOORD  rotation)

Definition at line 46 of file blobbox.cpp.

46  {
47  cblob_ptr->rotate(rotation);
48  rotate_box(rotation);
50 }
void compute_bounding_box()
Definition: blobbox.h:218
void rotate_box(FCOORD rotation)
Definition: blobbox.cpp:62
void rotate(const FCOORD &rotation)
Definition: stepblob.cpp:328
void BLOBNBOX::rotate_box ( FCOORD  rotation)

Definition at line 62 of file blobbox.cpp.

62  {
63  if (IsDiacritic()) {
64  ASSERT_HOST(rotation.x() >= kCosSmallAngle)
65  ICOORD top_pt((box.left() + box.right()) / 2, base_char_top_);
66  ICOORD bottom_pt(top_pt.x(), base_char_bottom_);
67  top_pt.rotate(rotation);
68  base_char_top_ = top_pt.y();
69  bottom_pt.rotate(rotation);
70  base_char_bottom_ = bottom_pt.y();
71  box.rotate(rotation);
72  } else {
73  box.rotate(rotation);
74  set_diacritic_box(box);
75  }
76 }
void rotate(const FCOORD &vec)
Definition: ipoints.h:241
void set_diacritic_box(const TBOX &diacritic_box)
Definition: blobbox.h:372
inT16 left() const
Definition: rect.h:67
inT16 right() const
Definition: rect.h:74
bool IsDiacritic() const
Definition: blobbox.h:357
integer coordinate
Definition: points.h:30
void rotate(const FCOORD &vec)
Definition: rect.h:182
#define ASSERT_HOST(x)
Definition: errcode.h:84
float x() const
Definition: points.h:209
void BLOBNBOX::set_base_char_blob ( BLOBNBOX blob)
inline

Definition at line 379 of file blobbox.h.

379  {
380  base_char_blob_ = blob;
381  }
void BLOBNBOX::set_bounding_box ( const TBOX new_box)
inline

Definition at line 213 of file blobbox.h.

213  {
214  box = new_box;
215  base_char_top_ = box.top();
216  base_char_bottom_ = box.bottom();
217  }
inT16 top() const
Definition: rect.h:53
inT16 bottom() const
Definition: rect.h:60
void BLOBNBOX::set_diacritic_box ( const TBOX diacritic_box)
inline

Definition at line 372 of file blobbox.h.

372  {
373  base_char_top_ = diacritic_box.top();
374  base_char_bottom_ = diacritic_box.bottom();
375  }
inT16 top() const
Definition: rect.h:53
inT16 bottom() const
Definition: rect.h:60
void BLOBNBOX::set_flow ( BlobTextFlowType  value)
inline

Definition at line 275 of file blobbox.h.

275  {
276  flow_ = value;
277  }
void BLOBNBOX::set_horz_possible ( bool  value)
inline

Definition at line 287 of file blobbox.h.

287  {
288  horz_possible_ = value;
289  }
void BLOBNBOX::set_horz_stroke_width ( float  width)
inline

Definition at line 317 of file blobbox.h.

317  {
318  horz_stroke_width_ = width;
319  }
void BLOBNBOX::set_leader_on_left ( bool  flag)
inline

Definition at line 338 of file blobbox.h.

338  {
339  leader_on_left_ = flag;
340  }
void BLOBNBOX::set_leader_on_right ( bool  flag)
inline

Definition at line 344 of file blobbox.h.

344  {
345  leader_on_right_ = flag;
346  }
void BLOBNBOX::set_left_crossing_rule ( int  new_left)
inline

Definition at line 305 of file blobbox.h.

305  {
306  left_crossing_rule_ = new_left;
307  }
void BLOBNBOX::set_left_rule ( int  new_left)
inline

Definition at line 293 of file blobbox.h.

293  {
294  left_rule_ = new_left;
295  }
void BLOBNBOX::set_left_tab_type ( TabType  new_type)
inline

Definition at line 251 of file blobbox.h.

251  {
252  left_tab_type_ = new_type;
253  }
void BLOBNBOX::set_line_crossings ( int  value)
inline

Definition at line 369 of file blobbox.h.

369  {
370  line_crossings_ = value;
371  }
void BLOBNBOX::set_neighbour ( BlobNeighbourDir  n,
BLOBNBOX neighbour,
bool  good 
)
inline

Definition at line 353 of file blobbox.h.

353  {
354  neighbours_[n] = neighbour;
355  good_stroke_neighbours_[n] = good;
356  }
BLOBNBOX * neighbour(BlobNeighbourDir n) const
Definition: blobbox.h:347
void BLOBNBOX::set_owner ( tesseract::ColPartition new_owner)
inline

Definition at line 332 of file blobbox.h.

332  {
333  owner_ = new_owner;
334  }
void BLOBNBOX::set_reduced_box ( TBOX  new_box)
inline

Definition at line 226 of file blobbox.h.

226  {
227  red_box = new_box;
228  reduced = TRUE;
229  }
#define TRUE
Definition: capi.h:27
void BLOBNBOX::set_region_type ( BlobRegionType  new_type)
inline

Definition at line 263 of file blobbox.h.

263  {
264  region_type_ = new_type;
265  }
void BLOBNBOX::set_repeated_set ( int  set_id)
inline

Definition at line 242 of file blobbox.h.

242  {
243  repeated_set_ = set_id;
244  }
void BLOBNBOX::set_right_crossing_rule ( int  new_right)
inline

Definition at line 311 of file blobbox.h.

311  {
312  right_crossing_rule_ = new_right;
313  }
void BLOBNBOX::set_right_rule ( int  new_right)
inline

Definition at line 299 of file blobbox.h.

299  {
300  right_rule_ = new_right;
301  }
void BLOBNBOX::set_right_tab_type ( TabType  new_type)
inline

Definition at line 257 of file blobbox.h.

257  {
258  right_tab_type_ = new_type;
259  }
void BLOBNBOX::set_special_text_type ( BlobSpecialTextType  new_type)
inline

Definition at line 269 of file blobbox.h.

269  {
270  spt_type_ = new_type;
271  }
void BLOBNBOX::set_vert_possible ( bool  value)
inline

Definition at line 281 of file blobbox.h.

281  {
282  vert_possible_ = value;
283  }
void BLOBNBOX::set_vert_stroke_width ( float  width)
inline

Definition at line 323 of file blobbox.h.

323  {
324  vert_stroke_width_ = width;
325  }
BlobSpecialTextType BLOBNBOX::special_text_type ( ) const
inline

Definition at line 266 of file blobbox.h.

266  {
267  return spt_type_;
268  }
ScrollView::Color BLOBNBOX::TextlineColor ( BlobRegionType  region_type,
BlobTextFlowType  flow_type 
)
static

Definition at line 393 of file blobbox.cpp.

394  {
395  switch (region_type) {
396  case BRT_HLINE:
397  return ScrollView::BROWN;
398  case BRT_VLINE:
399  return ScrollView::DARK_GREEN;
400  case BRT_RECTIMAGE:
401  return ScrollView::RED;
402  case BRT_POLYIMAGE:
403  return ScrollView::ORANGE;
404  case BRT_UNKNOWN:
405  return flow_type == BTFT_NONTEXT ? ScrollView::CYAN : ScrollView::WHITE;
406  case BRT_VERT_TEXT:
407  if (flow_type == BTFT_STRONG_CHAIN || flow_type == BTFT_TEXT_ON_IMAGE)
408  return ScrollView::GREEN;
409  if (flow_type == BTFT_CHAIN)
410  return ScrollView::LIME_GREEN;
411  return ScrollView::YELLOW;
412  case BRT_TEXT:
413  if (flow_type == BTFT_STRONG_CHAIN)
414  return ScrollView::BLUE;
415  if (flow_type == BTFT_TEXT_ON_IMAGE)
416  return ScrollView::LIGHT_BLUE;
417  if (flow_type == BTFT_CHAIN)
419  if (flow_type == BTFT_LEADER)
420  return ScrollView::WHEAT;
421  if (flow_type == BTFT_NONTEXT)
422  return ScrollView::PINK;
423  return ScrollView::MAGENTA;
424  default:
425  return ScrollView::GREY;
426  }
427 }
BlobRegionType region_type() const
Definition: blobbox.h:260
void BLOBNBOX::translate_box ( ICOORD  v)
inline

Definition at line 156 of file blobbox.h.

156  {
157  if (IsDiacritic()) {
158  box.move(v);
159  base_char_top_ += v.y();
160  base_char_bottom_ += v.y();
161  } else {
162  box.move(v);
163  set_diacritic_box(box);
164  }
165  }
void set_diacritic_box(const TBOX &diacritic_box)
Definition: blobbox.h:372
inT16 y() const
access_function
Definition: points.h:56
bool IsDiacritic() const
Definition: blobbox.h:357
void move(const ICOORD vec)
Definition: rect.h:146
bool BLOBNBOX::UniquelyHorizontal ( ) const
inline

Definition at line 386 of file blobbox.h.

386  {
387  return horz_possible_ && !vert_possible_;
388  }
bool BLOBNBOX::UniquelyVertical ( ) const
inline

Definition at line 383 of file blobbox.h.

383  {
384  return vert_possible_ && !horz_possible_;
385  }
static bool BLOBNBOX::UnMergeableType ( BlobRegionType  type)
inlinestatic

Definition at line 403 of file blobbox.h.

403  {
404  return IsLineType(type) || IsImageType(type);
405  }
static bool IsLineType(BlobRegionType type)
Definition: blobbox.h:399
static bool IsImageType(BlobRegionType type)
Definition: blobbox.h:395
bool BLOBNBOX::vert_possible ( ) const
inline

Definition at line 278 of file blobbox.h.

278  {
279  return vert_possible_;
280  }
float BLOBNBOX::vert_stroke_width ( ) const
inline

Definition at line 320 of file blobbox.h.

320  {
321  return vert_stroke_width_;
322  }

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