Пример #1
0
def rotations_faces(cube):
  U = cube.copy();
  N = t3d.rotate(cube, axis=0, steps=1);
  W = t3d.rotate(cube, axis=1, steps=1);
  UNW = [U,N,W];
  DSE = [t3d.reflect(X) for X in UNW];
  return UNW + DSE;
Пример #2
0
def rotations_nodes(cube):
  UNW = cube.copy();
  UNE = t3d.rotate(cube, axis=2,steps=1);
  USE = t3d.rotate(cube, axis=2,steps=2);
  USW = t3d.rotate(cube, axis=2,steps=3);
  R = [t3d.reflect(X) for X in [UNW,UNE,USE,USW]];
  return [UNW,UNE, USE,USW] + R
Пример #3
0
def rotations_edges(cube):
  UN = cube.copy();
  UE = t3d.rotate(cube, axis=2, steps=1);
  US = t3d.rotate(cube, axis=2, steps=2); 
  UW = t3d.rotate(cube, axis=2, steps=3); 
  NW = t3d.rotate(cube, axis=1, steps=3); 
  NE = t3d.rotate(cube, axis=1, steps=1);  
  R = [t3d.reflect(X) for X in [UN,UE,US,UW,NW,NE]];
  return [UN,UE,US,UW,NW,NE] + R;
Пример #4
0
def rotations_node_faces(cube):
  U_UNW = cube.copy();                       #U1
  U_UNE = t3d.rotate(cube, axis=2, steps=1); #U3
  U_USE = t3d.rotate(cube, axis=2, steps=2); #U5
  U_USW = t3d.rotate(cube, axis=2, steps=3); #U7
  
  Us = [U_UNW, U_UNE, U_USE, U_USW];
  Ns = [t3d.rotate(X, axis=0, steps=1) for X in Us]; # N7. N1, N3, N5
  Ws = [t3d.rotate(X, axis=1, steps=1) for X in Us]; # W3, W1, W7, W5

  UNWs = Us + Ns + Ws;
  DSEs = [t3d.reflect(X) for X in UNWs];
  
  return UNWs + DSEs;
Пример #5
0
def _test():
    import numpy as np
    import ClearMap.ImageProcessing.Topology.Topology3d as top

    from importlib import reload
    reload(top)

    label = top.cube_labeled()
    top.print_cube(label)

    # Test rotations
    c = np.zeros((3, 3, 3), dtype=bool)
    c[1, 0, 0] = True
    top.print_cube(c)

    cs = [top.rotate(c, axis=2, steps=r) for r in range(4)]
    [top.print_cube(cc) for cc in cs]

    reload(top)
    l = top.cube_labeled()
    rts = top.rotations6(l)

    [top.print_cube(r) for r in rts]

    reload(top)
    b = top.cube_from_index(6)
    i = top.cube_to_index(b)
    print(i, 6)

    us = np.zeros((3, 3, 3), dtype=int)
    us[1, 1, 2] = 1
    us[1, 0, 1] = 1
    us[1, 2, 0] = 2

    r12 = top.rotations12(us)
    [top.print_cube(cc) for cc in r12]

    #check configuration utlity
    reload(top)
    index = 11607
    source = top.cube_from_index(index)

    c = top.index_from_binary(source)
    c[1, 1, 1] == index

    x = np.random.rand(1500, 500, 500) > 0.6
    c = top.index_from_binary(x)

    import numpy as np
    import ClearMap.ImageProcessing.Topology.Topology3d as top

    #check fortran vs c order
    x = np.random.rand(5, 5, 5) > 0.35
    y = np.asanyarray(x, order='F')

    ix = top.index_from_binary(x)
    iy = top.index_from_binary(y)

    ax = ix.array
    ay = iy.array

    #%% profile
    import io
    io.DEFAULT_BUFFER_SIZE = 2**32

    import pstats, cProfile

    import numpy as np
    import ClearMap.ImageProcessing.Topology.Topology3d as top

    x = np.ones((3000, 500, 1000), dtype=bool, order='F')

    import ClearMap.IO.IO as io
    import ClearMap.ParallelProcessing.DataProcessing.ArrayProcessing as ap
    ap.write('test.npy', x)

    y = io.as_source('test.npy')
    z = io.create('resuly.npy', shape=y.shape, order='C', dtype='uint32')

    cProfile.runctx(
        "c =top.index_from_binary(y, method='!shared', sink=z, verbose=True, processes=None)",
        globals(), locals(), "Profile.prof")

    s = pstats.Stats("Profile.prof")
    s.strip_dirs().sort_stats("time").print_stats()

    import mmap
    mmap.ACCESS_COPY