Merge pull request #538 from ahojnnes/examples-travis

TST: Let Travis run all examples.
This commit is contained in:
Stefan van der Walt
2013-05-29 03:53:47 -07:00
18 changed files with 58 additions and 37 deletions
+8 -1
View File
@@ -19,6 +19,9 @@ install:
- sudo easy_install$PYSUF pip
- sudo pip-$PYVER install cython
- sudo apt-get install libfreeimage3
- if [[ $PYVER == '2.7' ]]; then sudo apt-get install $PYTHON-matplotlib; fi
- if [[ $PYVER == '3.2' ]]; then sudo pip-$PYVER install git+git://github.com/matplotlib/matplotlib.git@v1.2.x; fi
- sudo pip-$PYVER install flake8 --use-mirrors
- $PYTHON setup.py build
- sudo $PYTHON setup.py install
script:
@@ -26,4 +29,8 @@ script:
- mkdir for_test
- cd for_test
- nosetests-$PYVER --exe -v --cover-package=skimage skimage
# Change back to repository root directory and run all doc examples
- cd ..
- "echo 'backend : Agg' > matplotlibrc"
- for f in doc/examples/*.py; do $PYTHON "$f"; if [ $? -ne 0 ]; then exit $?; fi done
- flake8 --exit-zero skimage doc/examples viewer_examples
+5 -3
View File
@@ -7,6 +7,8 @@ In this example, we will see how to use geometric transformations in the context
of image processing.
"""
from __future__ import print_function
import math
import numpy as np
import matplotlib.pyplot as plt
@@ -31,7 +33,7 @@ First we create a transformation using explicit parameters:
tform = tf.SimilarityTransform(scale=1, rotation=math.pi / 2,
translation=(0, 1))
print tform._matrix
print(tform._matrix)
"""
Alternatively you can define a transformation by the transformation matrix
@@ -49,8 +51,8 @@ systems:
"""
coord = [1, 0]
print tform2(coord)
print tform2.inverse(tform(coord))
print(tform2(coord))
print(tform2.inverse(tform(coord)))
"""
Image warping
@@ -36,10 +36,11 @@ from skimage import data, filter, color
from skimage.transform import hough_circle
from skimage.feature import peak_local_max
from skimage.draw import circle_perimeter
from skimage.util import img_as_ubyte
# Load picture and detect edges
image = data.coins()[0:95, 70:370]
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))
+2 -1
View File
@@ -10,10 +10,11 @@ import matplotlib.pyplot as plt
from skimage import data
from skimage.filter.rank import entropy
from skimage.morphology import disk
from skimage.util import img_as_ubyte
# defining a 8- and a 16-bit test images
a8 = data.camera()
a8 = img_as_ubyte(data.camera())
a16 = a8.astype(np.uint16) * 4
ent8 = entropy(a8, disk(5)) # pixel value contain 10x the local entropy
+9 -7
View File
@@ -12,6 +12,8 @@ kernels. The mean and variance of the filtered images are then used as features
for classification, which is based on the least squared error for simplicity.
"""
from __future__ import print_function
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
@@ -69,19 +71,19 @@ ref_feats[0, :, :] = compute_feats(brick, kernels)
ref_feats[1, :, :] = compute_feats(grass, kernels)
ref_feats[2, :, :] = compute_feats(wall, kernels)
print 'Rotated images matched against references using Gabor filter banks:'
print('Rotated images matched against references using Gabor filter banks:')
print 'original: brick, rotated: 30deg, match result:',
print('original: brick, rotated: 30deg, match result: ', end='')
feats = compute_feats(nd.rotate(brick, angle=190, reshape=False), kernels)
print image_names[match(feats, ref_feats)]
print(image_names[match(feats, ref_feats)])
print 'original: brick, rotated: 70deg, match result:',
print('original: brick, rotated: 70deg, match result: ', end='')
feats = compute_feats(nd.rotate(brick, angle=70, reshape=False), kernels)
print image_names[match(feats, ref_feats)]
print(image_names[match(feats, ref_feats)])
print 'original: grass, rotated: 145deg, match result:',
print('original: grass, rotated: 145deg, match result: ', end='')
feats = compute_feats(nd.rotate(grass, angle=145, reshape=False), kernels)
print image_names[match(feats, ref_feats)]
print(image_names[match(feats, ref_feats)])
def power(image, kernel):
@@ -22,6 +22,7 @@ import matplotlib.pyplot as plt
from skimage import data
from skimage.color import rgb2hed
ihc_rgb = data.immunohistochemistry()
ihc_hed = rgb2hed(ihc_rgb)
+10 -7
View File
@@ -9,9 +9,12 @@ textures. For simplicity the histogram distributions are then tested against
each other using the Kullback-Leibler-Divergence.
"""
from __future__ import print_function
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from skimage.transform import rotate
from skimage.feature import local_binary_pattern
from skimage import data
@@ -57,13 +60,13 @@ refs = {
}
# classify rotated textures
print 'Rotated images matched against references using LBP:'
print 'original: brick, rotated: 30deg, match result:',
print match(refs, rotate(brick, angle=30, resize=False))
print 'original: brick, rotated: 70deg, match result:',
print match(refs, rotate(brick, angle=70, resize=False))
print 'original: grass, rotated: 145deg, match result:',
print match(refs, rotate(grass, angle=145, resize=False))
print('Rotated images matched against references using LBP:')
print('original: brick, rotated: 30deg, match result: ', end='')
print(match(refs, rotate(brick, angle=30, resize=False)))
print('original: brick, rotated: 70deg, match result: ', end='')
print(match(refs, rotate(brick, angle=70, resize=False)))
print('original: grass, rotated: 145deg, match result: ', end='')
print(match(refs, rotate(grass, angle=145, resize=False)))
# plot histograms of LBP of textures
fig, ((ax1, ax2, ax3), (ax4, ax5, ax6)) = plt.subplots(nrows=2, ncols=3,
+4 -5
View File
@@ -19,15 +19,14 @@ References
.. [2] http://en.wikipedia.org/wiki/Adaptive_histogram_equalization
"""
import numpy as np
import matplotlib.pyplot as plt
from skimage import data
from skimage.util.dtype import dtype_range
from skimage.util import img_as_ubyte
from skimage import exposure
from skimage.morphology import disk
import matplotlib.pyplot as plt
import numpy as np
from skimage.filter import rank
@@ -58,7 +57,7 @@ def plot_img_and_hist(img, axes, bins=256):
# Load an example image
img = data.moon()
img = img_as_ubyte(data.moon())
# Contrast stretching
p2 = np.percentile(img, 2)
+4 -4
View File
@@ -18,12 +18,12 @@ The example compares the local threshold with the global threshold.
import matplotlib.pyplot as plt
from skimage import data
from skimage.morphology.selem import disk
import skimage.filter.rank as rank
from skimage.filter import threshold_otsu
from skimage.morphology import disk
from skimage.filter import threshold_otsu, rank
from skimage.util import img_as_ubyte
p8 = data.page()
p8 = img_as_ubyte(data.page())
radius = 10
selem = disk(radius)
+4 -3
View File
@@ -16,13 +16,14 @@ See Wikipedia_ for more details on the algorithm.
from scipy import ndimage
import matplotlib.pyplot as plt
from skimage.morphology import watershed, disk
from skimage import data
# original data
from skimage.filter import rank
from skimage.util import img_as_ubyte
image = data.camera()
image = img_as_ubyte(data.camera())
# denoise image
denoised = rank.median(image, disk(2))
+5 -2
View File
@@ -7,8 +7,11 @@ This example shows how to approximate (Douglas-Peucker algorithm) and subdivide
(B-Splines) polygonal chains.
"""
from __future__ import print_function
import numpy as np
import matplotlib.pyplot as plt
from skimage.draw import ellipse
from skimage.measure import find_contours, approximate_polygon, \
subdivide_polygon
@@ -45,7 +48,7 @@ for _ in range(5):
# approximate subdivided polygon with Douglas-Peucker algorithm
appr_hand = approximate_polygon(new_hand, tolerance=0.02)
print "Number of coordinates:", len(hand), len(new_hand), len(appr_hand)
print("Number of coordinates:", len(hand), len(new_hand), len(appr_hand))
fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(9, 4))
@@ -70,7 +73,7 @@ for contour in find_contours(img, 0):
ax2.plot(coords[:, 1], coords[:, 0], '-r', linewidth=2)
coords2 = approximate_polygon(contour, tolerance=39.5)
ax2.plot(coords2[:, 1], coords2[:, 0], '-g', linewidth=2)
print "Number of coordinates:", len(contour), len(coords), len(coords2)
print("Number of coordinates:", len(contour), len(coords), len(coords2))
ax2.axis((0, 800, 0, 800))
+1
View File
@@ -58,6 +58,7 @@ of Quickshift, while ``n_segments`` chooses the number of centers for kmeans.
Pascal Fua, and Sabine Suesstrunk, SLIC Superpixels Compared to
State-of-the-art Superpixel Methods, TPAMI, May 2012.
"""
from __future__ import print_function
import matplotlib.pyplot as plt
import numpy as np
+1 -1
View File
@@ -126,7 +126,7 @@ class TestColorconv(TestCase):
# RGB<->HED roundtrip with ubyte image
def test_hed_rgb_roundtrip(self):
img_rgb = self.img_rgb
img_rgb = img_as_ubyte(self.img_rgb)
assert_equal(img_as_ubyte(hed2rgb(rgb2hed(img_rgb))), img_rgb)
# RGB<->HED roundtrip with float image
+2 -2
View File
@@ -169,7 +169,7 @@ def immunohistochemistry():
No known copyright restrictions.
"""
return load("ihc.jpg")
return load("ihc.png")
def chelsea():
@@ -183,4 +183,4 @@ def chelsea():
No copyright restrictions. CC0 by the photographer (Stefan van der Walt).
"""
return load("chelsea.jpg")
return load("chelsea.png")
Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 KiB