Merge branch 'imagecollection'

This commit is contained in:
Stefan van der Walt
2010-11-07 00:51:21 +02:00
5 changed files with 43 additions and 5 deletions
+3 -2
View File
@@ -12,6 +12,7 @@ from glob import glob
plugin_store = {'imread': [],
'imsave': [],
'imshow': [],
'imread_collection': [],
'_app_show': []}
plugin_provides = {}
@@ -54,7 +55,7 @@ def call(kind, *args, **kwargs):
Parameters
----------
kind : {'show', 'save', 'read'}
kind : {'imshow', 'imsave', 'imread', 'imread_collection'}
Function to look up.
plugin : str, optional
Plugin to load. Defaults to None, in which case the first
@@ -94,7 +95,7 @@ def use(name, kind=None):
----------
name : str
Name of plugin.
kind : {'save', 'read', 'show'}, optional
kind : {'imsave', 'imread', 'imshow', 'imread_collection'}, optional
Set the plugin for this function. By default,
the plugin is set for all functions.
+1 -2
View File
@@ -1,4 +1,3 @@
[test]
description = Test plugin
provides = imsave, imshow, imread
provides = imsave, imshow, imread, imread_collection
+4
View File
@@ -9,3 +9,7 @@ def imsave(fname, arr):
def imshow(arr, plugin_arg=None):
assert arr == [1, 2, 3]
assert plugin_arg == (1, 2)
def imread_collection(x, conserve_memory=True):
assert conserve_memory == False
assert x == '*.png'
+32 -1
View File
@@ -1,4 +1,5 @@
__all__ = ['imread', 'imsave', 'imshow', 'show', 'push', 'pop']
__all__ = ['imread', 'imread_collection', 'imsave', 'imshow', 'show',
'push', 'pop']
from scikits.image.io._plugins import call as call_plugin
from scikits.image.color import rgb2grey
@@ -75,6 +76,36 @@ def imread(fname, as_grey=False, plugin=None, flatten=None,
return img
def imread_collection(load_pattern, conserve_memory=True,
plugin=None, **plugin_args):
"""
Load a collection of images.
Parameters
----------
load_pattern : str or list
List of objects to load. These are usually filenames, but may
vary depending on the currently active plugin. See the docstring
for ``ImageCollection`` for the default behaviour of this parameter.
conserve_memory : bool, optional
If True, never keep more than one in memory at a specific
time. Otherwise, images will be cached once they are loaded.
Returns
-------
ic : ImageCollection
Collection of images.
Other parameters
----------------
plugin_args : keywords
Passed to the given plugin.
"""
return call_plugin('imread_collection', load_pattern, conserve_memory,
plugin=plugin, **plugin_args)
def imsave(fname, arr, plugin=None, **plugin_args):
"""Save an image to file.
+3
View File
@@ -23,6 +23,9 @@ class TestPlugin:
def test_show(self):
io.imshow([1, 2, 3], plugin_arg=(1, 2), plugin='test')
def test_collection(self):
io.imread_collection('*.png', conserve_memory=False, plugin='test')
def test_use(self):
plugin.use('test')
plugin.use('test', 'imshow')