forked from tesseract-ocr/tesseract
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmfoutline.h
124 lines (96 loc) · 4.21 KB
/
mfoutline.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/******************************************************************************
** Filename: mfoutline.h
** Purpose: Interface spec for fx outline structures
** Author: Dan Johnson
** History: Thu May 17 08:55:32 1990, DSJ, Created.
**
** (c) Copyright Hewlett-Packard Company, 1988.
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
** http://www.apache.org/licenses/LICENSE-2.0
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
******************************************************************************/
#ifndef MFOUTLINE_H
#define MFOUTLINE_H
/**----------------------------------------------------------------------------
Include Files and Type Defines
----------------------------------------------------------------------------**/
#include "blobs.h"
#include "host.h"
#include "oldlist.h"
#include "fpoint.h"
#include "params.h"
#define NORMAL_X_HEIGHT (0.5)
#define NORMAL_BASELINE (0.0)
typedef LIST MFOUTLINE;
typedef enum {
north, south, east, west, northeast, northwest, southeast, southwest
} DIRECTION;
typedef struct {
FPOINT Point;
FLOAT32 Slope;
unsigned Padding:20;
BOOL8 Hidden:TRUE;
BOOL8 ExtremityMark:TRUE;
DIRECTION Direction:4;
DIRECTION PreviousDirection:4;
} MFEDGEPT;
typedef enum {
outer, hole
} OUTLINETYPE;
typedef enum {
baseline, character
} NORM_METHOD;
/**----------------------------------------------------------------------------
Macros
----------------------------------------------------------------------------**/
#define AverageOf(A,B) (((A) + (B)) / 2)
/* macro for computing the scale factor to use to normalize characters */
#define MF_SCALE_FACTOR (NORMAL_X_HEIGHT / kBlnXHeight)
/* macros for manipulating micro-feature outlines */
#define DegenerateOutline(O) (((O) == NIL_LIST) || ((O) == list_rest(O)))
#define PointAt(O) ((MFEDGEPT *) first_node (O))
#define NextPointAfter(E) (list_rest (E))
#define MakeOutlineCircular(O) (set_rest (last (O), (O)))
/* macros for manipulating micro-feature outline edge points */
#define ClearMark(P) ((P)->ExtremityMark = FALSE)
#define MarkPoint(P) ((P)->ExtremityMark = TRUE)
/**----------------------------------------------------------------------------
Public Function Prototypes
----------------------------------------------------------------------------**/
void ComputeBlobCenter(TBLOB *Blob, TPOINT *BlobCenter);
LIST ConvertBlob(TBLOB *Blob);
MFOUTLINE ConvertOutline(TESSLINE *Outline);
LIST ConvertOutlines(TESSLINE *Outline,
LIST ConvertedOutlines,
OUTLINETYPE OutlineType);
void FilterEdgeNoise(MFOUTLINE Outline, FLOAT32 NoiseSegmentLength);
void FindDirectionChanges(MFOUTLINE Outline,
FLOAT32 MinSlope,
FLOAT32 MaxSlope);
void FreeMFOutline(void *agr); //MFOUTLINE Outline);
void FreeOutlines(LIST Outlines);
void MarkDirectionChanges(MFOUTLINE Outline);
MFEDGEPT *NewEdgePoint();
MFOUTLINE NextExtremity(MFOUTLINE EdgePoint);
void NormalizeOutline(MFOUTLINE Outline,
FLOAT32 XOrigin);
/*----------------------------------------------------------------------------
Private Function Prototypes
-----------------------------------------------------------------------------*/
void ChangeDirection(MFOUTLINE Start, MFOUTLINE End, DIRECTION Direction);
// Normalizes the Outline in-place using cn_denorm's local transformation,
// then converts from the integer feature range [0,255] to the clusterer
// feature range of [-0.5, 0.5].
void CharNormalizeOutline(MFOUTLINE Outline, const DENORM& cn_denorm);
void ComputeDirection(MFEDGEPT *Start,
MFEDGEPT *Finish,
FLOAT32 MinSlope,
FLOAT32 MaxSlope);
MFOUTLINE NextDirectionChange(MFOUTLINE EdgePoint);
#endif