From ce4a68f695cd8d5dafe90634c6e723b57f400860 Mon Sep 17 00:00:00 2001 From: Alexandre Fioravante de Siqueira Date: Mon, 29 Feb 2016 20:53:37 +0100 Subject: [PATCH] Solving space convex_hull + fixing local_otsu Solving space convex_hull + fixing local_otsu Solving space on censure --- doc/examples/edges/plot_convex_hull.py | 17 ++++++++------- .../features_detection/plot_censure.py | 21 +++++++++---------- doc/examples/segmentation/plot_local_otsu.py | 3 ++- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/doc/examples/edges/plot_convex_hull.py b/doc/examples/edges/plot_convex_hull.py index be50f541..f66653b7 100644 --- a/doc/examples/edges/plot_convex_hull.py +++ b/doc/examples/edges/plot_convex_hull.py @@ -13,12 +13,12 @@ A good overview of the algorithm is given on `Steve Eddin's blog `__. """ + import numpy as np import matplotlib.pyplot as plt from skimage.morphology import convex_hull_image - image = np.array( [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], @@ -31,6 +31,7 @@ original_image = np.copy(image) chull = convex_hull_image(image) image[chull] += 1 + # image is now: # [[ 0. 0. 0. 0. 0. 0. 0. 0. 0.] # [ 0. 0. 0. 0. 2. 0. 0. 0. 0.] @@ -39,15 +40,15 @@ image[chull] += 1 # [ 0. 2. 1. 1. 1. 1. 1. 2. 0.] # [ 0. 0. 0. 0. 0. 0. 0. 0. 0.]] +fig, (ax0, ax1) = plt.subplots(1, 2, figsize=(12, 4)) +plt.tight_layout() -fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10, 6)) +ax0.set_title('Original picture') +ax0.imshow(original_image, cmap=plt.cm.gray, interpolation='nearest') +ax0.set_xticks([]), ax0.set_yticks([]) -ax1.set_title('Original picture') -ax1.imshow(original_image, cmap=plt.cm.gray, interpolation='nearest') +ax1.set_title('Transformed picture') +ax1.imshow(image, cmap=plt.cm.gray, interpolation='nearest') ax1.set_xticks([]), ax1.set_yticks([]) -ax2.set_title('Transformed picture') -ax2.imshow(image, cmap=plt.cm.gray, interpolation='nearest') -ax2.set_xticks([]), ax2.set_yticks([]) - plt.show() diff --git a/doc/examples/features_detection/plot_censure.py b/doc/examples/features_detection/plot_censure.py index b2a52440..e4478262 100644 --- a/doc/examples/features_detection/plot_censure.py +++ b/doc/examples/features_detection/plot_censure.py @@ -6,36 +6,35 @@ CENSURE feature detector The CENSURE feature detector is a scale-invariant center-surround detector (CENSURE) that claims to outperform other detectors and is capable of real-time implementation. - """ + from skimage import data from skimage import transform as tf from skimage.feature import CENSURE from skimage.color import rgb2gray + import matplotlib.pyplot as plt - -img1 = rgb2gray(data.astronaut()) +img_orig = rgb2gray(data.astronaut()) tform = tf.AffineTransform(scale=(1.5, 1.5), rotation=0.5, translation=(150, -200)) -img2 = tf.warp(img1, tform) +img_warp = tf.warp(img_orig, tform) detector = CENSURE() -fig, ax = plt.subplots(nrows=1, ncols=2) +fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(12, 6)) +plt.tight_layout() -plt.gray() +detector.detect(img_orig) -detector.detect(img1) - -ax[0].imshow(img1) +ax[0].imshow(img_orig, cmap=plt.cm.gray) ax[0].axis('off') ax[0].scatter(detector.keypoints[:, 1], detector.keypoints[:, 0], 2 ** detector.scales, facecolors='none', edgecolors='r') -detector.detect(img2) +detector.detect(img_warp) -ax[1].imshow(img2) +ax[1].imshow(img_warp, cmap=plt.cm.gray) ax[1].axis('off') ax[1].scatter(detector.keypoints[:, 1], detector.keypoints[:, 0], 2 ** detector.scales, facecolors='none', edgecolors='r') diff --git a/doc/examples/segmentation/plot_local_otsu.py b/doc/examples/segmentation/plot_local_otsu.py index 8d7475d7..e51ef5e9 100644 --- a/doc/examples/segmentation/plot_local_otsu.py +++ b/doc/examples/segmentation/plot_local_otsu.py @@ -10,7 +10,7 @@ structuring element. The example compares the local threshold with the global threshold. -.. Note: local is much slower than global thresholding +.. note: local is much slower than global thresholding .. [1] http://en.wikipedia.org/wiki/Otsu's_method @@ -37,6 +37,7 @@ global_otsu = img >= threshold_global_otsu fig, ax = plt.subplots(2, 2, figsize=(8, 5), sharex=True, sharey=True, subplot_kw={'adjustable': 'box-forced'}) ax0, ax1, ax2, ax3 = ax.ravel() +plt.tight_layout() fig.colorbar(ax0.imshow(img, cmap=plt.cm.gray), ax=ax0, orientation='horizontal')