mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-03 20:22:48 +08:00
Merge pull request #1687 from connellybarnes/master
fix scikit-image bug #1680 (grayscale png round trip fails) and add u…
This commit is contained in:
@@ -87,6 +87,9 @@ def pil_to_ndarray(im, dtype=None, img_num=None):
|
||||
i += 1
|
||||
continue
|
||||
|
||||
if im.format == 'PNG' and im.mode == 'I' and dtype is None:
|
||||
dtype = 'uint16'
|
||||
|
||||
if im.mode == 'P':
|
||||
if grayscale is None:
|
||||
grayscale = _palette_is_grayscale(im)
|
||||
|
||||
@@ -6,7 +6,7 @@ from numpy.testing import (
|
||||
|
||||
from tempfile import NamedTemporaryFile
|
||||
|
||||
from ... import data_dir
|
||||
from ... import data_dir, img_as_float
|
||||
from .. import imread, imsave, use_plugin, reset_plugins
|
||||
from ..._shared.testing import mono_check, color_check
|
||||
from ..._shared._warnings import expected_warnings
|
||||
@@ -39,6 +39,15 @@ def setup_module(self):
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
def test_png_round_trip():
|
||||
f = NamedTemporaryFile(suffix='.png')
|
||||
fname = f.name
|
||||
f.close()
|
||||
I = np.eye(3)
|
||||
imsave(fname, I)
|
||||
Ip = img_as_float(imread(fname))
|
||||
os.remove(fname)
|
||||
assert np.sum(np.abs(Ip-I)) < 1e-3
|
||||
|
||||
def test_imread_flatten():
|
||||
# a color image is flattened
|
||||
|
||||
Reference in New Issue
Block a user