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