tesseract  3.03
/usr/local/google/home/jbreiden/tesseract-ocr-read-only/textord/edgblob.h
Go to the documentation of this file.
00001 /**********************************************************************
00002  * File:        edgblob.h  (Formerly edgeloop.h)
00003  * Description: Functions to clean up an outline before approximation.
00004  * Author:              Ray Smith
00005  * Created:             Tue Mar 26 16:56:25 GMT 1991
00006  *
00007  * (C) Copyright 1991, Hewlett-Packard Ltd.
00008  ** Licensed under the Apache License, Version 2.0 (the "License");
00009  ** you may not use this file except in compliance with the License.
00010  ** You may obtain a copy of the License at
00011  ** http://www.apache.org/licenses/LICENSE-2.0
00012  ** Unless required by applicable law or agreed to in writing, software
00013  ** distributed under the License is distributed on an "AS IS" BASIS,
00014  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  ** See the License for the specific language governing permissions and
00016  ** limitations under the License.
00017  *
00018  **********************************************************************/
00019 
00020 #ifndef           EDGBLOB_H
00021 #define           EDGBLOB_H
00022 
00023 #include          "scrollview.h"
00024 #include          "params.h"
00025 #include          "ocrblock.h"
00026 #include          "coutln.h"
00027 #include          "crakedge.h"
00028 
00029 #define BUCKETSIZE      16
00030 
00031 class OL_BUCKETS
00032 {
00033   public:
00034     OL_BUCKETS(               //constructor
00035                ICOORD bleft,  //corners
00036                ICOORD tright);
00037 
00038     ~OL_BUCKETS () {             //cleanup
00039       delete[]buckets;
00040     }
00041     C_OUTLINE_LIST *operator () (//array access
00042       inT16 x,                   //image coords
00043       inT16 y);
00044                                  //first non-empty bucket
00045     C_OUTLINE_LIST *start_scan() {
00046       for (index = 0; buckets[index].empty () && index < bxdim * bydim - 1;
00047         index++);
00048       return &buckets[index];
00049     }
00050                                  //next non-empty bucket
00051     C_OUTLINE_LIST *scan_next() {
00052       for (; buckets[index].empty () && index < bxdim * bydim - 1; index++);
00053       return &buckets[index];
00054     }
00055     inT32 count_children(                     //recursive sum
00056                          C_OUTLINE *outline,  //parent outline
00057                          inT32 max_count);    // max output
00058     inT32 outline_complexity(                 // new version of count_children
00059                          C_OUTLINE *outline,  // parent outline
00060                          inT32 max_count,     // max output
00061                          inT16 depth);        // level of recursion
00062     void extract_children(                     //single level get
00063                           C_OUTLINE *outline,  //parent outline
00064                           C_OUTLINE_IT *it);   //destination iterator
00065 
00066   private:
00067     C_OUTLINE_LIST * buckets;    //array of buckets
00068     inT16 bxdim;                 //size of array
00069     inT16 bydim;
00070     ICOORD bl;                   //corners
00071     ICOORD tr;
00072     inT32 index;                 //for extraction scan
00073 };
00074 
00075 void extract_edges(Pix* pix,        // thresholded image
00076                    BLOCK* block);   // block to scan
00077 void outlines_to_blobs(               //find blobs
00078                        BLOCK *block,  //block to scan
00079                        ICOORD bleft,  //block box //outlines in block
00080                        ICOORD tright,
00081                        C_OUTLINE_LIST *outlines);
00082 void fill_buckets(                           //find blobs
00083                   C_OUTLINE_LIST *outlines,  //outlines in block
00084                   OL_BUCKETS *buckets        //output buckets
00085                  );
00086 void empty_buckets(                     //find blobs
00087                    BLOCK *block,        //block to scan
00088                    OL_BUCKETS *buckets  //output buckets
00089                   );
00090 BOOL8 capture_children(                       //find children
00091                        OL_BUCKETS *buckets,   //bucket sort clanss
00092                        C_BLOB_IT *reject_it,  //dead grandchildren
00093                        C_OUTLINE_IT *blob_it  //output outlines
00094                       );
00095 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines