Add tests for multipage_rgb tif

This commit is contained in:
Steven Silvester
2015-05-09 09:32:56 -05:00
parent ef9c4d8d19
commit d351c13c2d
2 changed files with 17 additions and 3 deletions
+8 -2
View File
@@ -69,12 +69,18 @@ def test_imread_separate_channels():
f = NamedTemporaryFile(suffix='.tif')
fname = f.name
f.close()
imsave(fname, x, plugin='tifffile')
img = imread(fname, plugin='tifffile')
imsave(fname, x)
img = imread(fname)
os.remove(fname)
assert img.shape == (16, 8, 3), img.shape
@skipif(not imread_available)
def test_imread_multipage_rgb_tif():
img = imread(os.path.join(data_dir, 'multipage_rgb.png'))
assert img.shape == (10, 10, 3), img.shape
class TestSave:
def roundtrip(self, x, scaling=1):
f = NamedTemporaryFile(suffix='.png')
+9 -1
View File
@@ -4,6 +4,7 @@ import numpy as np
from numpy.testing import assert_raises, assert_equal, assert_allclose
from skimage import data_dir
from skimage.io import use_plugin
from skimage.io.collection import MultiImage, ImageCollection
import six
@@ -14,7 +15,8 @@ class TestMultiImage():
def setUp(self):
# This multipage TIF file was created with imagemagick:
# convert im1.tif im2.tif -adjoin multipage.tif
paths = [os.path.join(data_dir, 'multipage.tif'),
use_plugin('pil')
paths = [os.path.join(data_dir, 'multipage_rgb.tif'),
os.path.join(data_dir, 'no_time_for_that.gif')]
self.imgs = [MultiImage(paths[0]),
MultiImage(paths[0], conserve_memory=False),
@@ -24,6 +26,12 @@ class TestMultiImage():
ImageCollection(paths[1], conserve_memory=False),
ImageCollection('%s:%s' % (paths[0], paths[1]))]
def test_shapes(self):
img = self.imgs[-1]
imgs = img[:]
assert imgs[0].shape == imgs[1].shape
assert imgs[0].shape == (10, 10, 3)
def test_len(self):
assert len(self.imgs[0]) == len(self.imgs[1]) == 2
assert len(self.imgs[2]) == len(self.imgs[3]) == 24