Ejemplo n.º 1
0
def test_2D():
    X = np.loadtxt('data/fish_target.txt')
    Y = np.loadtxt('data/fish_source.txt')

    reg = deformable_registration(**{'X': X, 'Y': Y})
    TY, _ = reg.register()
    assert_array_almost_equal(X, TY, decimal=1)
Ejemplo n.º 2
0
def main():
    X = np.loadtxt('data/fish_target.txt')
    Y = np.loadtxt('data/fish_source.txt')

    fig = plt.figure()
    fig.add_axes([0, 0, 1, 1])
    callback = partial(visualize, ax=fig.axes[0])

    reg = deformable_registration(**{'X': X, 'Y': Y})
    reg.register(callback)
    plt.show()
Ejemplo n.º 3
0
def main():
    fish = loadmat('./data/fish.mat')
    X = fish['X']
    Y = fish['Y']

    fig = plt.figure()
    fig.add_axes([0, 0, 1, 1])
    callback = partial(visualize, ax=fig.axes[0])

    reg = deformable_registration(X, Y)
    reg.register(callback)
    plt.show()
Ejemplo n.º 4
0
def main():
    fish = loadmat('../data/fish.mat')
    X = np.zeros((fish['X'].shape[0], fish['X'].shape[1] + 1))
    X[:,:-1] = fish['X']

    Y = np.zeros((fish['Y'].shape[0], fish['Y'].shape[1] + 1))
    Y[:,:-1] = fish['Y']

    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    callback = partial(visualize, ax=ax)

    reg = deformable_registration(X, Y)
    reg.register(callback)
    plt.show()
Ejemplo n.º 5
0
def CPD(X, Y, draw=True):
    if draw:
        fig = plt.figure()
        fig.add_axes([0, 0, 1, 1])
        callback = partial(visualize, ax=fig.axes[0], draw=draw)
    else:
        callback = []

    reg = deformable_registration(**{'X': X, 'Y': Y})
    reg.register(callback)

    if draw:
        plt.show()

    return reg.TY
Ejemplo n.º 6
0
def test_3D():
    fish_target = np.loadtxt('data/fish_target.txt')
    X1 = np.zeros((fish_target.shape[0], fish_target.shape[1] + 1))
    X1[:, :-1] = fish_target
    X2 = np.ones((fish_target.shape[0], fish_target.shape[1] + 1))
    X2[:, :-1] = fish_target
    X = np.vstack((X1, X2))

    fish_source = np.loadtxt('data/fish_source.txt')
    Y1 = np.zeros((fish_source.shape[0], fish_source.shape[1] + 1))
    Y1[:, :-1] = fish_source
    Y2 = np.ones((fish_source.shape[0], fish_source.shape[1] + 1))
    Y2[:, :-1] = fish_source
    Y = np.vstack((Y1, Y2))

    reg = deformable_registration(**{'X': X, 'Y': Y})
    TY, _ = reg.register()
    assert_array_almost_equal(TY, X, decimal=0)
Ejemplo n.º 7
0
def get_cpd_transformation(target_points,
                           points_to_register,
                           alpha,
                           beta,
                           tolerance=1e-6,
                           max_iter=100,
                           callback=lambda *args: None):
    reg = deformable_registration(X=target_points,
                                  Y=points_to_register,
                                  alpha=alpha,
                                  beta=beta,
                                  tolerance=tolerance,
                                  max_iterations=max_iter)

    def cb(*args, **kwargs):
        callback(reg)

    reg.register(callback=cb)
    return reg.TY
Ejemplo n.º 8
0
def main():
    fish_target = np.loadtxt('data/fish_target.txt')
    X1 = np.zeros((fish_target.shape[0], fish_target.shape[1] + 1))
    X1[:, :-1] = fish_target
    X2 = np.ones((fish_target.shape[0], fish_target.shape[1] + 1))
    X2[:, :-1] = fish_target
    X = np.vstack((X1, X2))

    fish_source = np.loadtxt('data/fish_source.txt')
    Y1 = np.zeros((fish_source.shape[0], fish_source.shape[1] + 1))
    Y1[:, :-1] = fish_source
    Y2 = np.ones((fish_source.shape[0], fish_source.shape[1] + 1))
    Y2[:, :-1] = fish_source
    Y = np.vstack((Y1, Y2))

    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    callback = partial(visualize, ax=ax)

    reg = deformable_registration(**{'X': X, 'Y': Y})
    reg.register(callback)
    plt.show()
def main(ID_target, ID_source):

    target_load = o3d.io.read_point_cloud(
        'C:/Users/monre/OneDrive - Imperial College London/ME4/FYP/DATA/OAI-ZIB/processed_data/05.corresponded_deformable_no_scaling_PCDs/femur_bone_corresponded_deformable_' + ID_target + '.ply')
    femur_target = np.asarray(target_load.points)/8

    source_load = o3d.io.read_point_cloud(
        'C:/Users/monre/OneDrive - Imperial College London/ME4/FYP/DATA/OAI-ZIB/processed_data/05.trimmed_no_scaling_PCDs/femur_bone_trimmed_' + ID_source + '.ply')
    femur_source = np.asarray(source_load.points)/8

    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    callback = partial(visualize, ax=ax)

    reg = deformable_registration(**{'X': femur_target, 'Y': femur_source})

    reg.register(callback)
    #plt.show()

    dictionary = {"femur": reg.register(callback)[0],
                  "probability": reg.register(callback)[2]}
    return dictionary
Ejemplo n.º 10
0
def main():
    flat = np.array(flat_trans[0:-70])
    flat = flat.reshape((np.size(flat, 0), np.size(flat, 2)))
    print(np.shape(flat))

    curv = np.array(curv_trans[95:-120])
    curv = curv.reshape((np.size(curv, 0), np.size(curv, 2)))

    sshape = np.array(sshape_trans)

    X = np.zeros((flat.shape[0], flat.shape[1] + 1))
    X[:, :-1] = flat

    Y = np.zeros((curv.shape[0], curv.shape[1] + 1))
    Y[:, :-1] = curv

    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    callback = partial(visualize, ax=ax)

    reg = deformable_registration(X, Y)
    reg.register(callback)
    plt.show()
Ejemplo n.º 11
0
#im2 = tf.get_t()


im1 = gaussian3d(im1)
im2 = gaussian3d(im2)


peaks1 = findpeaks3d(im1 * np.array(im1 > np.quantile(im1,.99)))
peaks2 = findpeaks3d(im2 * np.array(im2 > np.quantile(im2,.99)))


fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
callback = partial(visualize, ax=ax)

reg = deformable_registration(**{ 'X': peaks1, 'Y': peaks2 })
reg.register(callback)
plt.show()
#reg.register()

'''
fig = plt.figure()


ax = fig.add_subplot(111, projection='3d')
ax.scatter(peaks1[:,0],  peaks1[:,1], peaks1[:,2], color='red', label='Target')
ax.scatter(peaks2[:,0],  peaks2[:,1], peaks2[:,2], color='blue', label='Source')
plt.show()