Beispiel #1
0
 def test_affine_subvolume_3d(self):
     from elf.transformation import compute_affine_matrix
     # TODO test more orders once implemented
     orders = [0, 1]
     matrices = [compute_affine_matrix(scale=(1, 2, 1), rotation=(15, 30, 0)),
                 compute_affine_matrix(scale=(3, 2, .5), rotation=(24, 33, 99)),
                 compute_affine_matrix(scale=(1., 1.3, .79), rotation=(12, -4, 8),
                                       translation=(10.5, 18., -33.2))]
     for mat in matrices:
         for order in orders:
             self._test_3d(mat, order=order)
Beispiel #2
0
 def test_affine_subvolume_2d(self):
     from elf.transformation import compute_affine_matrix
     # TODO test more orders once implemented
     orders = [0, 1]
     matrices = [compute_affine_matrix(scale=(2, 2), rotation=(45,)),
                 compute_affine_matrix(scale=(1, 2), rotation=(33,)),
                 compute_affine_matrix(scale=(3, 2), rotation=(137,)),
                 compute_affine_matrix(scale=(.5, 1.5), rotation=(23,),
                                       translation=(23., -14.))]
     for mat in matrices:
         for order in orders:
             self._test_2d(mat, order=order)
Beispiel #3
0
def bench_affine_2d(affine_function, N=5):
    times = []
    im = astronaut()[..., 0]
    matrix = compute_affine_matrix(scale=(.5, .5), rotation=(45,))
    for _ in range(N):
        t0 = time.time()
        affine_function(im, matrix)
        t0 = time.time() - t0
        times.append(t0)
    print(np.min(times), "s")
Beispiel #4
0
    def test_toy(self):
        from elf.transformation import compute_affine_matrix
        from elf.transformation import transform_subvolume_affine
        mat = compute_affine_matrix(scale=(2, 2), rotation=(45,), translation=(-1, 1))
        x = np.random.rand(10, 10)

        bb = np.s_[0:3, 0:3]
        res = transform_subvolume_affine(x, mat, bb, order=1)
        exp = affine_transform(x, mat, order=1)[bb]

        self.assertTrue(np.allclose(res, exp))
Beispiel #5
0
def bench_affine_3d(affine_function, N=5):
    path = '/home/pape/Work/data/isbi/isbi_train_volume.h5'
    with h5py.File(path, 'r') as f:
        data = f['raw'][:]

    times = []
    matrix = compute_affine_matrix(scale=(1., 2., 1.5), rotation=(16, 32, 7))
    for _ in range(N):
        t0 = time.time()
        affine_function(data, matrix)
        t0 = time.time() - t0
        times.append(t0)
    print(np.min(times), "s")
Beispiel #6
0
 def test_presmoothing(self):
     from elf.transformation import compute_affine_matrix
     mat = compute_affine_matrix(scale=(2, 2), rotation=(45, ))
     self._test_2d(mat, order=1, out_file='tmp.n5', sigma=1.)
Beispiel #7
0
 def _test_affine_subvolume_2d_chunked(self, out_file):
     from elf.transformation import compute_affine_matrix
     mat = compute_affine_matrix(scale=(2, 2), rotation=(45, ))
     self._test_2d(mat, order=0, out_file=out_file)
Beispiel #8
0
 def _test_affine_subvolume_3d_chunked(self, out_file):
     from elf.transformation import compute_affine_matrix
     mat = compute_affine_matrix(scale=(1, 2, 1), rotation=(15, 30, 0))
     self._test_3d(mat, order=0, out_file=out_file)