From cfb7d6cd313b6a79766c66b5aedaa85acdbdc5bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 29 May 2013 19:40:17 +0200 Subject: [PATCH 1/9] Set matplotlib backend globally --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 69534244..5ffb9646 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,11 +26,11 @@ install: - sudo $PYTHON setup.py install script: # Change into an innocuous directory and find tests from installation + - "echo 'backend : Agg' > $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 - flake8 --exit-zero skimage doc/examples viewer_examples From 3a4f729156d6cbc54df98d8656e5a8903c9e3039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 29 May 2013 19:48:33 +0200 Subject: [PATCH 2/9] Create matplotlib config directory --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5ffb9646..c818046a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,7 @@ 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" - mkdir for_test - cd for_test From 6bccdbf1057e00c06517480468b537dd4cbe0a72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 29 May 2013 20:04:35 +0200 Subject: [PATCH 3/9] Set matplotlib qt backend --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c818046a..a47dae84 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,10 +28,11 @@ 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 .. - - 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 From 255ac689992fff672c9adbd0777135c4c0add1d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 29 May 2013 20:17:17 +0200 Subject: [PATCH 4/9] Avoid import of matplotlib QT lib if QT is not installed --- skimage/viewer/utils/core.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/skimage/viewer/utils/core.py b/skimage/viewer/utils/core.py index 0dcd4176..0b97d8c3 100644 --- a/skimage/viewer/utils/core.py +++ b/skimage/viewer/utils/core.py @@ -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 From 153bc6edf9a450d6fb585ba73699e7b37e7bb6b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 29 May 2013 20:28:16 +0200 Subject: [PATCH 5/9] Use None instead of 'none' for qt backend --- skimage/viewer/qt/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skimage/viewer/qt/__init__.py b/skimage/viewer/qt/__init__.py index 55cafcfe..c816a172 100644 --- a/skimage/viewer/qt/__init__.py +++ b/skimage/viewer/qt/__init__.py @@ -12,7 +12,7 @@ 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!") From 817c9634e89be79c5ca4e08ce48c1eb1dd173f46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 29 May 2013 20:36:08 +0200 Subject: [PATCH 6/9] Fix setting of QT_API environment variable --- skimage/viewer/qt/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/skimage/viewer/qt/__init__.py b/skimage/viewer/qt/__init__.py index c816a172..8e7ab939 100644 --- a/skimage/viewer/qt/__init__.py +++ b/skimage/viewer/qt/__init__.py @@ -16,4 +16,7 @@ if qt_api is 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 From 2832b7a9a5e7c666c1931ef02800d139d2de3d77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 29 May 2013 20:57:47 +0200 Subject: [PATCH 7/9] Fix python 3 print statement in example script --- doc/examples/plot_matching.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/examples/plot_matching.py b/doc/examples/plot_matching.py index 43833d7c..9c4fb4eb 100644 --- a/doc/examples/plot_matching.py +++ b/doc/examples/plot_matching.py @@ -20,6 +20,8 @@ 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 @@ -109,9 +111,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 From ecc8c4640ad5b00604f29eeee43a98afa684ff86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 29 May 2013 21:23:07 +0200 Subject: [PATCH 8/9] Fix window size of sub-pixel corner detection --- doc/examples/plot_matching.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/examples/plot_matching.py b/doc/examples/plot_matching.py index 9c4fb4eb..2b83e17b 100644 --- a/doc/examples/plot_matching.py +++ b/doc/examples/plot_matching.py @@ -55,9 +55,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): From 545a83dd5262f2c28297be9341cae517f8d91a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 29 May 2013 22:06:27 +0200 Subject: [PATCH 9/9] Fix matching example script --- doc/examples/plot_matching.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/examples/plot_matching.py b/doc/examples/plot_matching.py index 2b83e17b..bae6d6e2 100644 --- a/doc/examples/plot_matching.py +++ b/doc/examples/plot_matching.py @@ -26,6 +26,7 @@ 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 @@ -34,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)