siavashk / pycpd

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

Add rigid, affine and deformable registration examples for the Stanford bunny #4

Closed siavashk closed 6 years ago

siavashk commented 7 years ago

I want to add examples for the Stanford bunny so that more examples from the original paper are covered.

siavashk commented 7 years ago

Added a rigid example in bf4161b

erikgaas commented 6 years ago

I ran the 3d bunny example and it seems to be diverging. Should I be tuning iterations or something else?

image

siavashk commented 6 years ago

The code is correct, the issue is that its first approximation of the transformation parameters for scale, rotation and translation (s, R, t) is quite off:

s = 0.00173093509915, t = [-0.02706625 0.09042602 0.00669968], R = [[ 0.99999606 -0.00255536 -0.00115781] [ 0.00255814 0.99999382 0.00240989] [ 0.00115165 -0.00241284 0.99999643]]

But if you wait until the last iteration, i.e. iteration 47th, you will see that it recovers the correct transformation:

s= 1.00000000068, t = [-0.99999992 -1. -1.00000008], R= [[ 1.00000000e+00 -2.92886267e-08 -4.32707450e-08] [ 2.92886251e-08 1.00000000e+00 -3.08270275e-08][ 4.32707460e-08 3.08270261e-08 1.00000000e+00]]

You can verify this by retrieving all output arguments of the register. That is in line 27 instead of calling reg.register(callback), use TY, R, t, s = reg.register(callback). You can verify that TY ≈ X, R ≈ I, t ≈ -1 and s ≈ 1.

Note that in the image that you sent me, blue points overlap with red points and the error is zero.