diff --git a/doc/examples/plot_circular_elliptical_hough_transform.py b/doc/examples/plot_circular_elliptical_hough_transform.py index 7fb67046..fbdd4f2c 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) @@ -146,3 +148,8 @@ ax2.set_title('Edge (white) and result (red)') ax2.imshow(edges) plt.show() + +""" +.. image:: PLOT2RST.current_figure + +""" 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') 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([]) 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') 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() 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 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 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())