Marco Virgolin
Marco Virgolin

Reputation: 165

VTK / ITK Dice Similarity Coefficient on Meshes

I am new to VTK and am trying to compute the Dice Similarity Coefficient (DSC), starting from 2 meshes. DSC can be computed as 2 Vab / (Va + Vb), where Vab is the overlapping volume among mesh A and mesh B.

To read a mesh (i.e. an organ contour exported in .vtk format using 3D Slicer, https://www.slicer.org) I use the following snippet:

string inputFilename1 = "organ1.vtk";

// Get all data from the file
vtkSmartPointer<vtkGenericDataObjectReader> reader1 = vtkSmartPointer<vtkGenericDataObjectReader>::New();
reader1->SetFileName(inputFilename1.c_str());
reader1->Update();

vtkSmartPointer<vtkPolyData> struct1 = reader1->GetPolyDataOutput();

I can compute the volume of the two meshes using vtkMassProperties (although I observed some differences between the ones computed with VTK and the ones computed with 3D Slicer).

To then intersect 2 meshses, I am trying to use vtkIntersectionPolyDataFilter. The output of this filter, however, is a set of lines that marks the intersection of the input vtkPolyData objects, and NOT a closed surface. I therefore need to somehow generate a mesh from these lines and compute its volume.

Do you know which can be a good, accurate way to generete such a mesh and how to do it?


Alternatively, I tried to use ITK as well. I found a package that is supposed to handle this problem (http://www.insight-journal.org/browse/publication/762, dated 2010) but I am not able to compile it against the latest version of ITK. It says that ITK must be compiled with the (now deprecated) ITK_USE_REVIEW flag ON. Needless to say, I compiled it with the new Module_ITKReview set to ON and also with backward compatibility but had no luck.


Finally, if you have any other alternative (scriptable) software/library to solve this problem, please let me know. I need to perform these computation automatically.

Upvotes: 0

Views: 1472

Answers (2)

mainactual
mainactual

Reputation: 1645

You could try vtkBooleanOperationPolyDataFilter

http://www.vtk.org/doc/nightly/html/classvtkBooleanOperationPolyDataFilter.html

filter->SetOperationToIntersection();

if your data is smooth and well-behaved, this filter works pretty good. However, sharp structures, e.g. the ones originating from binary image marching cubes algorithm can make a problem for it. That said, vtkPolyDataToImageStencil doesn't necessarily perform any better on this regard.

I had once impression that the boolean operation on polygons is not really ideal for "organs" of size 100k polygons and more. Depends.

Upvotes: 1

Simon Esneault
Simon Esneault

Reputation: 66

If you want to compute a Dice Similarity Coefficient, I suggest you first generate volumes (rasterize) from the meshes by use of vtkPolyDataToImageStencil. Then it's easy to compute the DSC.

Good luck :)

Upvotes: 0

Related Questions