Exemplo n.º 1
0
def test_slicing_returns_image():
    data = np.ones((2,3,4))
    img = fromarray(data, 'kji', 'zyx')
    assert isinstance(img, Image)
    assert img.ndim == 3
    # 2D slice
    img2D = subsample(img, slice_maker[:,:,0])
    assert isinstance(img2D, Image)
    assert img2D.ndim == 2
    # 1D slice
    img1D = subsample(img, slice_maker[:,0,0])
    assert isinstance(img1D, Image)
    assert img1D.ndim == 1
Exemplo n.º 2
0
def test_slice_steps():
    dim0, dim1, dim2 = gimg.shape
    slice_z = slice(0, dim0, 2)
    slice_y = slice(0, dim1, 2)
    slice_x = slice(0, dim2, 2)
    x = subsample(gimg, slice_maker[slice_z, slice_y, slice_x])
    newshape = tuple(np.floor((np.array(gimg.shape) - 1)/2) + 1)
    yield assert_equal, x.shape, newshape
Exemplo n.º 3
0
def test_parcels3():
    rho = subsample(gimg, slice_maker[0])
    parcelmap = np.asarray(rho).astype(np.int32)
    labels = np.unique(parcelmap)
    test = np.zeros(rho.shape)
    v = 0
    for i, d in data_generator(test, parcels(parcelmap, labels=labels)):
        v += d.shape[0]
    yield assert_equal, v, np.product(test.shape)
Exemplo n.º 4
0
def test_slice_type():
    s = slice(0,gimg.shape[0])
    x = subsample(gimg, slice_maker[s])
    yield assert_equal, x.shape, gimg.shape
Exemplo n.º 5
0
def test_slice_step():
    s = slice(0,4,2)
    x = subsample(gimg, slice_maker[s])
    yield assert_equal, x.shape, (2,) + tuple(gimg.shape[1:])
Exemplo n.º 6
0
def test_slice_block():
    x = subsample(gimg, slice_maker[1:3])
    yield assert_equal, x.shape, (2,) + tuple(gimg.shape[1:])
Exemplo n.º 7
0
def test_slice_plane():
    x = subsample(gimg, slice_maker[1])
    yield assert_equal, x.shape, gimg.shape[1:]