#include <linlsq.h>
Definition at line 29 of file linlsq.h.
◆ LLSQ()
tesseract::LLSQ::LLSQ |
( |
| ) |
|
|
inline |
◆ add() [1/3]
void tesseract::LLSQ::add |
( |
const LLSQ & |
other | ) |
|
Definition at line 67 of file linlsq.cpp.
67 {
68 total_weight += other.total_weight;
69 sigx += other.sigx;
70 sigy += other.sigy;
71 sigxx += other.sigxx;
72 sigxy += other.sigxy;
73 sigyy += other.sigyy;
74}
◆ add() [2/3]
void tesseract::LLSQ::add |
( |
double |
x, |
|
|
double |
y |
|
) |
| |
Definition at line 49 of file linlsq.cpp.
49 {
50 total_weight++;
56}
◆ add() [3/3]
void tesseract::LLSQ::add |
( |
double |
x, |
|
|
double |
y, |
|
|
double |
weight |
|
) |
| |
Definition at line 58 of file linlsq.cpp.
58 {
59 total_weight += weight;
62 sigxx +=
x *
x * weight;
63 sigxy +=
x *
y * weight;
64 sigyy +=
y *
y * weight;
65}
◆ c()
double tesseract::LLSQ::c |
( |
double |
m | ) |
const |
Definition at line 116 of file linlsq.cpp.
116 {
117 if (total_weight > 0.0) {
118 return (sigy -
m * sigx) / total_weight;
119 } else {
120 return 0;
121 }
122}
◆ clear()
void tesseract::LLSQ::clear |
( |
| ) |
|
Definition at line 34 of file linlsq.cpp.
34 {
35 total_weight = 0.0;
36 sigx = 0.0;
37 sigy = 0.0;
38 sigxx = 0.0;
39 sigxy = 0.0;
40 sigyy = 0.0;
41}
◆ count()
int32_t tesseract::LLSQ::count |
( |
| ) |
const |
|
inline |
Definition at line 44 of file linlsq.h.
44 {
45 return static_cast<int>(total_weight + 0.5);
46 }
◆ covariance()
double tesseract::LLSQ::covariance |
( |
| ) |
const |
|
inline |
Definition at line 76 of file linlsq.h.
76 {
77 if (total_weight > 0.0) {
78 return (sigxy - sigx * sigy / total_weight) / total_weight;
79 } else {
80 return 0.0;
81 }
82 }
◆ m()
double tesseract::LLSQ::m |
( |
| ) |
const |
Definition at line 100 of file linlsq.cpp.
100 {
103 if (x_var != 0.0) {
104 return covar / x_var;
105 } else {
106 return 0.0;
107 }
108}
double covariance() const
double x_variance() const
◆ mean_point()
FCOORD tesseract::LLSQ::mean_point |
( |
| ) |
const |
Definition at line 166 of file linlsq.cpp.
166 {
167 if (total_weight > 0.0) {
168 return FCOORD(sigx / total_weight, sigy / total_weight);
169 } else {
170 return FCOORD(0.0f, 0.0f);
171 }
172}
◆ pearson()
double tesseract::LLSQ::pearson |
( |
| ) |
const |
Definition at line 152 of file linlsq.cpp.
152 {
153 double r = 0.0;
154
156 if (covar != 0.0) {
158 if (var_product > 0.0) {
159 r = covar / std::sqrt(var_product);
160 }
161 }
162 return r;
163}
double y_variance() const
◆ remove()
void tesseract::LLSQ::remove |
( |
double |
x, |
|
|
double |
y |
|
) |
| |
Definition at line 82 of file linlsq.cpp.
82 {
83 if (total_weight <= 0.0) {
85 }
86 total_weight--;
92}
constexpr ERRCODE EMPTY_LLSQ("Can't delete from an empty LLSQ")
void error(const char *caller, TessErrorLogCode action, const char *format,...) const __attribute__((format(gnu_printf
◆ rms()
double tesseract::LLSQ::rms |
( |
double |
m, |
|
|
double |
c |
|
) |
| const |
Definition at line 130 of file linlsq.cpp.
130 {
131 double error;
132
133 if (total_weight > 0) {
134 error = sigyy +
m * (
m * sigxx + 2 * (
c * sigx - sigxy)) +
c * (total_weight *
c - 2 * sigy);
135 if (error >= 0) {
136 error = std::sqrt(error / total_weight);
137 } else {
138 error = 0;
139 }
140 } else {
141 error = 0;
142 }
143 return error;
144}
◆ rms_orth()
double tesseract::LLSQ::rms_orth |
( |
const FCOORD & |
dir | ) |
const |
Definition at line 195 of file linlsq.cpp.
195 {
196 FCOORD v = !dir;
197 v.normalise();
200}
◆ vector_fit()
FCOORD tesseract::LLSQ::vector_fit |
( |
| ) |
const |
Definition at line 250 of file linlsq.cpp.
250 {
254 double theta = 0.5 * atan2(2.0 * covar, x_var - y_var);
255 FCOORD result(cos(theta), sin(theta));
256 return result;
257}
◆ x_variance()
double tesseract::LLSQ::x_variance |
( |
| ) |
const |
|
inline |
Definition at line 83 of file linlsq.h.
83 {
84 if (total_weight > 0.0) {
85 return (sigxx - sigx * sigx / total_weight) / total_weight;
86 } else {
87 return 0.0;
88 }
89 }
◆ y_variance()
double tesseract::LLSQ::y_variance |
( |
| ) |
const |
|
inline |
Definition at line 90 of file linlsq.h.
90 {
91 if (total_weight > 0.0) {
92 return (sigyy - sigy * sigy / total_weight) / total_weight;
93 } else {
94 return 0.0;
95 }
96 }
The documentation for this class was generated from the following files:
- /media/home/debian/src/github/tesseract-ocr/tesseract/src/ccstruct/linlsq.h
- /media/home/debian/src/github/tesseract-ocr/tesseract/src/ccstruct/linlsq.cpp