siavashk / pycpd

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

modify fish_deformable_3D example and test the deform algorithm; chan… #18

Closed sandyhsia closed 5 years ago

sandyhsia commented 6 years ago

The fish_deformable_3D.py example is not sufficient to demo the correctness of the cpd algorithm. When I apply a R, t to the X point cloud, the fish_deformable_3D.py fails.

After I recheck the formula in the cpd paper, the initial implementation of sigma2 update seems not correct. I change the sigma2 update according to what's described here: screenshot 2018-08-20 23 06 06

siavashk commented 5 years ago

Sorry. I have been busy over the past month with other projects. What do you mean by applying (R, t) to deformable registration? (R, t) are rigid parameters, by definition deformable registration is non-rigid. It takes a Gaussian kernel and a set of weights.

I am going to look through the calculation of the variance now.

siavashk commented 5 years ago

OK, I looked at the commit and it seems that you are simulating a deformation field with a rigid transformation. Note that I did this without a rotation, since that would simulate a constant deformation field and hence would be easier to solve for.

Non-rigid registration methods typically have a smaller capture range compared to their rigid counterparts. Usually gross misalignments such as a rotation followed by translation are compensated for using rigid registration. Non-rigid registration is typically applied after this step to account for any residual deformation.

siavashk commented 5 years ago

Good catch on the variance. I had calculated the right term, but I forgot to subtract it. Basically, I needed to change: self.sigma2 = (xPx - trPXY) / (self.Np self.D) to self.sigma2 = (xPx - 2 trPXY + yPy) / (self.Np * self.D).

I think I was refactoring too fast and this one slipped me by. I have already fixed it in 8d0ef3bb38ec932f95d78ecbb6b3b1d7ff1f5d54, so I am rejecting this PR.