Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 "img.h"
26 #include "ocrblock.h"
27 #include "coutln.h"
28 #include "crakedge.h"
29 #include "notdll.h"
30
31 #define BUCKETSIZE 16
32
33 class OL_BUCKETS
34 {
35 public:
36 OL_BUCKETS( //constructor
37 ICOORD bleft, //corners
38 ICOORD tright);
39
40 ~OL_BUCKETS () { //cleanup
41 delete[]buckets;
42 }
43 C_OUTLINE_LIST *operator () (//array access
44 inT16 x, //image coords
45 inT16 y);
46 //first non-empty bucket
47 C_OUTLINE_LIST *start_scan() {
48 for (index = 0; buckets[index].empty () && index < bxdim * bydim - 1;
49 index++);
50 return &buckets[index];
51 }
52 //next non-empty bucket
53 C_OUTLINE_LIST *scan_next() {
54 for (; buckets[index].empty () && index < bxdim * bydim - 1; index++);
55 return &buckets[index];
56 }
57 inT32 count_children( //recursive sum
58 C_OUTLINE *outline, //parent outline
59 inT32 max_count); // max output
60 inT32 outline_complexity( // new version of count_children
61 C_OUTLINE *outline, // parent outline
62 inT32 max_count, // max output
63 inT16 depth); // level of recursion
64 void extract_children( //single level get
65 C_OUTLINE *outline, //parent outline
66 C_OUTLINE_IT *it); //destination iterator
67
68 private:
69 C_OUTLINE_LIST * buckets; //array of buckets
70 inT16 bxdim; //size of array
71 inT16 bydim;
72 ICOORD bl; //corners
73 ICOORD tr;
74 inT32 index; //for extraction scan
75 };
76
77 void extract_edges(Pix* pix, // thresholded image
78 BLOCK* block); // block to scan
79 void outlines_to_blobs( //find blobs
80 BLOCK *block, //block to scan
81 ICOORD bleft, //block box //outlines in block
82 ICOORD tright,
83 C_OUTLINE_LIST *outlines);
84 void fill_buckets( //find blobs
85 C_OUTLINE_LIST *outlines, //outlines in block
86 OL_BUCKETS *buckets //output buckets
87 );
88 void empty_buckets( //find blobs
89 BLOCK *block, //block to scan
90 OL_BUCKETS *buckets //output buckets
91 );
92 BOOL8 capture_children( //find children
93 OL_BUCKETS *buckets, //bucket sort clanss
94 C_BLOB_IT *reject_it, //dead grandchildren
95 C_OUTLINE_IT *blob_it //output outlines
96 );
97 #endif