From 2c635989d2d6f8264193e93cf3d446d8c4a578d5 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Fri, 30 Jan 2015 19:41:10 -0600 Subject: [PATCH] Force novice.Picture.from_size to return a uint8 image Force Picure.from_size to return a uint8 image Remove img_as_ubyte --- skimage/novice/_novice.py | 1 + skimage/novice/tests/test_novice.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/skimage/novice/_novice.py b/skimage/novice/_novice.py index cac72ee2..28df15d4 100644 --- a/skimage/novice/_novice.py +++ b/skimage/novice/_novice.py @@ -282,6 +282,7 @@ class Picture(object): color = color_dict[color] rgb_size = tuple(size) + (len(color),) array = np.ones(rgb_size, dtype=np.uint8) * color + array = array.astype(np.uint8) # Force RGBA internally (use max alpha) if array.shape[-1] == 3: diff --git a/skimage/novice/tests/test_novice.py b/skimage/novice/tests/test_novice.py index e2aafef0..36f4a537 100644 --- a/skimage/novice/tests/test_novice.py +++ b/skimage/novice/tests/test_novice.py @@ -86,6 +86,8 @@ def test_pixel_rgb(): pixel.rgb = np.arange(4) assert_equal(pixel.rgb, np.arange(3)) + assert pic.array.dtype == np.uint8 + def test_pixel_rgba(): pic = novice.Picture.from_size((3, 3), color=(10, 10, 10))