Converting Volumes to Meshes with VTK

Deborah Schmidt
Helmholtz Imaging | MDC Berlin
Sep 25, 2024
Slides available at https://ida-mdc.github.io/workshop-visualization/tutorial-mesh-conversion/

Introduction

  • VTK provides robust tools for generating meshes from volumes, including labelmaps and raw pixel data.
  • FlyingEdges3D is a highly efficient algorithm for generating iso-surfaces from volumetric data.
  • VTK supports advanced options for mesh optimization, including smoothing and decimation.

Solution to run conversion code automatically

To simplify and unify solutions used in our tutorials, we use Album, a tool for capturing and sharing specific software use cases in dedicated virtual environments.

Click the solution box next to this text and follow the displayed usage instructions to run the solution either from command line or graphical interface.

Conversion of 3D pixel datasets into meshes with VTK

visualization:pixel-volumes-to-meshes-vtk:0.2.0

This solution uses vtkFlyingEdges3D to generate meshes from pixel volumes, including optional smoothing and decimation of vertices, and can optionally display the result.
Tags: bioinformatics, neuroscience, data-analysis

Dependencies

Volume conversion using vtkFlyingEdges3D

  • Add zero border around dataset
  • Load volumetric image using vtkImageData
  • Generate meshes using vtkFlyingEdges3D algorithm
  • Set threshold between foreground and background via GenerateValues (int numContours, double rangeStart, double rangeEnd)

Smoothing

  • Number of iterations: Controls how many smoothing passes are applied.
  • Feature Edge Smoothing: Ensures that important edges are preserved while smoothing.
  • Boundary Smoothing: Smooths out the mesh along the boundaries.

Decimate geometry

  • Target Reduction: Defines the percentage reduction in the number of polygons (e.g., 0.5 for 50% reduction).
  • Preserve Topology: Ensures that the overall shape and connectivity of the mesh are maintained during decimation.

Write STL file

The final step in this process is to write the generated mesh to an STL file. STL files are widely used for 3D printing, simulations, and visualizations in tools like Blender.