diff --git a/bento.info b/bento.info index a36a4ebb..bfc607a8 100644 --- a/bento.info +++ b/bento.info @@ -33,7 +33,8 @@ UseBackends: Waf Library: Packages: skimage, skimage.color, skimage.data, skimage.draw, skimage.exposure, - skimage.feature, skimage.filters, skimage.graph, skimage.io, + skimage.feature, skimage.filters, skimage.future, skimage.future.graph, + skimage.graph, skimage.io, skimage.io._plugins, skimage.measure, skimage.morphology, skimage.scripts, skimage.restoration, skimage.segmentation, skimage.transform, skimage.util @@ -151,9 +152,9 @@ Library: Extension: skimage.feature._hessian_det_appx Sources: skimage/exposure/_hessian_det_appx.pyx - Extension: skimage.graph._ncut_cy + Extension: skimage.future.graph._ncut_cy Sources: - skimage/graph/_ncut_cy.pyx + skimage/future/graph/_ncut_cy.pyx Extension: skimage.external.tifffile._tifffile Sources: skimage/external/tifffile/_tifffile.c diff --git a/doc/examples/plot_ncut.py b/doc/examples/plot_ncut.py index 6b8a62ab..5596a297 100644 --- a/doc/examples/plot_ncut.py +++ b/doc/examples/plot_ncut.py @@ -12,7 +12,8 @@ References Pattern Analysis and Machine Intelligence, IEEE Transactions on, vol. 22, no. 8, pp. 888-905, August 2000. """ -from skimage import graph, data, io, segmentation, color +from skimage import data, io, segmentation, color +from skimage.future import graph from matplotlib import pyplot as plt diff --git a/doc/examples/plot_rag.py b/doc/examples/plot_rag.py index e44f4094..d4f2711c 100644 --- a/doc/examples/plot_rag.py +++ b/doc/examples/plot_rag.py @@ -14,7 +14,7 @@ The example below also shows how to use a custom function to select the larger weight instead. """ -from skimage.graph import rag +from skimage.future.graph import rag import networkx as nx from matplotlib import pyplot as plt import numpy as np diff --git a/doc/examples/plot_rag_draw.py b/doc/examples/plot_rag_draw.py index 0c1e1abc..bdc39678 100644 --- a/doc/examples/plot_rag_draw.py +++ b/doc/examples/plot_rag_draw.py @@ -6,7 +6,8 @@ Drawing Region Adjacency Graphs (RAGs) This example constructs a Region Adjacency Graph (RAG) and draws it with the `rag_draw` method. """ -from skimage import graph, data, segmentation +from skimage import data, segmentation +from skimage.future import graph from matplotlib import pyplot as plt, colors diff --git a/doc/examples/plot_rag_mean_color.py b/doc/examples/plot_rag_mean_color.py index ab962e65..4b2bfcae 100644 --- a/doc/examples/plot_rag_mean_color.py +++ b/doc/examples/plot_rag_mean_color.py @@ -9,7 +9,8 @@ difference in mean color. We then join regions with similar mean color. """ -from skimage import graph, data, io, segmentation, color +from skimage import data, io, segmentation, color +from skimage.future import graph from matplotlib import pyplot as plt diff --git a/doc/examples/plot_rag_merge.py b/doc/examples/plot_rag_merge.py index d454a096..37712d5b 100644 --- a/doc/examples/plot_rag_merge.py +++ b/doc/examples/plot_rag_merge.py @@ -10,7 +10,8 @@ until no highly similar region pairs remain. """ -from skimage import graph, data, io, segmentation, color +from skimage import data, io, segmentation, color +from skimage.future import graph import numpy as np diff --git a/skimage/future/__init__.py b/skimage/future/__init__.py new file mode 100644 index 00000000..0292a6ef --- /dev/null +++ b/skimage/future/__init__.py @@ -0,0 +1,10 @@ +"""Functionality with an experimental API. Although you can count on the +functions in this package being around in the future, the API may change with +any version update **and will not follow the skimage two-version deprecation +path**. Therefore, use the functions herein with care, and do not use them in +production code that will depend on updated skimage versions. +""" + +from . import graph + +__all__ = ['graph'] diff --git a/skimage/future/graph/__init__.py b/skimage/future/graph/__init__.py new file mode 100644 index 00000000..6b7e0aaa --- /dev/null +++ b/skimage/future/graph/__init__.py @@ -0,0 +1,12 @@ +from .graph_cut import cut_threshold, cut_normalized +from .rag import rag_mean_color, RAG, draw_rag +from .graph_merge import merge_hierarchical +ncut = cut_normalized + +__all__ = ['rag_mean_color', + 'cut_threshold', + 'cut_normalized', + 'ncut', + 'draw_rag', + 'merge_hierarchical', + 'RAG'] diff --git a/skimage/graph/_ncut.py b/skimage/future/graph/_ncut.py similarity index 100% rename from skimage/graph/_ncut.py rename to skimage/future/graph/_ncut.py diff --git a/skimage/graph/_ncut_cy.pyx b/skimage/future/graph/_ncut_cy.pyx similarity index 100% rename from skimage/graph/_ncut_cy.pyx rename to skimage/future/graph/_ncut_cy.pyx diff --git a/skimage/graph/graph_cut.py b/skimage/future/graph/graph_cut.py similarity index 98% rename from skimage/graph/graph_cut.py rename to skimage/future/graph/graph_cut.py index b4658bd1..d727eeac 100644 --- a/skimage/graph/graph_cut.py +++ b/skimage/future/graph/graph_cut.py @@ -37,7 +37,8 @@ def cut_threshold(labels, rag, thresh, in_place=True): Examples -------- - >>> from skimage import data, graph, segmentation + >>> from skimage import data, segmentation + >>> from skimage.future import graph >>> img = data.astronaut() >>> labels = segmentation.slic(img) >>> rag = graph.rag_mean_color(img, labels) @@ -107,7 +108,8 @@ def cut_normalized(labels, rag, thresh=0.001, num_cuts=10, in_place=True, Examples -------- - >>> from skimage import data, graph, segmentation + >>> from skimage import data, segmentation + >>> from skimage.future import graph >>> img = data.astronaut() >>> labels = segmentation.slic(img, compactness=30, n_segments=400) >>> rag = graph.rag_mean_color(img, labels, mode='similarity') diff --git a/skimage/graph/graph_merge.py b/skimage/future/graph/graph_merge.py similarity index 100% rename from skimage/graph/graph_merge.py rename to skimage/future/graph/graph_merge.py diff --git a/skimage/graph/rag.py b/skimage/future/graph/rag.py similarity index 98% rename from skimage/graph/rag.py rename to skimage/future/graph/rag.py index 120e9e91..b0fd9240 100644 --- a/skimage/graph/rag.py +++ b/skimage/future/graph/rag.py @@ -14,7 +14,7 @@ import numpy as np from scipy.ndimage import filters from scipy import ndimage as nd import math -from .. import draw, measure, segmentation, util, color +from ... import draw, measure, segmentation, util, color try: from matplotlib import colors from matplotlib import cm @@ -251,7 +251,8 @@ def rag_mean_color(image, labels, connectivity=2, mode='distance', Examples -------- - >>> from skimage import data, graph, segmentation + >>> from skimage import data, segmentation + >>> from skimage.future import graph >>> img = data.astronaut() >>> labels = segmentation.slic(img) >>> rag = graph.rag_mean_color(img, labels) @@ -364,7 +365,8 @@ def draw_rag(labels, rag, img, border_color=None, node_color='#ffff00', Examples -------- - >>> from skimage import data, graph, segmentation + >>> from skimage import data, segmentation + >>> from skimage.future import graph >>> img = data.coffee() >>> labels = segmentation.slic(img) >>> g = graph.rag_mean_color(img, labels) diff --git a/skimage/future/graph/setup.py b/skimage/future/graph/setup.py new file mode 100644 index 00000000..059a0779 --- /dev/null +++ b/skimage/future/graph/setup.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +from skimage._build import cython +import os.path + +base_path = os.path.abspath(os.path.dirname(__file__)) + + +def configuration(parent_package='', top_path=None): + from numpy.distutils.misc_util import Configuration, get_numpy_include_dirs + + config = Configuration('graph', parent_package, top_path) + config.add_data_dir('tests') + + # This function tries to create C files from the given .pyx files. If + # it fails, try to build with pre-generated .c files. + cython(['_ncut_cy.pyx'], working_path=base_path) + config.add_extension('_ncut_cy', sources=['_ncut_cy.c'], + include_dirs=[get_numpy_include_dirs()]) + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(maintainer='scikit-image Developers', + maintainer_email='scikit-image@googlegroups.com', + description='Graph-based Image-processing Algorithms', + url='https://github.com/scikit-image/scikit-image', + license='Modified BSD', + **(configuration(top_path='').todict()) + ) diff --git a/skimage/graph/tests/test_rag.py b/skimage/future/graph/tests/test_rag.py similarity index 99% rename from skimage/graph/tests/test_rag.py rename to skimage/future/graph/tests/test_rag.py index cfa49cdf..1cac2b2d 100644 --- a/skimage/graph/tests/test_rag.py +++ b/skimage/future/graph/tests/test_rag.py @@ -1,5 +1,5 @@ import numpy as np -from skimage import graph +from skimage.future import graph from skimage._shared.version_requirements import is_installed from numpy.testing.decorators import skipif from skimage import segmentation diff --git a/skimage/future/setup.py b/skimage/future/setup.py new file mode 100644 index 00000000..aaded0c7 --- /dev/null +++ b/skimage/future/setup.py @@ -0,0 +1,12 @@ + +def configuration(parent_package='skimage', top_path=None): + from numpy.distutils.misc_util import Configuration + config = Configuration('future', parent_package, top_path) + config.add_subpackage('graph') + return config + +if __name__ == "__main__": + from numpy.distutils.core import setup + + config = configuration(top_path='').todict() + setup(**config) diff --git a/skimage/graph/__init__.py b/skimage/graph/__init__.py index f93708c9..89260f1f 100644 --- a/skimage/graph/__init__.py +++ b/skimage/graph/__init__.py @@ -1,9 +1,5 @@ from .spath import shortest_path from .mcp import MCP, MCP_Geometric, MCP_Connect, MCP_Flexible, route_through_array -from .graph_cut import cut_threshold, cut_normalized -from .rag import rag_mean_color, RAG, draw_rag -from .graph_merge import merge_hierarchical -ncut = cut_normalized __all__ = ['shortest_path', diff --git a/skimage/graph/setup.py b/skimage/graph/setup.py index edc7b653..4c6aba06 100644 --- a/skimage/graph/setup.py +++ b/skimage/graph/setup.py @@ -17,7 +17,6 @@ def configuration(parent_package='', top_path=None): cython(['_spath.pyx'], working_path=base_path) cython(['_mcp.pyx'], working_path=base_path) cython(['heap.pyx'], working_path=base_path) - cython(['_ncut_cy.pyx'], working_path=base_path) config.add_extension('_spath', sources=['_spath.c'], include_dirs=[get_numpy_include_dirs()]) @@ -25,8 +24,6 @@ def configuration(parent_package='', top_path=None): include_dirs=[get_numpy_include_dirs()]) config.add_extension('heap', sources=['heap.c'], include_dirs=[get_numpy_include_dirs()]) - config.add_extension('_ncut_cy', sources=['_ncut_cy.c'], - include_dirs=[get_numpy_include_dirs()]) return config if __name__ == '__main__': diff --git a/skimage/setup.py b/skimage/setup.py index 94d00ea8..b33f5e81 100644 --- a/skimage/setup.py +++ b/skimage/setup.py @@ -14,6 +14,7 @@ def configuration(parent_package='', top_path=None): config.add_subpackage('feature') config.add_subpackage('restoration') config.add_subpackage('filters') + config.add_subpackage('future') config.add_subpackage('graph') config.add_subpackage('io') config.add_subpackage('measure')