Iso2mesh v0.8 or later is able to mesh a gray-scale 3D image directly. Here is an example to demonstrate how this works.
The sample dataset used here is from CGAL library, under the path of CGAL-3.4/examples/Surface_mesher/data/, the file name is skull_2.9.inr. The following plot shows a few slices across the image. The values of each voxel are real numbers between 0 and 6.
Instead of segmenting the volume first and making a image with finite labels (material indices), we can do the surface extraction directly from the gray-scale image. A list of isovalues needs to be specified when calling vol2surf. We added a short-hand version of vol2surf, and the command line to extract the level-set at v=1 is
the created surface is
Similarly, one can extract a set of surfaces at a list of specified thresholds. The following command will extract two surfaces, one at v=1, one at v=2.9:
the mesh overlay is shown below:
The rest of the meshing task is straightforward, like others. One can use surf2mesh (or s2m) to convert the above surface set to a mesh, or call vol2mesh (or v2m) directly to do the whole process (including the previous 2 steps).
opt(1).radbound=2; % the surface at the first levelset has resolution of 2 opt(2).radbound=1; % the surface at the first levelset has resolution of 1 [node,elem,face]=v2m(dat,[1,2.9],opt,10);
wala, you now have your mesh!
isn't that easy ? :)