tesseract  3.03
/usr/local/google/home/jbreiden/tesseract-ocr-read-only/ccmain/reject.h File Reference
#include "params.h"
#include "pageres.h"

Go to the source code of this file.

Functions

void reject_blanks (WERD_RES *word)
void reject_poor_matches (WERD_RES *word)
float compute_reject_threshold (WERD_CHOICE *word)
BOOL8 word_contains_non_1_digit (const char *word, const char *word_lengths)
void dont_allow_1Il (WERD_RES *word)
void flip_hyphens (WERD_RES *word)
void flip_0O (WERD_RES *word)
BOOL8 non_0_digit (const char *str, int length)

Function Documentation

Definition at line 229 of file reject.cpp.

                                                  {
  float threshold;               // rejection threshold
  float bestgap = 0.0f;          // biggest gap
  float gapstart;                // bottom of gap
                                 // super iterator
  BLOB_CHOICE_IT choice_it;      // real iterator

  int blob_count = word->length();
  GenericVector<float> ratings;
  ratings.init_to_size(blob_count, 0.0f);
  for (int i = 0; i < blob_count; ++i) {
    ratings[i] = word->certainty(i);
  }
  ratings.sort();
  gapstart = ratings[0] - 1;     // all reject if none better
  if (blob_count >= 3) {
    for (int index = 0; index < blob_count - 1; index++) {
      if (ratings[index + 1] - ratings[index] > bestgap) {
        bestgap = ratings[index + 1] - ratings[index];
        // find biggest
        gapstart = ratings[index];
      }
    }
  }
  threshold = gapstart + bestgap / 2;

  return threshold;
}
void dont_allow_1Il ( WERD_RES word)
void flip_0O ( WERD_RES word)
void flip_hyphens ( WERD_RES word)
BOOL8 non_0_digit ( const char *  str,
int  length 
)
void reject_blanks ( WERD_RES word)

Definition at line 181 of file reject.cpp.

                                   {
  inT16 i;
  inT16 offset;

  for (i = 0, offset = 0; word->best_choice->unichar_string()[offset] != '\0';
       offset += word->best_choice->unichar_lengths()[i], i += 1) {
    if (word->best_choice->unichar_string()[offset] == ' ')
                                 //rej unrecognised blobs
      word->reject_map[i].setrej_tess_failure ();
  }
}
void reject_poor_matches ( WERD_RES word)

Definition at line 210 of file reject.cpp.

                                         {
  float threshold = compute_reject_threshold(word->best_choice);
  for (int i = 0; i < word->best_choice->length(); ++i) {
    if (word->best_choice->unichar_id(i) == UNICHAR_SPACE)
      word->reject_map[i].setrej_tess_failure();
    else if (word->best_choice->certainty(i) < threshold)
      word->reject_map[i].setrej_poor_match();
  }
}
BOOL8 word_contains_non_1_digit ( const char *  word,
const char *  word_lengths 
)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines