tesseract  v4.0.0-17-g361f3264
Open Source OCR Engine
pithsync.h
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  * Created: Thu Nov 19 11:48:05 GMT 1992
6  *
7  * (C) Copyright 1992, 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 PITHSYNC_H
21 #define PITHSYNC_H
22 
23 #include "blobbox.h"
24 #include "params.h"
25 #include "statistc.h"
26 
27 class FPSEGPT_LIST;
28 
29 class FPCUTPT
30 {
31  public:
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  BOOL8 faking, //faking this one
60  BOOL8 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 
94  private:
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 };
105 double 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,
113  float projection_scale,
114  int16_t &occupation_count, //no of occupied cells
115  FPSEGPT_LIST *seg_list, //output list
116  int16_t start, //start of good range
117  int16_t end //end of good range
118  );
119 double check_pitch_sync3( //find segmentation
120  int16_t projection_left, //edges //to be considered 0
121  int16_t projection_right,
122  int16_t zero_count,
123  int16_t pitch, //pitch estimate
124  int16_t pitch_error, //tolerance
125  STATS *projection, //vertical
126  float projection_scale, //scale factor
127  int16_t &occupation_count, //no of occupied cells
128  FPSEGPT_LIST *seg_list, //output list
129  int16_t start, //start of good range
130  int16_t end //end of good range
131  );
132 #endif
double sq_sum
Definition: pithsync.h:102
FPCUTPT * pred
Definition: pithsync.h:100
int16_t fake_count
Definition: pithsync.h:92
int16_t index() const
Definition: pithsync.h:86
int32_t position()
Definition: pithsync.h:68
double cost_function()
Definition: pithsync.h:71
double squares()
Definition: pithsync.h:74
void assign_cheap(FPCUTPT cutpts[], int16_t array_origin, int16_t x, BOOL8 faking, BOOL8 mid_cut, int16_t offset, STATS *projection, float projection_scale, int16_t zero_count, int16_t pitch, int16_t pitch_error)
Definition: pithsync.cpp:202
int16_t cheap_cuts() const
Definition: pithsync.h:83
bool terminal
Definition: pithsync.h:91
Definition: pithsync.h:29
double sum()
Definition: pithsync.h:77
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:37
FPCUTPT * previous()
Definition: pithsync.h:80
uint32_t fwd_balance
Definition: pithsync.h:99
double mean_sum
Definition: pithsync.h:101
int16_t mid_cuts
Definition: pithsync.h:96
double cost
Definition: pithsync.h:103
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:94
int32_t xpos
Definition: pithsync.h:97
Definition: statistc.h:33
uint32_t back_balance
Definition: pithsync.h:98
bool faked
Definition: pithsync.h:90
int16_t region_index
Definition: pithsync.h:95
FPCUTPT()=default