From 43829f61cb6ea65b55cc6a75c788a9cc0521217d Mon Sep 17 00:00:00 2001 From: Maria Date: Fri, 16 Aug 2013 17:28:43 +0200 Subject: Added Logarithmus. --- bin/gui/control.c | 48 +++- bin/gui/control.glade | 639 +++++++++++++++++++++++++++++++------------------- 2 files changed, 444 insertions(+), 243 deletions(-) diff --git a/bin/gui/control.c b/bin/gui/control.c index b895f91..69a2cda 100644 --- a/bin/gui/control.c +++ b/bin/gui/control.c @@ -59,6 +59,7 @@ typedef struct { GtkWidget *histogram_view; GtkToggleButton *histogram_button; + GtkToggleButton *log_button; GtkAdjustment *frame_slider; RingBuffer *buffer; @@ -83,9 +84,10 @@ down_scale (ThreadData *data, gpointer buffer) gdouble min; gdouble max; gdouble factor; + gdouble dval; guint8 *output; gint stride; - gint i = 0; + gint i = 0; egg_histogram_get_range (EGG_HISTOGRAM_VIEW (data->histogram_view), &min, &max); factor = 255.0 / (max - min); @@ -99,7 +101,13 @@ down_scale (ThreadData *data, gpointer buffer) gint offset = y * stride * data->width; for (gint x = 0; x < data->display_width; x++, offset += stride) { - gdouble dval = (input[offset] - min) * factor; + + if (gtk_toggle_button_get_active (data->log_button)) + { + dval = log((input[offset] - min) * factor); + } else { + dval = (input[offset] - min) * factor; + } guchar val = (guchar) CLAMP(dval, 0.0, 255.0); output[i++] = val; @@ -115,12 +123,19 @@ down_scale (ThreadData *data, gpointer buffer) gint offset = y * stride * data->width; for (gint x = 0; x < data->display_width; x++, offset += stride) { - gdouble dval = (input[offset] - min) * factor; + + if (gtk_toggle_button_get_active (data->log_button)) + { + dval = log((input[offset] - min) * factor); + } else { + dval = (input[offset] - min) * factor; + } guchar val = (guchar) CLAMP(dval, 0.0, 255.0); output[i++] = val; output[i++] = val; output[i++] = val; + } } } @@ -132,6 +147,7 @@ up_scale (ThreadData *data, gpointer buffer) gdouble min; gdouble max; gdouble factor; + gdouble dval; guint8 *output; gint i = 0; gint zoom; @@ -147,7 +163,13 @@ up_scale (ThreadData *data, gpointer buffer) for (gint y = 0; y < data->display_height; y++) { for (gint x = 0; x < data->display_width; x++) { gint offset = ((gint) (y / zoom) * data->width) + ((gint) (x / zoom)); - gdouble dval = (input[offset] - min) * factor; + + if (gtk_toggle_button_get_active (data->log_button)) + { + dval = log((input[offset] - min) * factor); + } else { + dval = (input[offset] - min) * factor; + } guchar val = (guchar) CLAMP(dval, 0.0, 255.0); output[i++] = val; @@ -162,7 +184,12 @@ up_scale (ThreadData *data, gpointer buffer) for (gint y = 0; y < data->display_height; y++) { for (gint x = 0; x < data->display_width; x++) { gint offset = ((gint) (y / zoom) * data->width) + ((gint) (x / zoom)); - gdouble dval = (input[offset] - min) * factor; + if (gtk_toggle_button_get_active (data->log_button)) + { + dval = log((input[offset] - min) * factor); + } else { + dval = (input[offset] - min) * factor; + } guchar val = (guchar) CLAMP(dval, 0.0, 255.0); output[i++] = val; @@ -215,8 +242,14 @@ get_statistics (ThreadData *data, gdouble *mean, gdouble *sigma, guint *_max, gu } } - *mean = sum / n; - *sigma = sqrt((squared_sum - sum*sum/n) / (n - 1)); + if (gtk_toggle_button_get_active (data->log_button)) + { + *mean = log(sum/n); + *sigma = log(sqrt((squared_sum - sum*sum/n) / (n - 1))); + } else { + *mean = sum / n; + *sigma = sqrt((squared_sum - sum*sum/n) / (n - 1)); + } *_min = min; *_max = max; } @@ -702,6 +735,7 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name) td.record_button = GTK_WIDGET (gtk_builder_get_object (builder, "record-button")); td.download_button = GTK_WIDGET (gtk_builder_get_object (builder, "download-button")); td.histogram_button = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "histogram-checkbutton")); + td.log_button = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "logarithmus-checkbutton")); td.frame_slider = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "frames-adjustment")); td.count = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "acquisitions-adjustment")); diff --git a/bin/gui/control.glade b/bin/gui/control.glade index d4b663e..3467ed7 100644 --- a/bin/gui/control.glade +++ b/bin/gui/control.glade @@ -2,11 +2,9 @@ - - - - - + + 1 + 10 @@ -18,29 +16,269 @@ + + + + + + + + False + 6 + + + True + False + 2 + + + True + True + automatic + automatic + + + True + True + camera-types + False + 0 + + + Choose camera + + + + 0 + + + + + + + + + True + True + 0 + + + + + True + False + 6 + end + + + gtk-quit + False + True + True + True + True + + + + False + False + 0 + + + + + gtk-ok + False + True + True + True + True + + + False + False + 1 + + + + + False + True + 6 + 1 + + + + + + + 100 + 1 + 10 + 10 + + + False + 5 + normal + + + True + False + 2 + + + True + False + end + + + gtk-close + False + True + True + True + True + + + False + False + 0 + + + + + False + False + end + 0 + + + + + True + False + 10 + 6 + + + True + False + 0 + Downloading Frames … + + + False + False + 0 + + + + + True + False + download-adjustment + + + False + True + 1 + + + + + True + True + 1 + + + + + + download-close-button + + + + 100 + 0.01 + 10 + + + 1 + 10 + + + 65535 + 256 + 1 + 10 + + + 65535 + 1 + 10 + + + + + + + + + + + 400 % + 4 + + + 200 % + 2 + + + 100 % + 1 + + + 50 % + 0.5 + + + 25 % + 0.25 + + + + False Camera Control 1024 768 - + True + False True + False + False True + False _File True True + False gtk-new + False True + False True True @@ -48,7 +286,9 @@ gtk-open + False True + False True True @@ -56,7 +296,9 @@ gtk-save-as + False True + False True True @@ -64,15 +306,18 @@ True + False gtk-quit + False True + False True True - + @@ -81,16 +326,21 @@ + False True + False _Help True True + False gtk-about + False True + False True True @@ -102,15 +352,19 @@ False + True 0 True + False + False True + False Run True gtk-media-play @@ -122,7 +376,9 @@ + False True + False Record True gtk-media-record @@ -134,7 +390,9 @@ + False True + False Stop True gtk-media-stop @@ -146,7 +404,9 @@ + False True + False Download True network-receive @@ -159,6 +419,7 @@ False + True 1 @@ -178,10 +439,12 @@ True + False queue True + False gtk-missing-image @@ -196,6 +459,7 @@ True + False True @@ -204,10 +468,12 @@ True + False 12 True + False 0 Settings @@ -223,12 +489,14 @@ True + False 6 3 2 True + False 0 Exposure time: @@ -241,6 +509,7 @@ True + False 0 Acquire: @@ -255,27 +524,36 @@ True + False 6 True True + False + False + True + True exposure-adjustment 6 False + True 0 True + False 0 seconds + True + True 1 @@ -290,6 +568,7 @@ True + False 6 @@ -297,20 +576,28 @@ True 6 + False + False + True + True acquisitions-adjustment False + True 0 True + False 0 frames + True + True 1 @@ -326,6 +613,7 @@ Repeat + False True True False @@ -345,6 +633,7 @@ True False + False 6 @@ -352,19 +641,27 @@ True 6 + False + False + True + True False + True 0 True + False 0 times + True + True 1 @@ -381,12 +678,14 @@ False + True 1 True + False 0 0 6 @@ -404,6 +703,7 @@ True + False 0 12 @@ -416,6 +716,8 @@ + True + True 3 @@ -424,6 +726,7 @@ True + False Acquisition @@ -433,6 +736,7 @@ False + True 0 @@ -444,10 +748,12 @@ True + False 12 True + False 0 Histogram @@ -463,13 +769,16 @@ True + False 12 True + False True + False 0 Minimum: @@ -485,6 +794,10 @@ True True + False + False + True + True min-bin-value-adjustment @@ -497,6 +810,7 @@ True + False 0 Maximum: @@ -512,6 +826,10 @@ True True + False + False + True + True max-bin-value-adjustment @@ -535,6 +853,7 @@ Live Update + False True True False @@ -551,12 +870,15 @@ + True + True 1 True + False 12 2 2 @@ -565,6 +887,7 @@ True + False 0 Pixel counts: @@ -575,6 +898,7 @@ True + False 0 Distribution: @@ -587,44 +911,57 @@ True + False 6 True + False 0 µ = 0.0 + True + True 0 True + False 0 σ = 0.0 + True + True 1 True + False 0 min = 0 + True + True 2 True + False 0 max = 0 + True + True 3 @@ -640,6 +977,7 @@ True + False 0 0 @@ -650,6 +988,8 @@ + True + True 2 @@ -658,6 +998,7 @@ True + False Statistics @@ -667,6 +1008,7 @@ False + True 1 @@ -675,37 +1017,68 @@ True True - + True - 12 - 6 + False - + True - 0 - Zoom: + False + 12 + 6 + + + True + False + 0 + Zoom: + + + False + False + 0 + + + + + True + False + zoom-values + + + + 0 + + + + + False + False + 1 + + - False - False + True + True 0 - + + Logarithmus + False True - zoom-values - - - - 0 - - + True + False + 10 + 0 + True False False - 1 + 2 @@ -713,6 +1086,7 @@ True + False Preview @@ -744,6 +1118,7 @@ True + False Properties @@ -752,6 +1127,8 @@ + True + True 3 @@ -763,222 +1140,12 @@ + True + True 2 - - - - - - - - - - 400 % - 4 - - - 200 % - 2 - - - 100 % - 1 - - - 50 % - 0.5 - - - 25 % - 0.25 - - - - - 6 - - - True - 2 - - - True - True - automatic - automatic - - - True - True - camera-types - False - 0 - - - Choose camera - - - - 0 - - - - - - - - - 0 - - - - - True - 6 - end - - - gtk-quit - True - True - True - True - - - - False - False - 0 - - - - - gtk-ok - True - True - True - True - - - False - False - 1 - - - - - False - 6 - 1 - - - - - - - 65535 - 1 - 10 - - - 256 - 65535 - 1 - 10 - - - 1 - 10 - - - 5 - normal - - - True - 2 - - - True - 10 - 6 - - - True - 0 - Downloading Frames … - - - False - False - 0 - - - - - True - download-adjustment - - - False - 1 - - - - - 1 - - - - - True - end - - - gtk-close - True - True - True - True - - - False - False - 0 - - - - - False - False - end - 0 - - - - - - download-close-button - - - - 100 - 1 - 10 - 10 - - - 100 - 0.01 - 10 - - - 1 - 10 - -- cgit v1.2.3