[vtkusers] Solid Voxelization with VTK

Csaba Pinter csaba.pinter at queensu.ca
Tue Jun 5 10:14:52 EDT 2018


Hi Berti,

There is a pretty robust conversion algorithm implemented within 3D Slicer but using solely VTK:
https://github.com/Slicer/Slicer/blob/master/Libs/vtkSegmentationCore/vtkClosedSurfaceToBinaryLabelmapConversionRule.cxx#L118
It consists of a short pipeline of standard VTK filters (some preprocessing then vtkPolyDataToImageStencil and vtkImageStencil).

Let me know if you have any questions.

csaba


From: vtkusers <vtkusers-bounces at public.kitware.com> On Behalf Of Berti Krüger
Sent: Tuesday, June 5, 2018 03:26
To: David Gobbi <david.gobbi at gmail.com>
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] Solid Voxelization with VTK


Hi David,



thank you very much for your help.



I tried the example from your link. Unfortunately the result is same as using the vtkVoxelModeller:



[Screenshot result voxelization]
I get only a voxelization of the surface. The interior of the voxelized cone is still hollow and not filled with voxels (at least this is implied by the visualization).



For the visualization i use Bill Lorensen's example code from here:

https://lorensen.github.io/VTKExamples/site/Cxx/Medical/GenerateCubesFromLabels/<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Florensen.github.io%2FVTKExamples%2Fsite%2FCxx%2FMedical%2FGenerateCubesFromLabels%2F&data=02%7C01%7Ccsaba.pinter%40queensu.ca%7C63496d6b50e24ff32f7808d5cab5a98b%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C1%7C636637804016225671&sdata=4TKi7VbGBfbM4DpQuLib1m0YGmLJO%2FU7BAO6ZKCUpVU%3D&reserved=0>





I have attached this small example which compiles with VTK 8.1 to show the issue. It basicly only consist of the example code from your link (https://lorensen.github.io/VTKExamples/site/Cxx/PolyData/PolyDataToImageData/<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Florensen.github.io%2FVTKExamples%2Fsite%2FCxx%2FPolyData%2FPolyDataToImageData%2F&data=02%7C01%7Ccsaba.pinter%40queensu.ca%7C63496d6b50e24ff32f7808d5cab5a98b%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C1%7C636637804016225671&sdata=hXqgnekqjjNPflRneU0sU7DFo%2B%2FcdBfIFDcpE%2FZXiOg%3D&reserved=0>) and the visualization code from the  Bill Lorensen's example from the link above. I have not changed much.



Any idea what is going wrong or what can i do get also voxelization of the interior (solid voxelization)?



Thank you very much in advance.





Regards



Berti

PolyDataToImageData - lorensen.github.io<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Florensen.github.io%2FVTKExamples%2Fsite%2FCxx%2FPolyData%2FPolyDataToImageData%2F&data=02%7C01%7Ccsaba.pinter%40queensu.ca%7C63496d6b50e24ff32f7808d5cab5a98b%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C1%7C636637804016225671&sdata=hXqgnekqjjNPflRneU0sU7DFo%2B%2FcdBfIFDcpE%2FZXiOg%3D&reserved=0>
lorensen.github.io
If VTK is not installed but compiled on your system, you will need to specify the path to your VTK build:





GenerateCubesFromLabels - GitHub Pages<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Florensen.github.io%2FVTKExamples%2Fsite%2FCxx%2FMedical%2FGenerateCubesFromLabels%2F&data=02%7C01%7Ccsaba.pinter%40queensu.ca%7C63496d6b50e24ff32f7808d5cab5a98b%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C1%7C636637804016225671&sdata=4TKi7VbGBfbM4DpQuLib1m0YGmLJO%2FU7BAO6ZKCUpVU%3D&reserved=0>
lorensen.github.io
Usage: GenerateCubesFromLabels FullHead.mhd StartLabel EndLabel where InputVolume is a meta file containing a 3 volume of discrete labels.



________________________________
Von: David Gobbi <david.gobbi at gmail.com<mailto:david.gobbi at gmail.com>>
Gesendet: Montag, 28. Mai 2018 23:13
An: Berti Krüger
Cc: vtkusers at vtk.org<mailto:vtkusers at vtk.org>
Betreff: Re: [vtkusers] Solid Voxelization with VTK

Hi Berti,

If its a triangulated surface that you want to fill with voxels, use vtkPolyDataToImageStencil:
https://lorensen.github.io/VTKExamples/site/Cxx/PolyData/PolyDataToImageData/<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Florensen.github.io%2FVTKExamples%2Fsite%2FCxx%2FPolyData%2FPolyDataToImageData%2F&data=02%7C01%7Ccsaba.pinter%40queensu.ca%7C63496d6b50e24ff32f7808d5cab5a98b%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C1%7C636637804016225671&sdata=hXqgnekqjjNPflRneU0sU7DFo%2B%2FcdBfIFDcpE%2FZXiOg%3D&reserved=0>
PolyDataToImageData - lorensen.github.io<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Florensen.github.io%2FVTKExamples%2Fsite%2FCxx%2FPolyData%2FPolyDataToImageData%2F&data=02%7C01%7Ccsaba.pinter%40queensu.ca%7C63496d6b50e24ff32f7808d5cab5a98b%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C1%7C636637804016225671&sdata=hXqgnekqjjNPflRneU0sU7DFo%2B%2FcdBfIFDcpE%2FZXiOg%3D&reserved=0>
lorensen.github.io
If VTK is not installed but compiled on your system, you will need to specify the path to your VTK build:



If its a mesh of 3D elements and you want to sample the elements to create voxels, try vtkResampleToImage.

 - David



On Mon, May 28, 2018 at 4:41 PM, Berti Krüger <berti_krueger at hotmail.com<mailto:berti_krueger at hotmail.com>> wrote:
Hello Everyone.

For my Project i have to voxelize a 3D-Triangle-Mesh. I already found the
vtkVoxelModeller which, while somewhat slow (only around 200 Triangles per
second), works, but only voxelizes the outer shell where the mesh boundary
triangles are. The inner part of the mesh stays hollow.

Is there some way to get solid voxelization of 3D-Triangle-Meshes out of the
box with VTK ?


Thank you very much in advance,

Berti
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180605/73e9d2de/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 62429 bytes
Desc: image001.jpg
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180605/73e9d2de/attachment-0001.jpg>


More information about the vtkusers mailing list