From d4cb154d17f1afc76d9b1edb3257bab58d6b7ed4 Mon Sep 17 00:00:00 2001 From: Julian Taylor Date: Thu, 13 Mar 2014 21:48:45 +0100 Subject: [PATCH] improve performance of equalize example percentile can compute multiple ranks in one go which in the case of the example halves the required time. --- doc/examples/plot_equalize.py | 3 +-- doc/examples/plot_local_equalize.py | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/doc/examples/plot_equalize.py b/doc/examples/plot_equalize.py index 220a126e..3b3f3788 100644 --- a/doc/examples/plot_equalize.py +++ b/doc/examples/plot_equalize.py @@ -60,8 +60,7 @@ def plot_img_and_hist(img, axes, bins=256): img = data.moon() # Contrast stretching -p2 = np.percentile(img, 2) -p98 = np.percentile(img, 98) +p2, p98 = np.percentile(img, (2, 98)) img_rescale = exposure.rescale_intensity(img, in_range=(p2, p98)) # Equalization diff --git a/doc/examples/plot_local_equalize.py b/doc/examples/plot_local_equalize.py index c440594f..309d1e43 100644 --- a/doc/examples/plot_local_equalize.py +++ b/doc/examples/plot_local_equalize.py @@ -63,9 +63,7 @@ def plot_img_and_hist(img, axes, bins=256): # Load an example image img = img_as_ubyte(data.moon()) -# Contrast stretching -p2 = np.percentile(img, 2) -p98 = np.percentile(img, 98) +# Global equalize img_rescale = exposure.equalize_hist(img) # Equalization