Deformation fields with thin-plates

For my research, I had to create a set of smooth deformation fields where I knew which points were moved and by which amount.

I tried to find a script, but I couldn’t find an appropriate one, not even talking about one in Python. So here I propose my own version, allowing to interpolate a 1D, 2D or 3D deformation field based on some points.

How does it work ? It is based on Bookstein’s algorithm. The first step is the computation of the coefficients of the smooth deformation field and then they are used to compute the values on the deformation field on a grid and this grid is returned.

The function to use is denseDeformationFieldFromSparse(), the arguments being size, the size of the desired grid, points, the locations where the deformation field is known, and displacements, the amount of displacement for each previously given point.

This code is given as is, but feel free to comment so that bugs can be ironed out (if there are bugs). It was tested with 1D, 2D and 3D test cases which can also be found on the gist.

Thanks to Bill Baxter for the distance function that was proposed on the numpy discussion list.

Building with Scons and an optional SWIG

I now regularly use Scons as a cross-platform software construction tool. It is easy, written in Python, and I know Python, so no problem learning a new language as for CMake. In some cases when I use SWIG, the target platform does not have the SWIG executable. But when compiling a module, Scons must use this executable, whatever you try to do. In this case, one need to create a new SharedLibrary builder, so that this attribute will determine if SWIG is present or if the generated .c or .cpp files must be used instead.
Continue reading Building with Scons and an optional SWIG

Welcome !

After some thoughts, I’ve decided to create my new English blog. I already have a French one, on http://blog.developpez.com/index.php?blog=92, but now I feel I need to have an English one.

Currently, I’ve doing a PhD thesis in Strasbourg, France, with the Python language mainly, although some work is done in C++. It tackles the complicated problem of manifold learning, I hope I will have some concrete results soon !

My passions, besides CS (I’m a geek :()) is music (I’m a trumpet player, a drummer and a bassist) playing or playing with music. That is, I love mixing music, creating new tools for music or acoustics, …

I hope you will enjoy this blog 😉