tesseract
4.1.1
gradechop.cpp
Go to the documentation of this file.
1
/* -*-C-*-
2
********************************************************************************
3
*
4
* File: gradechop.cpp (Formerly gradechop.c)
5
* Description:
6
* Author: Mark Seaman, OCR Technology
7
*
8
* (c) Copyright 1987, Hewlett-Packard Company.
9
** Licensed under the Apache License, Version 2.0 (the "License");
10
** you may not use this file except in compliance with the License.
11
** You may obtain a copy of the License at
12
** http://www.apache.org/licenses/LICENSE-2.0
13
** Unless required by applicable law or agreed to in writing, software
14
** distributed under the License is distributed on an "AS IS" BASIS,
15
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
** See the License for the specific language governing permissions and
17
** limitations under the License.
18
*
19
*********************************************************************************/
20
/*----------------------------------------------------------------------
21
I n c l u d e s
22
----------------------------------------------------------------------*/
23
24
#include "
wordrec.h
"
25
#include "
chop.h
"
26
#include <algorithm>
27
#include <cmath>
28
29
/*----------------------------------------------------------------------
30
M a c r o s
31
----------------------------------------------------------------------*/
32
33
namespace
tesseract
{
34
35
/*----------------------------------------------------------------------
36
F u n c t i o n s
37
----------------------------------------------------------------------*/
38
39
/**********************************************************************
40
* grade_split_length
41
*
42
* Return a grade for the length of this split.
43
* 0 = "perfect"
44
* 100 = "no way jay"
45
**********************************************************************/
46
PRIORITY
Wordrec::grade_split_length
(
SPLIT
*split) {
47
PRIORITY
grade;
48
float
split_length;
49
50
split_length =
51
split->
point1
->
WeightedDistance
(*split->
point2
,
chop_x_y_weight
);
52
53
if
(split_length <= 0)
54
grade = 0;
55
else
56
grade = sqrt (split_length) *
chop_split_dist_knob
;
57
58
return
(std::max(0.0f, grade));
59
}
60
61
62
/**********************************************************************
63
* grade_sharpness
64
*
65
* Return a grade for the sharpness of this split.
66
* 0 = "perfect"
67
* 100 = "no way jay"
68
**********************************************************************/
69
PRIORITY
Wordrec::grade_sharpness
(
SPLIT
*split) {
70
PRIORITY
grade;
71
72
grade =
point_priority
(split->
point1
) +
point_priority
(split->
point2
);
73
74
if
(grade < -360.0)
75
grade = 0;
76
else
77
grade += 360.0;
78
79
grade *=
chop_sharpness_knob
;
/* Values 0 to -360 */
80
81
return
(grade);
82
}
83
84
85
}
// namespace tesseract
SPLIT::point1
EDGEPT * point1
Definition:
split.h:103
tesseract::Wordrec::point_priority
PRIORITY point_priority(EDGEPT *point)
Definition:
chop.cpp:66
tesseract::Wordrec::chop_split_dist_knob
double chop_split_dist_knob
Definition:
wordrec.h:214
wordrec.h
PRIORITY
float PRIORITY
Definition:
seam.h:36
tesseract
Definition:
altorenderer.cpp:25
EDGEPT::WeightedDistance
int WeightedDistance(const EDGEPT &other, int x_factor) const
Definition:
blobs.h:122
tesseract::Wordrec::grade_sharpness
PRIORITY grade_sharpness(SPLIT *split)
Definition:
gradechop.cpp:69
tesseract::Wordrec::chop_sharpness_knob
double chop_sharpness_knob
Definition:
wordrec.h:219
tesseract::Wordrec::grade_split_length
PRIORITY grade_split_length(SPLIT *split)
Definition:
gradechop.cpp:46
chop.h
tesseract::Wordrec::chop_x_y_weight
int chop_x_y_weight
Definition:
wordrec.h:223
SPLIT
Definition:
split.h:37
SPLIT::point2
EDGEPT * point2
Definition:
split.h:104
src
wordrec
gradechop.cpp
Generated on Thu Mar 26 2020 00:00:00 for tesseract by
1.8.18