siavashk / pycpd

Pure Numpy Implementation of the Coherent Point Drift Algorithm
MIT License
513 stars 115 forks source link

deformation registration not working with different scale points values #33

Closed junqiangchen closed 4 years ago

junqiangchen commented 4 years ago

Hi, Thanks for your CPD implementation.

When i try the nonrigid deformation, i follow the deformation registration example,this is ok.

when i change the points scale,such as 10,100,i find the deformation registration is not working wiht different scale value.

i also try affine registration and rigid registration,both that are working with different scale values.

i don't understand what is problem?

I'm attaching my code and the results in both cases.

Thanks, junqiangchen

here is my code

`from functools import partial from mpl_toolkits.mplot3d import Axes3D from pycpd import deformable_registration, affine_registration import time import matplotlib.pyplot as plt import numpy as np

def visualize(iteration, error, X, Y, ax): plt.cla() ax.scatter(X[:, 0], X[:, 1], X[:, 2], color='red', label='Target') ax.scatter(Y[:, 0], Y[:, 1], Y[:, 2], color='blue', label='Source') ax.text2D(0.87, 0.92, 'Iteration: {:d}\nError: {:06.4f}'.format(iteration, error), horizontalalignment='center', verticalalignment='center', transform=ax.transAxes, fontsize='x-large') ax.legend(loc='upper left', fontsize='x-large') plt.draw() plt.pause(0.001)

factor = 100 target = np.loadtxt("Cpd/data/face.txt") * factor X1 = np.zeros((target.shape[0], target.shape[1] + 1)) X1[:, :-1] = target X2 = np.ones((target.shape[0], target.shape[1] + 1)) X2[:, :-1] = target X = np.vstack((X1, X2))

source = np.loadtxt("Cpd/data/face_distorted.txt") * factor Y1 = np.zeros((source.shape[0], source.shape[1] + 1)) Y1[:, :-1] = source Y2 = np.ones((source.shape[0], source.shape[1] + 1)) Y2[:, :-1] = 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()`

非刚性变换 100倍非刚性变换

siavashk commented 4 years ago

when i change the points scale,such as 10,100,i find the deformation registration is not working wiht different scale value.

What do yo mean by " point scale"?

junqiangchen commented 4 years ago

when i change the points scale,such as 10,100,i find the deformation registration is not working wiht different scale value.

What do yo mean by " point scale"?

i want to registrate two points cloud data,but they are have different coordinate scale.

siavashk commented 4 years ago

Deformable registration methods typically have a short capture range. You should consider preprocessing both point clouds by centering them (removing their mean), and resampling them such that both point clouds have the same spacing (same scale in your terminology).

siavashk commented 4 years ago

Closing due to inactivity.