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:
Steven Silvester
2015-08-31 22:16:56 -05:00
2 changed files with 13 additions and 1 deletions
+3
View File
@@ -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)
+10 -1
View File
@@ -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