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