tesseract  4.00.00dev
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  * Created: Tue Mar 26 16:56:25 GMT 1991
6  *
7  * (C) Copyright 1991, Hewlett-Packard Ltd.
8  ** Licensed under the Apache License, Version 2.0 (the "License");
9  ** you may not use this file except in compliance with the License.
10  ** You may obtain a copy of the License at
11  ** http://www.apache.org/licenses/LICENSE-2.0
12  ** Unless required by applicable law or agreed to in writing, software
13  ** distributed under the License is distributed on an "AS IS" BASIS,
14  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  ** See the License for the specific language governing permissions and
16  ** limitations under the License.
17  *
18  **********************************************************************/
19 
20 #ifndef EDGBLOB_H
21 #define EDGBLOB_H
22 
23 #include "scrollview.h"
24 #include "params.h"
25 #include "ocrblock.h"
26 #include "coutln.h"
27 #include "crakedge.h"
28 
29 #define BUCKETSIZE 16
30 
32 {
33  public:
34  OL_BUCKETS( //constructor
35  ICOORD bleft, //corners
36  ICOORD tright);
37 
38  ~OL_BUCKETS () { //cleanup
39  delete[]buckets;
40  }
41  C_OUTLINE_LIST *operator () (//array access
42  inT16 x, //image coords
43  inT16 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 count_children( //recursive sum
56  C_OUTLINE *outline, //parent outline
57  inT32 max_count); // max output
58  inT32 outline_complexity( // new version of count_children
59  C_OUTLINE *outline, // parent outline
60  inT32 max_count, // max output
61  inT16 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  C_OUTLINE_LIST * buckets; //array of buckets
68  inT16 bxdim; //size of array
69  inT16 bydim;
70  ICOORD bl; //corners
71  ICOORD tr;
72  inT32 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 BOOL8 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
int32_t inT32
Definition: host.h:38
void extract_edges(Pix *pix, BLOCK *block)
Definition: edgblob.cpp:334
C_OUTLINE_LIST * scan_next()
Definition: edgblob.h:51
void outlines_to_blobs(BLOCK *block, ICOORD bleft, ICOORD tright, C_OUTLINE_LIST *outlines)
Definition: edgblob.cpp:354
void fill_buckets(C_OUTLINE_LIST *outlines, OL_BUCKETS *buckets)
Definition: edgblob.cpp:373
int16_t inT16
Definition: host.h:36
void empty_buckets(BLOCK *block, OL_BUCKETS *buckets)
Definition: edgblob.cpp:398
unsigned char BOOL8
Definition: host.h:44
~OL_BUCKETS()
Definition: edgblob.h:38
inT32 outline_complexity(C_OUTLINE *outline, inT32 max_count, inT16 depth)
Definition: edgblob.cpp:114
C_OUTLINE_LIST * operator()(inT16 x, inT16 y)
Definition: edgblob.cpp:87
void extract_children(C_OUTLINE *outline, C_OUTLINE_IT *it)
Definition: edgblob.cpp:299
C_OUTLINE_LIST * start_scan()
Definition: edgblob.h:45
Definition: ocrblock.h:30
integer coordinate
Definition: points.h:30
BOOL8 capture_children(OL_BUCKETS *buckets, C_BLOB_IT *reject_it, C_OUTLINE_IT *blob_it)
Definition: edgblob.cpp:440
inT32 count_children(C_OUTLINE *outline, inT32 max_count)
Definition: edgblob.cpp:183
OL_BUCKETS(ICOORD bleft, ICOORD tright)
Definition: edgblob.cpp:68