![]() Download Version log User: How to model User: plugin help file User: Blender survival guide *updated Programmer: How the skin is done Gallery Other IJ plugins CurveMorphing Credits About the author Hire me or donate Hosting & design: pixelets.com |
Curve MorphingA python module for morphing curves and creating 3D meshes.
Download the CurveMorphing module
I would very much appreciate if you can contribute a Windows Visual Studio compilation. PLEASE NOTE: this release is fully stable in the systems tested and for the purposes tested, but may not be for your particular setup. USE AT YOUR OWN RISK, the General Public License (GPL) applies, and if you come across any problems please report back with a ready test case to reproduce it. Blender python plugins that use the module
Screenshots This head below was generated by outlining the skull in an MRI scan of a human head. The Bézier curves were drawn over a stack of 50 slices using the 3D Editing plugin for ImageJ, and then imported using the load_shapes_v1.4.3.py and the CurveMorphing module with 1 interpolated curve between any two Z consecutive pair of curves, scale 0.1, and depth 5.5 (this is the distance in pixels that separates any two slices). The Bézier curves drawn had many different number of points each. The face is slightly deformed because this is the outline of the bones, the ears and the eyes, not the flesh. It took about 23 seconds to generate in my FreeBSD 5.3 Intel 2.8GHz 1GB DDR RAM. This is as it comes out, no smoothing, no nothing. From here, using standard Blender tools, one can generate and render a perfectly looking model of the head. ![]() Here is the display highlighting the vertices. I have pushed "smooth" once, so some vertices are not perfectly aligned in the XY plane: ![]() The images below illustrate the sort of problem solved by this C Python module. In commercially available programs such as Amira(TM), a volume is made from any set of consecutive outlines by thickening each outline and merging them all, creating what I call a "stack of pizzas", which is far less than optimal. There are two really undesirable consequences of this pizza stacking: 1) holes are created when one of the curves has an invagination so deep that it crosses the other side of the curve, and 2) curves that don't overlap at all in the Z axis are reconstructed as independent floating pizzas. Furthermore, if the user didn't outline a structure for a particular section, the final object will be sliced in two at that section. All these problems are addressed by the program presented here. The program provided here creates smooth interpolated curves between any two consecutive curves, thus avoiding the creation of holes in the object, and also avoiding the representation of two non-overlapping outlines as separate floating pizzas. Since the program attempts to match any two Z-consecutive outlines, if the outline of any section is missing, an interpolated one will be created for it. The automatic interpolation of outlines saves the user lots of drawing when the outline of an object doesn't change match from section to section; i.e. the user only has draw every other or one every three, four, etc. sections and still obtain a very good model of the object of interest. Finally, since the outline is subsampled, the accuracy of the curve representation is user-defineable. The automated subsampling chosen by the program is simply the average of the point interdistance of all curves that represent the outlines of an object. The default value for subsampling already results in the number of triangles and quad faces used being much, much lower than that of Amira's created objects, without affecting at all the quality of the rendered surface, and resulting in much smaller files. Some screenshots, showing a mesh made of 3 Bézier curves with different number of control points: ![]() ![]() How it works From the Jiang et al. 2002 paper: "Shape morphing, also known as metamorphosis, shape interpolation, shape blending, and shape evolving, is to compute a continuous transformation from one shape (the source) to another (the target). The curve morphing problem is formulated as that of computing a weigthed mean of two strings, which is then solved by [Wagner and Fischer's algorythm]." This implementation of the method described in Jiang et al. 2002 paper proceeds through several steps:
References
Work for developers to do This 1.0 release is by no means final, but fully working and stable for the purpose intended. Despite, I am a flexible programmer and, precisely because of that, my knowledge of any given language has huge gaps. If you can identify bottle necks, memory leaks, or suggest optimizations, please do! If the module crashes on you, please report back with a test case to reproduce the problem. Further, the curve morphing method is by no means restricted to 2D, but could be implemented for three-dimensional curves as well. I can lead you through the code if you'd like to go for such an implementation. I will not implement it myself because, to put it plainly, we already have what we need to do 3D models of biological data. And time is gold! Acknowledgements This C Python module would not have been possible without:
|