I want to create a a grid image made up of a grid of rods in vtk like so (Figure 1)
I tried vtkImageGridSource source:
grid0 = vtk.vtkImageGridSource()
grid0.SetDataScalarTypeToUnsignedChar()
grid0.SetGridSpacing(13, 13, 13)
grid0.SetGridOrigin(0, 0, 0)
grid0.SetLineValue(200)
grid0.SetFillValue(0)
grid0.SetDataExtent(0, 52, 0, 78, 0, 52)
grid0.Update()
volumeNode2 = slicer.mrmlScene.AddNewNodeByClass(“vtkMRMLScalarVolumeNode”, “gridImage”)
volumeNode2.SetAndObserveImageData(grid0.GetOutput())
volumeNode2.CreateDefaultDisplayNodes()
volumeNode2.SetAndObserveTransformNodeID(transformNode1.GetID())
but the grid is not made by rods but rather by planes crossing See Figure 2
Next I tried using vtkExtractEdges on an a vtkImageData, then applied a tube filter to the edges
extractEdges = vtk.vtkExtractEdges()
extractEdges.SetInputData(imageData)
extractEdges.Update()
edges = extractEdges.GetOutput()tubes = vtk.vtkTubeFilter()
#tubes.SetInputConnection(extractEdges.GetOutputPort())
tubes.SetInputData(edges)
tubes.SetRadius(.05)
tubes.SetNumberOfSides(360)
tubes.Update() # must call udpate before any GetOutput() otherwise use SetInputConnection/GetOutputPort combocleanFilter = vtk.vtkCleanPolyData()
cleanFilter.SetInputConnection(tubes.GetOutputPort())
cleanFilter.Update()
but didn’t get good results. Please see label image from segmentation module (Figure 3)
Any idea how to create a vtkImage like in Figure 1 ?
Thanks
GT