Exemplo n.º 1
0
import unittest
from cpa.imagereader import ImageReader
from cpa.properties import Properties

p = Properties()

# fake-up some props
p._filename = '../../CPAnalyst_test_data/test_images/'
p.image_channel_colors = ['red', 'green', 'blue', 'none', 'none', 'none']
p.object_name = ['cell', 'cells']
p.image_names = ['', '', '']
p.image_id = 'ImageNumber'

ir = ImageReader()


class TestImageReader(unittest.TestCase):
    def test_tif1(self):
        # TIF RGB, 8-bit, PackBits encoding
        fds = ['color.tif']
        images = ir.ReadImages(fds)
        assert len(images) == 3
        for im in images:
            assert 0. <= im.min() <= im.max() <= 1.
            assert im.shape == (512, 512)

    def test_tif2(self):
        # 2 RGB TIFS
        fds = ['color.tif', 'color.tif']
        images = ir.ReadImages(fds)
        assert len(images) == 6