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