00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef BLKOCC_H
00026 #define BLKOCC_H
00027
00028 #include "varable.h"
00029 #include "polyblob.h"
00030 #include "elst.h"
00031 #include "notdll.h"
00032 #include "notdll.h"
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 class REGION_OCC:public ELIST_LINK
00052 {
00053 public:
00054 float min_x;
00055 float max_x;
00056 inT16 region_type;
00057
00058 REGION_OCC() {
00059 };
00060
00061 REGION_OCC(
00062 float min,
00063 float max,
00064 inT16 region) {
00065 min_x = min;
00066 max_x = max;
00067 region_type = region;
00068 }
00069 };
00070
00071 ELISTIZEH (REGION_OCC)
00072 #define RANGE_IN_BAND( band_max, band_min, range_max, range_min ) \
00073 ( ((range_min) >= (band_min)) && ((range_max) < (band_max)) ) ? TRUE : FALSE
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 #define RANGE_OVERLAPS_BAND( band_max, band_min, range_max, range_min ) \
00092 ( ((range_max) >= (band_min)) && ((range_min) < (band_max)) ) ? TRUE : FALSE
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 class BAND
00131 {
00132 public:
00133 inT16 max_max;
00134 inT16 max;
00135 inT16 min_max;
00136 inT16 max_min;
00137 inT16 min;
00138 inT16 min_min;
00139
00140 BAND() {
00141 }
00142
00143 void set(
00144 inT16 new_max_max,
00145 inT16 new_max,
00146 inT16 new_min_max,
00147 inT16 new_max_min,
00148 inT16 new_min,
00149 inT16 new_min_min) {
00150 max_max = new_max_max;
00151 max = new_max;
00152 min_max = new_min_max;
00153 max_min = new_max_min;
00154 min = new_min;
00155 min_min = new_min_min;
00156 }
00157
00158 BOOL8 in_minimal(
00159 float y) {
00160 if ((y >= max_min) && (y < min_max))
00161 return TRUE;
00162 else
00163 return FALSE;
00164 }
00165
00166 BOOL8 in_nominal(
00167 float y) {
00168 if ((y >= min) && (y < max))
00169 return TRUE;
00170 else
00171 return FALSE;
00172 }
00173
00174 BOOL8 in_maximal(
00175 float y) {
00176 if ((y >= min_min) && (y < max_max))
00177 return TRUE;
00178 else
00179 return FALSE;
00180 }
00181
00182
00183 BOOL8 range_overlaps_minimal(float y1,
00184 float y2) {
00185 if (y1 > y2)
00186 return RANGE_OVERLAPS_BAND (min_max, max_min, y1, y2);
00187 else
00188 return RANGE_OVERLAPS_BAND (min_max, max_min, y2, y1);
00189 }
00190
00191
00192 BOOL8 range_overlaps_nominal(float y1,
00193 float y2) {
00194 if (y1 > y2)
00195 return RANGE_OVERLAPS_BAND (max, min, y1, y2);
00196 else
00197 return RANGE_OVERLAPS_BAND (max, min, y2, y1);
00198 }
00199
00200
00201 BOOL8 range_overlaps_maximal(float y1,
00202 float y2) {
00203 if (y1 > y2)
00204 return RANGE_OVERLAPS_BAND (max_max, min_min, y1, y2);
00205 else
00206 return RANGE_OVERLAPS_BAND (max_max, min_min, y2, y1);
00207 }
00208
00209 BOOL8 range_in_minimal(
00210 float y1,
00211 float y2) {
00212 if (y1 > y2)
00213 return RANGE_IN_BAND (min_max, max_min, y1, y2);
00214 else
00215 return RANGE_IN_BAND (min_max, max_min, y2, y1);
00216 }
00217
00218 BOOL8 range_in_nominal(
00219 float y1,
00220 float y2) {
00221 if (y1 > y2)
00222 return RANGE_IN_BAND (max, min, y1, y2);
00223 else
00224 return RANGE_IN_BAND (max, min, y2, y1);
00225 }
00226
00227 BOOL8 range_in_maximal(
00228 float y1,
00229 float y2) {
00230 if (y1 > y2)
00231 return RANGE_IN_BAND (max_max, min_min, y1, y2);
00232 else
00233 return RANGE_IN_BAND (max_max, min_min, y2, y1);
00234 }
00235 };
00236
00237
00238
00239 #define MAX_NUM_BANDS 5
00240 #define UNDEFINED_BAND 99
00241 #define NO_LOWER_LIMIT -9999
00242 #define NO_UPPER_LIMIT 9999
00243
00244 #define DOT_BAND 0
00245
00246
00247
00248 #define END_OF_WERD_CODE 255
00249
00250 extern BOOL_VAR_H (blockocc_show_result, FALSE, "Show intermediate results");
00251 extern INT_VAR_H (blockocc_desc_height, 0,
00252 "Descender height after normalisation");
00253 extern INT_VAR_H (blockocc_asc_height, 255,
00254 "Ascender height after normalisation");
00255 extern INT_VAR_H (blockocc_band_count, 4, "Number of bands used");
00256 extern double_VAR_H (textord_underline_threshold, 0.9,
00257 "Fraction of width occupied");
00258 BOOL8 test_underline(
00259 BOOL8 testing_on,
00260 PBLOB *blob,
00261 float baseline,
00262 float xheight
00263 );
00264 BOOL8 test_underline(
00265 BOOL8 testing_on,
00266 C_BLOB *blob,
00267 inT16 baseline,
00268 inT16 xheight
00269 );
00270
00271 void horizontal_cblob_projection(C_BLOB *blob,
00272 STATS *stats
00273 );
00274 void horizontal_coutline_projection(
00275 C_OUTLINE *outline,
00276 STATS *stats
00277 );
00278 void set_bands(
00279 float baseline,
00280 float xheight
00281 );
00282 void block_occ (PBLOB * blob,
00283 float occs[]
00284 );
00285
00286 void find_transitions(PBLOB *blob, REGION_OCC_LIST *region_occ_list);
00287 void record_region(
00288 inT16 band,
00289 float new_min,
00290 float new_max,
00291 inT16 region_type,
00292 REGION_OCC_LIST *region_occ_list);
00293 inT16 find_containing_maximal_band(
00294 float y1,
00295 float y2,
00296 BOOL8 *doubly_contained);
00297 void find_significant_line(POLYPT_IT it, inT16 *band);
00298 inT16 find_overlapping_minimal_band(
00299 float y1,
00300 float y2);
00301 inT16 find_region_type(inT16 entry_band,
00302 inT16 current_band,
00303 inT16 exit_band,
00304 float entry_x,
00305 float exit_x);
00306 void find_trans_point(POLYPT_IT *pt_it,
00307 inT16 current_band,
00308 inT16 next_band,
00309 FCOORD *transition_pt);
00310 void next_region(POLYPT_IT *start_pt_it,
00311 inT16 start_band,
00312 inT16 *to_band,
00313 float *min_x,
00314 float *max_x,
00315 inT16 *increment,
00316 FCOORD *exit_pt);
00317 inT16 find_band(
00318 float y);
00319 void compress_region_list(
00320 REGION_OCC_LIST *region_occ_list);
00321 void find_fbox(OUTLINE_IT *out_it,
00322 float *min_x,
00323 float *min_y,
00324 float *max_x,
00325 float *max_y);
00326 void maintain_limits(float *min_x, float *max_x, float x);
00327 #endif