mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-12 12:30:16 +08:00
Add test for palette_is_grayscale
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
__all__ = ['imread']
|
||||
__all__ = ['imread', 'palette_is_grayscale']
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import os.path
|
||||
import numpy as np
|
||||
|
||||
from scikits.image import data_dir
|
||||
from scikits.image.io import imread
|
||||
from scikits.image.io import imread, palette_is_grayscale
|
||||
|
||||
def test_imread_flatten():
|
||||
# a color image is flattened and returned as float32
|
||||
@@ -21,3 +21,13 @@ def test_imread_palette():
|
||||
assert img.ndim == 2
|
||||
img = imread(os.path.join(data_dir, 'palette_color.png'))
|
||||
assert img.ndim == 3
|
||||
|
||||
def test_palette_is_gray():
|
||||
try:
|
||||
from PIL import Image
|
||||
except ImportError:
|
||||
return
|
||||
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'))
|
||||
assert not palette_is_grayscale(color)
|
||||
|
||||
Reference in New Issue
Block a user