From 7447a444908886a818d1ed80da7ebd52161b375e Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 13 Jul 2011 20:57:06 +0200 Subject: Heuristic to prevent silly histogram axes --- src/scaling-report.c | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/scaling-report.c b/src/scaling-report.c index 330f9757..197f72f9 100644 --- a/src/scaling-report.c +++ b/src/scaling-report.c @@ -373,6 +373,7 @@ static void scale_factor_histogram(cairo_t *cr, const struct image *images, const double g_width = 320.0; const double g_height = 180.0; char tmp[32]; + int n_zero, n_half; show_text_simple(cr, title, g_width/2.0, -18.0, "Sans Bold 10", 0.0, J_CENTER); @@ -388,25 +389,44 @@ static void scale_factor_histogram(cairo_t *cr, const struct image *images, if ( osf > osf_max ) osf_max = osf; } osf_max = ceil(osf_max); - osf_inc = osf_max / nbins; - for ( b=0; b= osf_low[b]) && (osf < osf_high[b]) ) { - counts[b]++; - break; + osf_low[b] = b*osf_inc; + osf_high[b] = (b+1)*osf_inc; + counts[b] = 0; + } + + for ( i=0; i= osf_low[b]) + && (osf < osf_high[b]) ) + { + counts[b]++; + break; + } } } - } + + /* Count the number of bins with no counts, subtract 1 from + * the maximum value until this isn't the case */ + n_zero = 0; + n_half = 0; + for ( b=0; b n_half ) osf_max -= 1.0; + + } while ( n_zero > n_half ); f_max = 0; for ( b=0; b