Tesseract  3.02
tesseract-ocr/textord/pitsync1.h
Go to the documentation of this file.
00001 /**********************************************************************
00002  * File:        pitsync1.h  (Formerly pitsync.h)
00003  * Description: Code to find the optimum fixed pitch segmentation of some blobs.
00004  * Author:              Ray Smith
00005  * Created:             Thu Nov 19 11:48:05 GMT 1992
00006  *
00007  * (C) Copyright 1992, 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           PITSYNC1_H
00021 #define           PITSYNC1_H
00022 
00023 #include          "elst.h"
00024 #include          "clst.h"
00025 #include          "blobbox.h"
00026 #include          "params.h"
00027 #include          "statistc.h"
00028 #include          "pithsync.h"
00029 #include          "notdll.h"
00030 #include          "notdll.h"
00031 
00032 class FPSEGPT_LIST;
00033 
00034 class FPSEGPT:public ELIST_LINK
00035 {
00036   public:
00037     FPSEGPT() {  //empty
00038     }
00039     FPSEGPT(           //constructor
00040             inT16 x);  //position
00041     FPSEGPT(                           //constructor
00042             inT16 x,                   //position
00043             BOOL8 faking,              //faking this one
00044             inT16 offset,              //extra cost dist
00045             inT16 region_index,        //segment number
00046             inT16 pitch,               //proposed pitch
00047             inT16 pitch_error,         //allowed tolerance
00048             FPSEGPT_LIST *prev_list);  //previous segment
00049     FPSEGPT(FPCUTPT *cutpt);  //build from new type
00050 
00051     inT32 position() {  //acces func
00052       return xpos;
00053     }
00054     double cost_function() {
00055       return cost;
00056     }
00057     double squares() {
00058       return sq_sum;
00059     }
00060     double sum() {
00061       return mean_sum;
00062     }
00063     FPSEGPT *previous() {
00064       return pred;
00065     }
00066     inT16 cheap_cuts() const {  //no of cheap cuts
00067       return mid_cuts;
00068     }
00069 
00070                                  //faked split point
00071     BOOL8 faked;
00072     BOOL8 terminal;              //successful end
00073     inT16 fake_count;            //total fakes to here
00074 
00075   private:
00076     inT16 mid_cuts;              //no of cheap cuts
00077     inT32 xpos;                  //location
00078     FPSEGPT *pred;               //optimal previous
00079     double mean_sum;             //mean so far
00080     double sq_sum;               //summed distsances
00081     double cost;                 //cost function
00082 };
00083 
00084 ELISTIZEH (FPSEGPT) CLISTIZEH (FPSEGPT_LIST)
00085 extern
00086 INT_VAR_H (pitsync_linear_version, 0, "Use new fast algorithm");
00087 extern
00088 double_VAR_H (pitsync_joined_edge, 0.75,
00089 "Dist inside big blob for chopping");
00090 extern
00091 double_VAR_H (pitsync_offset_freecut_fraction, 0.25,
00092 "Fraction of cut for free cuts");
00093 extern
00094 INT_VAR_H (pitsync_fake_depth, 1, "Max advance fake generation");
00095 double check_pitch_sync(                        //find segmentation
00096                         BLOBNBOX_IT *blob_it,   //blobs to do
00097                         inT16 blob_count,       //no of blobs
00098                         inT16 pitch,            //pitch estimate
00099                         inT16 pitch_error,      //tolerance
00100                         STATS *projection,      //vertical
00101                         FPSEGPT_LIST *seg_list  //output list
00102                        );
00103 void make_illegal_segment(                          //find segmentation
00104                           FPSEGPT_LIST *prev_list,  //previous segments
00105                           TBOX blob_box,             //bounding box
00106                           BLOBNBOX_IT blob_it,      //iterator
00107                           inT16 region_index,       //number of segment
00108                           inT16 pitch,              //pitch estimate
00109                           inT16 pitch_error,        //tolerance
00110                           FPSEGPT_LIST *seg_list    //output list
00111                          );
00112 inT16 vertical_torow_projection(                   //project whole row
00113                                 TO_ROW *row,       //row to do
00114                                 STATS *projection  //output
00115                                );
00116 void vertical_cblob_projection(               //project outlines
00117                                C_BLOB *blob,  //blob to project
00118                                STATS *stats   //output
00119                               );
00120 void vertical_coutline_projection(                     //project outlines
00121                                   C_OUTLINE *outline,  //outline to project
00122                                   STATS *stats         //output
00123                                  );
00124 #endif