mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-20 12:40:31 +08:00
Minor changes to Tony Yu's palette_is_grayscale.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
__all__ = ['imread', 'palette_is_grayscale']
|
||||
__all__ = ['imread']
|
||||
|
||||
import numpy as np
|
||||
|
||||
@@ -45,13 +45,13 @@ def imread(fname, flatten=False, dtype=None):
|
||||
|
||||
|
||||
def palette_is_grayscale(pil_image):
|
||||
"""Return True if PIL image is grayscale.
|
||||
|
||||
"""Return True if PIL image in palette mode is grayscale.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
pil_image : PIL image
|
||||
PIL Image that is in Palette mode.
|
||||
|
||||
|
||||
Returns
|
||||
-------
|
||||
is_grayscale : bool
|
||||
|
||||
@@ -2,7 +2,8 @@ import os.path
|
||||
import numpy as np
|
||||
|
||||
from scikits.image import data_dir
|
||||
from scikits.image.io import imread, palette_is_grayscale
|
||||
from scikits.image.io import imread
|
||||
from scikits.image.io.pil_imread import palette_is_grayscale
|
||||
|
||||
def test_imread_flatten():
|
||||
# a color image is flattened and returned as float32
|
||||
@@ -23,10 +24,7 @@ def test_imread_palette():
|
||||
assert img.ndim == 3
|
||||
|
||||
def test_palette_is_gray():
|
||||
try:
|
||||
from PIL import Image
|
||||
except ImportError:
|
||||
return
|
||||
from PIL import Image
|
||||
gray = Image.open(os.path.join(data_dir, 'palette_gray.png'))
|
||||
assert palette_is_grayscale(gray)
|
||||
color = Image.open(os.path.join(data_dir, 'palette_color.png'))
|
||||
|
||||
Reference in New Issue
Block a user