Tesseract  3.02
tesseract-ocr/textord/pithsync.h
Go to the documentation of this file.
00001 /**********************************************************************
00002  * File:        pithsync.h  (Formerly pitsync2.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           PITHSYNC_H
00021 #define           PITHSYNC_H
00022 
00023 #include          "blobbox.h"
00024 #include          "params.h"
00025 #include          "statistc.h"
00026 #include          "notdll.h"
00027 
00028 class FPSEGPT_LIST;
00029 
00030 class FPCUTPT
00031 {
00032   public:
00033     FPCUTPT() {  //empty
00034     }
00035     void setup (                 //start of cut
00036       FPCUTPT cutpts[],          //predecessors
00037       inT16 array_origin,        //start coord
00038       STATS * projection,        //occupation
00039       inT16 zero_count,          //official zero
00040       inT16 pitch,               //proposed pitch
00041       inT16 x,                   //position
00042       inT16 offset);             //dist to gap
00043 
00044     void assign (                //evaluate cut
00045       FPCUTPT cutpts[],          //predecessors
00046       inT16 array_origin,        //start coord
00047       inT16 x,                   //position
00048       BOOL8 faking,              //faking this one
00049       BOOL8 mid_cut,             //doing free cut
00050       inT16 offset,              //extra cost dist
00051       STATS * projection,        //occupation
00052       float projection_scale,    //scaling
00053       inT16 zero_count,          //official zero
00054       inT16 pitch,               //proposed pitch
00055       inT16 pitch_error);        //allowed tolerance
00056 
00057     void assign_cheap (          //evaluate cut
00058       FPCUTPT cutpts[],          //predecessors
00059       inT16 array_origin,        //start coord
00060       inT16 x,                   //position
00061       BOOL8 faking,              //faking this one
00062       BOOL8 mid_cut,             //doing free cut
00063       inT16 offset,              //extra cost dist
00064       STATS * projection,        //occupation
00065       float projection_scale,    //scaling
00066       inT16 zero_count,          //official zero
00067       inT16 pitch,               //proposed pitch
00068       inT16 pitch_error);        //allowed tolerance
00069 
00070     inT32 position() {  //acces func
00071       return xpos;
00072     }
00073     double cost_function() {
00074       return cost;
00075     }
00076     double squares() {
00077       return sq_sum;
00078     }
00079     double sum() {
00080       return mean_sum;
00081     }
00082     FPCUTPT *previous() {
00083       return pred;
00084     }
00085     inT16 cheap_cuts() const {  //no of mi cuts
00086       return mid_cuts;
00087     }
00088     inT16 index() const {
00089       return region_index;
00090     }
00091 
00092     BOOL8 faked;                 //faked split point
00093     BOOL8 terminal;              //successful end
00094     inT16 fake_count;            //total fakes to here
00095 
00096   private:
00097     inT16 region_index;          //cut serial number
00098     inT16 mid_cuts;              //no of cheap cuts
00099     inT32 xpos;                  //location
00100     uinT32 back_balance;         //proj backwards
00101     uinT32 fwd_balance;          //proj forwards
00102     FPCUTPT *pred;               //optimal previous
00103     double mean_sum;             //mean so far
00104     double sq_sum;               //summed distsances
00105     double cost;                 //cost function
00106 };
00107 double check_pitch_sync2(                          //find segmentation
00108                          BLOBNBOX_IT *blob_it,     //blobs to do
00109                          inT16 blob_count,         //no of blobs
00110                          inT16 pitch,              //pitch estimate
00111                          inT16 pitch_error,        //tolerance
00112                          STATS *projection,        //vertical
00113                          inT16 projection_left,    //edges //scale factor
00114                          inT16 projection_right,
00115                          float projection_scale,
00116                          inT16 &occupation_count,  //no of occupied cells
00117                          FPSEGPT_LIST *seg_list,   //output list
00118                          inT16 start,              //start of good range
00119                          inT16 end                 //end of good range
00120                         );
00121 double check_pitch_sync3(                          //find segmentation
00122                          inT16 projection_left,    //edges //to be considered 0
00123                          inT16 projection_right,
00124                          inT16 zero_count,
00125                          inT16 pitch,              //pitch estimate
00126                          inT16 pitch_error,        //tolerance
00127                          STATS *projection,        //vertical
00128                          float projection_scale,   //scale factor
00129                          inT16 &occupation_count,  //no of occupied cells
00130                          FPSEGPT_LIST *seg_list,   //output list
00131                          inT16 start,              //start of good range
00132                          inT16 end                 //end of good range
00133                         );
00134 #endif