Hi,
I posted this on the slicer forum but I think the issue is with VTK.
I have the following code that extracts the edges from a vtkimagedata and applies a tube filter to the edges.
The issue is that the extractEdges filter does not use the scaling of the vtkimagedata. What am I missing ?
import os
nodeName = “MyNewVolume”
imageSize = [4, 6, 4]
voxelType=vtk.VTK_UNSIGNED_CHAR
imageOrigin = [0.0, 0.0, 0.0]
imageSpacing = [13.0, 13.0, 13.0]
imageDirections = [[1,0,0], [0,1,0], [0,0,1]]
fillVoxelValue = 500Create an empty image volume, filled with fillVoxelValue
imageData = vtk.vtkImageData()
imageData.SetDimensions(imageSize)
imageData.AllocateScalars(voxelType, 1)
imageData.GetPointData().GetScalars().Fill(fillVoxelValue)extractEdges = vtk.vtkExtractEdges()
extractEdges.SetInputData(imageData)Tube the edges
tubes = vtk.vtkTubeFilter()
tubes.SetInputConnection(extractEdges.GetOutputPort())
tubes.SetRadius(0.008)
tubes.SetNumberOfSides(32)model = slicer.modules.models.logic().AddModel(tubes.GetOutputPort())
Create volume node
volumeNode = slicer.mrmlScene.AddNewNodeByClass(“vtkMRMLScalarVolumeNode”, nodeName)
volumeNode.SetOrigin(imageOrigin)
volumeNode.SetSpacing(imageSpacing)
volumeNode.SetIJKToRASDirections(imageDirections)
volumeNode.SetAndObserveImageData(imageData)
volumeNode.CreateDefaultDisplayNodes()
volumeNode.CreateDefaultStorageNode()
As you can see in the image, the edges are shown but the scaling is not the right. Why is this ? How do I apply the correct scaling from the input imagedata ?
Thanks
GT