tesseract  v4.0.0-17-g361f3264
Open Source OCR Engine
edgblob.h
1 /**********************************************************************
2  * File: edgblob.h (Formerly edgeloop.h)
3  * Description: Functions to clean up an outline before approximation.
4  * Author: Ray Smith
5  *
6  * (C) Copyright 1991, Hewlett-Packard Ltd.
7  ** Licensed under the Apache License, Version 2.0 (the "License");
8  ** you may not use this file except in compliance with the License.
9  ** You may obtain a copy of the License at
10  ** http://www.apache.org/licenses/LICENSE-2.0
11  ** Unless required by applicable law or agreed to in writing, software
12  ** distributed under the License is distributed on an "AS IS" BASIS,
13  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  ** See the License for the specific language governing permissions and
15  ** limitations under the License.
16  *
17  **********************************************************************/
18 
19 #ifndef EDGBLOB_H
20 #define EDGBLOB_H
21 
22 #include "scrollview.h"
23 #include "params.h"
24 #include "ocrblock.h"
25 #include "coutln.h"
26 #include "crakedge.h"
27 
28 #include <memory>
29 
30 #define BUCKETSIZE 16
31 
33 {
34  public:
35  OL_BUCKETS( //constructor
36  ICOORD bleft, //corners
37  ICOORD tright);
38 
39  ~OL_BUCKETS () = default;
40 
41  C_OUTLINE_LIST *operator () (//array access
42  int16_t x, //image coords
43  int16_t y);
44  //first non-empty bucket
45  C_OUTLINE_LIST *start_scan() {
46  for (index = 0; buckets[index].empty () && index < bxdim * bydim - 1;
47  index++);
48  return &buckets[index];
49  }
50  //next non-empty bucket
51  C_OUTLINE_LIST *scan_next() {
52  for (; buckets[index].empty () && index < bxdim * bydim - 1; index++);
53  return &buckets[index];
54  }
55  int32_t count_children( //recursive sum
56  C_OUTLINE *outline, //parent outline
57  int32_t max_count); // max output
58  int32_t outline_complexity( // new version of count_children
59  C_OUTLINE *outline, // parent outline
60  int32_t max_count, // max output
61  int16_t depth); // level of recursion
62  void extract_children( //single level get
63  C_OUTLINE *outline, //parent outline
64  C_OUTLINE_IT *it); //destination iterator
65 
66  private:
67  std::unique_ptr<C_OUTLINE_LIST[]> buckets; //array of buckets
68  int16_t bxdim; //size of array
69  int16_t bydim;
70  ICOORD bl; //corners
72  int32_t index; //for extraction scan
73 };
74 
75 void extract_edges(Pix* pix, // thresholded image
76  BLOCK* block); // block to scan
77 void outlines_to_blobs( //find blobs
78  BLOCK *block, //block to scan
79  ICOORD bleft, //block box //outlines in block
80  ICOORD tright,
81  C_OUTLINE_LIST *outlines);
82 void fill_buckets( //find blobs
83  C_OUTLINE_LIST *outlines, //outlines in block
84  OL_BUCKETS *buckets //output buckets
85  );
86 void empty_buckets( //find blobs
87  BLOCK *block, //block to scan
88  OL_BUCKETS *buckets //output buckets
89  );
90 bool capture_children( //find children
91  OL_BUCKETS* buckets, //bucket sort clanss
92  C_BLOB_IT* reject_it, //dead grandchildren
93  C_OUTLINE_IT* blob_it //output outlines
94 );
95 #endif
Definition: edgblob.h:32
int32_t count_children(C_OUTLINE *outline, int32_t max_count)
Definition: edgblob.cpp:183
int32_t outline_complexity(C_OUTLINE *outline, int32_t max_count, int16_t depth)
Definition: edgblob.cpp:114
int16_t bydim
Definition: edgblob.h:69
ICOORD bl
Definition: edgblob.h:70
ICOORD tr
Definition: edgblob.h:71
C_OUTLINE_LIST * operator()(int16_t x, int16_t y)
Definition: edgblob.cpp:87
std::unique_ptr< C_OUTLINE_LIST[]> buckets
Definition: edgblob.h:67
void extract_children(C_OUTLINE *outline, C_OUTLINE_IT *it)
Definition: edgblob.cpp:299
int32_t index
Definition: edgblob.h:72
Definition: ocrblock.h:30
~OL_BUCKETS()=default
int16_t bxdim
Definition: edgblob.h:68
OL_BUCKETS(ICOORD bleft, ICOORD tright)
Definition: edgblob.cpp:68
C_OUTLINE_LIST * scan_next()
Definition: edgblob.h:51
integer coordinate
Definition: points.h:32
C_OUTLINE_LIST * start_scan()
Definition: edgblob.h:45
Definition: coutln.h:72