31 #define _USE_MATH_DEFINES
35 #define M_PI 3.14159265358979323846
41 #include "config_auto.h"
76 #define PROGRAM_FEATURE_TYPE "mf"
94 #ifndef GRAPHICS_DISABLED
95 static void DisplayProtoList(
const char* ch,
LIST protolist) {
97 520, 520, -130.0, 130.0, -130.0, 130.0);
98 LIST proto = protolist;
105 else if (prototype->
Merged)
112 float dx =
static_cast<float>(
LengthOf(prototype->
Mean) * cos(angle) / 2);
113 float dy =
static_cast<float>(
LengthOf(prototype->
Mean) * sin(angle) / 2);
114 c_move(window, (x - dx) * 256, (y - dy) * 256);
115 c_draw(window, (x + dx) * 256, (y + dy) * 256);
117 tprintf(
"Green proto at (%g,%g)+(%g,%g) %d samples\n",
120 tprintf(
"Red proto at (%g,%g)+(%g,%g) %d samples\n",
125 #endif // GRAPHICS_DISABLED
129 static LIST ClusterOneConfig(
int shape_id,
const char* class_label,
145 #ifndef GRAPHICS_DISABLED
146 if (strcmp(FLAGS_test_ch.c_str(), class_label) == 0)
147 DisplayProtoList(FLAGS_test_ch.c_str(), proto_list);
148 #endif // GRAPHICS_DISABLED
155 if (merge_class ==
NULL) {
157 mf_classes =
push(mf_classes, merge_class);
161 LIST proto_it = proto_list;
177 static_cast<FLOAT32>(merge_class->
NumMerged[p_id]),
194 int num_configs = shape_table->
NumShapes();
195 config_map->
Init(num_configs,
true);
197 for (
int c1 = 0; c1 < num_configs; ++c1) {
202 for (
int c2 = c1 + 1; c2 < num_configs; ++c2) {
204 config_map->
Merge(c1, c2);
213 int main (
int argc,
char **argv) {
264 SetupConfigMap(shape_table, &config_map);
276 unicharset = &shape_set;
280 for (
int s = 0; s < num_shapes; ++s) {
288 int num_configs = shape_table->
NumShapes();
290 for (
int s = 0; s < num_configs; ++s) {
291 int unichar_id, font_id;
292 if (unicharset == &shape_set) {
299 const char* class_label = unicharset->
id_to_unichar(unichar_id);
300 mf_classes = ClusterOneConfig(s, class_label, mf_classes, *shape_table,
303 STRING inttemp_file = file_prefix;
304 inttemp_file +=
"inttemp";
305 STRING pffmtable_file = file_prefix;
306 pffmtable_file +=
"pffmtable";
310 *shape_table, float_classes,
313 delete [] float_classes;
318 if (!FLAGS_test_ch.empty()) {
320 printf(
"Hit return to exit...\n");
321 while (getchar() !=
'\n');