textord/blkocc.h

Go to the documentation of this file.
00001 
00019 #ifndef           BLKOCC_H
00020 #define           BLKOCC_H
00021 
00022 #include          "varable.h"
00023 #include          "polyblob.h"
00024 #include          "elst.h"
00025 #include          "notdll.h"
00026 #include          "notdll.h"
00027 
00042 class REGION_OCC:public ELIST_LINK
00043 {
00044   public:
00045     float min_x;                 //Lowest x in region
00046     float max_x;                 //Highest x in region
00047     INT16 region_type;           //Type of crossing
00048 
00049     REGION_OCC() { 
00050     };                           //constructor used
00051     //only in COPIER etc
00052     REGION_OCC(  //constructor
00053                float min,
00054                float max,
00055                INT16 region) {
00056       min_x = min;
00057       max_x = max;
00058       region_type = region;
00059     }
00060 };
00061 
00062 ELISTIZEH (REGION_OCC)
00063 #define RANGE_IN_BAND( band_max, band_min, range_max, range_min ) \
00064 ( ((range_min) >= (band_min)) && ((range_max) < (band_max)) ) ? TRUE : FALSE
00065 
00086 #define RANGE_OVERLAPS_BAND( band_max, band_min, range_max, range_min ) \
00087 ( ((range_max) >= (band_min)) && ((range_min) < (band_max)) ) ? TRUE : FALSE
00088 
00135 class BAND
00136 {
00137   public:
00138     INT16 max_max;               //upper max
00139     INT16 max;                   //nominal max
00140     INT16 min_max;               //lower max
00141     INT16 max_min;               //upper min
00142     INT16 min;                   //nominal min
00143     INT16 min_min;               //lower min
00144 
00145     BAND() { 
00146     }                            // constructor
00147 
00148     void set(                      // initialise a band
00149              INT16 new_max_max,    // upper max
00150              INT16 new_max,        // new nominal max
00151              INT16 new_min_max,    // new lower max
00152              INT16 new_max_min,    // new upper min
00153              INT16 new_min,        // new nominal min
00154              INT16 new_min_min) {  // new lower min
00155       max_max = new_max_max;
00156       max = new_max;
00157       min_max = new_min_max;
00158       max_min = new_max_min;
00159       min = new_min;
00160       min_min = new_min_min;
00161     }
00162 
00163     BOOL8 in_minimal(            //in minimal limits?
00164                      float y) {  //y value
00165       if ((y >= max_min) && (y < min_max))
00166         return TRUE;
00167       else
00168         return FALSE;
00169     }
00170 
00171     BOOL8 in_nominal(            //in nominal limits?
00172                      float y) {  //y value
00173       if ((y >= min) && (y < max))
00174         return TRUE;
00175       else
00176         return FALSE;
00177     }
00178 
00179     BOOL8 in_maximal(            //in maximal limits?
00180                      float y) {  //y value
00181       if ((y >= min_min) && (y < max_max))
00182         return TRUE;
00183       else
00184         return FALSE;
00185     }
00186 
00187                                  //overlaps min limits?
00188     BOOL8 range_overlaps_minimal(float y1,    // one range limit
00189                                  float y2) {  // other range limit
00190       if (y1 > y2)
00191         return RANGE_OVERLAPS_BAND (min_max, max_min, y1, y2);
00192       else
00193         return RANGE_OVERLAPS_BAND (min_max, max_min, y2, y1);
00194     }
00195 
00196                                  //overlaps nom limits?
00197     BOOL8 range_overlaps_nominal(float y1,    // one range limit
00198                                  float y2) {  // other range limit
00199       if (y1 > y2)
00200         return RANGE_OVERLAPS_BAND (max, min, y1, y2);
00201       else
00202         return RANGE_OVERLAPS_BAND (max, min, y2, y1);
00203     }
00204 
00205                                  //overlaps max limits?
00206     BOOL8 range_overlaps_maximal(float y1,    // one range limit
00207                                  float y2) {  // other range limit
00208       if (y1 > y2)
00209         return RANGE_OVERLAPS_BAND (max_max, min_min, y1, y2);
00210       else
00211         return RANGE_OVERLAPS_BAND (max_max, min_min, y2, y1);
00212     }
00213 
00214     BOOL8 range_in_minimal(             //within min limits?
00215                            float y1,    //one range limit
00216                            float y2) {  //other range limit
00217       if (y1 > y2)
00218         return RANGE_IN_BAND (min_max, max_min, y1, y2);
00219       else
00220         return RANGE_IN_BAND (min_max, max_min, y2, y1);
00221     }
00222 
00223     BOOL8 range_in_nominal(             //within nom limits?
00224                            float y1,    //one range limit
00225                            float y2) {  //other range limit
00226       if (y1 > y2)
00227         return RANGE_IN_BAND (max, min, y1, y2);
00228       else
00229         return RANGE_IN_BAND (max, min, y2, y1);
00230     }
00231 
00232     BOOL8 range_in_maximal(             //within max limits?
00233                            float y1,    //one range limit
00234                            float y2) {  //other range limit
00235       if (y1 > y2)
00236         return RANGE_IN_BAND (max_max, min_min, y1, y2);
00237       else
00238         return RANGE_IN_BAND (max_max, min_min, y2, y1);
00239     }
00240 };
00241 
00243 #define MAX_NUM_BANDS 5
00244 
00245 #define UNDEFINED_BAND 99
00246 #define NO_LOWER_LIMIT -9999
00247 #define NO_UPPER_LIMIT 9999
00248 
00250 #define DOT_BAND 0
00251 
00253 #define END_OF_WERD_CODE 255
00254 
00257 extern BOOL_VAR_H (blockocc_show_result, FALSE, "Show intermediate results");
00258 extern INT_VAR_H (blockocc_desc_height, 0,
00259 "Descender height after normalisation");
00260 extern INT_VAR_H (blockocc_asc_height, 255,
00261 "Ascender height after normalisation");
00262 extern INT_VAR_H (blockocc_band_count, 4, "Number of bands used");
00263 extern double_VAR_H (textord_underline_threshold, 0.9,
00264 "Fraction of width occupied");
00267 BOOL8 test_underline(                   //look for underlines
00268                      BOOL8 testing_on,  //drawing blob
00269                      PBLOB *blob,       //blob to test
00270                      float baseline,    //coords of baseline
00271                      float xheight      //height of line
00272                     );
00273 BOOL8 test_underline(                   //look for underlines
00274                      BOOL8 testing_on,  //drawing blob
00275                      C_BLOB *blob,      //blob to test
00276                      INT16 baseline,    //coords of baseline
00277                      INT16 xheight      //height of line
00278                     );
00279                                  //project outlines
00280 void horizontal_cblob_projection(C_BLOB *blob,  //blob to project
00281                                  STATS *stats   //output
00282                                 );
00283 void horizontal_coutline_projection(                     //project outlines
00284                                     C_OUTLINE *outline,  //outline to project
00285                                     STATS *stats         //output
00286                                    );
00287 void set_bands(                 //init from varibles
00288                float baseline,  //top of bottom band
00289                float xheight    //height of split band
00290               );
00291 void block_occ (PBLOB * blob,    //blob to do
00292 float occs[]                     //output histogram
00293 );
00294                                  //blob to do
00295 void find_transitions(PBLOB *blob, REGION_OCC_LIST *region_occ_list); 
00296 void record_region(  //add region on list
00297                    INT16 band,
00298                    float new_min,
00299                    float new_max,
00300                    INT16 region_type,
00301                    REGION_OCC_LIST *region_occ_list);
00302 INT16 find_containing_maximal_band(  //find range's band
00303                                    float y1,
00304                                    float y2,
00305                                    BOOL8 *doubly_contained);
00306 void find_significant_line(POLYPT_IT it, INT16 *band); 
00307 INT16 find_overlapping_minimal_band(  //find range's band
00308                                     float y1,
00309                                     float y2);
00310 INT16 find_region_type(INT16 entry_band,
00311                        INT16 current_band,
00312                        INT16 exit_band,
00313                        float entry_x,
00314                        float exit_x);
00315 void find_trans_point(POLYPT_IT *pt_it,
00316                       INT16 current_band,
00317                       INT16 next_band,
00318                       FCOORD *transition_pt);
00319 void next_region(POLYPT_IT *start_pt_it,
00320                  INT16 start_band,
00321                  INT16 *to_band,
00322                  float *min_x,
00323                  float *max_x,
00324                  INT16 *increment,
00325                  FCOORD *exit_pt);
00326 INT16 find_band(  // find POINT's band
00327                 float y);
00328 void compress_region_list(  // join open regions
00329                           REGION_OCC_LIST *region_occ_list);
00330 void find_fbox(OUTLINE_IT *out_it,
00331                float *min_x,
00332                float *min_y,
00333                float *max_x,
00334                float *max_y);
00335 void maintain_limits(float *min_x, float *max_x, float x); 
00336 #endif

Generated on Wed Feb 28 19:49:11 2007 for Tesseract by  doxygen 1.5.1