From 843e72a70215467b02a054c17f035fd1ee5a6dd1 Mon Sep 17 00:00:00 2001 From: Antonino Ingargiola Date: Mon, 15 Oct 2007 23:45:08 +0200 Subject: [PATCH] IA: Histogramm speedups using the ndimage.measurements module --- pyplotsuite/imageanalyzer/histogramdialog.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/pyplotsuite/imageanalyzer/histogramdialog.py b/pyplotsuite/imageanalyzer/histogramdialog.py index 3d88a8f..a2512bc 100644 --- a/pyplotsuite/imageanalyzer/histogramdialog.py +++ b/pyplotsuite/imageanalyzer/histogramdialog.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2007 Antonio Ingargiola +# Copyright (C) 2006-2007 Antonino Ingargiola # # This file is part of PyPlotSuite . # @@ -8,11 +8,16 @@ # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. -from numpy import array, arange - +from numpy import array, arange, min from matplotlib.widgets import SpanSelector from pyplotsuite.common.gtk_generic_windows import GenericSecondaryPlotWindow -from pyplotsuite.common.img import histogram3, histogramfloat +try: + import scipy.ndimage.measurements as M +except ImportError: + try: + import numarray.nd_image.measurements as M + except ImportError: + has_measurements = False class HistogramApp(GenericSecondaryPlotWindow): """ @@ -26,13 +31,13 @@ class HistogramApp(GenericSecondaryPlotWindow): self.debug = debug # Calculate the histogram - if callerApp.imagemode == 'floatarray': - self.x, self.y = histogramfloat(callerApp.image_array) - self.y += 0.02 - else: - self.y = array(histogram3(callerApp.image, bits)) + 0.01 - self.x = arange(1, 2**bits+1) + n = 250 + m = min((0, self.callerApp.image_array.min())) + Max = self.callerApp.image_array.max() + self.x = arange(n)*Max/float(n-1) + self.y = M.histogram(self.callerApp.image_array, m, Max, n) self.dprint ('x', len(self.x), 'y', len(self.y)) + # Plot the histogram self.yscale = 'linear' self.showPoints = False @@ -44,7 +49,7 @@ class HistogramApp(GenericSecondaryPlotWindow): self.selection = None # Range selected (axvspan instance) self.plot_histogram() - self.plot_histogram() + #self.plot_histogram() # Spin Buttons handlers self.widthSpinButt = self.widgetTree.get_widget('widthSpinButt') -- 2.11.4.GIT