Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mf.cpp
Go to the documentation of this file.
1 /******************************************************************************
2 ** Filename: mf.c
3 ** Purpose: Micro-feature interface to flexible feature extractor.
4 ** Author: Dan Johnson
5 ** History: Thu May 24 09:08:38 1990, DSJ, Created.
6 **
7 ** (c) Copyright Hewlett-Packard Company, 1988.
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 ******************************************************************************/
21 #include "mf.h"
22
23 #include "featdefs.h"
24 #include "mfdefs.h"
25 #include "mfx.h"
26
27 #include <math.h>
28
35 /*---------------------------------------------------------------------------*/
36 FEATURE_SET ExtractMicros(TBLOB *Blob, const DENORM& denorm) {
37 /*
38 ** Parameters:
39 ** Blob blob to extract micro-features from
40 ** denorm control parameter to feature extractor.
41 ** Globals: none
42 ** Operation: Call the old micro-feature extractor and then copy
43 ** the features into the new format. Then deallocate the
44 ** old micro-features.
45 ** Return: Micro-features for Blob.
46 ** Exceptions: none
47 ** History: Wed May 23 18:06:38 1990, DSJ, Created.
48 */
49 int NumFeatures;
50 MICROFEATURES Features, OldFeatures;
51 FEATURE_SET FeatureSet;
52 FEATURE Feature;
53 MICROFEATURE OldFeature;
54
55 OldFeatures = (MICROFEATURES)BlobMicroFeatures(Blob, denorm);
56 if (OldFeatures == NULL)
57 return NULL;
58 NumFeatures = count (OldFeatures);
59 FeatureSet = NewFeatureSet (NumFeatures);
60
61 Features = OldFeatures;
62 iterate(Features) {
63 OldFeature = (MICROFEATURE) first_node (Features);
64 Feature = NewFeature (&MicroFeatureDesc);
65 Feature->Params[MFDirection] = OldFeature[ORIENTATION];
66 Feature->Params[MFXPosition] = OldFeature[XPOSITION];
67 Feature->Params[MFYPosition] = OldFeature[YPOSITION];
68 Feature->Params[MFLength] = OldFeature[MFLENGTH];
69
70 // Bulge features are deprecated and should not be used. Set to 0.
71 Feature->Params[MFBulge1] = 0.0f;
72 Feature->Params[MFBulge2] = 0.0f;
73
74 #ifndef _WIN32
75 // Assert that feature parameters are well defined.
76 int i;
77 for (i = 0; i < Feature->Type->NumParams; i++) {
78 ASSERT_HOST(!isnan(Feature->Params[i]));
79 }
80 #endif
81
82 AddFeature(FeatureSet, Feature);
83 }
84 FreeMicroFeatures(OldFeatures);
85 return FeatureSet;
86 } /* ExtractMicros */