Extend plugins with imshow_collection

A first implementation is made for Matplotlib.
This commit is contained in:
Stefan van der Walt
2016-03-02 16:22:24 -08:00
parent 0d7289ea76
commit 3ffca2fdbd
7 changed files with 54 additions and 10 deletions
+1 -2
View File
@@ -1,4 +1,3 @@
[matplotlib]
description = Display or save images using Matplotlib
provides = imshow, imread, _app_show
provides = imshow, imread, imshow_collection, _app_show
+13
View File
@@ -147,6 +147,7 @@ def imshow(im, ax=None, show_cbar=None, **kwargs):
if kwargs.get('cmap', None) == 'viridis':
kwargs['cmap'] = viridis
lo, hi, cmap = _get_display_range(im)
kwargs.setdefault('interpolation', 'nearest')
kwargs.setdefault('cmap', cmap)
kwargs.setdefault('vmin', lo)
@@ -160,8 +161,20 @@ def imshow(im, ax=None, show_cbar=None, **kwargs):
plt.colorbar(ax_im, cax=cax)
ax.set_adjustable('box-forced')
ax.get_figure().tight_layout()
return ax_im
def imshow_collection(ic, *args, **kwargs):
"""Display all images in the collection.
"""
fig, axes = plt.subplots(1, len(ic))
for n, image in enumerate(ic):
kwargs['axis'] = axes[n]
imshow(image, *args, **kwargs)
imread = plt.imread
show = plt.show
+1 -1
View File
@@ -1,3 +1,3 @@
[test]
description = Test plugin
provides = imsave, imshow, imread, imread_collection
provides = imsave, imshow, imread, imread_collection, imshow_collection
+7
View File
@@ -1,6 +1,8 @@
# This mock-up is called by ../tests/test_plugin.py
# to verify the behaviour of the plugin infrastructure
from skimage.io import ImageCollection
def imread(fname, dtype=None):
assert fname == 'test.png'
@@ -20,3 +22,8 @@ def imshow(arr, plugin_arg=None):
def imread_collection(x, conserve_memory=True):
assert conserve_memory == False
assert x == '*.png'
return ImageCollection([0, 1], load_func=lambda x: x)
def imshow_collection(x):
assert len(x) == 2