diff --git a/lectures/scripts/clock_deblur.py b/lectures/scripts/clock_deblur.py index 5cb97d7..32db270 100644 --- a/lectures/scripts/clock_deblur.py +++ b/lectures/scripts/clock_deblur.py @@ -2,9 +2,9 @@ import matplotlib.pyplot as plt from skimage import io -from skimage.viewer import ImageViewer -from skimage.viewer.widgets import Slider -from skimage.viewer.plugins.base import Plugin +#from skimage.viewer import ImageViewer +#from skimage.viewer.widgets import Slider +#from skimage.viewer.plugins.base import Plugin image = io.imread('../../images/clock_motion.png') @@ -48,13 +48,13 @@ def apply_inverse_filter(image, T, a, b, K=5, clip=500): return gg -viewer = ImageViewer(image) - -plugin = Plugin(image_filter=apply_inverse_filter) -plugin += Slider('T', 0, 1, value=0.5, value_type='float', update_on='release') -plugin += Slider('a', -0.1, 0.1, value=0, value_type='float', update_on='release') -plugin += Slider('b', -0.1, 0.1, value=0, value_type='float', update_on='release') -plugin += Slider('K', 0, 100, value=15, value_type='float', update_on='release') -plugin += Slider('clip', 0, 1000, value=750, value_type='float', update_on='release') -viewer += plugin -viewer.show() +#viewer = ImageViewer(image) +# +#plugin = Plugin(image_filter=apply_inverse_filter) +#plugin += Slider('T', 0, 1, value=0.5, value_type='float', update_on='release') +#plugin += Slider('a', -0.1, 0.1, value=0, value_type='float', update_on='release') +#plugin += Slider('b', -0.1, 0.1, value=0, value_type='float', update_on='release') +#plugin += Slider('K', 0, 100, value=15, value_type='float', update_on='release') +#plugin += Slider('clip', 0, 1000, value=750, value_type='float', update_on='release') +#viewer += plugin +#viewer.show() diff --git a/viewer_examples/0_image_viewer.py b/viewer_examples/0_image_viewer.py deleted file mode 100644 index e093278..0000000 --- a/viewer_examples/0_image_viewer.py +++ /dev/null @@ -1,7 +0,0 @@ -from skimage import data -from skimage.viewer import ImageViewer - - -image = data.camera() -viewer = ImageViewer(image) -viewer.show() diff --git a/viewer_examples/1_collection_viewer.py b/viewer_examples/1_collection_viewer.py deleted file mode 100644 index 8fd3aca..0000000 --- a/viewer_examples/1_collection_viewer.py +++ /dev/null @@ -1,10 +0,0 @@ -from skimage import data -from skimage.viewer import CollectionViewer -from skimage.transform import pyramid_gaussian - - -img = data.lena() -img_collection = tuple(pyramid_gaussian(img)) - -view = CollectionViewer(img_collection) -view.show() diff --git a/viewer_examples/2_canny.py b/viewer_examples/2_canny.py deleted file mode 100644 index 7148c70..0000000 --- a/viewer_examples/2_canny.py +++ /dev/null @@ -1,25 +0,0 @@ -from skimage import data -from skimage.feature import canny -from skimage.viewer import ImageViewer -from skimage.viewer.plugins.overlayplugin import OverlayPlugin -from skimage.viewer.widgets import Slider - - -class CannyPlugin(OverlayPlugin): - - def __init__(self, *args, **kwargs): - super(CannyPlugin, self).__init__(image_filter=canny, **kwargs) - - def attach(self, image_viewer): - # add widgets - self.add_widget(Slider('sigma', 0, 5)) - self.add_widget(Slider('low threshold', 0, 255, value_type='int')) - self.add_widget(Slider('high threshold', 0, 255, value_type='int')) - - super(CannyPlugin, self).attach(image_viewer) - - -image = data.camera() -viewer = ImageViewer(image) -viewer += CannyPlugin() -viewer.show() diff --git a/viewer_examples/3_canny_simple.py b/viewer_examples/3_canny_simple.py deleted file mode 100644 index f9dc5cc..0000000 --- a/viewer_examples/3_canny_simple.py +++ /dev/null @@ -1,15 +0,0 @@ -from skimage import data -from skimage.feature import canny -from skimage.viewer import ImageViewer -from skimage.viewer.widgets import Slider -from skimage.viewer.plugins.overlayplugin import OverlayPlugin - - -plugin = OverlayPlugin(image_filter=canny) -plugin += Slider('sigma', 0, 5) -plugin += Slider('low threshold', 0, 255, value_type='int') -plugin += Slider('high threshold', 0, 255, value_type='int') - -viewer = ImageViewer(data.camera()) -viewer += plugin -viewer.show() diff --git a/viewer_examples/4_lineprofile.py b/viewer_examples/4_lineprofile.py deleted file mode 100644 index 2f1b2cd..0000000 --- a/viewer_examples/4_lineprofile.py +++ /dev/null @@ -1,9 +0,0 @@ -from skimage import data -from skimage.viewer import ImageViewer -from skimage.viewer.plugins.lineprofile import LineProfile - - -image = data.camera() -viewer = ImageViewer(image) -viewer += LineProfile() -viewer.show() diff --git a/viewer_examples/5_color_histogram.py b/viewer_examples/5_color_histogram.py deleted file mode 100644 index aea4ae9..0000000 --- a/viewer_examples/5_color_histogram.py +++ /dev/null @@ -1,9 +0,0 @@ -from skimage import io -from skimage.viewer import ImageViewer -from skimage.viewer.plugins.color_histogram import ColorHistogram - - -image = io.imread('mms_scipy2013.png') -viewer = ImageViewer(image) -viewer += ColorHistogram(max_pct=0.99) -viewer.show() diff --git a/viewer_examples/6_watershed_demo.py b/viewer_examples/6_watershed_demo.py deleted file mode 100644 index 612ec6c..0000000 --- a/viewer_examples/6_watershed_demo.py +++ /dev/null @@ -1,43 +0,0 @@ -import matplotlib.pyplot as plt - -from skimage import data -from skimage import filter -from skimage import morphology -from skimage.viewer import ImageViewer -from skimage.viewer.widgets import history -from skimage.viewer.plugins.labelplugin import LabelPainter - - -class OKCancelButtons(history.OKCancelButtons): - - def update_original_image(self): - # OKCancelButtons updates the original image with the filtered image - # by default. Override this method to update the overlay. - self.plugin._show_watershed() - self.plugin.close() - - -class WatershedPlugin(LabelPainter): - - def help(self): - helpstr = ("Watershed plugin", - "----------------", - "Use mouse to paint each region with a different label.", - "Press OK to display segmented image.") - return '\n'.join(helpstr) - - def _show_watershed(self): - viewer = self.image_viewer - edge_image = filter.sobel(viewer.image) - labels = morphology.watershed(edge_image, self.paint_tool.overlay) - viewer.ax.imshow(labels, cmap=plt.cm.jet, alpha=0.5) - viewer.redraw() - - -image = data.coins() -plugin = WatershedPlugin() -plugin += OKCancelButtons() - -viewer = ImageViewer(image) -viewer += plugin -viewer.show() diff --git a/viewer_examples/7_probabilistic_hough.py b/viewer_examples/7_probabilistic_hough.py deleted file mode 100644 index bce0e5b..0000000 --- a/viewer_examples/7_probabilistic_hough.py +++ /dev/null @@ -1,39 +0,0 @@ -import numpy as np - -from skimage import data -from skimage import draw -from skimage.transform import probabilistic_hough_line - -from skimage.viewer import ImageViewer -from skimage.viewer.widgets import Slider -from skimage.viewer.plugins.overlayplugin import OverlayPlugin -from skimage.viewer.plugins.canny import CannyPlugin - - -def line_image(shape, lines): - image = np.zeros(shape, dtype=bool) - for end_points in lines: - end_points = np.asarray(end_points)[:, ::-1] - image[draw.line(*np.ravel(end_points))] = 1 - return image - - -def hough_lines(image, *args, **kwargs): - lines = probabilistic_hough_line(image, threshold=0.5, *args, **kwargs) - image = line_image(image.shape, lines) - return image - - -image = data.camera() -canny_viewer = ImageViewer(image) -canny_plugin = CannyPlugin() -canny_viewer += canny_plugin - -hough_plugin = OverlayPlugin(image_filter=hough_lines) -hough_plugin += Slider('line length', 0, 100, value=100, update_on='move') -hough_plugin += Slider('line gap', 0, 20, value=0, update_on='move') - -hough_viewer = ImageViewer(canny_plugin) -hough_viewer += hough_plugin - -canny_viewer.show() diff --git a/viewer_examples/mms_scipy2013.png b/viewer_examples/mms_scipy2013.png deleted file mode 100644 index c644de6..0000000 Binary files a/viewer_examples/mms_scipy2013.png and /dev/null differ