Exemplo n.º 1
0
 def __init__(self, **kwargs):
     if not is_installed('matplotlib', '>=1.2'):
         msg = "Matplotlib >= 1.2 required for OverlayPlugin."
         warn(RuntimeWarning(msg))
     super(OverlayPlugin, self).__init__(**kwargs)
     self._overlay_plot = None
     self._overlay = None
     self.cmap = None
     self.color_names = sorted(list(self.colors.keys()))
Exemplo n.º 2
0
 def __init__(self, **kwargs):
     if not is_installed("matplotlib", ">=1.2"):
         msg = "Matplotlib >= 1.2 required for OverlayPlugin."
         warn(RuntimeWarning(msg))
     super(OverlayPlugin, self).__init__(**kwargs)
     self._overlay_plot = None
     self._overlay = None
     self.cmap = None
     self.color_names = sorted(list(self.colors.keys()))
Exemplo n.º 3
0
    img = data.astronaut()
    img_collection = tuple(pyramid_gaussian(img))

    view = CollectionViewer(img_collection)
    make_key_event(48)

    view.update_index('', 2),
    assert_equal(view.image, img_collection[2])
    view.keyPressEvent(make_key_event(53))
    assert_equal(view.image, img_collection[5])
    view._format_coord(10, 10)


@skipif(not viewer_available)
@skipif(not is_installed('matplotlib', '>=1.2'))
def test_viewer_with_overlay():
    img = data.coins()
    ov = OverlayPlugin(image_filter=sobel)
    viewer = ImageViewer(img)
    viewer += ov

    import tempfile
    _, filename = tempfile.mkstemp(suffix='.png')

    ov.color = 3
    assert_equal(ov.color, 'yellow')

    with expected_warnings(['precision loss']):
        viewer.save_to_file(filename)
    ov.display_filtered_image(img)
Exemplo n.º 4
0
def test_is_installed():
    assert version_req.is_installed('python', '>=2.6')
    assert not version_req.is_installed('numpy', '<1.0')
Exemplo n.º 5
0
    img = data.astronaut()
    img_collection = tuple(pyramid_gaussian(img, multichannel=True))

    view = CollectionViewer(img_collection)
    make_key_event(48)

    view.update_index('', 2),
    assert_equal(view.image, img_collection[2])
    view.keyPressEvent(make_key_event(53))
    assert_equal(view.image, img_collection[5])
    view._format_coord(10, 10)


@pytest.mark.skipif(not has_qt, reason="Qt not installed")
@pytest.mark.skipif(not is_installed('matplotlib', '>=1.2'),
                    reason="matplotlib < 1.2")
def test_viewer_with_overlay():
    img = data.coins()
    ov = OverlayPlugin(image_filter=sobel)
    viewer = ImageViewer(img)
    viewer += ov

    import tempfile
    _, filename = tempfile.mkstemp(suffix='.png')

    ov.color = 3
    assert_equal(ov.color, 'yellow')

    with expected_warnings(['precision loss']):
        viewer.save_to_file(filename)
import numpy as np
from skimage.future import graph
from skimage._shared.version_requirements import is_installed
from numpy.testing.decorators import skipif
from skimage import segmentation
from numpy import testing


def max_edge(g, src, dst, n):
    default = {'weight': -np.inf}
    w1 = g[n].get(src, default)['weight']
    w2 = g[n].get(dst, default)['weight']
    return {'weight': max(w1, w2)}


@skipif(not is_installed('networkx'))
def test_rag_merge():
    g = graph.rag.RAG()

    for i in range(5):
        g.add_node(i, {'labels': [i]})

    g.add_edge(0, 1, {'weight': 10})
    g.add_edge(1, 2, {'weight': 20})
    g.add_edge(2, 3, {'weight': 30})
    g.add_edge(3, 0, {'weight': 40})
    g.add_edge(0, 2, {'weight': 50})
    g.add_edge(3, 4, {'weight': 60})

    gc = g.copy()
Exemplo n.º 7
0
import numpy as np
from skimage.future import graph
from skimage._shared.version_requirements import is_installed
from skimage import segmentation
import pytest


def max_edge(g, src, dst, n):
    default = {'weight': -np.inf}
    w1 = g[n].get(src, default)['weight']
    w2 = g[n].get(dst, default)['weight']
    return {'weight': max(w1, w2)}


@pytest.mark.skipif(not is_installed('networkx'),
                    reason="networkx not installed")
def test_rag_merge():
    g = graph.rag.RAG()

    for i in range(5):
        g.add_node(i, {'labels': [i]})

    g.add_edge(0, 1, {'weight': 10})
    g.add_edge(1, 2, {'weight': 20})
    g.add_edge(2, 3, {'weight': 30})
    g.add_edge(3, 0, {'weight': 40})
    g.add_edge(0, 2, {'weight': 50})
    g.add_edge(3, 4, {'weight': 60})

    gc = g.copy()
Exemplo n.º 8
0
from warnings import warn
from skimage._shared.version_requirements import is_installed

from .viewers import ImageViewer, CollectionViewer
from .qt import qt_api

viewer_available = not qt_api is None and is_installed("matplotlib")
if not viewer_available:
    warn("Viewer requires matplotlib and Qt")

del qt_api, is_installed, warn
Exemplo n.º 9
0
import numpy as np
from skimage.future import graph
from skimage._shared.version_requirements import is_installed
from skimage import segmentation
from skimage._shared import testing


def max_edge(g, src, dst, n):
    default = {'weight': -np.inf}
    w1 = g[n].get(src, default)['weight']
    w2 = g[n].get(dst, default)['weight']
    return {'weight': max(w1, w2)}


@testing.skipif(not is_installed('networkx'),
                reason="networkx not installed")
def test_rag_merge():
    g = graph.rag.RAG()

    for i in range(5):
        g.add_node(i, {'labels': [i]})

    g.add_edge(0, 1, {'weight': 10})
    g.add_edge(1, 2, {'weight': 20})
    g.add_edge(2, 3, {'weight': 30})
    g.add_edge(3, 0, {'weight': 40})
    g.add_edge(0, 2, {'weight': 50})
    g.add_edge(3, 4, {'weight': 60})

    gc = g.copy()
Exemplo n.º 10
0
from warnings import warn
from skimage._shared.version_requirements import is_installed

from .viewers import ImageViewer, CollectionViewer
from .qt import qt_api

viewer_available = not qt_api is None and is_installed('matplotlib')
if not viewer_available:
    warn('Viewer requires matplotlib and Qt')

del qt_api, is_installed, warn
Exemplo n.º 11
0
    img = data.astronaut()
    img_collection = tuple(pyramid_gaussian(img, multichannel=True))

    view = CollectionViewer(img_collection)
    make_key_event(48)

    view.update_index('', 2),
    assert_equal(view.image, img_collection[2])
    view.keyPressEvent(make_key_event(53))
    assert_equal(view.image, img_collection[5])
    view._format_coord(10, 10)


@pytest.mark.skipif(not has_qt, reason="Qt not installed")
@pytest.mark.skipif(not is_installed('matplotlib', '>=1.2'),
                    reason="matplotlib < 1.2")
def test_viewer_with_overlay():
    img = data.coins()
    ov = OverlayPlugin(image_filter=sobel)
    viewer = ImageViewer(img)
    viewer += ov

    import tempfile
    _, filename = tempfile.mkstemp(suffix='.png')

    ov.color = 3
    assert_equal(ov.color, 'yellow')

    with expected_warnings(['precision loss']):
        viewer.save_to_file(filename)
Exemplo n.º 12
0
import numpy as np
from skimage.future import graph
from skimage._shared.version_requirements import is_installed
from skimage import segmentation
import pytest


def max_edge(g, src, dst, n):
    default = {'weight': -np.inf}
    w1 = g[n].get(src, default)['weight']
    w2 = g[n].get(dst, default)['weight']
    return {'weight': max(w1, w2)}


@pytest.mark.skipif(not is_installed('networkx'),
                    reason="networkx not installed")
def test_rag_merge():
    g = graph.rag.RAG()

    for i in range(5):
        g.add_node(i, {'labels': [i]})

    g.add_edge(0, 1, {'weight': 10})
    g.add_edge(1, 2, {'weight': 20})
    g.add_edge(2, 3, {'weight': 30})
    g.add_edge(3, 0, {'weight': 40})
    g.add_edge(0, 2, {'weight': 50})
    g.add_edge(3, 4, {'weight': 60})

    gc = g.copy()
Exemplo n.º 13
0
import numpy as np
from skimage.future import graph
from skimage._shared.version_requirements import is_installed
from skimage import segmentation
from skimage._shared import testing


def max_edge(g, src, dst, n):
    default = {'weight': -np.inf}
    w1 = g[n].get(src, default)['weight']
    w2 = g[n].get(dst, default)['weight']
    return {'weight': max(w1, w2)}


@testing.skipif(not is_installed('networkx'),
                reason="networkx not installed")
def test_rag_merge():
    g = graph.rag.RAG()

    for i in range(5):
        g.add_node(i, {'labels': [i]})

    g.add_edge(0, 1, {'weight': 10})
    g.add_edge(1, 2, {'weight': 20})
    g.add_edge(2, 3, {'weight': 30})
    g.add_edge(3, 0, {'weight': 40})
    g.add_edge(0, 2, {'weight': 50})
    g.add_edge(3, 4, {'weight': 60})

    gc = g.copy()
Exemplo n.º 14
0
import numpy as np
from skimage.future import graph
from skimage._shared.version_requirements import is_installed
from numpy.testing.decorators import skipif
from skimage import segmentation
from numpy import testing


def max_edge(g, src, dst, n):
    default = {'weight': -np.inf}
    w1 = g[n].get(src, default)['weight']
    w2 = g[n].get(dst, default)['weight']
    return {'weight': max(w1, w2)}


@skipif(not is_installed('networkx'))
def test_rag_merge():
    g = graph.rag.RAG()

    for i in range(5):
        g.add_node(i, {'labels': [i]})

    g.add_edge(0, 1, {'weight': 10})
    g.add_edge(1, 2, {'weight': 20})
    g.add_edge(2, 3, {'weight': 30})
    g.add_edge(3, 0, {'weight': 40})
    g.add_edge(0, 2, {'weight': 50})
    g.add_edge(3, 4, {'weight': 60})

    gc = g.copy()
Exemplo n.º 15
0
from numpy.testing import assert_array_equal
import numpy as np
from skimage.future import graph
from skimage._shared.version_requirements import is_installed
from skimage import segmentation, data
from skimage._shared import testing


def max_edge(g, src, dst, n):
    default = {'weight': -np.inf}
    w1 = g[n].get(src, default)['weight']
    w2 = g[n].get(dst, default)['weight']
    return {'weight': max(w1, w2)}


@testing.skipif(not is_installed('networkx'), reason="networkx not installed")
def test_rag_merge():
    g = graph.rag.RAG()

    for i in range(5):
        g.add_node(i, {'labels': [i]})

    g.add_edge(0, 1, {'weight': 10})
    g.add_edge(1, 2, {'weight': 20})
    g.add_edge(2, 3, {'weight': 30})
    g.add_edge(3, 0, {'weight': 40})
    g.add_edge(0, 2, {'weight': 50})
    g.add_edge(3, 4, {'weight': 60})

    gc = g.copy()
Exemplo n.º 16
0
    img = data.astronaut()
    img_collection = tuple(pyramid_gaussian(img, multichannel=True))

    view = CollectionViewer(img_collection)
    make_key_event(48)

    view.update_index('', 2),
    assert_equal(view.image, img_collection[2])
    view.keyPressEvent(make_key_event(53))
    assert_equal(view.image, img_collection[5])
    view._format_coord(10, 10)


@testing.skipif(not has_qt, reason="Qt not installed")
@testing.skipif(not is_installed('matplotlib', '>=1.2'),
                reason="matplotlib < 1.2")
def test_viewer_with_overlay():
    img = data.coins()
    ov = OverlayPlugin(image_filter=sobel)
    viewer = ImageViewer(img)
    viewer += ov

    import tempfile
    _, filename = tempfile.mkstemp(suffix='.png')

    ov.color = 3
    assert_equal(ov.color, 'yellow')

    viewer.save_to_file(filename)
    ov.display_filtered_image(img)
Exemplo n.º 17
0
    img = data.astronaut()
    img_collection = tuple(pyramid_gaussian(img, multichannel=True))

    view = CollectionViewer(img_collection)
    make_key_event(48)

    view.update_index('', 2),
    assert_equal(view.image, img_collection[2])
    view.keyPressEvent(make_key_event(53))
    assert_equal(view.image, img_collection[5])
    view._format_coord(10, 10)


@testing.skipif(not has_qt, reason="Qt not installed")
@testing.skipif(not is_installed('matplotlib', '>=1.2'),
                reason="matplotlib < 1.2")
def test_viewer_with_overlay():
    img = data.coins()
    ov = OverlayPlugin(image_filter=sobel)
    viewer = ImageViewer(img)
    viewer += ov

    import tempfile
    _, filename = tempfile.mkstemp(suffix='.png')

    ov.color = 3
    assert_equal(ov.color, 'yellow')

    with expected_warnings(['precision loss']):
        viewer.save_to_file(filename)