tesseract  5.0.0-alpha-619-ge9db
edgblob.h
Go to the documentation of this file.
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 
32 class OL_BUCKETS
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
71  ICOORD tr;
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
outlines_to_blobs
void outlines_to_blobs(BLOCK *block, ICOORD bleft, ICOORD tright, C_OUTLINE_LIST *outlines)
Definition: edgblob.cpp:349
params.h
ICOORD
integer coordinate
Definition: points.h:30
OL_BUCKETS
Definition: edgblob.h:31
OL_BUCKETS::outline_complexity
int32_t outline_complexity(C_OUTLINE *outline, int32_t max_count, int16_t depth)
Definition: edgblob.cpp:109
C_OUTLINE
Definition: coutln.h:71
OL_BUCKETS::~OL_BUCKETS
~OL_BUCKETS()=default
OL_BUCKETS::operator()
C_OUTLINE_LIST * operator()(int16_t x, int16_t y)
Definition: edgblob.cpp:82
BLOCK
Definition: ocrblock.h:28
empty_buckets
void empty_buckets(BLOCK *block, OL_BUCKETS *buckets)
Definition: edgblob.cpp:393
coutln.h
OL_BUCKETS::count_children
int32_t count_children(C_OUTLINE *outline, int32_t max_count)
Definition: edgblob.cpp:178
OL_BUCKETS::start_scan
C_OUTLINE_LIST * start_scan()
Definition: edgblob.h:44
capture_children
bool capture_children(OL_BUCKETS *buckets, C_BLOB_IT *reject_it, C_OUTLINE_IT *blob_it)
Definition: edgblob.cpp:435
OL_BUCKETS::scan_next
C_OUTLINE_LIST * scan_next()
Definition: edgblob.h:50
ocrblock.h
crakedge.h
OL_BUCKETS::OL_BUCKETS
OL_BUCKETS(ICOORD bleft, ICOORD tright)
Definition: edgblob.cpp:63
OL_BUCKETS::extract_children
void extract_children(C_OUTLINE *outline, C_OUTLINE_IT *it)
Definition: edgblob.cpp:294
scrollview.h
fill_buckets
void fill_buckets(C_OUTLINE_LIST *outlines, OL_BUCKETS *buckets)
Definition: edgblob.cpp:368
extract_edges
void extract_edges(Pix *pix, BLOCK *block)
Definition: edgblob.cpp:329