From f292717dacaf46490ece9e015dd8542cd1affb22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Sun, 17 Jul 2016 12:01:08 +0200 Subject: [PATCH] Add option as_grey to load() --- skimage/data/__init__.py | 8 +++++--- skimage/data/tests/test_data.py | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/skimage/data/__init__.py b/skimage/data/__init__.py index e0e97d03..b1784f6a 100644 --- a/skimage/data/__init__.py +++ b/skimage/data/__init__.py @@ -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(): diff --git a/skimage/data/tests/test_data.py b/skimage/data/tests/test_data.py index 1eaf87cb..c1f5c4e4 100644 --- a/skimage/data/tests/test_data.py +++ b/skimage/data/tests/test_data.py @@ -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'))