Mapping points on segmentation (labelmap) to points on an isosurface

Hello, I am trying to understand on how to use coordinates, transforms using vtk to develop an application.

For this I am trying to create an isosurface from labelmaps (Nrrd format) using Marching Cubes, and trying to map the corresponding points on the created isosurface to points on a labelmap. Could anyone, please describe in brief on how one should go about it ? Specific questions that I could think of is :

  1. How would you represent the isosurface ? What kind of class would one use ?
  2. What transforms would you use ? (IJK,RAS,World)

Would really appreciate any help pointing me towards reading material, examples.


Isosurface points are defined in physical coordinate system (world coordinate system, usually LPS, but in 3D Slicer and a few other applications it is RAS), while voxel positions are specified in voxel coordinate system (IJK). You can convert between them by multiplying the homogeneous IJK coordinates by the IJKToWorld homogeneous transformation matrix (or multiply homogeneous World coordinates by WorldToIJK).

You can find full examples in Python for converting World->IJK and IJK->World in 3D Slicer’s script repository. In the examples the volume is also under an arbitrary linear/non-linear/composite transform (represented by a vtkGeneralTransform), so that is factored in as well.

Probably you want to use the more modern and much faster Flying Edges method instead.

Your generated isosurface in the screenshot above is very low quality. You can apply an anti-aliasing filter (low-pass filter) on the image before isosurface extraction, or apply a low-pass filter (such as vtkWindowedSincPolyDataFilter) on the extracted surface to remove the staircase artifacts.

Coordinate conversions, segmentations, isosurface extractions, smoothing, etc. are all implemented in 3D Slicer and the application has been developed to be fully customizable (you can simplify and/or extend everything), so I would strongly recommend to build your application on 3D Slicer instead of redevelop it from scratch.

Thanks Andras, this is really helpful, could you also please share a link for a VTK example where I can look at how to represent these volumes and models as transforms or perform transformations between them ?

I agree with you that 3D slicer has most of the functionalities that’s needed. I want to build a standalone application where I can define the UI elements and workflow for this application. I read about scripting and how I can make 3D slicer extensions.

But what I am looking to work towards is to make a custom application, where I can utilise modules already present in 3D slicer. Could you please suggest links for tutorials or steps to create this kind of custom application if its possible ?

The Slicer Custom Application Template is developed exactly for this purpose. It allows you to pick any features from Slicer that you like (you can add/remove any modules, enable/disable a number of major features, etc.), add anything that you need (modules from Slicer extensions, Python packages, your own custom modules), and customize every aspect of the application at every level. If you need help with anything then you can ask on the Slicer forum.