The surface created from Marching Cube and the mesh created from it is not smooth enough

Hi,

I am still in the process of learning ITK/VTK and struggling for a few days to create a mesh with three types (triangle, tetrahedron, and Simplex) of cells from the binary mask volume. I feel that I am doing some mistakes.

What I did is that

  • I created the surface by following the procedure in this link using marching cubes and setting the parameters as follows:

    double isoValue = 0.5; // threshold value
    surface->ComputeNormalsOn();
    surface->ComputeGradientsOn();
    surface->SetValue(0, isoValue); // second value acts as threshold
    surface->Update();

and saved the surface in a vtkPolyData

  • I created the triangle mesh by following the commands in this link.

My question is two-folded:

  1. The surface created using Marching Cube does not look smooth, and the mesh edges and cells also look the same (see the figures). Is this a usual representation of triangle mesh and marching cube? Or should I change any parameter?

Marching cube surface

marchingcube

Mesh surface
mesh
and the mesh structure types that I have defined:

#ifndef vtkFloatingPointType
#define vtkFloatingPointType double
#endif

const unsigned int PointDimension   = 3;
const unsigned int MaxCellDimension = 3;

typedef itk::DefaultStaticMeshTraits<
        vtkFloatingPointType,
        PointDimension,
        MaxCellDimension,
        vtkFloatingPointType,
        vtkFloatingPointType  >       MeshTraits;


typedef itk::Mesh<
        vtkFloatingPointType,
        PointDimension,
        MeshTraits              >     floatMeshType;
  1. What changes can I carry out in this code to have a tetrahedron mesh?

Thank you

For smooth surface, turn on Module_Cuberille when building ITK and use itk::CuberilleImageToMeshFilter instead of vtkMarchingCubes.

For tetrahedal mesh generation, take a look at this message. The main class is here.

3 Likes

@dzenanz Hi Sir, Thanks for introducing CuberilleImageToMeshFilter. I have attached two meshes: 1)CuberilleMesh 2)MarchingCubeMesh, which have been created triangle mesh by using two methods.
meshes.zip (2.3 MB)

using CuberFilterType=itk::CuberilleImageToMeshFilter<ImageType ,floatMeshType >;

CuberFilterType::Pointer cuberFilter=CuberFilterType::New();
cuberFilter->SetInput(image);

   try
        {
            cuberFilter->Update();
        }
        catch (itk::ExceptionObject & error)
        {
            std::cerr << "Error: " << error << std::endl;
            return EXIT_FAILURE;
        }

floatMeshType::Pointer cuberMesh = cuberFilter->GetOutput();

As you can view the meshes, there is not that much difference between the two meshes in terms of smoothness. I am wondering should I change any parameter for the cuberFilter ? Or if I am doing some mistakes somewhere.

The famous bunny mesh looks smooth and the size of triangles are big. As attached here:
bunny_mesh.zip (1.1 MB)

How the size and the number of triangle (or other cell types) in a mesh can affect the mesh processing?

Probably your input mesh is highly anisotropic. Resampling the image to have cubic voxels before segmentation will fix the issue. See some more details in this discussion.

For a smoother mesh, use a b-spline interpolator on the original volume data, not the thresholded volume, as described in the Cuberille Insight Journal article.

2 Likes

@matt.mccormick Thanks a lot Sir. Really appreciate it. This is the thing that needed it. May I ask one more question? What filter type should be used to view the created mesh by Cuberille? Should I convert it to UnstrcuturedGrid in Vtk and visualize using Vtk or can be visualized in ITK?

Thank you

1 Like

Hi @Sara_Caffe,

You can save the mesh with itk::MeshFileWriter, which can save the mesh as a vtkPolyData as a.vtk or other mesh file formats. The files can be read as vtkPolyData with VTK and rendered – this is the data structure VTK uses for rendering. vtkUnstructuredGrid can also be used, but it is converted to vtkPolyData for rendering.

Another option is to visualize in Jupyter with itkwidgets.

Or, visualize the files with itk-vtk-viewer, e.g.

3 Likes

BTW, i used in the past this pure VTK example, eliminates staircase artifacts completely with default parameters, produces very smooth meshes. Just for completeness.

https://lorensen.github.io/VTKExamples/site/Cxx/Medical/GenerateModelsFromLabels/

4 Likes

Hi can you send me your code I am facing similar issue @Sara_Caffe