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 "params.h"
00029 #include "elst.h"
00030 #include "notdll.h"
00031 #include "notdll.h"
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 class REGION_OCC:public ELIST_LINK
00051 {
00052 public:
00053 float min_x;
00054 float max_x;
00055 inT16 region_type;
00056
00057 REGION_OCC() {
00058 };
00059
00060 REGION_OCC(
00061 float min,
00062 float max,
00063 inT16 region) {
00064 min_x = min;
00065 max_x = max;
00066 region_type = region;
00067 }
00068 };
00069
00070 ELISTIZEH (REGION_OCC)
00071 #define RANGE_IN_BAND( band_max, band_min, range_max, range_min ) \
00072 ( ((range_min) >= (band_min)) && ((range_max) < (band_max)) ) ? TRUE : FALSE
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 #define RANGE_OVERLAPS_BAND( band_max, band_min, range_max, range_min ) \
00091 ( ((range_max) >= (band_min)) && ((range_min) < (band_max)) ) ? TRUE : FALSE
00092
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 class BAND
00130 {
00131 public:
00132 inT16 max_max;
00133 inT16 max;
00134 inT16 min_max;
00135 inT16 max_min;
00136 inT16 min;
00137 inT16 min_min;
00138
00139 BAND() {
00140 }
00141
00142 void set(
00143 inT16 new_max_max,
00144 inT16 new_max,
00145 inT16 new_min_max,
00146 inT16 new_max_min,
00147 inT16 new_min,
00148 inT16 new_min_min) {
00149 max_max = new_max_max;
00150 max = new_max;
00151 min_max = new_min_max;
00152 max_min = new_max_min;
00153 min = new_min;
00154 min_min = new_min_min;
00155 }
00156
00157 BOOL8 in_minimal(
00158 float y) {
00159 if ((y >= max_min) && (y < min_max))
00160 return TRUE;
00161 else
00162 return FALSE;
00163 }
00164
00165 BOOL8 in_nominal(
00166 float y) {
00167 if ((y >= min) && (y < max))
00168 return TRUE;
00169 else
00170 return FALSE;
00171 }
00172
00173 BOOL8 in_maximal(
00174 float y) {
00175 if ((y >= min_min) && (y < max_max))
00176 return TRUE;
00177 else
00178 return FALSE;
00179 }
00180
00181
00182 BOOL8 range_overlaps_minimal(float y1,
00183 float y2) {
00184 if (y1 > y2)
00185 return RANGE_OVERLAPS_BAND (min_max, max_min, y1, y2);
00186 else
00187 return RANGE_OVERLAPS_BAND (min_max, max_min, y2, y1);
00188 }
00189
00190
00191 BOOL8 range_overlaps_nominal(float y1,
00192 float y2) {
00193 if (y1 > y2)
00194 return RANGE_OVERLAPS_BAND (max, min, y1, y2);
00195 else
00196 return RANGE_OVERLAPS_BAND (max, min, y2, y1);
00197 }
00198
00199
00200 BOOL8 range_overlaps_maximal(float y1,
00201 float y2) {
00202 if (y1 > y2)
00203 return RANGE_OVERLAPS_BAND (max_max, min_min, y1, y2);
00204 else
00205 return RANGE_OVERLAPS_BAND (max_max, min_min, y2, y1);
00206 }
00207
00208 BOOL8 range_in_minimal(
00209 float y1,
00210 float y2) {
00211 if (y1 > y2)
00212 return RANGE_IN_BAND (min_max, max_min, y1, y2);
00213 else
00214 return RANGE_IN_BAND (min_max, max_min, y2, y1);
00215 }
00216
00217 BOOL8 range_in_nominal(
00218 float y1,
00219 float y2) {
00220 if (y1 > y2)
00221 return RANGE_IN_BAND (max, min, y1, y2);
00222 else
00223 return RANGE_IN_BAND (max, min, y2, y1);
00224 }
00225
00226 BOOL8 range_in_maximal(
00227 float y1,
00228 float y2) {
00229 if (y1 > y2)
00230 return RANGE_IN_BAND (max_max, min_min, y1, y2);
00231 else
00232 return RANGE_IN_BAND (max_max, min_min, y2, y1);
00233 }
00234 };
00235
00236
00237
00238 #define MAX_NUM_BANDS 5
00239 #define UNDEFINED_BAND 99
00240 #define NO_LOWER_LIMIT -9999
00241 #define NO_UPPER_LIMIT 9999
00242
00243 #define DOT_BAND 0
00244
00245
00246
00247 #define END_OF_WERD_CODE 255
00248
00249 extern BOOL_VAR_H (blockocc_show_result, FALSE, "Show intermediate results");
00250 extern INT_VAR_H (blockocc_desc_height, 0,
00251 "Descender height after normalisation");
00252 extern INT_VAR_H (blockocc_asc_height, 255,
00253 "Ascender height after normalisation");
00254 extern INT_VAR_H (blockocc_band_count, 4, "Number of bands used");
00255 extern double_VAR_H (textord_underline_threshold, 0.9,
00256 "Fraction of width occupied");
00257
00258 BOOL8 test_underline(
00259 BOOL8 testing_on,
00260 C_BLOB *blob,
00261 inT16 baseline,
00262 inT16 xheight
00263 );
00264
00265 #endif