tesseract  v4.0.0-17-g361f3264
Open Source OCR Engine
pitsync1.h
1 /**********************************************************************
2  * File: pitsync1.h (Formerly pitsync.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 PITSYNC1_H
21 #define PITSYNC1_H
22 
23 #include "elst.h"
24 #include "clst.h"
25 #include "blobbox.h"
26 #include "params.h"
27 #include "statistc.h"
28 #include "pithsync.h"
29 
30 class FPSEGPT_LIST;
31 
32 class FPSEGPT:public ELIST_LINK
33 {
34  public:
35  FPSEGPT() = default;
36  FPSEGPT( //constructor
37  int16_t x); //position
38  FPSEGPT( //constructor
39  int16_t x, //position
40  BOOL8 faking, //faking this one
41  int16_t offset, //extra cost dist
42  int16_t region_index, //segment number
43  int16_t pitch, //proposed pitch
44  int16_t pitch_error, //allowed tolerance
45  FPSEGPT_LIST *prev_list); //previous segment
46  FPSEGPT(FPCUTPT *cutpt); //build from new type
47 
48  int32_t position() { // access func
49  return xpos;
50  }
51  double cost_function() {
52  return cost;
53  }
54  double squares() {
55  return sq_sum;
56  }
57  double sum() {
58  return mean_sum;
59  }
61  return pred;
62  }
63  int16_t cheap_cuts() const { //no of cheap cuts
64  return mid_cuts;
65  }
66 
67  //faked split point
68  BOOL8 faked;
69  BOOL8 terminal; //successful end
70  int16_t fake_count; //total fakes to here
71 
72  private:
73  int16_t mid_cuts; //no of cheap cuts
74  int32_t xpos; //location
75  FPSEGPT *pred; //optimal previous
76  double mean_sum; //mean so far
77  double sq_sum; //summed distsances
78  double cost; //cost function
79 };
80 
81 ELISTIZEH (FPSEGPT) CLISTIZEH (FPSEGPT_LIST)
82 extern
83 INT_VAR_H (pitsync_linear_version, 0, "Use new fast algorithm");
84 extern
85 double_VAR_H (pitsync_joined_edge, 0.75,
86 "Dist inside big blob for chopping");
87 extern
88 double_VAR_H (pitsync_offset_freecut_fraction, 0.25,
89 "Fraction of cut for free cuts");
90 extern
91 INT_VAR_H (pitsync_fake_depth, 1, "Max advance fake generation");
92 double check_pitch_sync( //find segmentation
93  BLOBNBOX_IT *blob_it, //blobs to do
94  int16_t blob_count, //no of blobs
95  int16_t pitch, //pitch estimate
96  int16_t pitch_error, //tolerance
97  STATS *projection, //vertical
98  FPSEGPT_LIST *seg_list //output list
99  );
100 void make_illegal_segment( //find segmentation
101  FPSEGPT_LIST *prev_list, //previous segments
102  TBOX blob_box, //bounding box
103  BLOBNBOX_IT blob_it, //iterator
104  int16_t region_index, //number of segment
105  int16_t pitch, //pitch estimate
106  int16_t pitch_error, //tolerance
107  FPSEGPT_LIST *seg_list //output list
108  );
109 int16_t vertical_torow_projection( //project whole row
110  TO_ROW *row, //row to do
111  STATS *projection //output
112  );
113 void vertical_cblob_projection( //project outlines
114  C_BLOB *blob, //blob to project
115  STATS *stats //output
116  );
117 void vertical_coutline_projection( //project outlines
118  C_OUTLINE *outline, //outline to project
119  STATS *stats //output
120  );
121 #endif
int32_t position()
Definition: pitsync1.h:48
FPSEGPT * previous()
Definition: pitsync1.h:60
double cost_function()
Definition: pitsync1.h:51
double sum()
Definition: pitsync1.h:57
Definition: rect.h:34
FPSEGPT()=default
double cost
Definition: pitsync1.h:78
FPSEGPT * pred
Definition: pitsync1.h:75
Definition: pithsync.h:29
BOOL8 terminal
Definition: pitsync1.h:69
int32_t xpos
Definition: pitsync1.h:74
int16_t mid_cuts
Definition: pitsync1.h:73
Definition: stepblob.h:37
double squares()
Definition: pitsync1.h:54
Definition: blobbox.h:556
Definition: statistc.h:33
int16_t fake_count
Definition: pitsync1.h:70
BOOL8 faked
Definition: pitsync1.h:68
double sq_sum
Definition: pitsync1.h:77
int16_t cheap_cuts() const
Definition: pitsync1.h:63
Definition: pitsync1.h:32
Definition: coutln.h:72
double mean_sum
Definition: pitsync1.h:76