From 36d56b956dfb24657ad5533417914477c959ada2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Sun, 5 Jun 2016 17:17:34 +0200 Subject: [PATCH] DOC: some improvements --- .../xx_applications/plot_thresholding.py | 51 +++++++++++++------ 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/doc/examples/xx_applications/plot_thresholding.py b/doc/examples/xx_applications/plot_thresholding.py index 1c2ddcf0..0f4ac45b 100644 --- a/doc/examples/xx_applications/plot_thresholding.py +++ b/doc/examples/xx_applications/plot_thresholding.py @@ -90,26 +90,41 @@ from skimage.filters.thresholding import threshold_minimum image = data.camera() -thresh = threshold_minimum(image, bias='min') -binary = image > thresh +thresh_min = threshold_minimum(image, bias='min') +binary_min = image > thresh_min +thresh_mid = threshold_minimum(image, bias='mid') +binary_mid = image > thresh_mid +thresh_max = threshold_minimum(image, bias='max') +binary_max = image > thresh_max -fig = plt.figure(figsize=(8, 2.5)) -ax1 = plt.subplot(1, 3, 1, adjustable='box-forced') -ax2 = plt.subplot(1, 3, 2) -ax3 = plt.subplot(1, 3, 3, sharex=ax1, sharey=ax1, adjustable='box-forced') +fig, ax = plt.subplots(4, 2, figsize=(10, 10)) +axes = ax.ravel() -ax1.imshow(image, cmap=plt.cm.gray) -ax1.set_title('Original') -ax1.axis('off') +axes[0].imshow(image, cmap=plt.cm.gray) +axes[0].set_title('Original') +axes[0].axis('off') -ax2.hist(image) -ax2.set_title('Histogram') -ax2.axvline(thresh, color='r') +axes[1].hist(image.ravel(), bins=256) +axes[1].set_title('Histogram') -ax3.imshow(binary, cmap=plt.cm.gray) -ax3.set_title('Thresholded') -ax3.axis('off') +axes[2].imshow(binary_min, cmap=plt.cm.gray) +axes[2].set_title('Thresholded (min)') +axes[3].hist(image.ravel(), bins=256) +axes[3].axvline(thresh_min, color='r') + +axes[4].imshow(binary_mid, cmap=plt.cm.gray) +axes[4].set_title('Thresholded (mid)') +axes[5].hist(image.ravel(), bins=256) +axes[5].axvline(thresh_mid, color='r') + +axes[6].imshow(binary_max, cmap=plt.cm.gray) +axes[6].set_title('Thresholded (max)') +axes[7].hist(image.ravel(), bins=256) +axes[7].axvline(thresh_max, color='r') + +for a in axes[::2]: + a.axis('off') plt.show() """ @@ -147,7 +162,7 @@ ax1.imshow(image, cmap=plt.cm.gray) ax1.set_title('Original') ax1.axis('off') -ax2.hist(image) +ax2.hist(image.ravel(), bins=256) ax2.set_title('Histogram') ax2.axvline(thresh, color='r') @@ -261,3 +276,7 @@ ax3.set_title('Global Otsu (threshold = %d)' % threshold_global_otsu) ax3.axis('off') plt.show() +""" +.. image:: PLOT2RST.current_figure + +"""