コード例 #1
0
 def setUp(self):
     # This multipage TIF file was created with imagemagick:
     # convert im1.tif im2.tif -adjoin multipage.tif
     use_plugin('pil')
     paths = [os.path.join(data_dir, 'multipage_rgb.tif'),
              os.path.join(data_dir, 'no_time_for_that_tiny.gif')]
     self.imgs = [MultiImage(paths[0]),
                  MultiImage(paths[0], conserve_memory=False),
                  MultiImage(paths[1]),
                  MultiImage(paths[1], conserve_memory=False),
                  ImageCollection(paths[0]),
                  ImageCollection(paths[1], conserve_memory=False),
                  ImageCollection(os.pathsep.join(paths))]
コード例 #2
0
 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'),
         os.path.join(data_dir, 'no_time_for_that.gif')
     ]
     self.imgs = [
         MultiImage(paths[0]),
         MultiImage(paths[0], conserve_memory=False),
         MultiImage(paths[1]),
         MultiImage(paths[1], conserve_memory=False),
         ImageCollection(paths[0]),
         ImageCollection(paths[1], conserve_memory=False),
         ImageCollection('%s:%s' % (paths[0], paths[1]))
     ]
コード例 #3
0
 def setUp(self):
     reset_plugins()
     # Generic image collection with images of different shapes.
     self.images = ImageCollection(self.pattern)
     # Image collection with images having shapes that match.
     self.images_matched = ImageCollection(self.pattern_matched)
     # Same images as a collection of frames
     self.frames_matched = MultiImage(self.pattern_matched)
コード例 #4
0
def imgs():
    use_plugin('pil')

    paths = [
        testing.fetch('data/multipage_rgb.tif'),
        testing.fetch('data/no_time_for_that_tiny.gif')
    ]
    imgs = [
        MultiImage(paths[0]),
        MultiImage(paths[0], conserve_memory=False),
        MultiImage(paths[1]),
        MultiImage(paths[1], conserve_memory=False),
        MultiImage(os.pathsep.join(paths))
    ]
    yield imgs

    reset_plugins()
コード例 #5
0
def imgs():
    use_plugin('pil')
    paths = [
        os.path.join(data_dir, 'multipage_rgb.tif'),
        os.path.join(data_dir, 'no_time_for_that_tiny.gif')
    ]
    imgs = [
        MultiImage(paths[0]),
        MultiImage(paths[0], conserve_memory=False),
        MultiImage(paths[1]),
        MultiImage(paths[1], conserve_memory=False),
        ImageCollection(paths[0]),
        ImageCollection(paths[1], conserve_memory=False),
        ImageCollection(os.pathsep.join(paths))
    ]
    yield imgs

    reset_plugins()
コード例 #6
0
class TestMultiImage:
    def setUp(self):
        # This multipage TIF file was created with imagemagick:
        # convert im1.tif im2.tif -adjoin multipage.tif
        if PIL_available:
            self.img = MultiImage(os.path.join(data_dir, "multipage.tif"))

    @skipif(not PIL_available)
    def test_len(self):
        assert len(self.img) == 2

    @skipif(not PIL_available)
    def test_getitem(self):
        num = len(self.img)
        for i in range(-num, num):
            assert type(self.img[i]) is np.ndarray
        assert_allclose(self.img[0], self.img[-num])

        # assert_raises expects a callable, hence this thin wrapper function.
        def return_img(n):
            return self.img[n]

        assert_raises(IndexError, return_img, num)
        assert_raises(IndexError, return_img, -num - 1)

    @skipif(not PIL_available)
    def test_files_property(self):
        assert isinstance(self.img.filename, six.string_types)

        def set_filename(f):
            self.img.filename = f

        assert_raises(AttributeError, set_filename, "newfile")

    @skipif(not PIL_available)
    def test_conserve_memory_property(self):
        assert isinstance(self.img.conserve_memory, bool)

        def set_mem(val):
            self.img.conserve_memory = val

        assert_raises(AttributeError, set_mem, True)

    @skipif(not PIL_available)
    def test_concatenate(self):
        array = self.img.concatenate()
        assert_equal(array.shape, (len(self.img),) + self.img[0].shape)
コード例 #7
0
class TestMultiImage():
    def setUp(self):
        # This multipage TIF file was created with imagemagick:
        # convert im1.tif im2.tif -adjoin multipage.tif
        if PIL_available:
            self.img = MultiImage(os.path.join(data_dir, 'multipage.tif'))

    @skipif(not PIL_available)
    def test_len(self):
        assert len(self.img) == 2

    @skipif(not PIL_available)
    def test_getitem(self):
        num = len(self.img)
        for i in range(-num, num):
            assert type(self.img[i]) is np.ndarray
        assert_allclose(self.img[0], self.img[-num])

        # assert_raises expects a callable, hence this thin wrapper function.
        def return_img(n):
            return self.img[n]

        assert_raises(IndexError, return_img, num)
        assert_raises(IndexError, return_img, -num - 1)

    @skipif(not PIL_available)
    def test_files_property(self):
        assert isinstance(self.img.filename, six.string_types)

        def set_filename(f):
            self.img.filename = f

        assert_raises(AttributeError, set_filename, 'newfile')

    @skipif(not PIL_available)
    def test_conserve_memory_property(self):
        assert isinstance(self.img.conserve_memory, bool)

        def set_mem(val):
            self.img.conserve_memory = val

        assert_raises(AttributeError, set_mem, True)

    @skipif(not PIL_available)
    def test_concatenate(self):
        array = self.img.concatenate()
        assert_equal(array.shape, (len(self.img), ) + self.img[0].shape)
コード例 #8
0
 def setUp(self):
     # This multipage TIF file was created with imagemagick:
     # convert im1.tif im2.tif -adjoin multipage.tif
     if PIL_available:
         self.img = MultiImage(os.path.join(data_dir, "multipage.tif"))
コード例 #9
0
 def setUp(self):
     # This multipage TIF file was created with imagemagick:
     # convert im1.tif im2.tif -adjoin multipage.tif
     if PIL_available:
         self.img = MultiImage(os.path.join(data_dir, 'multipage.tif'))