tesseract  3.03
/usr/local/google/home/jbreiden/tesseract-ocr-read-only/wordrec/chopper.h File Reference
#include "cutil.h"
#include "matrix.h"
#include "seam.h"
#include "stopper.h"

Go to the source code of this file.

Functions

void preserve_outline (EDGEPT *start)
void preserve_outline_tree (TESSLINE *srcline)
EDGEPTrestore_outline (EDGEPT *start)
void restore_outline_tree (TESSLINE *srcline)
int any_shared_split_points (const GenericVector< SEAM * > &seams, SEAM *seam)
int check_blob (TBLOB *blob)
inT16 check_seam_order (TBLOB *blob, SEAM *seam)
inT16 total_containment (TBLOB *blob1, TBLOB *blob2)

Function Documentation

int any_shared_split_points ( const GenericVector< SEAM * > &  seams,
SEAM seam 
)

Definition at line 283 of file chopper.cpp.

                                                                           {
  int length;
  int index;

  length = seams.size();
  for (index = 0; index < length; index++)
    if (shared_split_points(seams[index], seam))
      return TRUE;
  return FALSE;
}
int check_blob ( TBLOB blob)

Definition at line 300 of file chopper.cpp.

                            {
  TESSLINE *outline;
  EDGEPT *edgept;

  for (outline = blob->outlines; outline != NULL; outline = outline->next) {
    edgept = outline->loop;
    do {
      if (edgept == NULL)
        break;
      edgept = edgept->next;
    }
    while (edgept != outline->loop);
    if (edgept == NULL)
      return 1;
  }
  return 0;
}
inT16 check_seam_order ( TBLOB blob,
SEAM seam 
)

Definition at line 397 of file chopper.cpp.

                                                {
  TESSLINE *outline;
  inT8 found_em[3];

  if (seam->split1 == NULL || blob == NULL)
    return (TRUE);

  found_em[0] = found_em[1] = found_em[2] = FALSE;

  for (outline = blob->outlines; outline; outline = outline->next) {
    if (!found_em[0] &&
      ((seam->split1 == NULL) ||
    is_split_outline (outline, seam->split1))) {
      found_em[0] = TRUE;
    }
    if (!found_em[1] &&
      ((seam->split2 == NULL) ||
    is_split_outline (outline, seam->split2))) {
      found_em[1] = TRUE;
    }
    if (!found_em[2] &&
      ((seam->split3 == NULL) ||
    is_split_outline (outline, seam->split3))) {
      found_em[2] = TRUE;
    }
  }

  if (!found_em[0] || !found_em[1] || !found_em[2])
    return (FALSE);
  else
    return (TRUE);
}
void preserve_outline ( EDGEPT start)

Definition at line 68 of file chopper.cpp.

                                     {
  EDGEPT *srcpt;

  if (start == NULL)
    return;
  srcpt = start;
  do {
    srcpt->flags[1] = 1;
    srcpt = srcpt->next;
  }
  while (srcpt != start);
  srcpt->flags[1] = 2;
}
void preserve_outline_tree ( TESSLINE srcline)

Definition at line 84 of file chopper.cpp.

                                              {
  TESSLINE *outline;

  for (outline = srcline; outline != NULL; outline = outline->next) {
    preserve_outline (outline->loop);
  }
}
EDGEPT* restore_outline ( EDGEPT start)

Definition at line 98 of file chopper.cpp.

                                       {
  EDGEPT *srcpt;
  EDGEPT *real_start;

  if (start == NULL)
    return NULL;
  srcpt = start;
  do {
    if (srcpt->flags[1] == 2)
      break;
    srcpt = srcpt->next;
  }
  while (srcpt != start);
  real_start = srcpt;
  do {
    srcpt = srcpt->next;
    if (srcpt->prev->flags[1] == 0) {
      remove_edgept(srcpt->prev);
    }
  }
  while (srcpt != real_start);
  return real_start;
}
void restore_outline_tree ( TESSLINE srcline)

Definition at line 124 of file chopper.cpp.

                                             {
  TESSLINE *outline;

  for (outline = srcline; outline != NULL; outline = outline->next) {
    outline->loop = restore_outline (outline->loop);
    outline->start = outline->loop->pos;
  }
}
inT16 total_containment ( TBLOB blob1,
TBLOB blob2 
)

Definition at line 702 of file chopper.cpp.

                                                    {
  TBOX box1 = blob1->bounding_box();
  TBOX box2 = blob2->bounding_box();
  return box1.contains(box2) || box2.contains(box1);
}
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines