mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-13 17:45:20 +08:00
Merge pull request #101 from stefanv/pil_bilevel_png
BUG: Correctly load bi-level images via PIL.
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 278 B |
@@ -21,8 +21,9 @@ def imread(fname, dtype=None):
|
||||
im = im.convert('L')
|
||||
else:
|
||||
im = im.convert('RGB')
|
||||
|
||||
if im.mode.startswith('I;16'):
|
||||
elif im.mode == '1':
|
||||
im = im.convert('L')
|
||||
elif im.mode == 'I;16':
|
||||
shape = im.size
|
||||
dtype = '>u2' if im.mode.endswith('B') else '<u2'
|
||||
im = np.fromstring(im.tostring(), dtype)
|
||||
|
||||
@@ -43,6 +43,14 @@ def test_palette_is_gray():
|
||||
color = Image.open(os.path.join(data_dir, 'palette_color.png'))
|
||||
assert not _palette_is_grayscale(color)
|
||||
|
||||
@skipif(not PIL_available)
|
||||
def test_bilevel():
|
||||
expected = np.zeros((10, 10))
|
||||
expected[::2] = 255
|
||||
|
||||
img = imread(os.path.join(data_dir, 'checker_bilevel.png'))
|
||||
assert_array_equal(img, expected)
|
||||
|
||||
class TestSave:
|
||||
def roundtrip(self, dtype, x, scaling=1):
|
||||
f = NamedTemporaryFile(suffix='.png')
|
||||
|
||||
Reference in New Issue
Block a user