tesseract v5.3.3.20231005
pithsync.h
Go to the documentation of this file.
1/**********************************************************************
2 * File: pithsync.h (Formerly pitsync2.h)
3 * Description: Code to find the optimum fixed pitch segmentation of some blobs.
4 * Author: Ray Smith
5 *
6 * (C) Copyright 1992, 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 PITHSYNC_H
20#define PITHSYNC_H
21
22#include "blobbox.h"
23#include "params.h"
24#include "statistc.h"
25
26namespace tesseract {
27
28class FPSEGPT_LIST;
29
30class FPCUTPT {
31public:
32 FPCUTPT() = default;
33 void setup( // start of cut
34 FPCUTPT cutpts[], // predecessors
35 int16_t array_origin, // start coord
36 STATS *projection, // occupation
37 int16_t zero_count, // official zero
38 int16_t pitch, // proposed pitch
39 int16_t x, // position
40 int16_t offset); // dist to gap
41
42 void assign( // evaluate cut
43 FPCUTPT cutpts[], // predecessors
44 int16_t array_origin, // start coord
45 int16_t x, // position
46 bool faking, // faking this one
47 bool mid_cut, // doing free cut
48 int16_t offset, // extra cost dist
49 STATS *projection, // occupation
50 float projection_scale, // scaling
51 int16_t zero_count, // official zero
52 int16_t pitch, // proposed pitch
53 int16_t pitch_error); // allowed tolerance
54
55 void assign_cheap( // evaluate cut
56 FPCUTPT cutpts[], // predecessors
57 int16_t array_origin, // start coord
58 int16_t x, // position
59 bool faking, // faking this one
60 bool mid_cut, // doing free cut
61 int16_t offset, // extra cost dist
62 STATS *projection, // occupation
63 float projection_scale, // scaling
64 int16_t zero_count, // official zero
65 int16_t pitch, // proposed pitch
66 int16_t pitch_error); // allowed tolerance
67
68 int32_t position() { // access func
69 return xpos;
70 }
71 double cost_function() {
72 return cost;
73 }
74 double squares() {
75 return sq_sum;
76 }
77 double sum() {
78 return mean_sum;
79 }
81 return pred;
82 }
83 int16_t cheap_cuts() const { // no of mi cuts
84 return mid_cuts;
85 }
86 int16_t index() const {
87 return region_index;
88 }
89
90 bool faked; // faked split point
91 bool terminal; // successful end
92 int16_t fake_count; // total fakes to here
93
94private:
95 int16_t region_index; // cut serial number
96 int16_t mid_cuts; // no of cheap cuts
97 int32_t xpos; // location
98 uint32_t back_balance; // proj backwards
99 uint32_t fwd_balance; // proj forwards
100 FPCUTPT *pred; // optimal previous
101 double mean_sum; // mean so far
102 double sq_sum; // summed distsances
103 double cost; // cost function
104};
105double check_pitch_sync2( // find segmentation
106 BLOBNBOX_IT *blob_it, // blobs to do
107 int16_t blob_count, // no of blobs
108 int16_t pitch, // pitch estimate
109 int16_t pitch_error, // tolerance
110 STATS *projection, // vertical
111 int16_t projection_left, // edges //scale factor
112 int16_t projection_right, float projection_scale,
113 int16_t &occupation_count, // no of occupied cells
114 FPSEGPT_LIST *seg_list, // output list
115 int16_t start, // start of good range
116 int16_t end // end of good range
117);
118double check_pitch_sync3( // find segmentation
119 int16_t projection_left, // edges //to be considered 0
120 int16_t projection_right, int16_t zero_count,
121 int16_t pitch, // pitch estimate
122 int16_t pitch_error, // tolerance
123 STATS *projection, // vertical
124 float projection_scale, // scale factor
125 int16_t &occupation_count, // no of occupied cells
126 FPSEGPT_LIST *seg_list, // output list
127 int16_t start, // start of good range
128 int16_t end // end of good range
129);
130
131} // namespace tesseract
132
133#endif
double check_pitch_sync2(BLOBNBOX_IT *blob_it, int16_t blob_count, int16_t pitch, int16_t pitch_error, STATS *projection, int16_t projection_left, int16_t projection_right, float projection_scale, int16_t &occupation_count, FPSEGPT_LIST *seg_list, int16_t start, int16_t end)
Definition: pithsync.cpp:292
double check_pitch_sync3(int16_t projection_left, int16_t projection_right, int16_t zero_count, int16_t pitch, int16_t pitch_error, STATS *projection, float projection_scale, int16_t &occupation_count, FPSEGPT_LIST *seg_list, int16_t start, int16_t end)
Definition: pithsync.cpp:484
void assign(FPCUTPT cutpts[], int16_t array_origin, int16_t x, bool faking, bool mid_cut, int16_t offset, STATS *projection, float projection_scale, int16_t zero_count, int16_t pitch, int16_t pitch_error)
Definition: pithsync.cpp:97
double cost_function()
Definition: pithsync.h:71
double sum()
Definition: pithsync.h:77
int16_t cheap_cuts() const
Definition: pithsync.h:83
int32_t position()
Definition: pithsync.h:68
void setup(FPCUTPT cutpts[], int16_t array_origin, STATS *projection, int16_t zero_count, int16_t pitch, int16_t x, int16_t offset)
Definition: pithsync.cpp:38
int16_t index() const
Definition: pithsync.h:86
int16_t fake_count
Definition: pithsync.h:92
void assign_cheap(FPCUTPT cutpts[], int16_t array_origin, int16_t x, bool faking, bool mid_cut, int16_t offset, STATS *projection, float projection_scale, int16_t zero_count, int16_t pitch, int16_t pitch_error)
Definition: pithsync.cpp:199
double squares()
Definition: pithsync.h:74
FPCUTPT * previous()
Definition: pithsync.h:80