diff options
author | Thomas White <taw@physics.org> | 2020-06-29 15:14:46 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-07-29 18:53:44 +0200 |
commit | a7f04b7da219da2efddaaec826eafa286975aa3d (patch) | |
tree | d43b567b0f288be9aeb08f93f5845b3bd5c2f1c1 | |
parent | 1632be3733a4e15f3f7e1cc47eb497086c5ae59c (diff) |
Automatic colour scale
-rw-r--r-- | src/crystfelimageview.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/crystfelimageview.c b/src/crystfelimageview.c index cb5021a0..36989ce4 100644 --- a/src/crystfelimageview.c +++ b/src/crystfelimageview.c @@ -36,6 +36,7 @@ #include <assert.h> #include <gtk/gtk.h> #include <glib-object.h> +#include <gsl/gsl_rstat.h> #include <utils.h> #include <detgeom.h> @@ -728,6 +729,36 @@ static GdkPixbuf *render_panel(float *data, int *badmap, int w, int h, } +static double auto_scale_top(const struct image *image) +{ + int pn; + gsl_rstat_workspace *wksp; + double top; + + wksp = gsl_rstat_alloc(); + if ( wksp == NULL ) return 100.0; + + for ( pn=0; pn<image->detgeom->n_panels; pn++ ) { + long int i; + int w, h; + w = image->detgeom->panels[pn].w; + h = image->detgeom->panels[pn].h; + for ( i=0; i<w*h; i++ ) { + if ( !image->bad[pn][i] ) { + gsl_rstat_add(image->dp[pn][i], wksp); + } + } + } + + top = gsl_rstat_mean(wksp) + gsl_rstat_sd(wksp); + gsl_rstat_free(wksp); + + top *= 6; + + return top; +} + + static int reload_image(CrystFELImageView *iv) { if ( iv->dtempl == NULL ) return 0; @@ -750,6 +781,7 @@ static int rerender_image(CrystFELImageView *iv) int i; double min_x, min_y, max_x, max_y; double border; + double scale_top; if ( iv->pixbufs == NULL ) { iv->pixbufs = calloc(iv->image->detgeom->n_panels, @@ -761,12 +793,14 @@ static int rerender_image(CrystFELImageView *iv) } } + scale_top = auto_scale_top(iv->image); + for ( i=0; i<iv->image->detgeom->n_panels; i++ ) { iv->pixbufs[i] = render_panel(iv->image->dp[i], iv->image->bad[i], iv->image->detgeom->panels[i].w, iv->image->detgeom->panels[i].h, - SCALE_COLOUR, 10.0); + SCALE_COLOUR, scale_top); if ( iv->pixbufs[i] == NULL ) return 1; } |