Merge PR #147 from 'tonysyu/fix-gallery-sizes

DOC: Fix gallery sizes.
This commit is contained in:
Stefan van der Walt
2012-02-21 14:47:06 -08:00
15 changed files with 83 additions and 93 deletions
+1
View File
@@ -40,6 +40,7 @@ Guidelines
* No major changes should be committed without review. Ask on the
`mailing list <http://groups.google.com/group/scikits-image>`_ if
you get no response to your pull request.
* Examples in the gallery should have a maximum figure width of 8 inches.
Test coverage
`````````````
+3 -3
View File
@@ -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)
+1 -1
View File
@@ -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')
+18 -22
View File
@@ -31,11 +31,11 @@ is not rocket science.
.. [3] http://en.wikipedia.org/wiki/Receptive_field
.. [4] http://en.wikipedia.org/wiki/K-means_clustering
.. [5] http://en.wikipedia.org/wiki/Lateral_geniculate_nucleus
.. [6] D. H. Hubel and T. N. Wiesel Receptive Fields of Single Neurones
in the Cat's Striate Cortex J. Physiol. pp. 574-591 (148) 1959
.. [7] D. H. Hubel and T. N. Wiesel Receptive Fields, Binocular
Interaction and Functional Architecture in the Cat's Visual Cortex J.
Physiol. 160 pp. 106-154 1962
.. [6] D. H. Hubel and T. N., Wiesel Receptive Fields of Single Neurones
in the Cat's Striate Cortex, J. Physiol. pp. 574-591 (148) 1959
.. [7] D. H. Hubel and T. N., Wiesel Receptive Fields, Binocular
Interaction, and Functional Architecture in the Cat's Visual Cortex,
J. Physiol. 160 pp. 106-154 1962
"""
import numpy as np
@@ -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()
+1 -2
View File
@@ -82,7 +82,6 @@ References
from skimage.feature import hog
from skimage import data, color, exposure
import numpy as np
import matplotlib.pyplot as plt
image = color.rgb2gray(data.lena())
@@ -90,7 +89,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)
+4 -3
View File
@@ -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()
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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')
+1 -1
View File
@@ -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')
+7 -7
View File
@@ -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()
+10 -13
View File
@@ -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()
+15 -15
View File
@@ -19,9 +19,10 @@ opposite of the distance) are chosen as markers, and the flooding of
basins from such markers separates the two circles along a watershed
line.
See `Wikipedia
<http://en.wikipedia.org/wiki/Watershed_(image_processing)>`__ for
more details on the algorithm.
See Wikipedia_ for more details on the algorithm.
.. _Wikipedia: <http://en.wikipedia.org/wiki/Watershed_(image_processing)>
"""
import numpy as np
@@ -36,25 +37,24 @@ r1, r2 = 16, 20
mask_circle1 = (x - x1)**2 + (y - y1)**2 < r1**2
mask_circle2 = (x - x2)**2 + (y - y2)**2 < r2**2
image = np.logical_or(mask_circle1, mask_circle2)
# Now we want to separate the two objects in image
# Generate the markers as local maxima of the distance
# to the background
# Generate the markers as local maxima of the distance to the background
from scipy import ndimage
distance = ndimage.distance_transform_edt(image)
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)
+1 -22
View File
@@ -114,27 +114,6 @@ def generate_example_rst(app):
fhindex = file(os.path.join(root_dir, 'index.txt'), 'w')
fhindex.write("""\
.. raw:: html
<style type="text/css">
.figure {
float: left;
margin: 1em;
}
.figure img {
display: block;
margin-left: auto;
margin-right: auto;
width: 200px;
}
.figure .caption {
width: 200px;
text-align: center !important;
}
</style>
Examples
========
@@ -280,7 +259,7 @@ def generate_file_rst(fname, target_dir, src_dir, plot_gallery):
this_template = plot_rst_template
from matplotlib import image
if os.path.exists(first_image_file):
image.thumbnail(first_image_file, thumb_file, 0.2)
image.thumbnail(first_image_file, thumb_file, 0.25)
if not os.path.exists(thumb_file):
# create something not to replace the thumbnail
+18 -1
View File
@@ -362,6 +362,23 @@ div.footer, div.footer a {
color: #888a85;
}
.figure {
float: left;
margin: 1em;
}
.figure img {
display: block;
margin-left: auto;
margin-right: auto;
max-height: 150px;
}
.figure .caption {
width: 200px;
text-align: center !important;
}
/* Styles copied from basic theme */
@@ -653,7 +670,7 @@ th {
/* ----------------- Example Gallery ----------------- */
.gallery {
min-height: 250px;
height: 200px;
}
.gallery p.caption a{