Coverage Report

Created: 2025-11-16 06:50

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/tesseract/src/textord/pithsync.h
Line
Count
Source
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
26
namespace tesseract {
27
28
class FPSEGPT_LIST;
29
30
class FPCUTPT {
31
public:
32
  FPCUTPT() = default;
33
  void setup(               // start of cut
34
      FPCUTPT cutpts[],     // predecessors
35
      int16_t array_origin, // start coord
36
      STATS *projection,    // occupation
37
      int16_t zero_count,   // official zero
38
      int16_t pitch,        // proposed pitch
39
      int16_t x,            // position
40
      int16_t offset);      // dist to gap
41
42
  void assign(                // evaluate cut
43
      FPCUTPT cutpts[],       // predecessors
44
      int16_t array_origin,   // start coord
45
      int16_t x,              // position
46
      bool faking,            // faking this one
47
      bool mid_cut,           // doing free cut
48
      int16_t offset,         // extra cost dist
49
      STATS *projection,      // occupation
50
      float projection_scale, // scaling
51
      int16_t zero_count,     // official zero
52
      int16_t pitch,          // proposed pitch
53
      int16_t pitch_error);   // allowed tolerance
54
55
  void assign_cheap(          // evaluate cut
56
      FPCUTPT cutpts[],       // predecessors
57
      int16_t array_origin,   // start coord
58
      int16_t x,              // position
59
      bool faking,            // faking this one
60
      bool mid_cut,           // doing free cut
61
      int16_t offset,         // extra cost dist
62
      STATS *projection,      // occupation
63
      float projection_scale, // scaling
64
      int16_t zero_count,     // official zero
65
      int16_t pitch,          // proposed pitch
66
      int16_t pitch_error);   // allowed tolerance
67
68
5.06M
  int32_t position() { // access func
69
5.06M
    return xpos;
70
5.06M
  }
71
1.49M
  double cost_function() {
72
1.49M
    return cost;
73
1.49M
  }
74
932k
  double squares() {
75
932k
    return sq_sum;
76
932k
  }
77
932k
  double sum() {
78
932k
    return mean_sum;
79
932k
  }
80
932k
  FPCUTPT *previous() {
81
932k
    return pred;
82
932k
  }
83
932k
  int16_t cheap_cuts() const { // no of mi cuts
84
932k
    return mid_cuts;
85
932k
  }
86
982k
  int16_t index() const {
87
982k
    return region_index;
88
982k
  }
89
90
  bool faked;         // faked split point
91
  bool terminal;      // successful end
92
  int16_t fake_count; // total fakes to here
93
94
private:
95
  int16_t region_index;  // cut serial number
96
  int16_t mid_cuts;      // no of cheap cuts
97
  int32_t xpos;          // location
98
  uint32_t back_balance; // proj backwards
99
  uint32_t fwd_balance;  // proj forwards
100
  FPCUTPT *pred;         // optimal previous
101
  double mean_sum;       // mean so far
102
  double sq_sum;         // summed distsances
103
  double cost;           // cost function
104
};
105
double check_pitch_sync2(    // find segmentation
106
    BLOBNBOX_IT *blob_it,    // blobs to do
107
    int16_t blob_count,      // no of blobs
108
    int16_t pitch,           // pitch estimate
109
    int16_t pitch_error,     // tolerance
110
    STATS *projection,       // vertical
111
    int16_t projection_left, // edges //scale factor
112
    int16_t projection_right, 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
);
118
double check_pitch_sync3(    // find segmentation
119
    int16_t projection_left, // edges //to be considered 0
120
    int16_t projection_right, int16_t zero_count,
121
    int16_t pitch,             // pitch estimate
122
    int16_t pitch_error,       // tolerance
123
    STATS *projection,         // vertical
124
    float projection_scale,    // scale factor
125
    int16_t &occupation_count, // no of occupied cells
126
    FPSEGPT_LIST *seg_list,    // output list
127
    int16_t start,             // start of good range
128
    int16_t end                // end of good range
129
);
130
131
} // namespace tesseract
132
133
#endif