|
tesseract 3.04.01
|
#include "picofeat.h"#include "classify.h"#include "efio.h"#include "featdefs.h"#include "fpoint.h"#include "mfoutline.h"#include "ocrfeatures.h"#include "params.h"#include "trainingsample.h"#include <math.h>#include <stdio.h>Go to the source code of this file.
Namespaces | |
| namespace | tesseract |
Functions | |
| void | ConvertSegmentToPicoFeat (FPOINT *Start, FPOINT *End, FEATURE_SET FeatureSet) |
| void | ConvertToPicoFeatures2 (MFOUTLINE Outline, FEATURE_SET FeatureSet) |
| void | NormalizePicoX (FEATURE_SET FeatureSet) |
Variables | |
| double | classify_pico_feature_length = 0.05 |
| void ConvertSegmentToPicoFeat | ( | FPOINT * | Start, |
| FPOINT * | End, | ||
| FEATURE_SET | FeatureSet | ||
| ) |
This routine converts an entire segment of an outline into a set of pico features which are added to FeatureSet. The length of the segment is rounded to the nearest whole number of pico-features. The pico-features are spaced evenly over the entire segment. Globals:
| Start | starting point of pico-feature |
| End | ending point of pico-feature |
| FeatureSet | set to add pico-feature to |
Definition at line 109 of file picofeat.cpp.
{
FEATURE Feature;
FLOAT32 Angle;
FLOAT32 Length;
int NumFeatures;
FPOINT Center;
FPOINT Delta;
int i;
Angle = NormalizedAngleFrom (Start, End, 1.0);
Length = DistanceBetween (*Start, *End);
NumFeatures = (int) floor (Length / classify_pico_feature_length + 0.5);
if (NumFeatures < 1)
NumFeatures = 1;
/* compute vector for one pico feature */
Delta.x = XDelta (*Start, *End) / NumFeatures;
Delta.y = YDelta (*Start, *End) / NumFeatures;
/* compute position of first pico feature */
Center.x = Start->x + Delta.x / 2.0;
Center.y = Start->y + Delta.y / 2.0;
/* compute each pico feature in segment and add to feature set */
for (i = 0; i < NumFeatures; i++) {
Feature = NewFeature (&PicoFeatDesc);
Feature->Params[PicoFeatDir] = Angle;
Feature->Params[PicoFeatX] = Center.x;
Feature->Params[PicoFeatY] = Center.y;
AddFeature(FeatureSet, Feature);
Center.x += Delta.x;
Center.y += Delta.y;
}
} /* ConvertSegmentToPicoFeat */
| void ConvertToPicoFeatures2 | ( | MFOUTLINE | Outline, |
| FEATURE_SET | FeatureSet | ||
| ) |
This routine steps through the specified outline and cuts it up into pieces of equal length. These pieces become the desired pico-features. Each segment in the outline is converted into an integral number of pico-features.
Globals:
| Outline | outline to extract micro-features from |
| FeatureSet | set of features to add pico-features to |
Definition at line 163 of file picofeat.cpp.
{
MFOUTLINE Next;
MFOUTLINE First;
MFOUTLINE Current;
if (DegenerateOutline(Outline))
return;
First = Outline;
Current = First;
Next = NextPointAfter(Current);
do {
/* note that an edge is hidden if the ending point of the edge is
marked as hidden. This situation happens because the order of
the outlines is reversed when they are converted from the old
format. In the old format, a hidden edge is marked by the
starting point for that edge. */
if (!(PointAt(Next)->Hidden))
ConvertSegmentToPicoFeat (&(PointAt(Current)->Point),
&(PointAt(Next)->Point), FeatureSet);
Current = Next;
Next = NextPointAfter(Current);
}
while (Current != First);
} /* ConvertToPicoFeatures2 */
| void NormalizePicoX | ( | FEATURE_SET | FeatureSet | ) |
This routine computes the average x position over all of the pico-features in FeatureSet and then renormalizes the pico-features to force this average to be the x origin (i.e. x=0).
| FeatureSet | pico-features to be normalized |
Definition at line 204 of file picofeat.cpp.
{
int i;
FEATURE Feature;
FLOAT32 Origin = 0.0;
for (i = 0; i < FeatureSet->NumFeatures; i++) {
Feature = FeatureSet->Features[i];
Origin += Feature->Params[PicoFeatX];
}
Origin /= FeatureSet->NumFeatures;
for (i = 0; i < FeatureSet->NumFeatures; i++) {
Feature = FeatureSet->Features[i];
Feature->Params[PicoFeatX] -= Origin;
}
} /* NormalizePicoX */
| double classify_pico_feature_length = 0.05 |
"Pico Feature Length"
Definition at line 39 of file picofeat.cpp.