From c0af3aaae6e3c29c4af1d36a7a5e551feeaf277d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 30 Nov 2013 18:54:29 +0100 Subject: [PATCH 1/9] Improve layout of gabor example plot --- doc/examples/plot_gabor.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/doc/examples/plot_gabor.py b/doc/examples/plot_gabor.py index db1ff7d6..87d99589 100644 --- a/doc/examples/plot_gabor.py +++ b/doc/examples/plot_gabor.py @@ -24,9 +24,6 @@ from skimage.util import img_as_float from skimage.filter import gabor_kernel -matplotlib.rcParams['font.size'] = 9 - - def compute_feats(image, kernels): feats = np.zeros((len(kernels), 2), dtype=np.double) for k, kernel in enumerate(kernels): @@ -104,24 +101,24 @@ for theta in (0, 1): # Save kernel and the power image for each image results.append((kernel, [power(img, kernel) for img in images])) -fig, axes = plt.subplots(nrows=5, ncols=4, figsize=(9, 6)) +fig, axes = plt.subplots(nrows=5, ncols=4, figsize=(5, 6)) plt.gray() -fig.suptitle('Image responses for Gabor filter kernels', fontsize=15) +fig.suptitle('Image responses for Gabor filter kernels', fontsize=12) axes[0][0].axis('off') # Plot original images for label, img, ax in zip(image_names, images, axes[0][1:]): ax.imshow(img) - ax.set_title(label) + ax.set_title(label, fontsize=9) ax.axis('off') for label, (kernel, powers), ax_row in zip(kernel_params, results, axes[1:]): # Plot Gabor kernel ax = ax_row[0] ax.imshow(np.real(kernel), interpolation='nearest') - ax.set_ylabel(label) + ax.set_ylabel(label, fontsize=7) ax.set_xticks([]) ax.set_yticks([]) From 76e0f7a0476b0834f5370ffc49e40529e5c43aa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 30 Nov 2013 19:01:18 +0100 Subject: [PATCH 2/9] Fix and improve circular hough hough transform example script --- doc/examples/plot_circular_elliptical_hough_transform.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/examples/plot_circular_elliptical_hough_transform.py b/doc/examples/plot_circular_elliptical_hough_transform.py index 7fb67046..0f1524c1 100755 --- a/doc/examples/plot_circular_elliptical_hough_transform.py +++ b/doc/examples/plot_circular_elliptical_hough_transform.py @@ -48,7 +48,7 @@ from skimage.util import img_as_ubyte image = img_as_ubyte(data.coins()[0:95, 70:370]) edges = filter.canny(image, sigma=3, low_threshold=10, high_threshold=50) -fig, ax = plt.subplots(ncols=1, nrows=1, figsize=(6, 6)) +fig, ax = plt.subplots(ncols=1, nrows=1, figsize=(5, 2)) # Detect two radii hough_radii = np.arange(15, 30, 2) @@ -77,6 +77,8 @@ ax.imshow(image, cmap=plt.cm.gray) """ +.. image:: PLOT2RST.current_figure + Ellipse detection ================= @@ -137,7 +139,7 @@ image_rgb[cy, cx] = (0, 0, 255) edges = color.gray2rgb(edges) edges[cy, cx] = (250, 0, 0) -fig2, (ax1, ax2) = plt.subplots(ncols=2, nrows=1, figsize=(10, 6)) +fig2, (ax1, ax2) = plt.subplots(ncols=2, nrows=1, figsize=(8, 4)) ax1.set_title('Original picture') ax1.imshow(image_rgb) From 7e45baa3e2b372d5a81dce656781879c0408bcc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 30 Nov 2013 19:06:20 +0100 Subject: [PATCH 3/9] Fix overlapping text --- doc/examples/plot_equalize.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/examples/plot_equalize.py b/doc/examples/plot_equalize.py index 52121e3a..220a126e 100644 --- a/doc/examples/plot_equalize.py +++ b/doc/examples/plot_equalize.py @@ -17,6 +17,8 @@ that fall within the 2nd and 98th percentiles [2]_. .. [2] http://homepages.inf.ed.ac.uk/rbf/HIPR2/stretch.htm """ + +import matplotlib import matplotlib.pyplot as plt import numpy as np @@ -24,6 +26,9 @@ from skimage import data, img_as_float from skimage import exposure +matplotlib.rcParams['font.size'] = 8 + + def plot_img_and_hist(img, axes, bins=256): """Plot an image along with its histogram and cumulative histogram. @@ -66,7 +71,7 @@ img_eq = exposure.equalize_hist(img) img_adapteq = exposure.equalize_adapthist(img, clip_limit=0.03) # Display results -f, axes = plt.subplots(2, 4, figsize=(8, 4)) +f, axes = plt.subplots(nrows=2, ncols=4, figsize=(8, 5)) ax_img, ax_hist, ax_cdf = plot_img_and_hist(img, axes[:, 0]) ax_img.set_title('Low contrast image') From 444d574efa65a91dac7d216df7a98071fa69e517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 30 Nov 2013 19:15:00 +0100 Subject: [PATCH 4/9] Fix overlapping text --- doc/examples/plot_local_equalize.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/examples/plot_local_equalize.py b/doc/examples/plot_local_equalize.py index 1fd8325f..c440594f 100644 --- a/doc/examples/plot_local_equalize.py +++ b/doc/examples/plot_local_equalize.py @@ -20,6 +20,7 @@ References """ import numpy as np +import matplotlib import matplotlib.pyplot as plt from skimage import data @@ -30,6 +31,9 @@ from skimage.morphology import disk from skimage.filter import rank +matplotlib.rcParams['font.size'] = 9 + + def plot_img_and_hist(img, axes, bins=256): """Plot an image along with its histogram and cumulative histogram. @@ -70,7 +74,7 @@ img_eq = rank.equalize(img, selem=selem) # Display results -f, axes = plt.subplots(2, 3, figsize=(8, 4)) +f, axes = plt.subplots(2, 3, figsize=(8, 5)) ax_img, ax_hist, ax_cdf = plot_img_and_hist(img, axes[:, 0]) ax_img.set_title('Low contrast image') From dcbbd55b523ee6ff90ec963c698f4b6e50bde502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 30 Nov 2013 19:32:37 +0100 Subject: [PATCH 5/9] Improve local otsu example script --- doc/examples/plot_local_otsu.py | 45 +++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/doc/examples/plot_local_otsu.py b/doc/examples/plot_local_otsu.py index 3a321780..aff7db62 100644 --- a/doc/examples/plot_local_otsu.py +++ b/doc/examples/plot_local_otsu.py @@ -15,6 +15,7 @@ The example compares the local threshold with the global threshold. .. [1] http://en.wikipedia.org/wiki/Otsu's_method """ +import matplotlib import matplotlib.pyplot as plt from skimage import data @@ -23,29 +24,41 @@ from skimage.filter import threshold_otsu, rank from skimage.util import img_as_ubyte -p8 = img_as_ubyte(data.page()) +matplotlib.rcParams['font.size'] = 9 -radius = 10 + +img = img_as_ubyte(data.page()) + +radius = 15 selem = disk(radius) -loc_otsu = rank.otsu(p8, selem) -t_glob_otsu = threshold_otsu(p8) -glob_otsu = p8 >= t_glob_otsu +local_otsu = rank.otsu(img, selem) +threshold_global_otsu = threshold_otsu(img) +global_otsu = img >= threshold_global_otsu -plt.figure() +plt.figure(figsize=(8, 5)) + plt.subplot(2, 2, 1) -plt.imshow(p8, cmap=plt.cm.gray) -plt.xlabel('original') -plt.colorbar() +plt.imshow(img, cmap=plt.cm.gray) +plt.title('Original') +plt.colorbar(orientation='horizontal') +plt.axis('off') + plt.subplot(2, 2, 2) -plt.imshow(loc_otsu, cmap=plt.cm.gray) -plt.xlabel('local Otsu ($radius=%d$)' % radius) -plt.colorbar() +plt.imshow(local_otsu, cmap=plt.cm.gray) +plt.title('Local Otsu (radius=%d)' % radius) +plt.colorbar(orientation='horizontal') +plt.axis('off') + plt.subplot(2, 2, 3) -plt.imshow(p8 >= loc_otsu, cmap=plt.cm.gray) -plt.xlabel('original >= local Otsu' % t_glob_otsu) +plt.imshow(img >= local_otsu, cmap=plt.cm.gray) +plt.title('Original >= Local Otsu' % threshold_global_otsu) +plt.axis('off') + plt.subplot(2, 2, 4) -plt.imshow(glob_otsu, cmap=plt.cm.gray) -plt.xlabel('global Otsu ($t = %d$)' % t_glob_otsu) +plt.imshow(global_otsu, cmap=plt.cm.gray) +plt.title('Global Otsu (threshold = %d)' % threshold_global_otsu) +plt.axis('off') + plt.show() From 1869ea9147e014af4dc61f567f0b0e5031be09d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 30 Nov 2013 19:33:25 +0100 Subject: [PATCH 6/9] Fix overlapping xtick labels --- doc/examples/plot_otsu.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/examples/plot_otsu.py b/doc/examples/plot_otsu.py index 5221e934..b3b8e279 100644 --- a/doc/examples/plot_otsu.py +++ b/doc/examples/plot_otsu.py @@ -14,12 +14,16 @@ the intra-class variance. .. [1] http://en.wikipedia.org/wiki/Otsu's_method """ +import matplotlib import matplotlib.pyplot as plt from skimage.data import camera from skimage.filter import threshold_otsu +matplotlib.rcParams['font.size'] = 9 + + image = camera() thresh = threshold_otsu(image) binary = image > thresh From 64b9c1847b65b0469772910f47def5da887517b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 30 Nov 2013 19:37:55 +0100 Subject: [PATCH 7/9] Show hidden text --- doc/examples/plot_shapes.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/doc/examples/plot_shapes.py b/doc/examples/plot_shapes.py index 2ae842a5..34d1108c 100644 --- a/doc/examples/plot_shapes.py +++ b/doc/examples/plot_shapes.py @@ -4,11 +4,17 @@ Shapes ====== This example shows how to draw several different shapes: -* line -* Bezier curve -* polygon -* circle -* ellipse + + - line + - Bezier curve + - polygon + - circle + - ellipse + +Anti-aliased drawing for: + + - line + - circle """ import math @@ -69,13 +75,6 @@ ax1.imshow(img) ax1.set_title('No anti-aliasing') ax1.axis('off') -""" - -Anti-aliased drawing for: -* line -* circle - -""" from skimage.draw import line_aa, circle_perimeter_aa From 17206296705045a966bd0d144426a48dd37f32d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 30 Nov 2013 19:39:39 +0100 Subject: [PATCH 8/9] Improve ssim example --- doc/examples/plot_ssim.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/examples/plot_ssim.py b/doc/examples/plot_ssim.py index 9fe0c930..4e657150 100644 --- a/doc/examples/plot_ssim.py +++ b/doc/examples/plot_ssim.py @@ -22,12 +22,16 @@ but with very different mean structural similarity indices. """ import numpy as np +import matplotlib import matplotlib.pyplot as plt from skimage import data, img_as_float from skimage.measure import structural_similarity as ssim +matplotlib.rcParams['font.size'] = 9 + + img = img_as_float(data.camera()) rows, cols = img.shape @@ -41,7 +45,7 @@ def mse(x, y): img_noise = img + noise img_const = img + abs(noise) -f, (ax0, ax1, ax2) = plt.subplots(1, 3) +f, (ax0, ax1, ax2) = plt.subplots(nrows=1, ncols=3, figsize=(8, 4)) mse_none = mse(img, img) ssim_none = ssim(img, img, dynamic_range=img.max() - img.min()) From 5abd6e3904b9d42d7d69fb081aaee114e99131ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Mon, 2 Dec 2013 01:13:36 +0100 Subject: [PATCH 9/9] Add missing plot directive --- doc/examples/plot_circular_elliptical_hough_transform.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/examples/plot_circular_elliptical_hough_transform.py b/doc/examples/plot_circular_elliptical_hough_transform.py index 0f1524c1..fbdd4f2c 100755 --- a/doc/examples/plot_circular_elliptical_hough_transform.py +++ b/doc/examples/plot_circular_elliptical_hough_transform.py @@ -148,3 +148,8 @@ ax2.set_title('Edge (white) and result (red)') ax2.imshow(edges) plt.show() + +""" +.. image:: PLOT2RST.current_figure + +"""