tesseract
4.0.0-beta.1-59-g2cc4
outlines.h
Go to the documentation of this file.
1
/* -*-C-*-
2
********************************************************************************
3
*
4
* File: outlines.h (Formerly outlines.h)
5
* Description: Combinatorial Splitter
6
* Author: Mark Seaman, OCR Technology
7
* Created: Thu Jul 27 11:27:55 1989
8
* Modified: Wed May 15 17:28:47 1991 (Mark Seaman) marks@hpgrlt
9
* Language: C
10
* Package: N/A
11
* Status: Experimental (Do Not Distribute)
12
*
13
* (c) Copyright 1989, 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
#ifndef OUTLINES_H
26
#define OUTLINES_H
27
28
#include "
blobs.h
"
29
#include "
chop.h
"
30
31
#include <math.h>
32
33
/*----------------------------------------------------------------------
34
C o n s t a n t s
35
----------------------------------------------------------------------*/
36
#define LARGE_DISTANCE 100000
/* Used for closest dist */
37
#define MIN_BLOB_SIZE 10
/* Big units */
38
#define MAX_ASPECT_RATIO 2.5
/* Widest character */
39
40
/*----------------------------------------------------------------------
41
M a c r o s
42
----------------------------------------------------------------------*/
43
/**********************************************************************
44
* same_point
45
*
46
* Return TRUE if the point values are the same. The parameters must
47
* be of type POINT.
48
**********************************************************************/
49
#define same_point(p1,p2) \
50
((abs (p1.x - p2.x) < chop_same_distance) && \
51
(abs (p1.y - p2.y) < chop_same_distance))
52
53
/**********************************************************************
54
* dist_square
55
*
56
* Return the square of the distance between these two points. The
57
* parameters must be of type POINT.
58
**********************************************************************/
59
60
#define dist_square(p1,p2) \
61
((p2.x - p1.x) * (p2.x - p1.x) + \
62
(p2.y - p1.y) * (p2.y - p1.y))
63
64
/**********************************************************************
65
* closest
66
*
67
* The expression provides the EDGEPT that is closest to the point in
68
* question. All three parameters must be of type EDGEPT.
69
**********************************************************************/
70
71
#define closest(test_p,p1,p2) \
72
(p1 ? \
73
(p2 ? \
74
((dist_square (test_p->pos, p1->pos) < \
75
dist_square (test_p->pos, p2->pos)) ? \
76
p1 : \
77
p2) : \
78
p1) : \
79
p2)
80
81
/**********************************************************************
82
* edgept_dist
83
*
84
* Return the distance (squared) between the two edge points.
85
**********************************************************************/
86
87
#define edgept_dist(p1,p2) \
88
(dist_square ((p1)->pos, (p2)->pos))
89
90
/**********************************************************************
91
* is_exterior_point
92
*
93
* Return TRUE if the point supplied is an exterior projection from the
94
* outline.
95
**********************************************************************/
96
97
#define is_exterior_point(edge,point) \
98
(same_point (edge->prev->pos, point->pos) || \
99
same_point (edge->next->pos, point->pos) || \
100
(angle_change (edge->prev, edge, edge->next) - \
101
angle_change (edge->prev, edge, point) > 20))
102
103
/**********************************************************************
104
* is_equal
105
*
106
* Return TRUE if the POINTs are equal.
107
**********************************************************************/
108
109
#define is_equal(p1,p2) \
110
(((p1).x == (p2).x) && ((p1).y == (p2).y))
111
112
/**********************************************************************
113
* is_on_line
114
*
115
* Return TRUE if the point is on the line segment between the two end
116
* points. The two end points are included as part of the line. The
117
* parameters must be of type POINT.
118
**********************************************************************/
119
120
#define is_on_line(p,p0,p1) \
121
(within_range ((p).x, (p0).x, (p1).x) && \
122
within_range ((p).y, (p0).y, (p1).y))
123
124
/**********************************************************************
125
* within_range
126
*
127
* Return TRUE if the first number is in between the second two numbers.
128
* Return FALSE otherwise.
129
**********************************************************************/
130
131
#define within_range(x,x0,x1) \
132
(((x0 <= x) && (x <= x1)) || ((x1 <= x) && (x <= x0)))
133
134
#endif
blobs.h
chop.h
wordrec
outlines.h
Generated on Wed Mar 28 2018 20:00:39 for tesseract by
1.8.13