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