Add option as_grey to load()

This commit is contained in:
François Boulogne
2016-07-17 12:01:08 +02:00
parent 6685651da5
commit f292717dac
2 changed files with 6 additions and 3 deletions
+5 -3
View File
@@ -33,13 +33,15 @@ __all__ = ['load',
'astronaut']
def load(f):
def load(f, as_grey=False):
"""Load an image file located in the data directory.
Parameters
----------
f : string
File name.
as_grey : bool, optional
Convert to greyscale.
Returns
-------
@@ -47,7 +49,7 @@ def load(f):
Image loaded from ``skimage.data_dir``.
"""
use_plugin('pil')
return imread(_os.path.join(data_dir, f))
return imread(_os.path.join(data_dir, f), as_grey=as_grey)
def camera():
@@ -172,7 +174,7 @@ def horse():
"""
with warnings.catch_warnings():
warnings.simplefilter("ignore")
return img_as_bool(load("horse.png"))
return img_as_bool(load("horse.png", as_grey=True))
def clock():
+1
View File
@@ -43,6 +43,7 @@ def test_coffee():
def test_horse():
""" Test that "horse" image can be loaded. """
horse = data.horse()
assert_equal(horse.ndim, 2)
assert_equal(horse.dtype, np.dtype('bool'))