tesseract 4.1.1
Loading...
Searching...
No Matches
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
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
75void extract_edges(Pix* pix, // thresholded image
76 BLOCK* block); // block to scan
77void 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);
82void fill_buckets( //find blobs
83 C_OUTLINE_LIST *outlines, //outlines in block
84 OL_BUCKETS *buckets //output buckets
85 );
86void empty_buckets( //find blobs
87 BLOCK *block, //block to scan
88 OL_BUCKETS *buckets //output buckets
89 );
90bool 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
void extract_edges(Pix *pix, BLOCK *block)
Definition: edgblob.cpp:329
void empty_buckets(BLOCK *block, OL_BUCKETS *buckets)
Definition: edgblob.cpp:393
bool capture_children(OL_BUCKETS *buckets, C_BLOB_IT *reject_it, C_OUTLINE_IT *blob_it)
Definition: edgblob.cpp:435
void fill_buckets(C_OUTLINE_LIST *outlines, OL_BUCKETS *buckets)
Definition: edgblob.cpp:368
void outlines_to_blobs(BLOCK *block, ICOORD bleft, ICOORD tright, C_OUTLINE_LIST *outlines)
Definition: edgblob.cpp:349
Definition: ocrblock.h:31
integer coordinate
Definition: points.h:32
int32_t outline_complexity(C_OUTLINE *outline, int32_t max_count, int16_t depth)
Definition: edgblob.cpp:109
void extract_children(C_OUTLINE *outline, C_OUTLINE_IT *it)
Definition: edgblob.cpp:294
C_OUTLINE_LIST * operator()(int16_t x, int16_t y)
Definition: edgblob.cpp:82
C_OUTLINE_LIST * start_scan()
Definition: edgblob.h:45
~OL_BUCKETS()=default
int32_t count_children(C_OUTLINE *outline, int32_t max_count)
Definition: edgblob.cpp:178
C_OUTLINE_LIST * scan_next()
Definition: edgblob.h:51