mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-24 13:20:43 +08:00
DOC: Limit figures to 8 inch widths.
This commit is contained in:
@@ -10,9 +10,9 @@ edges are thinned down to 1-pixel curves by removing non-maximum pixels of the
|
||||
gradient magnitude. Finally, edge pixels are kept or removed using hysteresis
|
||||
thresholding on the gradient magnitude.
|
||||
|
||||
The Canny has three adjustable parameters: the width of the Gaussian (the
|
||||
The Canny has three adjustable parameters: the width of the Gaussian (the
|
||||
noisier the image, the greater the width), and the low and high threshold for
|
||||
the hysteresis thresholding.
|
||||
the hysteresis thresholding.
|
||||
"""
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
@@ -32,7 +32,7 @@ edges1 = filter.canny(im)
|
||||
edges2 = filter.canny(im, sigma=3)
|
||||
|
||||
# display results
|
||||
plt.figure(figsize=(10, 4))
|
||||
plt.figure(figsize=(8, 3))
|
||||
|
||||
plt.subplot(131)
|
||||
plt.imshow(im, cmap=plt.cm.jet)
|
||||
|
||||
@@ -65,7 +65,7 @@ img_eq = exposure.equalize(img)
|
||||
|
||||
|
||||
# Display results
|
||||
f, axes = plt.subplots(2, 3, figsize=(11, 5))
|
||||
f, axes = plt.subplots(2, 3, figsize=(8, 4))
|
||||
|
||||
ax_img, ax_hist, ax_cdf = plot_img_and_hist(img, axes[:, 0])
|
||||
ax_img.set_title('Low contrast image')
|
||||
|
||||
@@ -71,27 +71,23 @@ fb2 = fb2.reshape((-1,) + patch_shape)
|
||||
fb2_montage = montage2d(fb2, rescale_intensity=True)
|
||||
|
||||
# --
|
||||
plt.figure(figsize=(9, 3))
|
||||
fig, axes = plt.subplots(2, 2, figsize=(7, 6))
|
||||
ax0, ax1, ax2, ax3 = axes.ravel()
|
||||
|
||||
ax0.imshow(lena, cmap=plt.cm.gray)
|
||||
ax0.set_title("Lena (original)")
|
||||
|
||||
plt.subplot(2, 2, 1)
|
||||
plt.imshow(lena, cmap=plt.cm.gray)
|
||||
plt.axis('off')
|
||||
plt.title("Lena (original)")
|
||||
ax1.imshow(fb1_montage, cmap=plt.cm.gray)
|
||||
ax1.set_title("K-means filterbank (codebook)\non Lena (original)")
|
||||
|
||||
plt.subplot(2, 2, 2)
|
||||
plt.imshow(fb1_montage, cmap=plt.cm.gray)
|
||||
plt.axis('off')
|
||||
plt.title("K-means filterbank (codebook) on Lena (original)")
|
||||
ax2.imshow(lena_dog, cmap=plt.cm.gray)
|
||||
ax2.set_title("Lena (LGN-like DoG)")
|
||||
|
||||
plt.subplot(2, 2, 3)
|
||||
plt.imshow(lena_dog, cmap=plt.cm.gray)
|
||||
plt.axis('off')
|
||||
plt.title("Lena (LGN-like DoG)")
|
||||
ax3.imshow(fb2_montage, cmap=plt.cm.gray)
|
||||
ax3.set_title("K-means filterbank (codebook)\non Lena (LGN-like DoG)")
|
||||
|
||||
plt.subplot(2, 2, 4)
|
||||
plt.imshow(fb2_montage, cmap=plt.cm.gray)
|
||||
plt.axis('off')
|
||||
plt.title("K-means filterbank (codebook) on Lena (LGN-like DoG)")
|
||||
for ax in axes.ravel():
|
||||
ax.axis('off')
|
||||
|
||||
fig.subplots_adjust(hspace=0.3)
|
||||
plt.show()
|
||||
|
||||
@@ -90,7 +90,7 @@ image = color.rgb2gray(data.lena())
|
||||
fd, hog_image = hog(image, orientations=8, pixels_per_cell=(16, 16),
|
||||
cells_per_block=(1, 1), visualise=True)
|
||||
|
||||
plt.figure(figsize=(10, 5))
|
||||
plt.figure(figsize=(8, 4))
|
||||
|
||||
plt.subplot(121).set_axis_off()
|
||||
plt.imshow(image, cmap=plt.cm.gray)
|
||||
|
||||
@@ -52,7 +52,7 @@ References
|
||||
.. [1] C. Galamhos, J. Matas and J. Kittler,"Progressive probabilistic
|
||||
Hough transform for line detection", in IEEE Computer Society
|
||||
Conference on Computer Vision and Pattern Recognition, 1999.
|
||||
|
||||
|
||||
.. [2] Duda, R. O. and P. E. Hart, "Use of the Hough Transformation to
|
||||
Detect Lines and Curves in Pictures," Comm. ACM, Vol. 15,
|
||||
pp. 11-15 (January, 1972)
|
||||
@@ -79,7 +79,7 @@ image[idx, idx] = 255
|
||||
|
||||
h, theta, d = hough(image)
|
||||
|
||||
plt.figure(figsize=(12, 5))
|
||||
plt.figure(figsize=(8, 4))
|
||||
|
||||
plt.subplot(121)
|
||||
plt.imshow(image, cmap=plt.cm.gray)
|
||||
@@ -101,7 +101,7 @@ image = data.camera()
|
||||
edges = canny(image, 2, 1, 25)
|
||||
lines = probabilistic_hough(edges, threshold=10, line_length=5, line_gap=3)
|
||||
|
||||
plt.figure(figsize=(12, 4))
|
||||
plt.figure(figsize=(8, 3))
|
||||
|
||||
plt.subplot(131)
|
||||
plt.imshow(image, cmap=plt.cm.gray)
|
||||
@@ -121,3 +121,4 @@ for line in lines:
|
||||
plt.title('Lines found with PHT')
|
||||
plt.axis('image')
|
||||
plt.show()
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ noisy = l + 0.4 * l.std() * np.random.random(l.shape)
|
||||
|
||||
tv_denoised = tv_denoise(noisy, weight=10)
|
||||
|
||||
plt.figure(figsize=(12,2.8))
|
||||
plt.figure(figsize=(8, 2))
|
||||
|
||||
plt.subplot(131)
|
||||
plt.imshow(noisy, cmap=plt.cm.gray, vmin=40, vmax=220)
|
||||
|
||||
@@ -25,7 +25,7 @@ image = camera()
|
||||
thresh = threshold_otsu(image)
|
||||
binary = image > thresh
|
||||
|
||||
plt.figure(figsize=(10, 3.5))
|
||||
plt.figure(figsize=(8, 2.5))
|
||||
plt.subplot(1, 3, 1)
|
||||
plt.imshow(image, cmap=plt.cm.gray)
|
||||
plt.title('Original')
|
||||
|
||||
@@ -28,7 +28,7 @@ from scipy.ndimage import zoom
|
||||
image = imread(data_dir + "/phantom.png", as_grey=True)
|
||||
image = zoom(image, 0.4)
|
||||
|
||||
plt.figure(figsize=(9, 8.5), dpi=75)
|
||||
plt.figure(figsize=(8, 8.5))
|
||||
|
||||
plt.subplot(221)
|
||||
plt.title("Original");
|
||||
|
||||
@@ -58,7 +58,7 @@ markers[data > 1.3] = 2
|
||||
labels = random_walker(data, markers, beta=10, mode='bf')
|
||||
|
||||
# Plot results
|
||||
plt.figure(figsize=(9, 3.5))
|
||||
plt.figure(figsize=(8, 3.2))
|
||||
plt.subplot(131)
|
||||
plt.imshow(data, cmap='gray', interpolation='nearest')
|
||||
plt.axis('off')
|
||||
|
||||
@@ -6,14 +6,14 @@ Skeletonize
|
||||
Skeletonization reduces binary objects to 1 pixel wide representations. This
|
||||
can be useful for feature extraction, and/or representing an object's topology.
|
||||
|
||||
The algorithm works by making successive passes of the image. On each pass,
|
||||
The algorithm works by making successive passes of the image. On each pass,
|
||||
border pixels are identified and removed on the condition that they do not
|
||||
break the connectivity of the corresponding object.
|
||||
break the connectivity of the corresponding object.
|
||||
|
||||
This module provides an example of calling the routine and displaying the
|
||||
results. The input is a 2D ndarray, with either boolean or integer elements.
|
||||
In the case of boolean, 'True' indicates foreground, and for integer arrays,
|
||||
the foreground is 1's.
|
||||
the foreground is 1's.
|
||||
"""
|
||||
from skimage.morphology import skeletonize
|
||||
from skimage.draw import draw
|
||||
@@ -30,9 +30,9 @@ image[10:-10, -100:-10] = 1
|
||||
|
||||
# foreground object 2
|
||||
rs, cs = draw.bresenham(250, 150, 10, 280)
|
||||
for i in range(10): image[rs+i, cs] = 1
|
||||
for i in range(10): image[rs+i, cs] = 1
|
||||
rs, cs = draw.bresenham(10, 150, 250, 280)
|
||||
for i in range(20): image[rs+i, cs] = 1
|
||||
for i in range(20): image[rs+i, cs] = 1
|
||||
|
||||
# foreground object 3
|
||||
ir, ic = np.indices(image.shape)
|
||||
@@ -45,7 +45,7 @@ image[circle2] = 0
|
||||
skeleton = skeletonize(image)
|
||||
|
||||
# display results
|
||||
plt.figure(figsize=(10,6))
|
||||
plt.figure(figsize=(8, 4.5))
|
||||
|
||||
plt.subplot(121)
|
||||
plt.imshow(image, cmap=plt.cm.gray)
|
||||
@@ -57,7 +57,7 @@ plt.imshow(skeleton, cmap=plt.cm.gray)
|
||||
plt.axis('off')
|
||||
plt.title('skeleton', fontsize=20)
|
||||
|
||||
plt.subplots_adjust(wspace=0.02, hspace=0.02, top=0.98,
|
||||
plt.subplots_adjust(wspace=0.02, hspace=0.02, top=0.98,
|
||||
bottom=0.02, left=0.02, right=0.98)
|
||||
|
||||
plt.show()
|
||||
|
||||
@@ -44,24 +44,21 @@ max_view = np.max(flatten_view, axis=2)
|
||||
median_view = np.median(flatten_view, axis=2)
|
||||
|
||||
# -- display resampled images
|
||||
plt.figure(figsize=(10, 10))
|
||||
fig, axes = plt.subplots(2, 2, figsize=(8, 8))
|
||||
ax0, ax1, ax2, ax3 = axes.ravel()
|
||||
|
||||
plt.subplot(221)
|
||||
plt.title("Original rescaled with\n spline interpolation (order=3)")
|
||||
ax0.set_title("Original rescaled with\n spline interpolation (order=3)")
|
||||
l_resized = ndi.zoom(l, 2, order=3)
|
||||
plt.imshow(l_resized, cmap=cm.Greys_r)
|
||||
ax0.imshow(l_resized, cmap=cm.Greys_r)
|
||||
|
||||
plt.subplot(222)
|
||||
plt.title("Block view with\n local mean pooling")
|
||||
plt.imshow(mean_view, cmap=cm.Greys_r)
|
||||
ax1.set_title("Block view with\n local mean pooling")
|
||||
ax1.imshow(mean_view, cmap=cm.Greys_r)
|
||||
|
||||
plt.subplot(223)
|
||||
plt.title("Block view with\n local max pooling")
|
||||
plt.imshow(max_view, cmap=cm.Greys_r)
|
||||
ax2.set_title("Block view with\n local max pooling")
|
||||
ax2.imshow(max_view, cmap=cm.Greys_r)
|
||||
|
||||
plt.subplot(224)
|
||||
plt.title("Block view with\n local median pooling")
|
||||
plt.imshow(median_view, cmap=cm.Greys_r)
|
||||
ax3.set_title("Block view with\n local median pooling")
|
||||
ax3.imshow(median_view, cmap=cm.Greys_r)
|
||||
|
||||
plt.subplots_adjust(hspace=0.4, wspace=0.4)
|
||||
plt.show()
|
||||
|
||||
@@ -45,16 +45,15 @@ local_maxi = is_local_maximum(distance, image, np.ones((3, 3)))
|
||||
markers = ndimage.label(local_maxi)[0]
|
||||
labels = watershed(-distance, markers, mask=image)
|
||||
|
||||
plt.figure(figsize=(9, 3))
|
||||
plt.subplot(131)
|
||||
plt.imshow(image, cmap=plt.cm.gray, interpolation='nearest')
|
||||
plt.axis('off')
|
||||
plt.subplot(132)
|
||||
plt.imshow(-distance, cmap=plt.cm.jet, interpolation='nearest')
|
||||
plt.axis('off')
|
||||
plt.subplot(133)
|
||||
plt.imshow(labels, cmap=plt.cm.spectral, interpolation='nearest')
|
||||
plt.axis('off')
|
||||
fig, axes = plt.subplots(ncols=3, figsize=(8, 2.7))
|
||||
ax0, ax1, ax2 = axes
|
||||
|
||||
ax0.imshow(image, cmap=plt.cm.gray, interpolation='nearest')
|
||||
ax1.imshow(-distance, cmap=plt.cm.jet, interpolation='nearest')
|
||||
ax2.imshow(labels, cmap=plt.cm.spectral, interpolation='nearest')
|
||||
|
||||
for ax in axes:
|
||||
ax.axis('off')
|
||||
|
||||
plt.subplots_adjust(hspace=0.01, wspace=0.01, top=1, bottom=0, left=0,
|
||||
right=1)
|
||||
|
||||
Reference in New Issue
Block a user