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