Tesseract  3.02
tesseract-ocr/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          "img.h"
00026 #include          "ocrblock.h"
00027 #include          "coutln.h"
00028 #include          "crakedge.h"
00029 #include          "notdll.h"
00030 
00031 #define BUCKETSIZE      16
00032 
00033 class OL_BUCKETS
00034 {
00035   public:
00036     OL_BUCKETS(               //constructor
00037                ICOORD bleft,  //corners
00038                ICOORD tright);
00039 
00040     ~OL_BUCKETS () {             //cleanup
00041       delete[]buckets;
00042     }
00043     C_OUTLINE_LIST *operator () (//array access
00044       inT16 x,                   //image coords
00045       inT16 y);
00046                                  //first non-empty bucket
00047     C_OUTLINE_LIST *start_scan() {
00048       for (index = 0; buckets[index].empty () && index < bxdim * bydim - 1;
00049         index++);
00050       return &buckets[index];
00051     }
00052                                  //next non-empty bucket
00053     C_OUTLINE_LIST *scan_next() {
00054       for (; buckets[index].empty () && index < bxdim * bydim - 1; index++);
00055       return &buckets[index];
00056     }
00057     inT32 count_children(                     //recursive sum
00058                          C_OUTLINE *outline,  //parent outline
00059                          inT32 max_count);    // max output
00060     inT32 outline_complexity(                 // new version of count_children
00061                          C_OUTLINE *outline,  // parent outline
00062                          inT32 max_count,     // max output
00063                          inT16 depth);        // level of recursion
00064     void extract_children(                     //single level get
00065                           C_OUTLINE *outline,  //parent outline
00066                           C_OUTLINE_IT *it);   //destination iterator
00067 
00068   private:
00069     C_OUTLINE_LIST * buckets;    //array of buckets
00070     inT16 bxdim;                 //size of array
00071     inT16 bydim;
00072     ICOORD bl;                   //corners
00073     ICOORD tr;
00074     inT32 index;                 //for extraction scan
00075 };
00076 
00077 void extract_edges(Pix* pix,        // thresholded image
00078                    BLOCK* block);   // block to scan
00079 void outlines_to_blobs(               //find blobs
00080                        BLOCK *block,  //block to scan
00081                        ICOORD bleft,  //block box //outlines in block
00082                        ICOORD tright,
00083                        C_OUTLINE_LIST *outlines);
00084 void fill_buckets(                           //find blobs
00085                   C_OUTLINE_LIST *outlines,  //outlines in block
00086                   OL_BUCKETS *buckets        //output buckets
00087                  );
00088 void empty_buckets(                     //find blobs
00089                    BLOCK *block,        //block to scan
00090                    OL_BUCKETS *buckets  //output buckets
00091                   );
00092 BOOL8 capture_children(                       //find children
00093                        OL_BUCKETS *buckets,   //bucket sort clanss
00094                        C_BLOB_IT *reject_it,  //dead grandchildren
00095                        C_OUTLINE_IT *blob_it  //output outlines
00096                       );
00097 #endif