tesseract 4.1.1
Loading...
Searching...
No Matches
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 *
6 * (C) Copyright 1992, Hewlett-Packard Ltd.
7 ** Licensed under the Apache License, Version 2.0 (the "License");
8 ** you may not use this file except in compliance with the License.
9 ** You may obtain a copy of the License at
10 ** http://www.apache.org/licenses/LICENSE-2.0
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 *
17 **********************************************************************/
18
19#ifndef PITHSYNC_H
20#define PITHSYNC_H
21
22#include "blobbox.h"
23#include "params.h"
24#include "statistc.h"
25
26class FPSEGPT_LIST;
27
29{
30 public:
31 FPCUTPT() = default;
32 void setup ( //start of cut
33 FPCUTPT cutpts[], //predecessors
34 int16_t array_origin, //start coord
35 STATS * projection, //occupation
36 int16_t zero_count, //official zero
37 int16_t pitch, //proposed pitch
38 int16_t x, //position
39 int16_t offset); //dist to gap
40
41 void assign( //evaluate cut
42 FPCUTPT cutpts[], //predecessors
43 int16_t array_origin, //start coord
44 int16_t x, //position
45 bool faking, //faking this one
46 bool mid_cut, //doing free cut
47 int16_t offset, //extra cost dist
48 STATS* projection, //occupation
49 float projection_scale, //scaling
50 int16_t zero_count, //official zero
51 int16_t pitch, //proposed pitch
52 int16_t pitch_error); //allowed tolerance
53
54 void assign_cheap ( //evaluate cut
55 FPCUTPT cutpts[], //predecessors
56 int16_t array_origin, //start coord
57 int16_t x, //position
58 bool faking, //faking this one
59 bool mid_cut, //doing free cut
60 int16_t offset, //extra cost dist
61 STATS * projection, //occupation
62 float projection_scale, //scaling
63 int16_t zero_count, //official zero
64 int16_t pitch, //proposed pitch
65 int16_t pitch_error); //allowed tolerance
66
67 int32_t position() { // access func
68 return xpos;
69 }
70 double cost_function() {
71 return cost;
72 }
73 double squares() {
74 return sq_sum;
75 }
76 double sum() {
77 return mean_sum;
78 }
80 return pred;
81 }
82 int16_t cheap_cuts() const { //no of mi cuts
83 return mid_cuts;
84 }
85 int16_t index() const {
86 return region_index;
87 }
88
89 bool faked; //faked split point
90 bool terminal; //successful end
91 int16_t fake_count; //total fakes to here
92
93 private:
94 int16_t region_index; //cut serial number
95 int16_t mid_cuts; //no of cheap cuts
96 int32_t xpos; //location
97 uint32_t back_balance; //proj backwards
98 uint32_t fwd_balance; //proj forwards
99 FPCUTPT *pred; //optimal previous
100 double mean_sum; //mean so far
101 double sq_sum; //summed distsances
102 double cost; //cost function
103};
104double check_pitch_sync2( //find segmentation
105 BLOBNBOX_IT *blob_it, //blobs to do
106 int16_t blob_count, //no of blobs
107 int16_t pitch, //pitch estimate
108 int16_t pitch_error, //tolerance
109 STATS *projection, //vertical
110 int16_t projection_left, //edges //scale factor
111 int16_t projection_right,
112 float projection_scale,
113 int16_t &occupation_count, //no of occupied cells
114 FPSEGPT_LIST *seg_list, //output list
115 int16_t start, //start of good range
116 int16_t end //end of good range
117 );
118double check_pitch_sync3( //find segmentation
119 int16_t projection_left, //edges //to be considered 0
120 int16_t projection_right,
121 int16_t zero_count,
122 int16_t pitch, //pitch estimate
123 int16_t pitch_error, //tolerance
124 STATS *projection, //vertical
125 float projection_scale, //scale factor
126 int16_t &occupation_count, //no of occupied cells
127 FPSEGPT_LIST *seg_list, //output list
128 int16_t start, //start of good range
129 int16_t end //end of good range
130 );
131#endif
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:488
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:291
Definition: statistc.h:31
int16_t index() const
Definition: pithsync.h:85
double squares()
Definition: pithsync.h:73
int16_t cheap_cuts() const
Definition: pithsync.h:82
int16_t fake_count
Definition: pithsync.h:91
bool faked
Definition: pithsync.h:89
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:34
double cost_function()
Definition: pithsync.h:70
void assign(FPCUTPT cutpts[], int16_t array_origin, int16_t x, bool faking, bool mid_cut, int16_t offset, STATS *projection, float projection_scale, int16_t zero_count, int16_t pitch, int16_t pitch_error)
Definition: pithsync.cpp:91
FPCUTPT * previous()
Definition: pithsync.h:79
double sum()
Definition: pithsync.h:76
bool terminal
Definition: pithsync.h:90
FPCUTPT()=default
void assign_cheap(FPCUTPT cutpts[], int16_t array_origin, int16_t x, bool faking, bool mid_cut, int16_t offset, STATS *projection, float projection_scale, int16_t zero_count, int16_t pitch, int16_t pitch_error)
Definition: pithsync.cpp:199
int32_t position()
Definition: pithsync.h:67