Hi everyone!
I’m reading uint16 numpy array using vtkImageImport and them try to cut one slice from this volume but I get a blue image only, whreas the volume is rendered in grayscale as needed. Could anyone please suggest why am I getting this blue image when cutting?
Here is a part of code I use:
for reading:
dataImporter = vtk.vtkImageImport()
dataImporter.SetImportVoidPointer(image)
if image.dtype == np.uint8:
dataImporter.SetDataScalarTypeToUnsignedChar()
elif image.dtype == np.uint16:
dataImporter.SetDataScalarTypeToUnsignedShort()
dataImporter.SetNumberOfScalarComponents(1)
for cutting:
def cut_plane(self, j, obj, slices):
import vtk
# Create a plane to cut
# XZ = (1,0,0) XY = (0,0,1), YZ = (0,1,0)
plane = vtk.vtkPlane()
plane.SetOrigin(slices[::-1])
if j == 1:
# axial
plane.SetNormal(0, 0, 1)
elif j == 2:
plane.SetNormal(0, 1, 0)
elif j == 3:
plane.SetNormal(1, 0, 0)
cutter = vtk.vtkCutter()
cutter.SetCutFunction(plane)
cutter.SetInputData(obj.GetMapper().GetInput())
cutter.Update()
return cutter
Thank you!
Helga.