tesseract  4.0.0-1-g2a2b
normmatch.cpp File Reference
#include "normmatch.h"
#include <cstdio>
#include <cmath>
#include "classify.h"
#include "clusttool.h"
#include "emalloc.h"
#include "globals.h"
#include "helpers.h"
#include "normfeat.h"
#include "unicharset.h"
#include "params.h"

Go to the source code of this file.

Classes

struct  NORM_PROTOS
 

Namespaces

 tesseract
 

Functions

NORM_PROTOSReadNormProtos (FILE *File)
 
NormEvidenceOf

Return the new type of evidence number corresponding to this normalization adjustment. The equation that represents the transform is: 1 / (1 + (NormAdj / midpoint) ^ curl)

double NormEvidenceOf (double NormAdj)
 
void PrintNormMatch (FILE *File, int NumParams, PROTOTYPE *Proto, FEATURE Feature)
 

Variables

double classify_norm_adj_midpoint = 32.0
 
double classify_norm_adj_curl = 2.0
 
const double kWidthErrorWeighting = 0.125
 

Function Documentation

◆ NormEvidenceOf()

double NormEvidenceOf ( double  NormAdj)

Definition at line 179 of file normmatch.cpp.

179  {
180  NormAdj /= classify_norm_adj_midpoint;
181 
182  if (classify_norm_adj_curl == 3)
183  NormAdj = NormAdj * NormAdj * NormAdj;
184  else if (classify_norm_adj_curl == 2)
185  NormAdj = NormAdj * NormAdj;
186  else
187  NormAdj = pow (NormAdj, classify_norm_adj_curl);
188  return (1.0 / (1.0 + NormAdj));
189 }
double classify_norm_adj_curl
Definition: normmatch.cpp:61
double classify_norm_adj_midpoint
Definition: normmatch.cpp:60

◆ PrintNormMatch()

void PrintNormMatch ( FILE *  File,
int  NumParams,
PROTOTYPE Proto,
FEATURE  Feature 
)

This routine dumps out detailed normalization match info.

Parameters
Fileopen text file to dump match debug info to
NumParams# of parameters in proto and feature
Proto[]array of prototype parameters
Feature[]array of feature parameters Globals: none
Returns
none

Definition at line 202 of file normmatch.cpp.

205  {
206  int i;
207  float ParamMatch;
208  float TotalMatch;
209 
210  for (i = 0, TotalMatch = 0.0; i < NumParams; i++) {
211  ParamMatch = (Feature->Params[i] - Mean(Proto, i)) /
212  StandardDeviation(Proto, i);
213 
214  fprintf (File, " %6.1f", ParamMatch);
215 
216  if (i == CharNormY || i == CharNormRx)
217  TotalMatch += ParamMatch * ParamMatch;
218  }
219  fprintf (File, " --> %6.1f (%4.2f)\n",
220  TotalMatch, NormEvidenceOf (TotalMatch));
221 
222 } /* PrintNormMatch */
float StandardDeviation(PROTOTYPE *Proto, uint16_t Dimension)
Definition: cluster.cpp:639
float Params[1]
Definition: ocrfeatures.h:62
float Mean(PROTOTYPE *Proto, uint16_t Dimension)
Definition: cluster.cpp:628
double NormEvidenceOf(double NormAdj)
Definition: normmatch.cpp:179

◆ ReadNormProtos()

NORM_PROTOS* ReadNormProtos ( FILE *  File)

Variable Documentation

◆ classify_norm_adj_curl

double classify_norm_adj_curl = 2.0

"Norm adjust curl ..."

Definition at line 61 of file normmatch.cpp.

◆ classify_norm_adj_midpoint

double classify_norm_adj_midpoint = 32.0

control knobs used to control the normalization adjustment process "Norm adjust midpoint ..."

Definition at line 60 of file normmatch.cpp.

◆ kWidthErrorWeighting

const double kWidthErrorWeighting = 0.125

Weight of width variance against height and vertical position.

Definition at line 63 of file normmatch.cpp.