mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-12 12:30:16 +08:00
Extend plugins with imshow_collection
A first implementation is made for Matplotlib.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
[matplotlib]
|
||||
description = Display or save images using Matplotlib
|
||||
provides = imshow, imread, _app_show
|
||||
|
||||
provides = imshow, imread, imshow_collection, _app_show
|
||||
|
||||
@@ -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,3 +1,3 @@
|
||||
[test]
|
||||
description = Test plugin
|
||||
provides = imsave, imshow, imread, imread_collection
|
||||
provides = imsave, imshow, imread, imread_collection, imshow_collection
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user