tesseract  5.0.0-alpha-619-ge9db
gradechop.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * File: gradechop.cpp (Formerly gradechop.c)
4  * Description:
5  * Author: Mark Seaman, OCR Technology
6  *
7  * (c) Copyright 1987, Hewlett-Packard Company.
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  I n c l u d e s
21 ----------------------------------------------------------------------*/
22 
23 #include "wordrec.h"
24 #include "chop.h"
25 #include <algorithm>
26 #include <cmath>
27 
28 /*----------------------------------------------------------------------
29  M a c r o s
30 ----------------------------------------------------------------------*/
31 
32 namespace tesseract {
33 
34 /*----------------------------------------------------------------------
35  F u n c t i o n s
36 ----------------------------------------------------------------------*/
37 
38 /**********************************************************************
39  * grade_split_length
40  *
41  * Return a grade for the length of this split.
42  * 0 = "perfect"
43  * 100 = "no way jay"
44  **********************************************************************/
46  PRIORITY grade;
47  float split_length;
48 
49  split_length =
51 
52  if (split_length <= 0)
53  grade = 0;
54  else
55  grade = sqrt (split_length) * chop_split_dist_knob;
56 
57  return (std::max(0.0f, grade));
58 }
59 
60 
61 /**********************************************************************
62  * grade_sharpness
63  *
64  * Return a grade for the sharpness of this split.
65  * 0 = "perfect"
66  * 100 = "no way jay"
67  **********************************************************************/
69  PRIORITY grade;
70 
71  grade = point_priority (split->point1) + point_priority (split->point2);
72 
73  if (grade < -360.0)
74  grade = 0;
75  else
76  grade += 360.0;
77 
78  grade *= chop_sharpness_knob; /* Values 0 to -360 */
79 
80  return (grade);
81 }
82 
83 
84 } // namespace tesseract
tesseract::Wordrec::point_priority
PRIORITY point_priority(EDGEPT *point)
Definition: chop.cpp:65
SPLIT::point2
EDGEPT * point2
Definition: split.h:101
chop.h
wordrec.h
tesseract::Wordrec::chop_split_dist_knob
double chop_split_dist_knob
Definition: wordrec.h:214
tesseract
Definition: baseapi.h:65
EDGEPT::WeightedDistance
int WeightedDistance(const EDGEPT &other, int x_factor) const
Definition: blobs.h:120
tesseract::Wordrec::grade_sharpness
PRIORITY grade_sharpness(SPLIT *split)
Definition: gradechop.cpp:81
tesseract::Wordrec::grade_split_length
PRIORITY grade_split_length(SPLIT *split)
Definition: gradechop.cpp:59
SPLIT
Definition: split.h:34
tesseract::Wordrec::chop_x_y_weight
int chop_x_y_weight
Definition: wordrec.h:223
tesseract::Wordrec::chop_sharpness_knob
double chop_sharpness_knob
Definition: wordrec.h:219
PRIORITY
float PRIORITY
Definition: seam.h:34
SPLIT::point1
EDGEPT * point1
Definition: split.h:100