Merge pull request #571 from ahojnnes/travis-fix

Fix: Use None instead of 'none' for qt_api (fix Travis error), set matplotlib backend
  also use python 3 print() in example.
This commit is contained in:
Josh Warner
2013-05-29 21:10:01 -07:00
4 changed files with 26 additions and 12 deletions
+4 -2
View File
@@ -26,11 +26,13 @@ install:
- sudo $PYTHON setup.py install
script:
# Change into an innocuous directory and find tests from installation
- mkdir $HOME/.matplotlib
- "echo 'backend : Agg' > $HOME/.matplotlib/matplotlibrc"
- "echo 'backend.qt4 : PyQt4' >> $HOME/.matplotlib/matplotlibrc"
- 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
- for f in doc/examples/*.py; do $PYTHON "$f"; if [ $? -ne 0 ]; then exit 1; fi done
- flake8 --exit-zero skimage doc/examples viewer_examples
+11 -7
View File
@@ -20,10 +20,13 @@ sufficient. Therefore, the RANSAC algorithm is used on top of the normal model
to robustly estimate the parameter set by detecting outliers.
"""
from __future__ import print_function
import numpy as np
from matplotlib import pyplot as plt
from skimage import data
from skimage.util import img_as_float
from skimage.feature import corner_harris, corner_subpix, corner_peaks
from skimage.transform import warp, AffineTransform
from skimage.exposure import rescale_intensity
@@ -32,10 +35,11 @@ from skimage.measure import ransac
# generate synthetic checkerboard image and add gradient for the later matching
checkerboard = data.checkerboard()
checkerboard = img_as_float(data.checkerboard())
img_orig = np.zeros(list(checkerboard.shape) + [3])
img_orig[..., 0] = checkerboard
gradient_r, gradient_c = np.mgrid[0:img_orig.shape[0], 0:img_orig.shape[1]]
gradient_r, gradient_c = np.mgrid[0:img_orig.shape[0],
0:img_orig.shape[1]] / float(img_orig.shape[0])
img_orig[..., 1] = gradient_r
img_orig[..., 2] = gradient_c
img_orig = rescale_intensity(img_orig)
@@ -53,9 +57,9 @@ coords_warped = corner_peaks(corner_harris(img_warped_gray),
threshold_rel=0.001, min_distance=5)
# determine sub-pixel corner position
coords_orig_subpix = corner_subpix(img_orig_gray, coords_orig, window_size=10)
coords_orig_subpix = corner_subpix(img_orig_gray, coords_orig, window_size=9)
coords_warped_subpix = corner_subpix(img_warped_gray, coords_warped,
window_size=10)
window_size=9)
def gaussian_weights(window_ext, sigma=1):
@@ -109,9 +113,9 @@ outliers = inliers == False
# compare "true" and estimated transform parameters
print tform.scale, tform.translation, tform.rotation
print model.scale, model.translation, model.rotation
print model_robust.scale, model_robust.translation, model_robust.rotation
print(tform.scale, tform.translation, tform.rotation)
print(model.scale, model.translation, model.rotation)
print(model_robust.scale, model_robust.translation, model_robust.rotation)
# visualize correspondences
+4 -1
View File
@@ -12,8 +12,11 @@ if qt_api is None:
import PyQt4
qt_api = 'pyqt'
except ImportError:
qt_api = 'none'
qt_api = None
# Note that we don't want to raise an error because that would
# cause the TravisCI build to fail.
warnings.warn("Could not import PyQt4: ImageViewer not available!")
if qt_api is not None:
os.environ['QT_API'] = qt_api
+7 -2
View File
@@ -2,13 +2,18 @@ import warnings
import numpy as np
from ..qt import qt_api
try:
import matplotlib as mpl
from matplotlib.figure import Figure
from matplotlib import _pylab_helpers
from matplotlib.colors import LinearSegmentedColormap
from matplotlib.backends.backend_qt4 import FigureManagerQT
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg
if qt_api is None:
raise ImportError
else:
from matplotlib.backends.backend_qt4 import FigureManagerQT
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg
except ImportError:
FigureCanvasQTAgg = object # hack to prevent nosetest and autodoc errors
LinearSegmentedColormap = object