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