tesseract  5.0.0-alpha-619-ge9db
pitsync1.h
Go to the documentation of this file.
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  bool 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  }
60  FPSEGPT *previous() {
61  return pred;
62  }
63  int16_t cheap_cuts() const { //no of cheap cuts
64  return mid_cuts;
65  }
66 
67  bool faked; //faked split point
68  bool terminal; //successful end
69  int16_t fake_count; //total fakes to here
70 
71  private:
72  int16_t mid_cuts; //no of cheap cuts
73  int32_t xpos; //location
74  FPSEGPT *pred; //optimal previous
75  double mean_sum; //mean so far
76  double sq_sum; //summed distsances
77  double cost; //cost function
78 };
79 
80 ELISTIZEH (FPSEGPT) CLISTIZEH (FPSEGPT_LIST)
81 extern
82 INT_VAR_H (pitsync_linear_version, 0, "Use new fast algorithm");
83 extern
85 "Dist inside big blob for chopping");
86 extern
88 "Fraction of cut for free cuts");
89 extern
90 INT_VAR_H (pitsync_fake_depth, 1, "Max advance fake generation");
91 double check_pitch_sync( //find segmentation
92  BLOBNBOX_IT *blob_it, //blobs to do
93  int16_t blob_count, //no of blobs
94  int16_t pitch, //pitch estimate
95  int16_t pitch_error, //tolerance
96  STATS *projection, //vertical
97  FPSEGPT_LIST *seg_list //output list
98  );
99 void make_illegal_segment( //find segmentation
100  FPSEGPT_LIST *prev_list, //previous segments
101  TBOX blob_box, //bounding box
102  BLOBNBOX_IT blob_it, //iterator
103  int16_t region_index, //number of segment
104  int16_t pitch, //pitch estimate
105  int16_t pitch_error, //tolerance
106  FPSEGPT_LIST *seg_list //output list
107  );
108 int16_t vertical_torow_projection( //project whole row
109  TO_ROW *row, //row to do
110  STATS *projection //output
111  );
112 void vertical_cblob_projection( //project outlines
113  C_BLOB *blob, //blob to project
114  STATS *stats //output
115  );
116 void vertical_coutline_projection( //project outlines
117  C_OUTLINE *outline, //outline to project
118  STATS *stats //output
119  );
120 #endif
elst.h
pithsync.h
FPSEGPT::faked
bool faked
Definition: pitsync1.h:66
FPSEGPT::terminal
bool terminal
Definition: pitsync1.h:67
blobbox.h
params.h
FPSEGPT::fake_count
int16_t fake_count
Definition: pitsync1.h:68
pitsync_joined_edge
double pitsync_joined_edge
Definition: pitsync1.cpp:25
FPSEGPT::FPSEGPT
FPSEGPT()=default
pitsync_offset_freecut_fraction
double pitsync_offset_freecut_fraction
Definition: pitsync1.cpp:27
make_illegal_segment
void make_illegal_segment(FPSEGPT_LIST *prev_list, TBOX blob_box, BLOBNBOX_IT blob_it, int16_t region_index, int16_t pitch, int16_t pitch_error, FPSEGPT_LIST *seg_list)
Definition: pitsync1.cpp:355
FPSEGPT::squares
double squares()
Definition: pitsync1.h:53
FPSEGPT::position
int32_t position()
Definition: pitsync1.h:47
double_VAR_H
#define double_VAR_H(name, val, comment)
Definition: params.h:298
C_BLOB
Definition: stepblob.h:36
C_OUTLINE
Definition: coutln.h:71
FPSEGPT::cost_function
double cost_function()
Definition: pitsync1.h:50
statistc.h
FPSEGPT::cheap_cuts
int16_t cheap_cuts() const
Definition: pitsync1.h:62
FPSEGPT::sum
double sum()
Definition: pitsync1.h:56
CLISTIZEH
CLISTIZEH(STRING) CLISTIZE(STRING) namespace tesseract
Definition: reject.cpp:50
FPCUTPT
Definition: pithsync.h:27
vertical_coutline_projection
void vertical_coutline_projection(C_OUTLINE *outline, STATS *stats)
Definition: blobbox.cpp:873
INT_VAR_H
#define INT_VAR_H(name, val, comment)
Definition: params.h:292
ELISTIZEH
ELISTIZEH(FPSEGPT) CLISTIZEH(FPSEGPT_LIST) extern int pitsync_linear_version=0
STATS
Definition: statistc.h:30
pitsync_fake_depth
int pitsync_fake_depth
Definition: pitsync1.cpp:28
FPSEGPT::previous
FPSEGPT * previous()
Definition: pitsync1.h:59
check_pitch_sync
double check_pitch_sync(BLOBNBOX_IT *blob_it, int16_t blob_count, int16_t pitch, int16_t pitch_error, STATS *projection, FPSEGPT_LIST *seg_list)
Definition: pitsync1.cpp:138
TO_ROW
Definition: blobbox.h:543
ELIST_LINK
Definition: elst.h:74
FPSEGPT
Definition: pitsync1.h:31
vertical_cblob_projection
void vertical_cblob_projection(C_BLOB *blob, STATS *stats)
Definition: blobbox.cpp:854
vertical_torow_projection
int16_t vertical_torow_projection(TO_ROW *row, STATS *projection)
clst.h
TBOX
Definition: rect.h:33