diff options
-rw-r--r-- | main.c | 31 |
1 files changed, 14 insertions, 17 deletions
@@ -213,47 +213,44 @@ FIND_CBS = { }; static void -print_csv_row( +ctx_csv_print_row( const ctx_t * const ctx, + FILE * const fh, const size_t i ) { const size_t num_clusters = i + 2; const float mean_distance = ctx->rows[i].distance / NUM_TESTS, mean_variance = ctx->rows[i].variance / NUM_TESTS, mean_cluster_size = ctx->rows[i].cluster_size / NUM_TESTS, - mean_empty_clusters = 1.0 * ctx->rows[i].num_empty_clusters / NUM_TESTS, - score = km_score(mean_distance, mean_empty_clusters); + mean_empty = 1.0 * ctx->rows[i].num_empty_clusters / NUM_TESTS, + score = km_score(mean_distance, mean_empty); // print result - printf("%zu,%0.3f,%0.3f,%0.3f,%0.3f,%0.3f\n", + fprintf(fh, "%zu,%0.3f,%0.3f,%0.3f,%0.3f,%0.3f\n", num_clusters, score, mean_distance, mean_variance, mean_cluster_size, - mean_empty_clusters + mean_empty ); } static void -print_csv( - const ctx_t * const ctx +ctx_csv_print( + const ctx_t * const ctx, + FILE * const fh ) { // print headers - printf( - "#," - "score," - "distance," - "variance," - "cluster_size," - "empty_clusters\n" - ); + fprintf(fh, "#,score,distance,variance,cluster_size,empty_clusters\n"); + // print rows for (size_t i = 0; i < MAX_CLUSTERS - 2; i++) { - print_csv_row(ctx, i); + ctx_csv_print_row(ctx, fh, i); } } +// static image data buffer static uint8_t im_data[3 * IM_WIDTH * IM_HEIGHT]; static void @@ -347,7 +344,7 @@ int main(int argc, char *argv[]) { } // print csv - print_csv(&ctx); + ctx_csv_print(&ctx, stdout); // sort best results from lowest to highest ctx_best_sort(&ctx); |